From 7addefccab6396ef74c6e2ce5c6b089379d4c225 Mon Sep 17 00:00:00 2001 From: Kinflou <149606337+Kinflou@users.noreply.github.com> Date: Sat, 14 Nov 2026 21:51:58 +0800 Subject: [PATCH 1/2] Try it: run the lesson on the playground's simulate view The lesson's widget was a small hand-made copy of the playground's simulate view. It's now that view, from comline-web-kit (a workspace of the playground repo) in its lesson layout: the Chat client and server from chat.lesson.json, the client's calls, the server's behaviours (reply, echo, drop) and the frame log, themed with the tutorial's palette. - comline-web-kit replaces the direct comline-simulator dependency; it depends on the simulator itself. CI skips the kit's editor WASM (COMLINE_KIT_EDITOR=0), as it skips the scripted engine. - Vite serves the kit as source (optimizeDeps.exclude), and TypeScript allows its .ts import paths. - The page says to click the server to change its behaviour. - A Playwright test sends a call, sees the reply and frames, switches the server to drop, and sees the next call time out. --- .github/workflows/deploy.yml | 12 +- .gitignore | 3 + .yarnrc.yml | 10 +- package.json | 2 +- src/lib/sim/Simulation.svelte | 273 +++--------------- .../sect-3_try-it/+page.svelte | 13 +- tests/try-it.test.ts | 23 ++ tsconfig.json | 4 +- vite.config.ts | 5 + yarn.lock | 155 +++++++++- 10 files changed, 253 insertions(+), 247 deletions(-) create mode 100644 tests/try-it.test.ts diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c8059e1..a33de0c 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -45,9 +45,10 @@ jobs: - name: Yarn run: corepack enable - # `comline-simulator` is a git dependency that compiles to WASM in its - # `prepack` (Rust to wasm-bindgen). The image has cargo, wasm-bindgen and - # wasm-opt; this caches the registry and git checkouts across runs. + # `comline-web-kit` (the playground's simulate view) is a git dependency, + # and so is its engine, `comline-simulator`, which compiles to WASM in + # its `prepack` (Rust to wasm-bindgen). The image has cargo, wasm-bindgen + # and wasm-opt; this caches the registry and git checkouts across runs. - name: Cache cargo uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: @@ -57,8 +58,8 @@ jobs: key: ${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('yarn.lock') }} restore-keys: ${{ runner.os }}-${{ runner.arch }}-cargo- - # Yarn Berry's global cache holds the built `comline-simulator` - # archive: a hit skips the Rust build entirely. + # Yarn Berry's global cache holds the packed `comline-web-kit` and the + # built `comline-simulator` archives: a hit skips the Rust build entirely. - name: Cache yarn uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: @@ -70,6 +71,7 @@ jobs: - name: Install dependencies env: COMLINE_SIMULATOR_SCRIPT: '0' # the tutorial only needs the lean sim + COMLINE_KIT_EDITOR: '0' # and not the kit's editor WASM run: yarn install - name: build diff --git a/.gitignore b/.gitignore index 11701b9..e426790 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,6 @@ vite.config.ts.timestamp-* # JetBrains IDEA settings .idea/ + +# Playwright +/test-results diff --git a/.yarnrc.yml b/.yarnrc.yml index 618f1ef..3e189ba 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -1,11 +1,13 @@ yarnPath: .yarn/releases/yarn-4.18.0.cjs nodeLinker: node-modules -# `comline-simulator` is the sim engine — a git dep that builds itself to WASM -# in its `prepack`/`prepare`. Yarn 4 gates git deps and disables scripts by -# default; both are needed. The build is not byte-reproducible (wasm-opt runs -# only where installed) so let Yarn refresh the tarball checksum. +# `comline-web-kit` (the playground's simulate view, a workspace of the +# playground repo) and `comline-simulator` (its engine) are git deps that +# build in their `prepack`. Yarn 4 gates git deps and disables scripts by +# default; both are needed. The builds are not byte-reproducible (wasm-opt +# runs only where installed) so let Yarn refresh the tarball checksums. approvedGitRepositories: + - "https://github.com/ComlineProject/playground.git" - "https://github.com/ComlineProject/simulator.git" enableScripts: true checksumBehavior: update diff --git a/package.json b/package.json index e6c7ab7..41b589f 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "type": "module", "dependencies": { "@sveltejs/adapter-static": "^3.0.10", - "comline-simulator": "git+https://github.com/ComlineProject/simulator.git#1eab1f84f1ae7760135ca4a7a519c78091001a44" + "comline-web-kit": "git+https://github.com/ComlineProject/playground.git#workspace=comline-web-kit&commit=f5df44539f2a5c25e7dfe72bbf9efa6ef4d1df59" }, "resolutions": { "cookie": "^0.7.2", diff --git a/src/lib/sim/Simulation.svelte b/src/lib/sim/Simulation.svelte index ee81133..3bce105 100644 --- a/src/lib/sim/Simulation.svelte +++ b/src/lib/sim/Simulation.svelte @@ -1,246 +1,67 @@ -
{error}
- {:else if !model} + {:else if loading}loading the simulation…
- {:else} -{result}
- {/if} - -