Skip to content

Commit

Permalink
Move image conversion out of plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
iBicha committed Jan 27, 2025
1 parent 3cb3c4b commit 1964040
Show file tree
Hide file tree
Showing 8 changed files with 134 additions and 247 deletions.
1 change: 0 additions & 1 deletion config/bsconfig.base.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@
"../tools/bs-plugins/json-yaml-plugin.ts",
"../tools/bs-plugins/validation-plugin.ts",
"../tools/bs-plugins/logger-plugin.ts",
"../tools/bs-plugins/image-gen-plugin.ts",
"../tools/bs-plugins/type-gen-plugin.ts",
"../tools/bs-plugins/web-server-plugin.ts",
"../tools/bs-plugins/locale-validation-plugin.ts",
Expand Down
1 change: 0 additions & 1 deletion config/bsconfig.tests.base.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"../tools/bs-plugins/json-yaml-plugin.ts",
"../tools/bs-plugins/validation-plugin.ts",
"../tools/bs-plugins/logger-plugin.ts",
"../tools/bs-plugins/image-gen-plugin.ts",
"../tools/bs-plugins/type-gen-plugin.ts",
"../tools/bs-plugins/web-server-plugin.ts",
"../tools/bs-plugins/locale-validation-plugin.ts",
Expand Down
16 changes: 0 additions & 16 deletions docs/plugins.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Playlet Brighterscript Plugins

- [Json5/Yaml support](#json5yaml-support)
- [Convert images](#convert-images)
- [Manifest editing](#manifest-editing)
- [Validation](#validation)
- [Includes](#includes)
Expand Down Expand Up @@ -33,21 +32,6 @@ Brightscript can only parse json natively using [ParseJson](https://developer.ro

At the end of the build, the plugin scans for certain files (`jsonc`, `json`, `json5` and `yaml`), and converts them to plain json, while keeping the original file name. That way they are all parsable by the [ParseJson](https://developer.roku.com/en-ca/docs/references/brightscript/language/global-utility-functions.md#parsejsonjsonstring-as-string-flags---as-string-as-object) function, even though their original format is not compatible.

## Convert images

**[Source](/tools/bs-plugins/image-gen-plugin.ts)**

This plugin allows us to convert svg files to png files.

### Why

This is used to convert splash screen, app poster, as well as icons in the app. Having svg images (or vector images in general) as the source of truth is better, in case images need to be modified or resized. Since Roku can't load them, we convert them to png.

### How

Each `.svg` file found will have an associated `.svg.meta.json5` file, which will contain the hash (MD5) of the svg, conversion paramters, and the hash of the output files. This allows us to hash existing files and see if a conversion is needed.
Notice how each `.svg` file can be configured to generate multiple png files. This is especially the case to generate the app artwork (splash screen/poster) with different sizes from the same logo `.svg` file.

## Manifest editing

**[Source](/tools/bs-plugins/manifest-edit-plugin.ts)**
Expand Down
96 changes: 10 additions & 86 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"argparse": "^2.0.1",
"brighterscript": "0.68.4",
"brighterscript-formatter": "^1.7.8",
"cheerio": "^1.0.0-rc.11",
"convert-svg-to-png": "^0.6.4",
"crypto-js": "^4.2.0",
"dotenv": "^16.4.7",
Expand Down Expand Up @@ -62,6 +63,7 @@
"sign-released-package": "node tools/sign-released-package.js",
"screenshot": "node tools/screenshot.js",
"generate-sponsorblock-config": "node tools/generate-sponsorblock-config.js",
"convert-images": "node tools/convert-images.js",
"update-rale-component": "cd tools/RALE && rm TrackerTask.xml && curl -o TrackerTask.zip https://devtools.web.roku.com/roku-advanced-layout-editor/app/TrackerTask.zip && unzip TrackerTask.zip && rm TrackerTask.zip",
"postinstall": "cd playlet-lib && npm install && cd ../playlet-app && npm install && cd ../playlet-web && npm install",
"update-deps": "npx npm-check-updates --deep --upgrade --install always --reject tailwindcss",
Expand Down
124 changes: 0 additions & 124 deletions tools/bs-plugins/image-gen-plugin.ts

This file was deleted.

19 changes: 0 additions & 19 deletions tools/convert-image.js

This file was deleted.

Loading

0 comments on commit 1964040

Please sign in to comment.