Skip to content

Extract the editor and simulate view into comline-web-kit - #119

Merged
Kinflou merged 2 commits into
masterfrom
kit/extract
Nov 14, 2026
Merged

Kinflou merged 2 commits into
masterfrom
kit/extract

Conversation

@Kinflou

@Kinflou Kinflou commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

Step 1 of #118. Nothing in the playground changes, for users or in the tests. The editor and the simulate view move into a package the tutorial can use.

Layout

The repo becomes a Yarn workspace with two members: app/ (the playground site) and kit/ (comline-web-kit). .yarnrc.yml, yarn.lock and the Yarn release move to the root.

Entry point What From
comline-web-kit/editor mountEditor, makeState, readOnlyExtensions, the compile worker, and createCompiler (the worker client main.ts had inline) app/src/editor.ts, worker.ts, main.ts
comline-web-kit/sim createSim, the shape types, and loadSim (the engine's WASM init that main.ts did) app/src/sim/
comline-web-kit/sim/scripted the Rhai engine's loader view.ts
comline-web-kit/sim.css the simulate view's styles app/src/style.css
comline-web-kit/editor-wasm the editor WASM, now built into kit/pkg-editor app/src/wasm

Changes beyond the move

  • Styles are scoped and themeable. sim.css rules are prefixed with .cl-sim, a class the view's root now carries. Inside it, --bg, --fg and the rest are redefined from --cl-* properties, whose defaults are the playground's colours. A page sets --cl-bg and so on to theme the view; the playground sets nothing and looks the same.
  • Scripting is opt-in. createSim used to import the scripted engine itself. A build resolves dynamic imports too, so every page using the view needed pkg-script/, and a build installed with COMLINE_SIMULATOR_SCRIPT=0 failed. The loader is now comline-web-kit/sim/scripted, passed as createSim({ loadScripted }). Without a loader, script isn't offered, and a new test covers that. The playground passes the loader, so it offers scripting as before.
  • Install from git. The kit's prepack (kit/scripts/prepare.sh, like the simulator's) builds the editor WASM when another site installs the kit from git. COMLINE_KIT_EDITOR=0 skips it for a site that only uses the sim.

CI and docs

  • deploy.yml installs, tests and builds at the root, and builds the editor WASM into kit/pkg-editor.
  • .gitignore follows the moves.
  • The README describes the kit and how another site uses it.

Verified locally

  • Tests: yarn test runs the kit's 35 tests (34 moved, plus the new one), then the app's 26. That's 43 passing and 18 skipped (the WASI-generator cases that need CI's generator builds), the same as master plus the new test.
  • Build: yarn build typechecks and builds. The bundle still has the worker, the editor WASM and both engine WASMs.
  • Use from another project: a scratch project depending on git+https://github.com/ComlineProject/playground.git#workspace=comline-web-kit&commit=<sha> installs the kit with COMLINE_KIT_EDITOR=0 COMLINE_SIMULATOR_SCRIPT=0. A Vite page there using createSim and sim.css builds without the scripted engine, with optimizeDeps.exclude: ["comline-web-kit"].
  • Looks the same: headless Chromium screenshots of master's build and this branch's build are byte-identical. That's in two states: the editor after compiling the first example, and the simulate view with a server and a client placed and the server selected. Neither logged any console errors.

The repo becomes a Yarn workspace: app/ (the playground site) and kit/
(comline-web-kit), the playground's machinery as a package the tutorial and
other pages can use.

- comline-web-kit/editor: the CodeMirror editor, the compile worker, and
  createCompiler, the worker client that main.ts had inline.
- comline-web-kit/sim: createSim and the shape types, plus loadSim, the
  engine WASM init main.ts did. Its styles move to comline-web-kit/sim.css,
  scoped under .cl-sim (the view's root) and themed with --cl-* properties
  whose defaults are the playground's colours.
- comline-web-kit/editor-wasm: the editor WASM, now built into
  kit/pkg-editor. The kit's prepack builds it when the kit is installed from
  git; COMLINE_KIT_EDITOR=0 skips that for a site that only uses the sim.

The app imports all of it from the kit and looks and behaves as before. The
tests move with their code: 34 in the kit, 26 in the app, the same 60.
A build resolves dynamic imports too, so the scripted engine's import in
createSim made every page that uses the view need pkg-script/, including a
site installed with COMLINE_SIMULATOR_SCRIPT=0. The loader is now its own
entry point that a page passes to createSim; without it, the view doesn't
offer the `script` behaviour. The playground passes it, as before.
@Kinflou
Kinflou merged commit 12edbf7 into master Nov 14, 2026
8 checks passed
@Kinflou
Kinflou deleted the kit/extract branch November 14, 2026 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant