Try it
Below is a Chat client and server, both generated from the same schema and wired together. Send
diff --git a/src/routes/part-2_basics/+page.svelte b/src/routes/part-2_basics/+page.svelte
new file mode 100644
index 0000000..5d8b138
--- /dev/null
+++ b/src/routes/part-2_basics/+page.svelte
@@ -0,0 +1,10 @@
+
+
+
+
+ Basics
+ This page is coming soon.
+
diff --git a/src/routes/part-2_basics/sect-1_your-first-schema/+page.svelte b/src/routes/part-2_basics/sect-1_your-first-schema/+page.svelte
new file mode 100644
index 0000000..3c2851d
--- /dev/null
+++ b/src/routes/part-2_basics/sect-1_your-first-schema/+page.svelte
@@ -0,0 +1,44 @@
+
+
+
+
+ Your first schema
+
+ A schema describes the data two programs exchange and the calls one makes on the other. The one
+ in the editor has a , , and a ,
+ , with one function that takes a person and returns a string.
+
+
+ Press Compile to turn it into code. Switch between Rust and TypeScript to see the same
+ schema in each.
+
+
+ Try it
+
+ - Add a field
to , and compile again.
+ -
+ Misspell
. The editor underlines the mistake straight away, and Compile
+ lists it.
+
+ - Hover over a name to see what it is, or start typing a type to get suggestions.
+
+
+
+
diff --git a/src/routes/part-2_basics/sect-2_structs-and-enums/+page.svelte b/src/routes/part-2_basics/sect-2_structs-and-enums/+page.svelte
new file mode 100644
index 0000000..b96f12a
--- /dev/null
+++ b/src/routes/part-2_basics/sect-2_structs-and-enums/+page.svelte
@@ -0,0 +1,10 @@
+
+
+
+
+ Structs and enums
+ This page is coming soon.
+
diff --git a/src/routes/part-2_basics/sect-3_protocols/+page.svelte b/src/routes/part-2_basics/sect-3_protocols/+page.svelte
new file mode 100644
index 0000000..68e0b68
--- /dev/null
+++ b/src/routes/part-2_basics/sect-3_protocols/+page.svelte
@@ -0,0 +1,10 @@
+
+
+
+
+ Protocols
+ This page is coming soon.
+
diff --git a/src/routes/part-3_generating-code/+page.svelte b/src/routes/part-3_generating-code/+page.svelte
new file mode 100644
index 0000000..0805956
--- /dev/null
+++ b/src/routes/part-3_generating-code/+page.svelte
@@ -0,0 +1,10 @@
+
+
+
+
+ Generating code
+ This page is coming soon.
+
diff --git a/src/routes/part-3_generating-code/sect-1_running-the-generator/+page.svelte b/src/routes/part-3_generating-code/sect-1_running-the-generator/+page.svelte
new file mode 100644
index 0000000..ce30220
--- /dev/null
+++ b/src/routes/part-3_generating-code/sect-1_running-the-generator/+page.svelte
@@ -0,0 +1,10 @@
+
+
+
+
+ Running the generator
+ This page is coming soon.
+
diff --git a/src/routes/part-3_generating-code/sect-2_using-the-generated-code/+page.svelte b/src/routes/part-3_generating-code/sect-2_using-the-generated-code/+page.svelte
new file mode 100644
index 0000000..2a6f246
--- /dev/null
+++ b/src/routes/part-3_generating-code/sect-2_using-the-generated-code/+page.svelte
@@ -0,0 +1,10 @@
+
+
+
+
+ Using the generated code
+ This page is coming soon.
+
diff --git a/src/styles/global.css b/src/styles/global.css
index 9b886e6..62715f2 100644
--- a/src/styles/global.css
+++ b/src/styles/global.css
@@ -2,25 +2,106 @@
box-sizing: border-box;
}
+/* The palette. Dark is the default; `` (the header's
+ toggle) swaps in the light one: warm paper rather than white. */
+:root {
+ --page-bg: #12110F;
+ --panel-bg: #1a1714;
+ --bar-bg: #322922;
+ --fg: #F2E1CA;
+ --muted: #a8927a;
+ --accent: #DBB594;
+ --border: #614A39;
+
+ --btn-bg: #322922;
+ --btn-fg: #DBB594;
+ --btn-border: #4D3C2F;
+ --btn-hover: #3E3128;
+ --btn-active: #28211D;
+ --current-bg: #322922;
+
+ --ok: #9ece6a;
+ --err: #f7768e;
+ --warn: #e0af68;
+
+ /* Schema and generated-code colours (the editor's, and inline ). */
+ --tok-kw: #bb9af7;
+ --tok-type: #7dcfff;
+ --tok-str: #9ece6a;
+ --tok-comment: #565f89;
+ --tok-num: #ff9e64;
+ --tok-ann: #e0af68;
+ --tok-var: #73daca;
+ --tok-fn: #7aa2f7;
+ --tok-op: #9aa5ce;
+ --tok-self: #f7768e;
+ --active-line: #ffffff08;
+ --selection: #3d59a1;
+
+ color-scheme: dark;
+}
+
+:root[data-theme="light"] {
+ --page-bg: #e9dfcf;
+ --panel-bg: #f4ecdf;
+ --bar-bg: #e0d2bc;
+ --fg: #3b2f25;
+ --muted: #7a6654;
+ --accent: #8a5a2b;
+ --border: #b39a7f;
+
+ --btn-bg: #e0d2bc;
+ --btn-fg: #5a3d22;
+ --btn-border: #b39a7f;
+ --btn-hover: #d6c4a8;
+ --btn-active: #cbb696;
+ --current-bg: #ddcbb0;
+
+ --ok: #3f7a2a;
+ --err: #b0303f;
+ --warn: #9a6b00;
+
+ --tok-kw: #7c3fbf;
+ --tok-type: #1f6a86;
+ --tok-str: #4b7d1e;
+ --tok-comment: #8a7a68;
+ --tok-num: #b4561b;
+ --tok-ann: #9a6400;
+ --tok-var: #2a7d72;
+ --tok-fn: #3558a8;
+ --tok-op: #6b5a4a;
+ --tok-self: #b0303f;
+ --active-line: #0000000a;
+ --selection: #c9d6ee;
+
+ color-scheme: light;
+}
+
+/* Header, main and footer fill the window exactly, and main takes the height
+ left over. The page never scrolls; what's inside main does. */
body {
+ display: flex;
+ flex-direction: column;
width: 100%;
- height: 100%;
+ height: 100vh;
+ height: 100dvh;
+ overflow: hidden;
margin: 0;
- background: #12110F;
+ background: var(--page-bg);
//font-family: 'Manrope Variable', sans-serif;
}
h1,h2,h3,h4,li {
font-family: 'VT323', monospace;
font-weight: normal;
- color: #F2E1CA;
+ color: var(--fg);
}
a,p,text,label {
font-family: 'VT323', monospace;
padding-left: 10pt;
- color: #F2E1CA;
+ color: var(--fg);
}
.box {
@@ -34,5 +115,5 @@ a,p,text,label {
margin-bottom: 1pt;
border-style: ridge;
- border-color: #614A39;
+ border-color: var(--border);
}
diff --git a/tests/first-schema.test.ts b/tests/first-schema.test.ts
new file mode 100644
index 0000000..7608628
--- /dev/null
+++ b/tests/first-schema.test.ts
@@ -0,0 +1,29 @@
+import { expect, test } from '@playwright/test';
+
+// "Your first schema" runs the playground's editor (comline-web-kit) and its
+// compiler: the starting schema compiles to Rust and TypeScript, and a typo
+// in it is reported instead.
+test('first schema: compiles, switches language, and reports a mistake', async ({ page }) => {
+ await page.goto('/part-2_basics/sect-1_your-first-schema/');
+
+ const lesson = page.locator('.schema-editor');
+ await expect(lesson.locator('.cm-content')).toContainText('protocol Greeter');
+
+ await lesson.getByRole('button', { name: 'Compile' }).click();
+ await expect(lesson.locator('.status.ok')).toBeVisible({ timeout: 30_000 });
+ await expect(lesson.locator('.code.out .cm-content')).toContainText('Generated by Comline');
+
+ await lesson.getByRole('combobox').selectOption('typescript');
+ await expect(lesson.locator('.status.ok')).toBeVisible();
+ // (CodeMirror only renders the lines in view, so this looks near the top.)
+ await expect(lesson.locator('.code.out .cm-content')).toContainText('interface Person');
+
+ // Misspell the field's type.
+ await lesson
+ .locator('.code:not(.out) .cm-line', { hasText: /^\s*name: string$/ })
+ .click();
+ await page.keyboard.press('End');
+ await page.keyboard.type('g');
+ await lesson.getByRole('button', { name: 'Compile' }).click();
+ await expect(lesson.locator('.status.err')).toContainText('stringg');
+});
diff --git a/tests/navigation.test.ts b/tests/navigation.test.ts
new file mode 100644
index 0000000..a92230c
--- /dev/null
+++ b/tests/navigation.test.ts
@@ -0,0 +1,37 @@
+import { expect, test } from '@playwright/test';
+
+// The sidebar is a tree of parts and their sections. It marks the page the
+// reader is on, and its links move between pages.
+test('navigation: the tree marks the current page and links to the others', async ({ page }) => {
+ await page.goto('/part-1_introduction/sect-1_what-is-comline/');
+
+ const nav = page.getByRole('navigation', { name: 'Tutorial contents' });
+ await expect(nav.locator('[aria-current="page"]')).toHaveText('1.1 What is Comline?');
+ await expect(nav.getByRole('link', { name: '1.3 Try it' })).toBeVisible();
+
+ await nav.getByRole('link', { name: '1.3 Try it' }).click();
+ await expect(page.getByRole('heading', { name: 'Try it' })).toBeVisible();
+ await expect(nav.locator('[aria-current="page"]')).toHaveText('1.3 Try it');
+});
+
+// Only the part holding the current page starts open; the others fold away
+// and open from their arrow. Next carries on from one part into the next.
+test('navigation: parts fold, and Next crosses into the next part', async ({ page }) => {
+ await page.goto('/part-2_basics/sect-2_structs-and-enums/');
+
+ const nav = page.getByRole('navigation', { name: 'Tutorial contents' });
+ const part = (n: number) => nav.locator('details').nth(n);
+ await expect(part(0)).not.toHaveAttribute('open');
+ await expect(part(1)).toHaveAttribute('open');
+ await expect(part(2)).not.toHaveAttribute('open');
+ await expect(nav.getByRole('link', { name: '3.1 Running the generator' })).toBeHidden();
+
+ await part(2).locator('summary').click({ position: { x: 4, y: 8 } });
+ await expect(nav.getByRole('link', { name: '3.1 Running the generator' })).toBeVisible();
+
+ await page.getByRole('link', { name: 'Next' }).click();
+ await expect(nav.locator('[aria-current="page"]')).toHaveText('2.3 Protocols');
+ await page.getByRole('link', { name: 'Next' }).click();
+ await expect(nav.locator('[aria-current="page"]')).toHaveText('3. Generating code');
+ await expect(part(1)).not.toHaveAttribute('open');
+});
diff --git a/tests/theme.test.ts b/tests/theme.test.ts
new file mode 100644
index 0000000..1ddd4e2
--- /dev/null
+++ b/tests/theme.test.ts
@@ -0,0 +1,23 @@
+import { expect, test } from '@playwright/test';
+
+// Dark is the default. The header's toggle switches to the light theme, and
+// the choice is kept across a reload until it's switched back.
+test('theme: starts dark, switches to light, and remembers it', async ({ page }) => {
+ await page.goto('/part-1_introduction/');
+ const html = page.locator('html');
+ const background = () => page.evaluate(() => getComputedStyle(document.body).backgroundColor);
+
+ await expect(html).not.toHaveAttribute('data-theme');
+ const dark = await background();
+
+ await page.getByRole('button', { name: /Light/ }).click();
+ await expect(html).toHaveAttribute('data-theme', 'light');
+ expect(await background()).not.toBe(dark);
+
+ await page.reload();
+ await expect(html).toHaveAttribute('data-theme', 'light');
+
+ await page.getByRole('button', { name: /Dark/ }).click();
+ await expect(html).not.toHaveAttribute('data-theme');
+ expect(await background()).toBe(dark);
+});
diff --git a/vite.config.ts b/vite.config.ts
index 90ae519..952435c 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -8,6 +8,11 @@ export default defineConfig({
optimizeDeps: {
exclude: ['comline-web-kit']
},
+ // The kit's compiler runs in a module worker (`type: "module"`), which the
+ // build has to emit as an ES module too.
+ worker: {
+ format: 'es'
+ },
test: {
include: ['src/**/*.{test,spec}.{js,ts}']
}
diff --git a/yarn.lock b/yarn.lock
index 55cbe99..f5b5bba 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -5,7 +5,7 @@ __metadata:
version: 10
cacheKey: 10c0
-"@codemirror/autocomplete@npm:^6.18.0":
+"@codemirror/autocomplete@npm:^6.0.0, @codemirror/autocomplete@npm:^6.18.0":
version: 6.20.4
resolution: "@codemirror/autocomplete@npm:6.20.4"
dependencies:
@@ -29,7 +29,32 @@ __metadata:
languageName: node
linkType: hard
-"@codemirror/language@npm:^6.0.0, @codemirror/language@npm:^6.10.0":
+"@codemirror/lang-javascript@npm:^6.2.5":
+ version: 6.2.5
+ resolution: "@codemirror/lang-javascript@npm:6.2.5"
+ dependencies:
+ "@codemirror/autocomplete": "npm:^6.0.0"
+ "@codemirror/language": "npm:^6.6.0"
+ "@codemirror/lint": "npm:^6.0.0"
+ "@codemirror/state": "npm:^6.0.0"
+ "@codemirror/view": "npm:^6.17.0"
+ "@lezer/common": "npm:^1.0.0"
+ "@lezer/javascript": "npm:^1.0.0"
+ checksum: 10c0/a9b10c58ad9dbcc54e17a641a114fc7718e362281dc9533828ed2a3a09270eb5677febb4ddad6d0cc2c439496f0ba0b7aa893d08de0b1ddc44df5c9ab0d7d299
+ languageName: node
+ linkType: hard
+
+"@codemirror/lang-rust@npm:^6.0.2":
+ version: 6.0.2
+ resolution: "@codemirror/lang-rust@npm:6.0.2"
+ dependencies:
+ "@codemirror/language": "npm:^6.0.0"
+ "@lezer/rust": "npm:^1.0.0"
+ checksum: 10c0/f0f3345c279a84572d29ee9284ac6b96abcb8521db7c2247b561dc59823adeabd529280e5313e304e11bce6f3fb57386e7859e183fb0404bd8d8a81751587695
+ languageName: node
+ linkType: hard
+
+"@codemirror/language@npm:^6.0.0, @codemirror/language@npm:^6.10.0, @codemirror/language@npm:^6.6.0":
version: 6.13.1
resolution: "@codemirror/language@npm:6.13.1"
dependencies:
@@ -44,7 +69,7 @@ __metadata:
languageName: node
linkType: hard
-"@codemirror/lint@npm:^6.8.0":
+"@codemirror/lint@npm:^6.0.0, @codemirror/lint@npm:^6.8.0":
version: 6.9.8
resolution: "@codemirror/lint@npm:6.9.8"
dependencies:
@@ -442,14 +467,14 @@ __metadata:
languageName: node
linkType: hard
-"@lezer/common@npm:^1.0.0, @lezer/common@npm:^1.1.0, @lezer/common@npm:^1.3.0, @lezer/common@npm:^1.5.0":
+"@lezer/common@npm:^1.0.0, @lezer/common@npm:^1.1.0, @lezer/common@npm:^1.2.0, @lezer/common@npm:^1.3.0, @lezer/common@npm:^1.5.0":
version: 1.5.5
resolution: "@lezer/common@npm:1.5.5"
checksum: 10c0/d989bd7453d1fd90f2c0baf33fcf6e5f2082fcf3f1faf8b271ae51bef1ad388e2e53f5d91c16e841b70fe4d2ed7ed08adb3fb23cb03fee6455dad3c72f6ff998
languageName: node
linkType: hard
-"@lezer/highlight@npm:^1.0.0, @lezer/highlight@npm:^1.2.3":
+"@lezer/highlight@npm:^1.0.0, @lezer/highlight@npm:^1.1.3, @lezer/highlight@npm:^1.2.3":
version: 1.2.5
resolution: "@lezer/highlight@npm:1.2.5"
dependencies:
@@ -458,7 +483,18 @@ __metadata:
languageName: node
linkType: hard
-"@lezer/lr@npm:^1.0.0":
+"@lezer/javascript@npm:^1.0.0":
+ version: 1.5.6
+ resolution: "@lezer/javascript@npm:1.5.6"
+ dependencies:
+ "@lezer/common": "npm:^1.2.0"
+ "@lezer/highlight": "npm:^1.1.3"
+ "@lezer/lr": "npm:^1.3.0"
+ checksum: 10c0/9cb004eb81cab833bdc25504e5632edf154f62f67c22b1fdc0023c1fc4deccab2be48f016a77e70198b2b49d13b16bc6a65d9826f54f81acf8ffd3edcf1f44cc
+ languageName: node
+ linkType: hard
+
+"@lezer/lr@npm:^1.0.0, @lezer/lr@npm:^1.3.0":
version: 1.4.12
resolution: "@lezer/lr@npm:1.4.12"
dependencies:
@@ -467,6 +503,17 @@ __metadata:
languageName: node
linkType: hard
+"@lezer/rust@npm:^1.0.0":
+ version: 1.0.3
+ resolution: "@lezer/rust@npm:1.0.3"
+ dependencies:
+ "@lezer/common": "npm:^1.2.0"
+ "@lezer/highlight": "npm:^1.0.0"
+ "@lezer/lr": "npm:^1.0.0"
+ checksum: 10c0/f4e5f1bdc8e90556059a0d8a119692b6cb3cfc39848f272b9cc01f38a3dcc00311a62a1b3099222fef68c24a6cc05d50f8f040d01f8c553f4e8c5802a36ad867
+ languageName: node
+ linkType: hard
+
"@marijn/find-cluster-break@npm:^1.0.0":
version: 1.0.4
resolution: "@marijn/find-cluster-break@npm:1.0.4"
@@ -1141,9 +1188,9 @@ __metadata:
languageName: node
linkType: hard
-"comline-web-kit@git+https://github.com/ComlineProject/playground.git#workspace=comline-web-kit&commit=fe53d2edcd25cf8bcd77d9f52a3c2ec09d453136":
+"comline-web-kit@git+https://github.com/ComlineProject/playground.git#workspace=comline-web-kit&commit=2e058f14451ec96da0d72ab462abd89697773132":
version: 0.1.0
- resolution: "comline-web-kit@https://github.com/ComlineProject/playground.git#workspace=comline-web-kit&commit=fe53d2edcd25cf8bcd77d9f52a3c2ec09d453136"
+ resolution: "comline-web-kit@https://github.com/ComlineProject/playground.git#workspace=comline-web-kit&commit=2e058f14451ec96da0d72ab462abd89697773132"
dependencies:
"@codemirror/autocomplete": "npm:^6.18.0"
"@codemirror/commands": "npm:^6.7.0"
@@ -1153,7 +1200,7 @@ __metadata:
"@codemirror/view": "npm:^6.34.0"
"@lezer/highlight": "npm:^1.2.3"
comline-simulator: "git+https://github.com/ComlineProject/simulator.git#564851a8fa00709cd94db8ce8ab1c4325a691fc4"
- checksum: 10c0/56780f4fe2eea8433c39374ec8ab2890344d92edc806dc6c62af9a34488f1ebe247438a4b1f41aadc06f0a99b74532e281b5ad2ec505352241ff856728a09b66
+ checksum: 10c0/26796fcd738bb84f670344f28f57c07d94dc9d8143d2937fba94ac36dfb07670ff6e2cb1ca3bb7674137e6392bcaa8da3c8af436f72547bb143811e6bf58a785
languageName: node
linkType: hard
@@ -2451,12 +2498,17 @@ __metadata:
version: 0.0.0-use.local
resolution: "tutorial@workspace:."
dependencies:
+ "@codemirror/lang-javascript": "npm:^6.2.5"
+ "@codemirror/lang-rust": "npm:^6.0.2"
+ "@codemirror/language": "npm:^6.10.0"
+ "@codemirror/state": "npm:^6.4.0"
+ "@codemirror/view": "npm:^6.34.0"
"@eslint/js": "npm:^10.0.1"
"@playwright/test": "npm:^1.62.1"
"@sveltejs/adapter-static": "npm:^3.0.10"
"@sveltejs/kit": "npm:^2.70.3"
"@sveltejs/vite-plugin-svelte": "npm:^6.2.4"
- comline-web-kit: "git+https://github.com/ComlineProject/playground.git#workspace=comline-web-kit&commit=fe53d2edcd25cf8bcd77d9f52a3c2ec09d453136"
+ comline-web-kit: "git+https://github.com/ComlineProject/playground.git#workspace=comline-web-kit&commit=2e058f14451ec96da0d72ab462abd89697773132"
eslint: "npm:^10.9.1"
eslint-config-prettier: "npm:^10.1.8"
eslint-plugin-svelte: "npm:^3.23.0"
From a04de52a5b4c0c3dc45e2d85c3fd88d09e34359d Mon Sep 17 00:00:00 2001
From: Kinflou <149606337+Kinflou@users.noreply.github.com>
Date: Sun, 15 Nov 2026 00:25:01 +0800
Subject: [PATCH 2/2] Pin comline-web-kit to playground master
---
package.json | 2 +-
yarn.lock | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/package.json b/package.json
index d382b61..5c82e0a 100644
--- a/package.json
+++ b/package.json
@@ -41,7 +41,7 @@
"@codemirror/state": "^6.4.0",
"@codemirror/view": "^6.34.0",
"@sveltejs/adapter-static": "^3.0.10",
- "comline-web-kit": "git+https://github.com/ComlineProject/playground.git#workspace=comline-web-kit&commit=2e058f14451ec96da0d72ab462abd89697773132"
+ "comline-web-kit": "git+https://github.com/ComlineProject/playground.git#workspace=comline-web-kit&commit=f6077cc1a176f1cedd70225e804774e0ca4d00bc"
},
"resolutions": {
"cookie": "^0.7.2",
diff --git a/yarn.lock b/yarn.lock
index f5b5bba..f2eaf90 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1188,9 +1188,9 @@ __metadata:
languageName: node
linkType: hard
-"comline-web-kit@git+https://github.com/ComlineProject/playground.git#workspace=comline-web-kit&commit=2e058f14451ec96da0d72ab462abd89697773132":
+"comline-web-kit@git+https://github.com/ComlineProject/playground.git#workspace=comline-web-kit&commit=f6077cc1a176f1cedd70225e804774e0ca4d00bc":
version: 0.1.0
- resolution: "comline-web-kit@https://github.com/ComlineProject/playground.git#workspace=comline-web-kit&commit=2e058f14451ec96da0d72ab462abd89697773132"
+ resolution: "comline-web-kit@https://github.com/ComlineProject/playground.git#workspace=comline-web-kit&commit=f6077cc1a176f1cedd70225e804774e0ca4d00bc"
dependencies:
"@codemirror/autocomplete": "npm:^6.18.0"
"@codemirror/commands": "npm:^6.7.0"
@@ -2508,7 +2508,7 @@ __metadata:
"@sveltejs/adapter-static": "npm:^3.0.10"
"@sveltejs/kit": "npm:^2.70.3"
"@sveltejs/vite-plugin-svelte": "npm:^6.2.4"
- comline-web-kit: "git+https://github.com/ComlineProject/playground.git#workspace=comline-web-kit&commit=2e058f14451ec96da0d72ab462abd89697773132"
+ comline-web-kit: "git+https://github.com/ComlineProject/playground.git#workspace=comline-web-kit&commit=f6077cc1a176f1cedd70225e804774e0ca4d00bc"
eslint: "npm:^10.9.1"
eslint-config-prettier: "npm:^10.1.8"
eslint-plugin-svelte: "npm:^3.23.0"