# Development ## Setup and checks Run commands from the project root. Install Node.js and npm; the project migration was checked on this laptop with Node.js 26.13.0 and npm 11.20.0. The build uses the system `tar` command. Browser tests use Chromium at `/usr/bin/chromium`; change the executable path in `tests/viewer.test.mjs` when developing elsewhere. ```sh npm ci npm run typecheck npm run build npm test ``` `npm ci` installs the versions in `package-lock.json`. The build bundles the plugin into `dist/`, then writes `publish/local.lpowers.code-studio.jpl`, the matching catalogue metadata JSON and `publish/SHA256SUMS`. `npm run dist` is an alias for that build. Joplin does not need Node.js, Chromium or system language formatters installed separately to run the finished plugin. The tests cover renderer behaviour, exact copying, wrapping, formatting, block targeting, Undo integration, catalogue metadata and distribution contents. Full historical desktop checks are kept separately from public source exports; passing browser tests alone does not establish that a new Joplin version works correctly. See [publication preparation](PUBLISHING.md) for the required live acceptance checks. ## Important dependency choices - The WASM formatters receive packaged bytes through an explicit loader. Their browser entry points are used without runtime downloads. - Prettier imports inside formatter plugins resolve to `prettier/standalone` during bundling. This keeps Node configuration-loading helpers out of the Joplin runtime bundle. - TOML uses the pinned pure JavaScript plugin. Its parser and lexer share the pinned root Chevrotain version; do not replace this with a native addon without checking portability. - Keep `vendor-licenses/`, bundled dependency notices and the font licence in release packages. - The Lua/Dart, dprint Dockerfile/HCL and Scalar Rust assets are copied into the installer. Rust's Brotli compression is expanded during the build using Node's standard library; its runtime receives raw bytes. Keep the Rust embedded-library notices and binary-only dprint package licences in the installer too. - Dart is deliberately pinned to `@wasm-fmt/dart_fmt` 0.3.0: the 0.4.0 package failed valid input with `RuntimeError: illegal cast` in the current host. Recheck both Node and Joplin when upgrading it. The pinned Scalar browser entry is imported directly because the package's Node entry resolves an unbundled asset path. - PowerShell's formatter may synthesise missing delimiters; our token/literal guard rejects those changes. Its output targets PowerShell 7. Retro BASIC formatting changes only leading layout whitespace and line endings; tests must preserve every physical statement and program number. - Retro display stores a `retro` field in each fence's info. Use `src/retro.ts` for detection/mutation so quoted titles survive. Font files under `assets/retro-fonts/` must remain unchanged and ship with their licences and provenance. Tests exercise local font loading, palettes in cards/comparisons, metadata-only edits, read-only failures, rerendering and simulated Rich Text Undo/Redo. - The `lodash-es` override selects 4.18.1 to address security advisories while retaining the existing Chevrotain/TOML parser versions. Markdown-it 14.3.3 and esbuild 0.28.1 address their reported advisories. Recheck compatibility and the audit when changing these pins. - Joplin declarations and the API shim are in `api/`, with their generator licence. ## Trying a new build In Joplin Desktop, open **Tools → Options → Plugins**, use the gear menu to install from a file, select the generated `.jpl`, then restart Joplin. Use the normal UI to quit so pending note edits can be saved. Keep the plugin ID `local.lpowers.code-studio` when upgrading an existing installation. Despite the historical filename, its display name is Code Block Studio. Renaming the ID would produce a separate plugin with separate preferences. For a change to formatting or editor integration, check both Markdown preview and Rich Text. Verify Apply, Cancel, both Copy choices and native Undo. Compare the saved code and surrounding note content. Use disposable examples; do not replace user notes for testing. ## Releases Gitea is the primary development repository. The separate public-source Gitea repository holds reviewed exports; GitHub hosts the public source and release downloads. Development changes and reviewed exports go to Gitea first. Leonard handles GitHub synchronisation manually; the manual Gitea npm workflow publishes the preserved release tarball as a separate, authorised step. See [publication preparation](PUBLISHING.md). Use `npm run screenshots` to regenerate the fictional-example component screenshots and original icons after a build; its assertions verify that the captured controls and source preservation work. 1. Keep the version consistent in `src/manifest.json`, `package.json` and the root package entry in `package-lock.json`. 2. Update the change history, documentation and validation results. 3. Run the checks above and the desktop checks appropriate to the change. 4. Commit and push development changes to private Gitea first. Run `npm run prepare-public` to stage an export of committed Gitea source in a fresh checkout of `codeblock-studio-public`. Review `git diff --cached` in the printed checkout; private history and uncommitted work are not copied. 5. Commit the reviewed public source locally, run the checks from that clean commit, and build the installer, metadata and source ZIP. Record SHA-256 checksums and verify archive contents. 6. Preserve those exact files under `releases/vVERSION/`, then commit and push them to private Gitea. Push the reviewed public source commit and intended public tag from the public checkout to its Gitea origin, and attach the matching Gitea release assets. The owner then uses **Synchronize Now** on that repository's GitHub push mirror; GitHub release descriptions/assets require their own step. Keep distributed bytes unchanged; rebuilding can change archive timestamps and checksums. Do not mirror private Git history to GitHub. Generated dependencies, `dist/`, `publish/`, local work and `archive/` are excluded from Git. Only the reviewed release assets under `releases/` are intended for distribution. The [Gitea npm workflow](GITEA-NPM.md) consumes the preserved tarball rather than rebuilding it; publishing remains a separate, explicit action. Retro font variants are already bundled. To regenerate only those variants, run `scripts/prepare-retro-fonts.py` in a Python environment with FontTools. Normal builds need neither; preserve the original files, companion licences and per-directory change notices. See `assets/retro-fonts/README.md` for provenance and exact changes. The Rich Text language picker listens for TinyMCE’s `OpenWindow` event and uses the native dialog’s `languageInput` data field. Keep suggestions generated from `renderer.codeLanguages()` during the build rather than adding a second hand-maintained list. Test keyboard selection against the native dialog, since Enter normally submits it. `tests/language-picker.test.mjs` covers the cross-document hook, filtering, custom labels, mouse/keyboard selection, repeated loading and unrelated/disabled dialogs. Language choices carry a primary `value`, display `label` and `aliases` array. Keep aliases searchable/typeable while grouping duplicate rows, and retain distinct format variants (including shell sessions versus POSIX shell scripts). Catalogue tests check unique display names, complete Highlight.js spelling coverage, representative alias groups and distinct dialects; browser checks cover short-name filtering and exact typed aliases.