|
@@ -3,16 +3,18 @@
|
|
|
<br>
|
|
|
|
|
|
### Images:
|
|
|
-- PNG images and external assets are stored in `assets/images`
|
|
|
-- SVG images are stored in `assets/icons`
|
|
|
-- CSS files in `assets/style`
|
|
|
-- Translations are in `assets/translations`
|
|
|
+- Own PNG/JPG/GIF images are stored in [`assets/images`](./images)
|
|
|
+- External images are stored in [`assets/images/external`](./images/external)
|
|
|
+- The BYTM logo files are in [`assets/images/logo`](./images/logo)
|
|
|
+- SVG icons are stored in [`assets/icons`](./icons)
|
|
|
+- CSS stylesheets are in [`assets/style`](./style)
|
|
|
+- Translations are in [`assets/translations`](./translations)
|
|
|
|
|
|
<br>
|
|
|
|
|
|
## JSON file formats:
|
|
|
> [!NOTE]
|
|
|
-> Note: If a property is wrapped with square brackets (`[name]`), it means that the property is optional
|
|
|
+> Note: If a property is followed by a question mark, that means it is optional
|
|
|
|
|
|
<br>
|
|
|
|
|
@@ -31,29 +33,51 @@ The keys of the object are the locale codes, and the values are the locale objec
|
|
|
<br>
|
|
|
|
|
|
### [`plugins.json`](plugins.json)
|
|
|
-(Not fully implemented yet, but should still be filled out when a plugin is added)
|
|
|
+(Not implemented yet. As soon as a plugin is added, this needs to be fleshed out)
|
|
|
|
|
|
-For the structure of this array of objects, see `type PluginObj` in [`src/types.ts`](../src/types.ts)
|
|
|
+<!-- TODO: For the structure of this array of objects, see `type PluginObj` in [`src/types.ts`](../src/types.ts) -->
|
|
|
+
|
|
|
+<br>
|
|
|
+
|
|
|
+### [`resources.json`](resources.json)
|
|
|
+This file contains the resources that are loaded into the runtime through the `@resource` userscript directive.
|
|
|
+That includes all icons, images, CSS files, fonts, translations and other assets.
|
|
|
+
|
|
|
+Inside the file is an object, whose keys are the resource names and the values are the path to the resource or a configuration object.
|
|
|
+The path to the resource can be relative, in which case it's resolved relative to the `assets` directory.
|
|
|
+If it starts with a slash, it will be resolved relative to the project root (where `package.json` is).
|
|
|
+
|
|
|
+All values will be run through the function `resolveResourceVal()` in [`src/tools/post-build.ts`](./src/tools/post-build.ts) to replace placeholders with dynamic values.
|
|
|
+For example, `$BRANCH` will be replaced with the branch name. Find all possible replacements in that function's declaration.
|
|
|
+
|
|
|
+The configuration object can have the following properties:
|
|
|
+| Property | Type | Description |
|
|
|
+| :------- | :------- | :----------------------- |
|
|
|
+| `path` | `string` | The path to the resource |
|
|
|
+| `ref?` | `string` | The GitHub ref to use for the resource, e.g. `main`, a Git tag like `v2.0.0` or a commit hash - defaults to the branch resolved in [`src/tools/post-build.ts`](./src/tools/post-build.ts) |
|
|
|
|
|
|
<br>
|
|
|
|
|
|
### [`require.json`](require.json)
|
|
|
This file contains the npm libraries that are loaded into the runtime through the `@require` userscript directive.
|
|
|
-It's an array of objects, which each have one of the following sets of properties:
|
|
|
+This is done to massively reduce the bundle size and make use of the userscript extension's caching.
|
|
|
+Each library will be set as an external in the [Rollup configuration](../rollup.config.js) to prevent it from including it in the bundle.
|
|
|
+The version of each package will be inferred from [`package.json`](../package.json) to ensure consistent versions across the project.
|
|
|
|
|
|
-Using npm and a CDN:
|
|
|
-| Property | Type | Description |
|
|
|
-| :---------- | :-------- | :------------------------------------------------------------------------------------ |
|
|
|
-| `pkgName` | `string` | The name of the npm package, as in `npm i <pkgName>` |
|
|
|
-| `path` | `string` | The path to the file that should be loaded, relative to the library root dir |
|
|
|
-| `global` | `string` | The name of the global variable that the library exports |
|
|
|
-| `[baseUrl]` | `string` | Base URL of the CDN to use - `https://cdn.jsdelivr.net/npm/` by default |
|
|
|
-| `[link]` | `boolean` | Whether `npm link` is active and the library should instead be included in the bundle |
|
|
|
-
|
|
|
+Inside the file is an array of objects, which each have one of the following properties:
|
|
|
+
|
|
|
+Using npm packages through a CDN:
|
|
|
+| Property | Type | Description |
|
|
|
+| :--------- | :-------- | :---------------------------------------------------------------------------------- |
|
|
|
+| `pkgName` | `string` | The name of the npm package, as in `npm i <pkgName>` |
|
|
|
+| `path` | `string` | The path to the file that should be loaded, relative to the library root dir |
|
|
|
+| `global` | `string` | The name of the global variable that the library exports |
|
|
|
+| `baseUrl?` | `string` | Base URL of the CDN to use - `https://cdn.jsdelivr.net/npm/` by default - package will be appended as `pkgName@versionFromPkgJson` |
|
|
|
+| `link?` | `boolean` | Whether `npm link` is active and the library should be force-included in the bundle |
|
|
|
|
|
|
Using a direct URL:
|
|
|
-| Property | Type | Description |
|
|
|
-| :------- | :-------- | :------------------------------------------------------------------------------------ |
|
|
|
-| `url` | `string` | URL to the file to include |
|
|
|
-| `global` | `string` | The name of the global variable that the library exports |
|
|
|
-| `[link]` | `boolean` | Whether `npm link` is active and the library should instead be included in the bundle |
|
|
|
+| Property | Type | Description |
|
|
|
+| :------- | :-------- | :---------------------------------------------------------------------------------- |
|
|
|
+| `url` | `string` | URL to the file to include |
|
|
|
+| `global` | `string` | The name of the global variable that the library exports |
|
|
|
+| `link?` | `boolean` | Whether `npm link` is active and the library should be force-included in the bundle |
|