@flatkit/sugarflat 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -5
- package/dist/index.js +24 -5
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -52,17 +52,31 @@ Two consequences, both deliberate:
|
|
|
52
52
|
how `match` has always worked in the language proper.
|
|
53
53
|
|
|
54
54
|
```
|
|
55
|
-
place organs {
|
|
55
|
+
place organs {
|
|
56
|
+
prompt "Place each organ in the body"
|
|
57
|
+
target Chest at 300,300
|
|
58
|
+
item heart -> Chest at 120,140
|
|
59
|
+
}
|
|
56
60
|
|
|
57
|
-
raw scene { layer "backdrop" { rect 0 0 760 620 fill linear(90, 0:#1b2a4a, 1:#4a6fa5) } }
|
|
58
|
-
raw { object "
|
|
61
|
+
raw scene under { layer "backdrop" { rect 0 0 760 620 fill linear(90, 0:#1b2a4a, 1:#4a6fa5) } }
|
|
62
|
+
raw { object "organs_TChest" { opacity = 0.9 } }
|
|
59
63
|
```
|
|
60
64
|
|
|
61
65
|
## Several blocks in one document
|
|
62
66
|
|
|
63
67
|
```
|
|
64
|
-
place words {
|
|
65
|
-
|
|
68
|
+
place words {
|
|
69
|
+
prompt "Put each word under its part of speech"
|
|
70
|
+
target Nouns at 200,200
|
|
71
|
+
item cat -> Nouns at 120,80
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
compose coins {
|
|
75
|
+
prompt "Make exactly 150"
|
|
76
|
+
total 150
|
|
77
|
+
chip 50 at 200,500
|
|
78
|
+
chip 100 at 420,500
|
|
79
|
+
}
|
|
66
80
|
|
|
67
81
|
raw scene under { layer "bg" { rect 0 0 760 620 fill #112233 } }
|
|
68
82
|
```
|
package/dist/index.js
CHANGED
|
@@ -56,10 +56,22 @@ function container(name, x, y, art, hitbox) {
|
|
|
56
56
|
const box = hitbox ? ` hitbox ${hitbox.w} ${hitbox.h}` : "";
|
|
57
57
|
return [` group "${name}" at ${x},${y} pivot 0,0${box} {`, ' layer "art" {', ...art.map((l) => ` ${l}`), " }", " }"];
|
|
58
58
|
}
|
|
59
|
-
var
|
|
59
|
+
var RUNON = /^(?:prompt|target|item|total|chip|step)\b.*\s{2,}(?:prompt|target|item|total|chip|step)\b/;
|
|
60
|
+
function lines(kind, name, body) {
|
|
61
|
+
const out = body.split("\n").map((l) => l.replace(/\/\/.*$/, "").trim()).filter(Boolean);
|
|
62
|
+
for (const line of out) {
|
|
63
|
+
if (!RUNON.test(line)) continue;
|
|
64
|
+
const laid = line.split(/\s{2,}/).filter(Boolean).map((st) => ` ${st}`).join("\n");
|
|
65
|
+
throw new Error(`${kind} "${name}": two statements on one line \u2014 a block takes ONE per line, like FlatInk itself:
|
|
66
|
+
${kind} ${name} {
|
|
67
|
+
${laid}
|
|
68
|
+
}`);
|
|
69
|
+
}
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
60
72
|
function parsePlace(name, body, p) {
|
|
61
73
|
const m = { prompt: "", targets: [], items: [] };
|
|
62
|
-
for (const line of lines(body)) {
|
|
74
|
+
for (const line of lines("place", name, body)) {
|
|
63
75
|
let x;
|
|
64
76
|
if (x = line.match(/^prompt\s+"(.*)"$/)) m.prompt = x[1];
|
|
65
77
|
else if (x = line.match(/^target\s+(?:"([^"]+)"|(\S+))\s+at\s+(-?[\d.]+),(-?[\d.]+)$/)) {
|
|
@@ -121,7 +133,7 @@ function expandCompose(name, body, theme, ctx) {
|
|
|
121
133
|
let target = 0;
|
|
122
134
|
const chips = [];
|
|
123
135
|
let prompt = "";
|
|
124
|
-
for (const line of lines(body)) {
|
|
136
|
+
for (const line of lines("compose", name, body)) {
|
|
125
137
|
let x;
|
|
126
138
|
if (x = line.match(/^prompt\s+"(.*)"$/)) prompt = x[1];
|
|
127
139
|
else if (x = line.match(/^total\s+(\d+)$/)) target = Number(x[1]);
|
|
@@ -155,7 +167,7 @@ function expandSteps(name, body, theme, ctx) {
|
|
|
155
167
|
const { prefix: p, index: b, doneVar } = ctx;
|
|
156
168
|
let prompt = "";
|
|
157
169
|
const steps = [];
|
|
158
|
-
for (const line of lines(body)) {
|
|
170
|
+
for (const line of lines("steps", name, body)) {
|
|
159
171
|
let x;
|
|
160
172
|
if (x = line.match(/^prompt\s+"(.*)"$/)) prompt = x[1];
|
|
161
173
|
else if (x = line.match(/^step\s+"(.*)"\s+at\s+(-?[\d.]+),(-?[\d.]+)$/)) steps.push({ label: x[1], x: x[2], y: x[3] });
|
|
@@ -213,7 +225,14 @@ function sugarCard(opts = {}) {
|
|
|
213
225
|
`Canvas: ${doc.width}x${doc.height}, origin top-left. Coordinates are the CENTRE of each thing.`,
|
|
214
226
|
"Anything you do not describe is not drawn.",
|
|
215
227
|
"",
|
|
216
|
-
"## Blocks",
|
|
228
|
+
"## Blocks \u2014 ONE statement per line, like FlatInk itself",
|
|
229
|
+
"",
|
|
230
|
+
"place <name> { compose <name> { steps <name> {",
|
|
231
|
+
' prompt "\u2026" prompt "\u2026" prompt "\u2026"',
|
|
232
|
+
' target <T> at x,y total <n> step "\u2026" at x,y',
|
|
233
|
+
" item <i> -> <T> at x,y chip <v> at x,y }",
|
|
234
|
+
"} }",
|
|
235
|
+
"",
|
|
217
236
|
...gestures({ theme }).map((g) => `- ${g.summary}`),
|
|
218
237
|
"",
|
|
219
238
|
"Several blocks may share a document; give each a DISTINCT name. They are laid out in the order you",
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/document.ts","../src/ident.ts","../src/theme.ts","../src/gestures.ts","../src/index.ts"],"sourcesContent":["// ─────────────────────────────────────────────────────────────────────────────\n// document.ts — the document a sugar block expands into.\n//\n// Two things a sugar MUST know and an author MUST be able to read: the canvas the gesture is laid out\n// for, and the timeline it rides. Both were literals buried inside an expander, which cost twice:\n// • the expansion never emitted `size` at all, so it fell back on the compiler's 800x600 default\n// while the board was painted for 760x620 -- everything past x=760 was clipped in silence, on the\n// whole corpus, for months (nothing says so: a missing `size` still compiles);\n// • prompting a model for the right coordinates meant reading the generator's source.\n// Exposed here, overridable per call, and stamped onto every expansion by `ensureHeader`.\n// ─────────────────────────────────────────────────────────────────────────────\n\n/** The canvas + timeline a sugar block expands into. */\nexport type DocumentSpec = {\n width: number\n height: number\n fps: number\n /** Timeline length. Long enough that `time` does not wrap mid-activity (the compiler warns under 120). */\n durationFrames: number\n}\n\n/** The board the gestures are laid out for. Override per call when a host uses another canvas. */\nexport const DEFAULT_DOCUMENT: DocumentSpec = { width: 760, height: 620, fps: 24, durationFrames: 120 }\n\n/** `true` if the source already declares its canvas — `size` must be the FIRST statement of a program. */\nexport const hasSizeHeader = (src: string): boolean => /^[ \\t]*size\\s+-?[\\d.]+\\s+-?[\\d.]+/m.test(src)\n\n/** `true` if the source already declares a root timeline. */\nexport const hasTimelineHeader = (src: string): boolean => /^[ \\t]*timeline\\s+\\d+/m.test(src)\n\n/**\n * Prepend whatever header the expansion is missing. `size` is REQUIRED by the format and silently\n * defaulted by the compiler when absent, so emitting it is not a nicety: it is the difference between\n * the document the author designed and the one that gets drawn.\n */\nexport function ensureHeader(flatink: string, doc: DocumentSpec = DEFAULT_DOCUMENT): string {\n const head: string[] = []\n if (!hasSizeHeader(flatink)) head.push(`size ${doc.width} ${doc.height}`)\n if (!hasTimelineHeader(flatink)) head.push(`timeline ${doc.fps} ${doc.durationFrames}`)\n return head.length ? `${head.join('\\n')}\\n${flatink}` : flatink\n}\n","// ─────────────────────────────────────────────────────────────────────────────\n// ident.ts — a human label -> a FlatInk identifier.\n//\n// A sugar lets an author name things in their own language (\"chene\", \"Vegetaux\", \"21 janvier 1793\"),\n// and those names become identifiers (`var`, `object`). FlatInk identifiers are `[A-Za-z0-9_]`, so an\n// accent does not error -- the lexer stops at it and reads the tail. `chene` written with its accent\n// became `var <accented>X`, read as `neX`: two variables where the author wrote one, and no diagnostic.\n// Transliterate here, once, rather than in every gesture.\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * A FlatInk identifier derived from a human label: accents folded to ASCII, anything else to `_`, and\n * a leading digit prefixed (an identifier may not start with one). Stable and idempotent, so the same\n * label always yields the same name — the sugar's variables and the author's references must agree.\n */\nexport function ident(label: string): string {\n const ascii = label.normalize('NFD').replace(/\\p{Diacritic}/gu, '').replace(/[^A-Za-z0-9_]/g, '_')\n return /^[0-9]/.test(ascii) ? `n${ascii}` : ascii\n}\n\n/** `true` if the label survives `ident` unchanged — i.e. it is already a usable identifier. */\nexport const isIdent = (label: string): boolean => ident(label) === label && label.length > 0\n","// ─────────────────────────────────────────────────────────────────────────────\n// theme.ts — where appearance lives, so that gestures do not carry any.\n//\n// A gesture emits STRUCTURE and BEHAVIOR: named groups at the coordinates the author gave, their drop\n// boxes, their state, their handlers. It must never decide what any of it LOOKS like — a sugar that\n// ships a look hands every activity built on it the same face, and that has already happened once.\n//\n// So appearance is a parameter. `BLANK` draws nothing at all, which is what makes the claim testable\n// rather than aspirational: expand a gesture with `BLANK` and the output must not contain one colour,\n// one font, or one stroke. `GREYBOX` is a deliberately plain default so a freshly written block is\n// playable immediately — it is provisional by design, and swapping it is a single argument.\n// ─────────────────────────────────────────────────────────────────────────────\n\n/** What a drawn thing is FOR. Four roles cover every gesture; a theme need not distinguish more. */\nexport type Role =\n | 'item' // something the learner moves\n | 'target' // where an item belongs\n | 'card' // a panel the learner reads and taps\n | 'chip' // a small tappable value\n\nexport type Theme = {\n readonly name: string\n /** Footprint of a role. The gesture uses it for drop boxes; the theme must draw within it. */\n size(role: Role): { w: number; h: number }\n /** Drawing statements for a role, in LOCAL coordinates centred on 0,0. May be empty. */\n draw(role: Role, label: string): string[]\n}\n\n/** Every role, in a stable order — for a reference card, or to sweep a theme. */\nexport const ROLES: Role[] = ['item', 'target', 'card', 'chip']\n\nconst SIZES: Record<Role, { w: number; h: number }> = {\n item: { w: 92, h: 92 },\n target: { w: 208, h: 118 },\n card: { w: 180, h: 140 },\n chip: { w: 96, h: 96 },\n}\n\n/**\n * Draws nothing. The gesture still emits every group, every box and every handler, so an author (or a\n * skin) supplies the whole appearance — and the test suite uses it to prove the gestures themselves\n * carry no visual opinion.\n */\nexport const BLANK: Theme = {\n name: 'blank',\n size: (role) => SIZES[role],\n draw: () => [],\n}\n\n/** Rounded rectangle path, centred on the origin — the greybox's only shape vocabulary. */\nconst plate = (w: number, h: number, r: number): string => `rect ${-w / 2} ${-h / 2} ${w} ${h} ${r}`\n\n/**\n * A plain, provisional greybox: readable, anonymous, and meant to be replaced. It exists so `place x {\n * … }` is playable the moment it is written; it is not a design, and anything built for an audience\n * should pass its own theme (or redraw beside the gesture with `raw { … }`).\n */\nexport const GREYBOX: Theme = {\n name: 'greybox',\n size: (role) => SIZES[role],\n draw(role, label) {\n const { w, h } = SIZES[role]\n const text = (size: number, boxW: number, boxH: number, colour: string, y: number) =>\n `text \"${label.replace(/\"/g, \"'\")}\" at ${-boxW / 2},${y} font \"system-ui, sans-serif\" size ${size} align center line 1.2 color ${colour} box ${boxW} ${boxH} wrap`\n switch (role) {\n case 'item':\n return [`circle 0 0 ${w / 2 - 12} fill #e8c46b`, `circle 0 0 ${w / 2 - 12} nofill stroke #b8923f 2`, text(14, w - 8, 20, '#4a3a1e', -9)]\n case 'target':\n return [`${plate(w - 8, h - 8, 14)} fill #2e3a4e`, `${plate(w - 8, h - 8, 14)} nofill stroke #5a6f8a 2 dash 8,6`, text(16, w - 28, 22, '#aeb6c4', -h / 2 + 10)]\n case 'card':\n return [`${plate(w, h, 16)} fill #2b3447`, `${plate(w, h, 16)} nofill stroke #44516a 2`, text(15, w - 20, h - 40, '#d7deea', -h / 2 + 26)]\n case 'chip':\n return [`circle 0 0 ${w / 2 - 8} fill #e8c46b`, `circle 0 0 ${w / 2 - 8} nofill stroke #b8923f 3`, text(22, w - 16, 28, '#4a3a1e', -13)]\n }\n },\n}\n","// ─────────────────────────────────────────────────────────────────────────────\n// gestures.ts — the three primitives.\n//\n// Five named gestures came in (`tri`, `ordonner`, `placement`, `composer`, `etapes`). Read side by\n// side, the first three share ONE implementation: the only thing that differed between them was which\n// shape their targets were drawn as -- rectangles, squares or dotted discs. That is appearance, and\n// appearance is the theme's business, so they collapse into a single `place`.\n//\n// Each gesture emits state, structure and behavior. Not one colour, not one font: `BLANK` proves it.\n// Coordinates DO appear, and that is not an opinion -- they are the ones the author wrote in the block.\n//\n// A gesture returns PARTS, never a finished program: its `var` lines, its layers, its behavior. That is\n// what lets a document hold several of them -- a program has exactly one `scene`, so merging text after\n// the fact was always going to be surgery. Assembling parts is not.\n// ─────────────────────────────────────────────────────────────────────────────\nimport type { Expansion, Gesture, GestureContext } from './index'\nimport { ident } from './ident'\nimport { GREYBOX, ROLES, type Role, type Theme } from './theme'\n\n/** Everything a gesture needs beyond the author's text. */\nexport type GestureOptions = { theme?: Theme }\n\nconst q = (s: string) => s.replace(/\"/g, \"'\")\n\n/** Statements of a named group placed at `x,y`, drawn by the theme, optionally a drop box. */\nfunction container(name: string, x: string, y: string, art: string[], hitbox?: { w: number; h: number }): string[] {\n const box = hitbox ? ` hitbox ${hitbox.w} ${hitbox.h}` : ''\n return [` group \"${name}\" at ${x},${y} pivot 0,0${box} {`, ' layer \"art\" {', ...art.map((l) => ` ${l}`), ' }', ' }']\n}\n\n/** Split a block body into its non-empty, comment-free lines. */\nconst lines = (body: string): string[] => body.split('\\n').map((l) => l.replace(/\\/\\/.*$/, '').trim()).filter(Boolean)\n\n// ── place ────────────────────────────────────────────────────────────────────\n// The drop gesture: items belong on targets. Several items may share a target (a sort) or each may have\n// its own (an ordering, a labelled diagram) -- that falls out of the data, it is not a separate gesture.\n\ntype PlaceModel = {\n prompt: string\n targets: { id: string; label: string; x: string; y: string }[]\n items: { id: string; label: string; target: string; x: string; y: string }[]\n}\n\nfunction parsePlace(name: string, body: string, p: string): PlaceModel {\n const m: PlaceModel = { prompt: '', targets: [], items: [] }\n for (const line of lines(body)) {\n let x: RegExpMatchArray | null\n if ((x = line.match(/^prompt\\s+\"(.*)\"$/))) m.prompt = x[1]\n else if ((x = line.match(/^target\\s+(?:\"([^\"]+)\"|(\\S+))\\s+at\\s+(-?[\\d.]+),(-?[\\d.]+)$/))) {\n const label = x[1] ?? x[2]\n m.targets.push({ id: `${p}T${ident(label)}`, label, x: x[3], y: x[4] })\n } else if ((x = line.match(/^item\\s+(?:\"([^\"]+)\"|(\\S+))\\s*->\\s*(?:\"([^\"]+)\"|(\\S+))\\s+at\\s+(-?[\\d.]+),(-?[\\d.]+)$/))) {\n const label = x[1] ?? x[2]\n m.items.push({ id: `${p}I${ident(label)}`, label, target: `${p}T${ident(x[3] ?? x[4])}`, x: x[5], y: x[6] })\n } else throw new Error(`place \"${name}\": unrecognised line: ${line}`)\n }\n if (!m.targets.length) throw new Error(`place \"${name}\": no target — an item has nowhere to go`)\n if (!m.items.length) throw new Error(`place \"${name}\": no item — nothing for the learner to do`)\n const known = new Set(m.targets.map((t) => t.id))\n for (const it of m.items) {\n if (!known.has(it.target)) throw new Error(`place \"${name}\": item \"${it.label}\" points at an unknown target`)\n }\n return m\n}\n\nfunction expandPlace(name: string, body: string, theme: Theme, ctx: GestureContext): Expansion {\n const { prefix: p, index: b, doneVar } = ctx\n const m = parsePlace(name, body, p)\n const n = m.items.length\n const vars = [`// ${p}— place \"${q(name)}\"`, ...(m.prompt ? [`// prompt: ${q(m.prompt)}`] : []), `var ${p}progress = 0`, `var ${doneVar} = 0`]\n for (const it of m.items) vars.push(`var ${it.id}X = ${it.x}`, `var ${it.id}Y = ${it.y}`, `var ${it.id}Placed = 0`)\n\n const layers = [` layer \"${p}targets\" {`]\n for (const t of m.targets) layers.push(...container(t.id, t.x, t.y, theme.draw('target', t.label), theme.size('target')))\n layers.push(' }', ` layer \"${p}items\" {`)\n for (const it of m.items) layers.push(...container(it.id, it.x, it.y, theme.draw('item', it.label)))\n layers.push(' }')\n\n const behavior: string[] = []\n m.items.forEach((it, i) => {\n behavior.push(`object \"${it.id}\" {`)\n behavior.push(` drag ${it.id}X, ${it.id}Y { enabled ${it.id}Placed == 0 }`)\n behavior.push(` when dropped on ${it.target} at pointer {`)\n behavior.push(` if ${it.id}Placed < 0.5 {`)\n behavior.push(` ${it.id}Placed = 1`, ` ${p}progress = ${p}progress + 1`)\n // Snap onto the target it was dropped on, reading the target's LIVE position -- so a skin may move\n // the target anywhere and the item still lands on it.\n behavior.push(` ${it.id}X = ${it.target}.x`, ` ${it.id}Y = ${it.target}.y`)\n behavior.push(` send \"correct\", { block = ${b}, item = ${i} }`)\n behavior.push(` if ${p}progress == ${n} {`, ` ${doneVar} = 1`, ` send \"part\", { block = ${b} }`, ' }')\n behavior.push(' }', ' }')\n for (const t of m.targets) {\n if (t.id === it.target) continue\n behavior.push(` when dropped on ${t.id} at pointer {`)\n behavior.push(` ${it.id}X = ${it.x}`, ` ${it.id}Y = ${it.y}`) // back where it started\n behavior.push(` send \"incorrect\", { block = ${b}, item = ${i} }`)\n behavior.push(' }')\n }\n behavior.push(` x = ${it.id}X`, ` y = ${it.id}Y`, '}', '')\n })\n return {\n vars,\n layers,\n behavior,\n meta: { keyword: 'place', name, prompt: m.prompt, items: m.items.map((i) => i.label), targets: m.targets.map((t) => t.label), objects: [...m.targets, ...m.items].map((o) => o.id), doneVar },\n }\n}\n\n// ── compose ──────────────────────────────────────────────────────────────────\n// Tap values until they add up to a target. Overshooting resets the total -- the whole point of the\n// exercise is that going over is a mistake you feel, not one you are prevented from making.\n\nfunction expandCompose(name: string, body: string, theme: Theme, ctx: GestureContext): Expansion {\n const { prefix: p, index: b, doneVar } = ctx\n let target = 0\n const chips: { value: string; x: string; y: string }[] = []\n let prompt = ''\n for (const line of lines(body)) {\n let x: RegExpMatchArray | null\n if ((x = line.match(/^prompt\\s+\"(.*)\"$/))) prompt = x[1]\n else if ((x = line.match(/^total\\s+(\\d+)$/))) target = Number(x[1])\n else if ((x = line.match(/^chip\\s+(\\d+)\\s+at\\s+(-?[\\d.]+),(-?[\\d.]+)$/))) chips.push({ value: x[1], x: x[2], y: x[3] })\n else throw new Error(`compose \"${name}\": unrecognised line: ${line}`)\n }\n if (!target) throw new Error(`compose \"${name}\": no \\`total <n>\\` — there is nothing to reach`)\n if (!chips.length) throw new Error(`compose \"${name}\": no chip — nothing for the learner to tap`)\n\n const vars = [`// ${p}— compose \"${q(name)}\"`, ...(prompt ? [`// prompt: ${q(prompt)}`] : []), `var ${p}total = 0`, `var ${doneVar} = 0`]\n const layers = [` layer \"${p}chips\" {`]\n chips.forEach((c, i) => layers.push(...container(`${p}C${i}`, c.x, c.y, theme.draw('chip', c.value), theme.size('chip'))))\n layers.push(' }')\n\n const behavior: string[] = []\n chips.forEach((c, i) => {\n behavior.push(`object \"${p}C${i}\" {`, ' when clicked {', ` if ${doneVar} < 0.5 {`)\n behavior.push(` if ${p}total + ${c.value} > ${target} {`)\n behavior.push(` ${p}total = 0`, ` send \"incorrect\", { block = ${b}, item = ${i} }`)\n behavior.push(' } else {')\n behavior.push(` ${p}total = ${p}total + ${c.value}`, ` send \"correct\", { block = ${b}, item = ${i} }`)\n behavior.push(` if ${p}total == ${target} {`, ` ${doneVar} = 1`, ` send \"part\", { block = ${b} }`, ' }')\n behavior.push(' }', ' }', ' }', '}', '')\n })\n return {\n vars,\n layers,\n behavior,\n meta: { keyword: 'compose', name, prompt, items: chips.map((c) => c.value), targets: [], objects: chips.map((_c, i) => `${p}C${i}`), doneVar },\n }\n}\n\n// ── steps ────────────────────────────────────────────────────────────────────\n// A gated sequence: step i only responds when it is the current one. Tapping out of order does nothing\n// at all -- no error, no penalty, which is what makes it usable as an escape-room stage.\n\nfunction expandSteps(name: string, body: string, theme: Theme, ctx: GestureContext): Expansion {\n const { prefix: p, index: b, doneVar } = ctx\n let prompt = ''\n const steps: { label: string; x: string; y: string }[] = []\n for (const line of lines(body)) {\n let x: RegExpMatchArray | null\n if ((x = line.match(/^prompt\\s+\"(.*)\"$/))) prompt = x[1]\n else if ((x = line.match(/^step\\s+\"(.*)\"\\s+at\\s+(-?[\\d.]+),(-?[\\d.]+)$/))) steps.push({ label: x[1], x: x[2], y: x[3] })\n else throw new Error(`steps \"${name}\": unrecognised line: ${line}`)\n }\n if (!steps.length) throw new Error(`steps \"${name}\": no step — the sequence is empty`)\n\n const vars = [`// ${p}— steps \"${q(name)}\"`, ...(prompt ? [`// prompt: ${q(prompt)}`] : []), `var ${p}step = 0`, `var ${doneVar} = 0`]\n const layers = [` layer \"${p}steps\" {`]\n steps.forEach((s, i) => layers.push(...container(`${p}S${i}`, s.x, s.y, theme.draw('card', s.label), theme.size('card'))))\n layers.push(' }')\n\n const behavior: string[] = []\n steps.forEach((_s, i) => {\n behavior.push(`object \"${p}S${i}\" {`, ' when clicked {', ` if ${p}step == ${i} {`, ` ${p}step = ${p}step + 1`, ` send \"step\", { block = ${b}, item = ${i} }`)\n if (i === steps.length - 1) behavior.push(` ${doneVar} = 1`, ` send \"part\", { block = ${b} }`)\n behavior.push(' }', ' }')\n // The only thing the gesture says about looks: a step that is not current is dimmed, because\n // \"which one is live\" is STATE, not decoration. A theme that disagrees rebinds opacity itself.\n behavior.push(` opacity = ${p}step == ${i} ? 1 : 0.45`, '}', '')\n })\n return {\n vars,\n layers,\n behavior,\n meta: { keyword: 'steps', name, prompt, items: steps.map((s) => s.label), targets: [], objects: steps.map((_s, i) => `${p}S${i}`), doneVar },\n }\n}\n\n/** `208x118` — the footprint of a role under a theme, for a summary or a prompt. */\nconst footprint = (theme: Theme, role: Role): string => {\n const { w, h } = theme.size(role)\n return `${w}x${h}`\n}\n\n/**\n * Build the shipped gestures against a theme. `GREYBOX` unless the caller supplies one.\n *\n * Each `summary` carries the FOOTPRINTS of the roles it places, because the author writes positions and\n * two overlapping surfaces make a drop ambiguous. Measured on ten model-written activities: a prompt\n * giving only \"space them out\" produced overlapping hitboxes in 4 of 10; the same prompt with the\n * numbers, 0 of 10. The sizes were public all along — nothing said you had to go and read them.\n */\nexport function gestures(opts: GestureOptions = {}): Gesture[] {\n const theme = opts.theme ?? GREYBOX\n return [\n {\n keyword: 'place',\n summary: `place <name> { prompt \"…\" target <T> at x,y item <i> -> <T> at x,y } — drag items onto where they belong. Footprints: target ${footprint(theme, 'target')}, item ${footprint(theme, 'item')}; keep centres at least one footprint apart or the drop is ambiguous`,\n expand: (name, body, _doc, ctx) => expandPlace(name, body, theme, ctx),\n },\n {\n keyword: 'compose',\n summary: `compose <name> { prompt \"…\" total <n> chip <v> at x,y } — tap values until they add up; overshooting resets. Footprint: chip ${footprint(theme, 'chip')}`,\n expand: (name, body, _doc, ctx) => expandCompose(name, body, theme, ctx),\n },\n {\n keyword: 'steps',\n summary: `steps <name> { prompt \"…\" step \"…\" at x,y } — a gated sequence; out-of-order taps do nothing. Footprint: card ${footprint(theme, 'card')}`,\n expand: (name, body, _doc, ctx) => expandSteps(name, body, theme, ctx),\n },\n ]\n}\n\n/**\n * The paste-ready reference for a model writing sugar: the grammar of every gesture, the footprints it\n * must respect, and the canvas it is laying out on. This is the artefact `summary` was being used as by\n * hand — assembled here so nobody has to know that the sizes live on the theme.\n */\nexport function sugarCard(opts: GestureOptions & { document?: { width: number; height: number } } = {}): string {\n const theme = opts.theme ?? GREYBOX\n const doc = opts.document ?? { width: 760, height: 620 }\n return [\n '# FlatInk sugar — a document is one or more blocks',\n '',\n `Canvas: ${doc.width}x${doc.height}, origin top-left. Coordinates are the CENTRE of each thing.`,\n 'Anything you do not describe is not drawn.',\n '',\n '## Blocks',\n ...gestures({ theme }).map((g) => `- ${g.summary}`),\n '',\n 'Several blocks may share a document; give each a DISTINCT name. They are laid out in the order you',\n 'write them, each keeps its own state, and each emits `part` when its own portion is finished. The',\n 'document emits `completed` once, when every block is done.',\n '',\n '## Footprints — respect them or two things overlap and the drop becomes ambiguous',\n ...ROLES.map((role) => `- ${role}: ${footprint(theme, role)}`),\n '',\n `A row of targets fits about ${Math.floor(doc.width / (theme.size('target').w + 20))} across; a row of items about ${Math.floor(doc.width / (theme.size('item').w + 20))}.`,\n 'Leave a gap the size of the thing itself between two centres. Two blocks must not share the same area.',\n '',\n '## Escape hatch — three forms, and they are not interchangeable',\n 'The blocks draw NOTHING beyond the pieces above. Everything else goes through one of these:',\n '',\n 'raw scene under { layer \"bg\" { … } } <- BACKGROUND and decor. Drawn BEHIND everything.',\n 'raw scene { layer \"banner\" { … } } <- overlays drawn ON TOP: a title, a frame, a caption.',\n 'raw { var lives = 3 object \"X\" { … } } <- header and behavior: var, fn, asset, object blocks.',\n '',\n 'A `layer` written in a plain `raw { … }` lands OUTSIDE the scene and is a compile error — anything',\n 'that is drawn belongs in one of the two `raw scene` forms. Any of them may be written on one line.',\n ].join('\\n')\n}\n","// ─────────────────────────────────────────────────────────────────────────────\n// @flatkit/sugarflat — declarative sugar for FlatInk.\n//\n// A compact block expands into INSPECTABLE `.flatink`. The expansion is the artefact of record: the\n// sugar is an authoring tool, never a runtime, and anything it writes can be written by hand instead.\n//\n// WHY IT LIVES IN THIS REPO. Not to put authoring opinions into the language — it is a separate\n// package, out of the lockstep group, and `@flatkit/compiler` never depends on it. It lives here so\n// the two move together: a grammar change breaks these tests in the same CI run. That is the whole\n// argument, and it was demonstrated rather than argued — the previous out-of-tree sugar never emitted\n// the format's REQUIRED `size` line, on its entire corpus, for months, unnoticed.\n//\n// THE LINE THIS PACKAGE DOES NOT CROSS: no visual opinion. A gesture emits state and behavior; it\n// never emits a coordinate, a colour or a font. The language already ships interaction opinions\n// (`drag`, `when dropped on … at pointer`, `hitbox`, `match`, `feedback`, `spring`) — what it has\n// never shipped is a look, and a sugar that shipped one would hand every activity the same face.\n// ─────────────────────────────────────────────────────────────────────────────\nimport { DEFAULT_DOCUMENT, ensureHeader, type DocumentSpec } from './document'\nimport { gestures } from './gestures'\nimport { ident } from './ident'\n\nexport { DEFAULT_DOCUMENT, ensureHeader, hasSizeHeader, hasTimelineHeader, type DocumentSpec } from './document'\nexport { ident, isIdent } from './ident'\nexport { gestures, sugarCard, type GestureOptions } from './gestures'\nexport { BLANK, GREYBOX, ROLES, type Role, type Theme } from './theme'\n\n/**\n * What a gesture parsed out of the author's block, beside the DSL it wrote.\n *\n * A host needs this. The expansion deliberately carries no text a host can read back — the prompt is the\n * learner's instruction and the payloads are indices (`send \"correct\", { item = 2 }`), so without the\n * labels there is nothing to display and nothing to map an index onto. Re-parsing the block by hand to\n * recover data the package already parsed is not an integration; it is a second parser waiting to drift.\n */\nexport type GestureMeta = {\n keyword: string\n /** The block's name — also the prefix on every name it emits. */\n name: string\n /** The learner's instruction, verbatim. Drawn by the host or a theme — never by the gesture. */\n prompt: string\n /** Labels in payload order: `{ block = b, item = 2 }` is `blocks[b].items[2]`. */\n items: string[]\n /** Target labels, in the order they were declared. Empty when the gesture has none. */\n targets: string[]\n /** Every object id it emitted, prefixed — what a skin binds to, without having to guess the scheme. */\n objects: string[]\n /** The variable that turns 1 when this block is finished. */\n doneVar: string\n}\n\n/** Where a block sits in the document. Names are prefixed so two blocks never collide. */\nexport type GestureContext = {\n /** 0-based position, and the `block` field of every payload it sends. */\n index: number\n /** `<name>_` — put it in front of every var and every object id. */\n prefix: string\n /** The variable to set to 1 when the block is done; the document watches it. */\n doneVar: string\n}\n\n/** What a gesture returns: PARTS, never a finished program — a document has exactly one `scene`. */\nexport type Expansion = {\n /** `var` declarations. They go in the header, where `var` is legal. */\n vars: string[]\n /** Layer statements, indented for the inside of `scene { … }`. */\n layers: string[]\n /** `object` blocks and scene-wide handlers. */\n behavior: string[]\n meta: GestureMeta\n}\n\n/** A sugar block: the keyword that opens it, and how it expands. */\nexport type Gesture = {\n /** The opening keyword, e.g. `place`. Matched only at column 0, followed by a name and `{`. */\n keyword: string\n /** One line, for diagnostics and for the reference a model is prompted with. */\n summary: string\n /** `body` is the text between the braces; `name` the block's name. */\n expand: (name: string, body: string, doc: DocumentSpec, ctx: GestureContext) => Expansion\n}\n\nexport type DesugarOptions = {\n /** The canvas + timeline the expansion targets. */\n document?: DocumentSpec\n /** Gestures to recognise. Defaults to the registered set. */\n gestures?: Gesture[]\n}\n\nexport type DesugarResult = {\n /** The expanded (or passed-through) FlatInk. */\n flatink: string\n /** Which gesture matched — `raw` for an escape-only source, `null` for plain FlatInk. */\n kind: string | null\n expanded: boolean\n /** What each block understood, in document order: `{ block = 2 }` refers to `meta[2]`. Empty when\n * nothing was expanded, since there is no block to have understood anything from. */\n meta: GestureMeta[]\n}\n\n/** Raised when a source opens a block that looks like sugar but no gesture claims it. */\nexport class UnknownSugarError extends Error {\n constructor(readonly keyword: string, known: string[]) {\n super(\n `unknown sugar block \"${keyword}\" — no gesture claims it, so nothing was expanded. ` +\n `Known blocks: ${known.length ? known.join(', ') : '(none registered)'}. ` +\n `If this is meant to be plain FlatInk, it is not: \"${keyword}\" is not a FlatInk statement either.`,\n )\n this.name = 'UnknownSugarError'\n }\n}\n\n/** The gestures this package ships, drawn by the default theme. Each entry is a public promise. */\nexport const GESTURES: Gesture[] = gestures()\n\n/** A block opens at column 0: `<keyword> <name> {`. The name may be quoted (so it can hold spaces). */\nconst BLOCK_OPEN = /^([a-zA-Z][\\w-]*)[ \\t]+(?:\"([^\"]+)\"|([^\\s{\"]+))[ \\t]*\\{/m\n\n/**\n * The escape hatch, in three forms. A sugar that cannot be opted out of stops being scaffolding and\n * becomes a cage: the previous generation of this idea flattened every activity into the same shape\n * until the template was pulled apart. Anything a gesture writes must remain writable by hand, beside it.\n *\n * raw { … } verbatim at TOP LEVEL — header (`asset`, `var`, `fn`) and `object` blocks\n * raw scene { … } verbatim inside the generated scene, ON TOP of it — banners, overlays\n * raw scene under { … } verbatim inside the generated scene, UNDERNEATH it — backgrounds\n *\n * `under` is not a nicety. A gesture emits no appearance by design, so a background is the FIRST thing\n * any skin needs — and spliced on top, an opaque full-canvas rect hides the entire activity while\n * `checkProgram` reports a clean program. Ten activities shipped that way, read as broken assets.\n */\nconst RAW_OPEN = /^raw(?:[ \\t]+scene(?:[ \\t]+(under))?)?[ \\t]*\\{/gm\n\ntype RawParts = { top: string[]; over: string[]; under: string[]; rest: string }\n\n/**\n * Pull every `raw …` block out of `text`. Brace-counted rather than line-anchored, so the one-line form\n * works — the README and `sugarCard()` both write `raw { … }` on one line, and a regex demanding a\n * newline after `{` left the keyword to travel on to the compiler, which reported `unexpected statement\n * \"raw\"`: a sugar defect described in FlatInk's vocabulary, the very thing `UnknownSugarError` fixed.\n */\nfunction takeRaw(text: string): RawParts {\n const out: RawParts = { top: [], over: [], under: [], rest: '' }\n let cursor = 0\n RAW_OPEN.lastIndex = 0\n for (let m = RAW_OPEN.exec(text); m; m = RAW_OPEN.exec(text)) {\n const openBrace = m.index + m[0].length - 1\n const end = blockEnd(text, openBrace)\n if (end < 0) break // unbalanced: leave it alone, the compiler will say so\n const raw = text.slice(openBrace + 1, end)\n // One-line form (`raw { var x = 1 }`) keeps the spaces that hugged the braces; the multi-line form\n // keeps its own indentation, which is the author's.\n const body = raw.includes('\\n') ? raw.replace(/^\\r?\\n/, '').replace(/\\r?\\n[ \\t]*$/, '') : raw.trim()\n const bucket = m[0].includes('scene') ? (m[1] ? out.under : out.over) : out.top\n bucket.push(body)\n out.rest += text.slice(cursor, m.index)\n cursor = end + 1\n RAW_OPEN.lastIndex = cursor\n }\n out.rest += text.slice(cursor)\n return out\n}\n\n/** Index of the `}` closing the brace at `openBrace`, or -1 if unbalanced. */\nfunction blockEnd(text: string, openBrace: number): number {\n let depth = 1\n for (let i = openBrace + 1; i < text.length; i++) {\n if (text[i] === '{') depth++\n else if (text[i] === '}' && --depth === 0) return i\n }\n return -1\n}\n\nconst RAW_NOTE = '// -- raw (escape hatch: verbatim FlatInk) --'\n\n/** Raised when two blocks share a name — every name they emit would collide. */\nexport class DuplicateBlockError extends Error {\n constructor(name: string) {\n super(`two blocks are both named \"${name}\" — the name prefixes every variable and object a block emits, so they would overwrite each other. Give each block its own name.`)\n this.name = 'DuplicateBlockError'\n }\n}\n\n/** One gesture block found in the source, with its span so the text around it can be recovered. */\ntype Found = { gesture: Gesture; name: string; body: string; start: number; end: number }\n\n/** Every gesture block in `src`, in document order. */\nfunction findBlocks(src: string, gestures: Gesture[]): Found[] {\n const re = new RegExp(BLOCK_OPEN.source, 'gm')\n const found: Found[] = []\n for (let m = re.exec(src); m; m = re.exec(src)) {\n const gesture = gestures.find((g) => g.keyword === m![1])\n if (!gesture) {\n // A keyword that opens a block at column 0 and is neither sugar nor FlatInk is a block we do not\n // know — say so with the list, rather than downstream in another vocabulary.\n if (m[1] !== 'raw' && !FLATINK_BLOCKS.has(m[1])) throw new UnknownSugarError(m[1], gestures.map((g) => g.keyword))\n continue\n }\n const braceAt = m.index + m[0].length - 1\n const close = blockEnd(src, braceAt)\n if (close < 0) break\n found.push({ gesture, name: m[2] ?? m[3] ?? gesture.keyword, body: src.slice(braceAt + 1, close), start: m.index, end: close + 1 })\n re.lastIndex = close + 1\n }\n return found\n}\n\n/**\n * Assemble the blocks into ONE program.\n *\n * A document has exactly one `scene`, one header and one behavior half, so composing gestures is not a\n * matter of concatenating their output — it is a matter of never producing whole programs in the first\n * place. Each block contributes parts; this puts them in the three places the format has.\n *\n * Two things the assembly decides, and they are the reason \"several blocks\" is a design and not a loop:\n *\n * • **Names are prefixed by the block's name, always** — including when a document holds one block.\n * Prefixing only on collision would mean the same source compiles to different names depending on\n * whether a sibling exists, so a skin written against one block would break the day a second arrived.\n * Every id is in `meta[].objects`, so nothing has to be guessed.\n * • **`completed` belongs to the DOCUMENT.** Each block emits `part` with its own index when its\n * portion is finished; `completed` fires once, when every block is done. With a single block the two\n * coincide, which is what `completed` always meant.\n */\nfunction assemble(blocks: { expansion: Expansion }[], under: string[], over: string[], doc: DocumentSpec): string {\n const out: string[] = [`size ${doc.width} ${doc.height}`, `timeline ${doc.fps} ${doc.durationFrames}`]\n const done = blocks.map((b) => b.expansion.meta.doneVar)\n if (done.length) out.push('var allDone = 0')\n for (const b of blocks) out.push(...b.expansion.vars)\n\n out.push('', 'scene {')\n if (under.length) out.push(' // -- raw scene under (verbatim, drawn BEHIND every block) --', ...under)\n for (const b of blocks) out.push(...b.expansion.layers)\n if (over.length) out.push(' // -- raw scene (verbatim, drawn ON TOP of every block) --', ...over)\n out.push('}', '')\n\n for (const b of blocks) out.push(...b.expansion.behavior)\n // `completed` = the whole document. One block: it fires the moment that block does, which is what it\n // has always meant. Several: only once all of them have. The `allDone` guard matters -- an unguarded\n // `send` inside `every frame` would emit it again on every frame for the rest of the session.\n if (done.length) {\n out.push('every frame {', ' if allDone < 0.5 {', ` if ${done.join(' + ')} >= ${done.length} {`, ' allDone = 1', ' send \"completed\"', ' }', ' }', '}')\n }\n return out.join('\\n')\n}\n\n/** Block keywords that belong to FlatINK itself — a source opening with one of these is a program. */\nconst FLATINK_BLOCKS = new Set(['scene', 'object', 'symbol', 'layer', 'group', 'match', 'each', 'states', 'params', 'when', 'every', 'repeat', 'fn', 'at'])\n\n/**\n * Expand a sugar source into `.flatink`.\n *\n * Plain FlatInk passes through untouched. A block nobody claims RAISES rather than passing through: a\n * silent fall-through sent the author's block downstream as if it were FlatInk, to fail a hundred lines\n * later on messages that only talk about FlatInk.\n *\n * A document may hold SEVERAL blocks. They are laid out in the order they are written, each keeps its own\n * state under its own name, and each emits `part` when its portion is finished; `completed` fires once,\n * when every block is done.\n *\n * ```ts\n * import { desugar } from '@flatkit/sugarflat'\n * import { checkProgram } from '@flatkit/compiler'\n *\n * const { flatink, meta } = desugar(srcFromAnLLM)\n * const { ok, report } = checkProgram(flatink) // the expansion is the artefact of record\n * ```\n */\nexport function desugar(src: string, opts: DesugarOptions = {}): DesugarResult {\n const doc = opts.document ?? DEFAULT_DOCUMENT\n const gestures = opts.gestures ?? GESTURES\n\n const found = findBlocks(src, gestures)\n if (!found.length) {\n // Plain FlatInk, plus any `raw { … }` used on its own. `raw scene` has no generated scene to splice\n // into here, so it would silently vanish -- say so instead.\n const parts = takeRaw(src)\n if (parts.over.length || parts.under.length) {\n throw new Error('`raw scene { … }` needs a gesture block to splice into — this source has none. Write a plain `scene { … }` yourself.')\n }\n const out = [parts.rest.trim(), ...(parts.top.length ? [RAW_NOTE, ...parts.top] : [])].filter(Boolean).join('\\n')\n return { flatink: parts.top.length ? out : src, kind: parts.top.length ? 'raw' : null, expanded: parts.top.length > 0, meta: [] }\n }\n\n const seen = new Set<string>()\n for (const b of found) {\n const key = ident(b.name)\n if (seen.has(key)) throw new DuplicateBlockError(b.name)\n seen.add(key)\n }\n\n // Everything OUTSIDE the blocks travels with them: `raw` in its three forms, and any plain FlatInk the\n // author wrote beside them. Dropping it made the escape hatch a no-op -- decor was written, the\n // expansion compiled, `checkProgram` said ok, and nothing was there.\n const outside: RawParts = { top: [], over: [], under: [], rest: '' }\n const absorb = (text: string) => {\n const part = takeRaw(text)\n outside.top.push(...part.top)\n outside.over.push(...part.over)\n outside.under.push(...part.under)\n outside.rest += part.rest\n }\n let cursor = 0\n for (const b of found) { absorb(src.slice(cursor, b.start)); cursor = b.end }\n absorb(src.slice(cursor))\n\n const blocks = found.map((b, index) => {\n const prefix = `${ident(b.name)}_`\n return { expansion: b.gesture.expand(b.name, b.body, doc, { index, prefix, doneVar: `${prefix}done` }) }\n })\n\n // Top-level content goes in the HEADER position, wherever the author wrote it: `var` (like `asset`,\n // `use`, `def`) is a header declaration and a parse error after `scene`, while `object`/`fn` are legal\n // on either side. Moving an `object` up changes nothing -- behavior binds by name, not by position.\n const header = [outside.rest.trim(), ...(outside.top.length ? [RAW_NOTE, ...outside.top] : [])].filter(Boolean).join('\\n')\n const program = assemble(blocks, outside.under, outside.over, doc)\n return {\n flatink: ensureHeader(header ? `${header}\\n\\n${program}` : program, doc),\n kind: found.map((b) => b.gesture.keyword).join('+'),\n expanded: true,\n meta: blocks.map((b) => b.expansion.meta),\n }\n}\n"],"mappings":";AAsBO,IAAM,mBAAiC,EAAE,OAAO,KAAK,QAAQ,KAAK,KAAK,IAAI,gBAAgB,IAAI;AAG/F,IAAM,gBAAgB,CAAC,QAAyB,qCAAqC,KAAK,GAAG;AAG7F,IAAM,oBAAoB,CAAC,QAAyB,yBAAyB,KAAK,GAAG;AAOrF,SAAS,aAAa,SAAiB,MAAoB,kBAA0B;A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EAAE,MAAM,EAAE,MAAM,KAAK,EAAE,OAAO,QAAQ,SAAS,GAAG,MAAM,OAAO,CAAC,EAAE;AAAA,EACzG,CAAC;AAKD,QAAM,SAAS,CAAC,QAAQ,KAAK,KAAK,GAAG,GAAI,QAAQ,IAAI,SAAS,CAAC,UAAU,GAAG,QAAQ,GAAG,IAAI,CAAC,CAAE,EAAE,OAAO,OAAO,EAAE,KAAK,IAAI;AACzH,QAAM,UAAU,SAAS,QAAQ,QAAQ,OAAO,QAAQ,MAAM,GAAG;AACjE,SAAO;AAAA,IACL,SAAS,aAAa,SAAS,GAAG,MAAM;AAAA;AAAA,EAAO,OAAO,KAAK,SAAS,GAAG;AAAA,IACvE,MAAM,MAAM,IAAI,CAAC,MAAM,EAAE,QAAQ,OAAO,EAAE,KAAK,GAAG;AAAA,IAClD,UAAU;AAAA,IACV,MAAM,OAAO,IAAI,CAAC,MAAM,EAAE,UAAU,IAAI;AAAA,EAC1C;AACF;","names":["gestures"]}
|
|
1
|
+
{"version":3,"sources":["../src/document.ts","../src/ident.ts","../src/theme.ts","../src/gestures.ts","../src/index.ts"],"sourcesContent":["// ─────────────────────────────────────────────────────────────────────────────\n// document.ts — the document a sugar block expands into.\n//\n// Two things a sugar MUST know and an author MUST be able to read: the canvas the gesture is laid out\n// for, and the timeline it rides. Both were literals buried inside an expander, which cost twice:\n// • the expansion never emitted `size` at all, so it fell back on the compiler's 800x600 default\n// while the board was painted for 760x620 -- everything past x=760 was clipped in silence, on the\n// whole corpus, for months (nothing says so: a missing `size` still compiles);\n// • prompting a model for the right coordinates meant reading the generator's source.\n// Exposed here, overridable per call, and stamped onto every expansion by `ensureHeader`.\n// ─────────────────────────────────────────────────────────────────────────────\n\n/** The canvas + timeline a sugar block expands into. */\nexport type DocumentSpec = {\n width: number\n height: number\n fps: number\n /** Timeline length. Long enough that `time` does not wrap mid-activity (the compiler warns under 120). */\n durationFrames: number\n}\n\n/** The board the gestures are laid out for. Override per call when a host uses another canvas. */\nexport const DEFAULT_DOCUMENT: DocumentSpec = { width: 760, height: 620, fps: 24, durationFrames: 120 }\n\n/** `true` if the source already declares its canvas — `size` must be the FIRST statement of a program. */\nexport const hasSizeHeader = (src: string): boolean => /^[ \\t]*size\\s+-?[\\d.]+\\s+-?[\\d.]+/m.test(src)\n\n/** `true` if the source already declares a root timeline. */\nexport const hasTimelineHeader = (src: string): boolean => /^[ \\t]*timeline\\s+\\d+/m.test(src)\n\n/**\n * Prepend whatever header the expansion is missing. `size` is REQUIRED by the format and silently\n * defaulted by the compiler when absent, so emitting it is not a nicety: it is the difference between\n * the document the author designed and the one that gets drawn.\n */\nexport function ensureHeader(flatink: string, doc: DocumentSpec = DEFAULT_DOCUMENT): string {\n const head: string[] = []\n if (!hasSizeHeader(flatink)) head.push(`size ${doc.width} ${doc.height}`)\n if (!hasTimelineHeader(flatink)) head.push(`timeline ${doc.fps} ${doc.durationFrames}`)\n return head.length ? `${head.join('\\n')}\\n${flatink}` : flatink\n}\n","// ─────────────────────────────────────────────────────────────────────────────\n// ident.ts — a human label -> a FlatInk identifier.\n//\n// A sugar lets an author name things in their own language (\"chene\", \"Vegetaux\", \"21 janvier 1793\"),\n// and those names become identifiers (`var`, `object`). FlatInk identifiers are `[A-Za-z0-9_]`, so an\n// accent does not error -- the lexer stops at it and reads the tail. `chene` written with its accent\n// became `var <accented>X`, read as `neX`: two variables where the author wrote one, and no diagnostic.\n// Transliterate here, once, rather than in every gesture.\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * A FlatInk identifier derived from a human label: accents folded to ASCII, anything else to `_`, and\n * a leading digit prefixed (an identifier may not start with one). Stable and idempotent, so the same\n * label always yields the same name — the sugar's variables and the author's references must agree.\n */\nexport function ident(label: string): string {\n const ascii = label.normalize('NFD').replace(/\\p{Diacritic}/gu, '').replace(/[^A-Za-z0-9_]/g, '_')\n return /^[0-9]/.test(ascii) ? `n${ascii}` : ascii\n}\n\n/** `true` if the label survives `ident` unchanged — i.e. it is already a usable identifier. */\nexport const isIdent = (label: string): boolean => ident(label) === label && label.length > 0\n","// ─────────────────────────────────────────────────────────────────────────────\n// theme.ts — where appearance lives, so that gestures do not carry any.\n//\n// A gesture emits STRUCTURE and BEHAVIOR: named groups at the coordinates the author gave, their drop\n// boxes, their state, their handlers. It must never decide what any of it LOOKS like — a sugar that\n// ships a look hands every activity built on it the same face, and that has already happened once.\n//\n// So appearance is a parameter. `BLANK` draws nothing at all, which is what makes the claim testable\n// rather than aspirational: expand a gesture with `BLANK` and the output must not contain one colour,\n// one font, or one stroke. `GREYBOX` is a deliberately plain default so a freshly written block is\n// playable immediately — it is provisional by design, and swapping it is a single argument.\n// ─────────────────────────────────────────────────────────────────────────────\n\n/** What a drawn thing is FOR. Four roles cover every gesture; a theme need not distinguish more. */\nexport type Role =\n | 'item' // something the learner moves\n | 'target' // where an item belongs\n | 'card' // a panel the learner reads and taps\n | 'chip' // a small tappable value\n\nexport type Theme = {\n readonly name: string\n /** Footprint of a role. The gesture uses it for drop boxes; the theme must draw within it. */\n size(role: Role): { w: number; h: number }\n /** Drawing statements for a role, in LOCAL coordinates centred on 0,0. May be empty. */\n draw(role: Role, label: string): string[]\n}\n\n/** Every role, in a stable order — for a reference card, or to sweep a theme. */\nexport const ROLES: Role[] = ['item', 'target', 'card', 'chip']\n\nconst SIZES: Record<Role, { w: number; h: number }> = {\n item: { w: 92, h: 92 },\n target: { w: 208, h: 118 },\n card: { w: 180, h: 140 },\n chip: { w: 96, h: 96 },\n}\n\n/**\n * Draws nothing. The gesture still emits every group, every box and every handler, so an author (or a\n * skin) supplies the whole appearance — and the test suite uses it to prove the gestures themselves\n * carry no visual opinion.\n */\nexport const BLANK: Theme = {\n name: 'blank',\n size: (role) => SIZES[role],\n draw: () => [],\n}\n\n/** Rounded rectangle path, centred on the origin — the greybox's only shape vocabulary. */\nconst plate = (w: number, h: number, r: number): string => `rect ${-w / 2} ${-h / 2} ${w} ${h} ${r}`\n\n/**\n * A plain, provisional greybox: readable, anonymous, and meant to be replaced. It exists so `place x {\n * … }` is playable the moment it is written; it is not a design, and anything built for an audience\n * should pass its own theme (or redraw beside the gesture with `raw { … }`).\n */\nexport const GREYBOX: Theme = {\n name: 'greybox',\n size: (role) => SIZES[role],\n draw(role, label) {\n const { w, h } = SIZES[role]\n const text = (size: number, boxW: number, boxH: number, colour: string, y: number) =>\n `text \"${label.replace(/\"/g, \"'\")}\" at ${-boxW / 2},${y} font \"system-ui, sans-serif\" size ${size} align center line 1.2 color ${colour} box ${boxW} ${boxH} wrap`\n switch (role) {\n case 'item':\n return [`circle 0 0 ${w / 2 - 12} fill #e8c46b`, `circle 0 0 ${w / 2 - 12} nofill stroke #b8923f 2`, text(14, w - 8, 20, '#4a3a1e', -9)]\n case 'target':\n return [`${plate(w - 8, h - 8, 14)} fill #2e3a4e`, `${plate(w - 8, h - 8, 14)} nofill stroke #5a6f8a 2 dash 8,6`, text(16, w - 28, 22, '#aeb6c4', -h / 2 + 10)]\n case 'card':\n return [`${plate(w, h, 16)} fill #2b3447`, `${plate(w, h, 16)} nofill stroke #44516a 2`, text(15, w - 20, h - 40, '#d7deea', -h / 2 + 26)]\n case 'chip':\n return [`circle 0 0 ${w / 2 - 8} fill #e8c46b`, `circle 0 0 ${w / 2 - 8} nofill stroke #b8923f 3`, text(22, w - 16, 28, '#4a3a1e', -13)]\n }\n },\n}\n","// ─────────────────────────────────────────────────────────────────────────────\n// gestures.ts — the three primitives.\n//\n// Five named gestures came in (`tri`, `ordonner`, `placement`, `composer`, `etapes`). Read side by\n// side, the first three share ONE implementation: the only thing that differed between them was which\n// shape their targets were drawn as -- rectangles, squares or dotted discs. That is appearance, and\n// appearance is the theme's business, so they collapse into a single `place`.\n//\n// Each gesture emits state, structure and behavior. Not one colour, not one font: `BLANK` proves it.\n// Coordinates DO appear, and that is not an opinion -- they are the ones the author wrote in the block.\n//\n// A gesture returns PARTS, never a finished program: its `var` lines, its layers, its behavior. That is\n// what lets a document hold several of them -- a program has exactly one `scene`, so merging text after\n// the fact was always going to be surgery. Assembling parts is not.\n// ─────────────────────────────────────────────────────────────────────────────\nimport type { Expansion, Gesture, GestureContext } from './index'\nimport { ident } from './ident'\nimport { GREYBOX, ROLES, type Role, type Theme } from './theme'\n\n/** Everything a gesture needs beyond the author's text. */\nexport type GestureOptions = { theme?: Theme }\n\nconst q = (s: string) => s.replace(/\"/g, \"'\")\n\n/** Statements of a named group placed at `x,y`, drawn by the theme, optionally a drop box. */\nfunction container(name: string, x: string, y: string, art: string[], hitbox?: { w: number; h: number }): string[] {\n const box = hitbox ? ` hitbox ${hitbox.w} ${hitbox.h}` : ''\n return [` group \"${name}\" at ${x},${y} pivot 0,0${box} {`, ' layer \"art\" {', ...art.map((l) => ` ${l}`), ' }', ' }']\n}\n\n/** A line holding two statements: one keyword, then another after a run of spaces. */\nconst RUNON = /^(?:prompt|target|item|total|chip|step)\\b.*\\s{2,}(?:prompt|target|item|total|chip|step)\\b/\n\n/**\n * Split a block body into its non-empty, comment-free lines — ONE STATEMENT PER LINE, like FlatInk\n * itself. A body written inline is a run-on, and it deserves its own message: the grammar sketch in\n * `summary` shows the shape on one line, so that is the natural thing to copy.\n */\nfunction lines(kind: string, name: string, body: string): string[] {\n const out = body.split('\\n').map((l) => l.replace(/\\/\\/.*$/, '').trim()).filter(Boolean)\n for (const line of out) {\n if (!RUNON.test(line)) continue\n const laid = line.split(/\\s{2,}/).filter(Boolean).map((st) => ` ${st}`).join('\\n')\n throw new Error(`${kind} \"${name}\": two statements on one line — a block takes ONE per line, like FlatInk itself:\\n ${kind} ${name} {\\n${laid}\\n }`)\n }\n return out\n}\n\n// ── place ────────────────────────────────────────────────────────────────────\n// The drop gesture: items belong on targets. Several items may share a target (a sort) or each may have\n// its own (an ordering, a labelled diagram) -- that falls out of the data, it is not a separate gesture.\n\ntype PlaceModel = {\n prompt: string\n targets: { id: string; label: string; x: string; y: string }[]\n items: { id: string; label: string; target: string; x: string; y: string }[]\n}\n\nfunction parsePlace(name: string, body: string, p: string): PlaceModel {\n const m: PlaceModel = { prompt: '', targets: [], items: [] }\n for (const line of lines('place', name, body)) {\n let x: RegExpMatchArray | null\n if ((x = line.match(/^prompt\\s+\"(.*)\"$/))) m.prompt = x[1]\n else if ((x = line.match(/^target\\s+(?:\"([^\"]+)\"|(\\S+))\\s+at\\s+(-?[\\d.]+),(-?[\\d.]+)$/))) {\n const label = x[1] ?? x[2]\n m.targets.push({ id: `${p}T${ident(label)}`, label, x: x[3], y: x[4] })\n } else if ((x = line.match(/^item\\s+(?:\"([^\"]+)\"|(\\S+))\\s*->\\s*(?:\"([^\"]+)\"|(\\S+))\\s+at\\s+(-?[\\d.]+),(-?[\\d.]+)$/))) {\n const label = x[1] ?? x[2]\n m.items.push({ id: `${p}I${ident(label)}`, label, target: `${p}T${ident(x[3] ?? x[4])}`, x: x[5], y: x[6] })\n } else throw new Error(`place \"${name}\": unrecognised line: ${line}`)\n }\n if (!m.targets.length) throw new Error(`place \"${name}\": no target — an item has nowhere to go`)\n if (!m.items.length) throw new Error(`place \"${name}\": no item — nothing for the learner to do`)\n const known = new Set(m.targets.map((t) => t.id))\n for (const it of m.items) {\n if (!known.has(it.target)) throw new Error(`place \"${name}\": item \"${it.label}\" points at an unknown target`)\n }\n return m\n}\n\nfunction expandPlace(name: string, body: string, theme: Theme, ctx: GestureContext): Expansion {\n const { prefix: p, index: b, doneVar } = ctx\n const m = parsePlace(name, body, p)\n const n = m.items.length\n const vars = [`// ${p}— place \"${q(name)}\"`, ...(m.prompt ? [`// prompt: ${q(m.prompt)}`] : []), `var ${p}progress = 0`, `var ${doneVar} = 0`]\n for (const it of m.items) vars.push(`var ${it.id}X = ${it.x}`, `var ${it.id}Y = ${it.y}`, `var ${it.id}Placed = 0`)\n\n const layers = [` layer \"${p}targets\" {`]\n for (const t of m.targets) layers.push(...container(t.id, t.x, t.y, theme.draw('target', t.label), theme.size('target')))\n layers.push(' }', ` layer \"${p}items\" {`)\n for (const it of m.items) layers.push(...container(it.id, it.x, it.y, theme.draw('item', it.label)))\n layers.push(' }')\n\n const behavior: string[] = []\n m.items.forEach((it, i) => {\n behavior.push(`object \"${it.id}\" {`)\n behavior.push(` drag ${it.id}X, ${it.id}Y { enabled ${it.id}Placed == 0 }`)\n behavior.push(` when dropped on ${it.target} at pointer {`)\n behavior.push(` if ${it.id}Placed < 0.5 {`)\n behavior.push(` ${it.id}Placed = 1`, ` ${p}progress = ${p}progress + 1`)\n // Snap onto the target it was dropped on, reading the target's LIVE position -- so a skin may move\n // the target anywhere and the item still lands on it.\n behavior.push(` ${it.id}X = ${it.target}.x`, ` ${it.id}Y = ${it.target}.y`)\n behavior.push(` send \"correct\", { block = ${b}, item = ${i} }`)\n behavior.push(` if ${p}progress == ${n} {`, ` ${doneVar} = 1`, ` send \"part\", { block = ${b} }`, ' }')\n behavior.push(' }', ' }')\n for (const t of m.targets) {\n if (t.id === it.target) continue\n behavior.push(` when dropped on ${t.id} at pointer {`)\n behavior.push(` ${it.id}X = ${it.x}`, ` ${it.id}Y = ${it.y}`) // back where it started\n behavior.push(` send \"incorrect\", { block = ${b}, item = ${i} }`)\n behavior.push(' }')\n }\n behavior.push(` x = ${it.id}X`, ` y = ${it.id}Y`, '}', '')\n })\n return {\n vars,\n layers,\n behavior,\n meta: { keyword: 'place', name, prompt: m.prompt, items: m.items.map((i) => i.label), targets: m.targets.map((t) => t.label), objects: [...m.targets, ...m.items].map((o) => o.id), doneVar },\n }\n}\n\n// ── compose ──────────────────────────────────────────────────────────────────\n// Tap values until they add up to a target. Overshooting resets the total -- the whole point of the\n// exercise is that going over is a mistake you feel, not one you are prevented from making.\n\nfunction expandCompose(name: string, body: string, theme: Theme, ctx: GestureContext): Expansion {\n const { prefix: p, index: b, doneVar } = ctx\n let target = 0\n const chips: { value: string; x: string; y: string }[] = []\n let prompt = ''\n for (const line of lines('compose', name, body)) {\n let x: RegExpMatchArray | null\n if ((x = line.match(/^prompt\\s+\"(.*)\"$/))) prompt = x[1]\n else if ((x = line.match(/^total\\s+(\\d+)$/))) target = Number(x[1])\n else if ((x = line.match(/^chip\\s+(\\d+)\\s+at\\s+(-?[\\d.]+),(-?[\\d.]+)$/))) chips.push({ value: x[1], x: x[2], y: x[3] })\n else throw new Error(`compose \"${name}\": unrecognised line: ${line}`)\n }\n if (!target) throw new Error(`compose \"${name}\": no \\`total <n>\\` — there is nothing to reach`)\n if (!chips.length) throw new Error(`compose \"${name}\": no chip — nothing for the learner to tap`)\n\n const vars = [`// ${p}— compose \"${q(name)}\"`, ...(prompt ? [`// prompt: ${q(prompt)}`] : []), `var ${p}total = 0`, `var ${doneVar} = 0`]\n const layers = [` layer \"${p}chips\" {`]\n chips.forEach((c, i) => layers.push(...container(`${p}C${i}`, c.x, c.y, theme.draw('chip', c.value), theme.size('chip'))))\n layers.push(' }')\n\n const behavior: string[] = []\n chips.forEach((c, i) => {\n behavior.push(`object \"${p}C${i}\" {`, ' when clicked {', ` if ${doneVar} < 0.5 {`)\n behavior.push(` if ${p}total + ${c.value} > ${target} {`)\n behavior.push(` ${p}total = 0`, ` send \"incorrect\", { block = ${b}, item = ${i} }`)\n behavior.push(' } else {')\n behavior.push(` ${p}total = ${p}total + ${c.value}`, ` send \"correct\", { block = ${b}, item = ${i} }`)\n behavior.push(` if ${p}total == ${target} {`, ` ${doneVar} = 1`, ` send \"part\", { block = ${b} }`, ' }')\n behavior.push(' }', ' }', ' }', '}', '')\n })\n return {\n vars,\n layers,\n behavior,\n meta: { keyword: 'compose', name, prompt, items: chips.map((c) => c.value), targets: [], objects: chips.map((_c, i) => `${p}C${i}`), doneVar },\n }\n}\n\n// ── steps ────────────────────────────────────────────────────────────────────\n// A gated sequence: step i only responds when it is the current one. Tapping out of order does nothing\n// at all -- no error, no penalty, which is what makes it usable as an escape-room stage.\n\nfunction expandSteps(name: string, body: string, theme: Theme, ctx: GestureContext): Expansion {\n const { prefix: p, index: b, doneVar } = ctx\n let prompt = ''\n const steps: { label: string; x: string; y: string }[] = []\n for (const line of lines('steps', name, body)) {\n let x: RegExpMatchArray | null\n if ((x = line.match(/^prompt\\s+\"(.*)\"$/))) prompt = x[1]\n else if ((x = line.match(/^step\\s+\"(.*)\"\\s+at\\s+(-?[\\d.]+),(-?[\\d.]+)$/))) steps.push({ label: x[1], x: x[2], y: x[3] })\n else throw new Error(`steps \"${name}\": unrecognised line: ${line}`)\n }\n if (!steps.length) throw new Error(`steps \"${name}\": no step — the sequence is empty`)\n\n const vars = [`// ${p}— steps \"${q(name)}\"`, ...(prompt ? [`// prompt: ${q(prompt)}`] : []), `var ${p}step = 0`, `var ${doneVar} = 0`]\n const layers = [` layer \"${p}steps\" {`]\n steps.forEach((s, i) => layers.push(...container(`${p}S${i}`, s.x, s.y, theme.draw('card', s.label), theme.size('card'))))\n layers.push(' }')\n\n const behavior: string[] = []\n steps.forEach((_s, i) => {\n behavior.push(`object \"${p}S${i}\" {`, ' when clicked {', ` if ${p}step == ${i} {`, ` ${p}step = ${p}step + 1`, ` send \"step\", { block = ${b}, item = ${i} }`)\n if (i === steps.length - 1) behavior.push(` ${doneVar} = 1`, ` send \"part\", { block = ${b} }`)\n behavior.push(' }', ' }')\n // The only thing the gesture says about looks: a step that is not current is dimmed, because\n // \"which one is live\" is STATE, not decoration. A theme that disagrees rebinds opacity itself.\n behavior.push(` opacity = ${p}step == ${i} ? 1 : 0.45`, '}', '')\n })\n return {\n vars,\n layers,\n behavior,\n meta: { keyword: 'steps', name, prompt, items: steps.map((s) => s.label), targets: [], objects: steps.map((_s, i) => `${p}S${i}`), doneVar },\n }\n}\n\n/** `208x118` — the footprint of a role under a theme, for a summary or a prompt. */\nconst footprint = (theme: Theme, role: Role): string => {\n const { w, h } = theme.size(role)\n return `${w}x${h}`\n}\n\n/**\n * Build the shipped gestures against a theme. `GREYBOX` unless the caller supplies one.\n *\n * Each `summary` carries the FOOTPRINTS of the roles it places, because the author writes positions and\n * two overlapping surfaces make a drop ambiguous. Measured on ten model-written activities: a prompt\n * giving only \"space them out\" produced overlapping hitboxes in 4 of 10; the same prompt with the\n * numbers, 0 of 10. The sizes were public all along — nothing said you had to go and read them.\n */\nexport function gestures(opts: GestureOptions = {}): Gesture[] {\n const theme = opts.theme ?? GREYBOX\n return [\n {\n keyword: 'place',\n summary: `place <name> { prompt \"…\" target <T> at x,y item <i> -> <T> at x,y } — drag items onto where they belong. Footprints: target ${footprint(theme, 'target')}, item ${footprint(theme, 'item')}; keep centres at least one footprint apart or the drop is ambiguous`,\n expand: (name, body, _doc, ctx) => expandPlace(name, body, theme, ctx),\n },\n {\n keyword: 'compose',\n summary: `compose <name> { prompt \"…\" total <n> chip <v> at x,y } — tap values until they add up; overshooting resets. Footprint: chip ${footprint(theme, 'chip')}`,\n expand: (name, body, _doc, ctx) => expandCompose(name, body, theme, ctx),\n },\n {\n keyword: 'steps',\n summary: `steps <name> { prompt \"…\" step \"…\" at x,y } — a gated sequence; out-of-order taps do nothing. Footprint: card ${footprint(theme, 'card')}`,\n expand: (name, body, _doc, ctx) => expandSteps(name, body, theme, ctx),\n },\n ]\n}\n\n/**\n * The paste-ready reference for a model writing sugar: the grammar of every gesture, the footprints it\n * must respect, and the canvas it is laying out on. This is the artefact `summary` was being used as by\n * hand — assembled here so nobody has to know that the sizes live on the theme.\n */\nexport function sugarCard(opts: GestureOptions & { document?: { width: number; height: number } } = {}): string {\n const theme = opts.theme ?? GREYBOX\n const doc = opts.document ?? { width: 760, height: 620 }\n return [\n '# FlatInk sugar — a document is one or more blocks',\n '',\n `Canvas: ${doc.width}x${doc.height}, origin top-left. Coordinates are the CENTRE of each thing.`,\n 'Anything you do not describe is not drawn.',\n '',\n '## Blocks — ONE statement per line, like FlatInk itself',\n '',\n 'place <name> { compose <name> { steps <name> {',\n ' prompt \"…\" prompt \"…\" prompt \"…\"',\n ' target <T> at x,y total <n> step \"…\" at x,y',\n ' item <i> -> <T> at x,y chip <v> at x,y }',\n '} }',\n '',\n ...gestures({ theme }).map((g) => `- ${g.summary}`),\n '',\n 'Several blocks may share a document; give each a DISTINCT name. They are laid out in the order you',\n 'write them, each keeps its own state, and each emits `part` when its own portion is finished. The',\n 'document emits `completed` once, when every block is done.',\n '',\n '## Footprints — respect them or two things overlap and the drop becomes ambiguous',\n ...ROLES.map((role) => `- ${role}: ${footprint(theme, role)}`),\n '',\n `A row of targets fits about ${Math.floor(doc.width / (theme.size('target').w + 20))} across; a row of items about ${Math.floor(doc.width / (theme.size('item').w + 20))}.`,\n 'Leave a gap the size of the thing itself between two centres. Two blocks must not share the same area.',\n '',\n '## Escape hatch — three forms, and they are not interchangeable',\n 'The blocks draw NOTHING beyond the pieces above. Everything else goes through one of these:',\n '',\n 'raw scene under { layer \"bg\" { … } } <- BACKGROUND and decor. Drawn BEHIND everything.',\n 'raw scene { layer \"banner\" { … } } <- overlays drawn ON TOP: a title, a frame, a caption.',\n 'raw { var lives = 3 object \"X\" { … } } <- header and behavior: var, fn, asset, object blocks.',\n '',\n 'A `layer` written in a plain `raw { … }` lands OUTSIDE the scene and is a compile error — anything',\n 'that is drawn belongs in one of the two `raw scene` forms. Any of them may be written on one line.',\n ].join('\\n')\n}\n","// ─────────────────────────────────────────────────────────────────────────────\n// @flatkit/sugarflat — declarative sugar for FlatInk.\n//\n// A compact block expands into INSPECTABLE `.flatink`. The expansion is the artefact of record: the\n// sugar is an authoring tool, never a runtime, and anything it writes can be written by hand instead.\n//\n// WHY IT LIVES IN THIS REPO. Not to put authoring opinions into the language — it is a separate\n// package, out of the lockstep group, and `@flatkit/compiler` never depends on it. It lives here so\n// the two move together: a grammar change breaks these tests in the same CI run. That is the whole\n// argument, and it was demonstrated rather than argued — the previous out-of-tree sugar never emitted\n// the format's REQUIRED `size` line, on its entire corpus, for months, unnoticed.\n//\n// THE LINE THIS PACKAGE DOES NOT CROSS: no visual opinion. A gesture emits state and behavior; it\n// never emits a coordinate, a colour or a font. The language already ships interaction opinions\n// (`drag`, `when dropped on … at pointer`, `hitbox`, `match`, `feedback`, `spring`) — what it has\n// never shipped is a look, and a sugar that shipped one would hand every activity the same face.\n// ─────────────────────────────────────────────────────────────────────────────\nimport { DEFAULT_DOCUMENT, ensureHeader, type DocumentSpec } from './document'\nimport { gestures } from './gestures'\nimport { ident } from './ident'\n\nexport { DEFAULT_DOCUMENT, ensureHeader, hasSizeHeader, hasTimelineHeader, type DocumentSpec } from './document'\nexport { ident, isIdent } from './ident'\nexport { gestures, sugarCard, type GestureOptions } from './gestures'\nexport { BLANK, GREYBOX, ROLES, type Role, type Theme } from './theme'\n\n/**\n * What a gesture parsed out of the author's block, beside the DSL it wrote.\n *\n * A host needs this. The expansion deliberately carries no text a host can read back — the prompt is the\n * learner's instruction and the payloads are indices (`send \"correct\", { item = 2 }`), so without the\n * labels there is nothing to display and nothing to map an index onto. Re-parsing the block by hand to\n * recover data the package already parsed is not an integration; it is a second parser waiting to drift.\n */\nexport type GestureMeta = {\n keyword: string\n /** The block's name — also the prefix on every name it emits. */\n name: string\n /** The learner's instruction, verbatim. Drawn by the host or a theme — never by the gesture. */\n prompt: string\n /** Labels in payload order: `{ block = b, item = 2 }` is `blocks[b].items[2]`. */\n items: string[]\n /** Target labels, in the order they were declared. Empty when the gesture has none. */\n targets: string[]\n /** Every object id it emitted, prefixed — what a skin binds to, without having to guess the scheme. */\n objects: string[]\n /** The variable that turns 1 when this block is finished. */\n doneVar: string\n}\n\n/** Where a block sits in the document. Names are prefixed so two blocks never collide. */\nexport type GestureContext = {\n /** 0-based position, and the `block` field of every payload it sends. */\n index: number\n /** `<name>_` — put it in front of every var and every object id. */\n prefix: string\n /** The variable to set to 1 when the block is done; the document watches it. */\n doneVar: string\n}\n\n/** What a gesture returns: PARTS, never a finished program — a document has exactly one `scene`. */\nexport type Expansion = {\n /** `var` declarations. They go in the header, where `var` is legal. */\n vars: string[]\n /** Layer statements, indented for the inside of `scene { … }`. */\n layers: string[]\n /** `object` blocks and scene-wide handlers. */\n behavior: string[]\n meta: GestureMeta\n}\n\n/** A sugar block: the keyword that opens it, and how it expands. */\nexport type Gesture = {\n /** The opening keyword, e.g. `place`. Matched only at column 0, followed by a name and `{`. */\n keyword: string\n /** One line, for diagnostics and for the reference a model is prompted with. */\n summary: string\n /** `body` is the text between the braces; `name` the block's name. */\n expand: (name: string, body: string, doc: DocumentSpec, ctx: GestureContext) => Expansion\n}\n\nexport type DesugarOptions = {\n /** The canvas + timeline the expansion targets. */\n document?: DocumentSpec\n /** Gestures to recognise. Defaults to the registered set. */\n gestures?: Gesture[]\n}\n\nexport type DesugarResult = {\n /** The expanded (or passed-through) FlatInk. */\n flatink: string\n /** Which gesture matched — `raw` for an escape-only source, `null` for plain FlatInk. */\n kind: string | null\n expanded: boolean\n /** What each block understood, in document order: `{ block = 2 }` refers to `meta[2]`. Empty when\n * nothing was expanded, since there is no block to have understood anything from. */\n meta: GestureMeta[]\n}\n\n/** Raised when a source opens a block that looks like sugar but no gesture claims it. */\nexport class UnknownSugarError extends Error {\n constructor(readonly keyword: string, known: string[]) {\n super(\n `unknown sugar block \"${keyword}\" — no gesture claims it, so nothing was expanded. ` +\n `Known blocks: ${known.length ? known.join(', ') : '(none registered)'}. ` +\n `If this is meant to be plain FlatInk, it is not: \"${keyword}\" is not a FlatInk statement either.`,\n )\n this.name = 'UnknownSugarError'\n }\n}\n\n/** The gestures this package ships, drawn by the default theme. Each entry is a public promise. */\nexport const GESTURES: Gesture[] = gestures()\n\n/** A block opens at column 0: `<keyword> <name> {`. The name may be quoted (so it can hold spaces). */\nconst BLOCK_OPEN = /^([a-zA-Z][\\w-]*)[ \\t]+(?:\"([^\"]+)\"|([^\\s{\"]+))[ \\t]*\\{/m\n\n/**\n * The escape hatch, in three forms. A sugar that cannot be opted out of stops being scaffolding and\n * becomes a cage: the previous generation of this idea flattened every activity into the same shape\n * until the template was pulled apart. Anything a gesture writes must remain writable by hand, beside it.\n *\n * raw { … } verbatim at TOP LEVEL — header (`asset`, `var`, `fn`) and `object` blocks\n * raw scene { … } verbatim inside the generated scene, ON TOP of it — banners, overlays\n * raw scene under { … } verbatim inside the generated scene, UNDERNEATH it — backgrounds\n *\n * `under` is not a nicety. A gesture emits no appearance by design, so a background is the FIRST thing\n * any skin needs — and spliced on top, an opaque full-canvas rect hides the entire activity while\n * `checkProgram` reports a clean program. Ten activities shipped that way, read as broken assets.\n */\nconst RAW_OPEN = /^raw(?:[ \\t]+scene(?:[ \\t]+(under))?)?[ \\t]*\\{/gm\n\ntype RawParts = { top: string[]; over: string[]; under: string[]; rest: string }\n\n/**\n * Pull every `raw …` block out of `text`. Brace-counted rather than line-anchored, so the one-line form\n * works — the README and `sugarCard()` both write `raw { … }` on one line, and a regex demanding a\n * newline after `{` left the keyword to travel on to the compiler, which reported `unexpected statement\n * \"raw\"`: a sugar defect described in FlatInk's vocabulary, the very thing `UnknownSugarError` fixed.\n */\nfunction takeRaw(text: string): RawParts {\n const out: RawParts = { top: [], over: [], under: [], rest: '' }\n let cursor = 0\n RAW_OPEN.lastIndex = 0\n for (let m = RAW_OPEN.exec(text); m; m = RAW_OPEN.exec(text)) {\n const openBrace = m.index + m[0].length - 1\n const end = blockEnd(text, openBrace)\n if (end < 0) break // unbalanced: leave it alone, the compiler will say so\n const raw = text.slice(openBrace + 1, end)\n // One-line form (`raw { var x = 1 }`) keeps the spaces that hugged the braces; the multi-line form\n // keeps its own indentation, which is the author's.\n const body = raw.includes('\\n') ? raw.replace(/^\\r?\\n/, '').replace(/\\r?\\n[ \\t]*$/, '') : raw.trim()\n const bucket = m[0].includes('scene') ? (m[1] ? out.under : out.over) : out.top\n bucket.push(body)\n out.rest += text.slice(cursor, m.index)\n cursor = end + 1\n RAW_OPEN.lastIndex = cursor\n }\n out.rest += text.slice(cursor)\n return out\n}\n\n/** Index of the `}` closing the brace at `openBrace`, or -1 if unbalanced. */\nfunction blockEnd(text: string, openBrace: number): number {\n let depth = 1\n for (let i = openBrace + 1; i < text.length; i++) {\n if (text[i] === '{') depth++\n else if (text[i] === '}' && --depth === 0) return i\n }\n return -1\n}\n\nconst RAW_NOTE = '// -- raw (escape hatch: verbatim FlatInk) --'\n\n/** Raised when two blocks share a name — every name they emit would collide. */\nexport class DuplicateBlockError extends Error {\n constructor(name: string) {\n super(`two blocks are both named \"${name}\" — the name prefixes every variable and object a block emits, so they would overwrite each other. Give each block its own name.`)\n this.name = 'DuplicateBlockError'\n }\n}\n\n/** One gesture block found in the source, with its span so the text around it can be recovered. */\ntype Found = { gesture: Gesture; name: string; body: string; start: number; end: number }\n\n/** Every gesture block in `src`, in document order. */\nfunction findBlocks(src: string, gestures: Gesture[]): Found[] {\n const re = new RegExp(BLOCK_OPEN.source, 'gm')\n const found: Found[] = []\n for (let m = re.exec(src); m; m = re.exec(src)) {\n const gesture = gestures.find((g) => g.keyword === m![1])\n if (!gesture) {\n // A keyword that opens a block at column 0 and is neither sugar nor FlatInk is a block we do not\n // know — say so with the list, rather than downstream in another vocabulary.\n if (m[1] !== 'raw' && !FLATINK_BLOCKS.has(m[1])) throw new UnknownSugarError(m[1], gestures.map((g) => g.keyword))\n continue\n }\n const braceAt = m.index + m[0].length - 1\n const close = blockEnd(src, braceAt)\n if (close < 0) break\n found.push({ gesture, name: m[2] ?? m[3] ?? gesture.keyword, body: src.slice(braceAt + 1, close), start: m.index, end: close + 1 })\n re.lastIndex = close + 1\n }\n return found\n}\n\n/**\n * Assemble the blocks into ONE program.\n *\n * A document has exactly one `scene`, one header and one behavior half, so composing gestures is not a\n * matter of concatenating their output — it is a matter of never producing whole programs in the first\n * place. Each block contributes parts; this puts them in the three places the format has.\n *\n * Two things the assembly decides, and they are the reason \"several blocks\" is a design and not a loop:\n *\n * • **Names are prefixed by the block's name, always** — including when a document holds one block.\n * Prefixing only on collision would mean the same source compiles to different names depending on\n * whether a sibling exists, so a skin written against one block would break the day a second arrived.\n * Every id is in `meta[].objects`, so nothing has to be guessed.\n * • **`completed` belongs to the DOCUMENT.** Each block emits `part` with its own index when its\n * portion is finished; `completed` fires once, when every block is done. With a single block the two\n * coincide, which is what `completed` always meant.\n */\nfunction assemble(blocks: { expansion: Expansion }[], under: string[], over: string[], doc: DocumentSpec): string {\n const out: string[] = [`size ${doc.width} ${doc.height}`, `timeline ${doc.fps} ${doc.durationFrames}`]\n const done = blocks.map((b) => b.expansion.meta.doneVar)\n if (done.length) out.push('var allDone = 0')\n for (const b of blocks) out.push(...b.expansion.vars)\n\n out.push('', 'scene {')\n if (under.length) out.push(' // -- raw scene under (verbatim, drawn BEHIND every block) --', ...under)\n for (const b of blocks) out.push(...b.expansion.layers)\n if (over.length) out.push(' // -- raw scene (verbatim, drawn ON TOP of every block) --', ...over)\n out.push('}', '')\n\n for (const b of blocks) out.push(...b.expansion.behavior)\n // `completed` = the whole document. One block: it fires the moment that block does, which is what it\n // has always meant. Several: only once all of them have. The `allDone` guard matters -- an unguarded\n // `send` inside `every frame` would emit it again on every frame for the rest of the session.\n if (done.length) {\n out.push('every frame {', ' if allDone < 0.5 {', ` if ${done.join(' + ')} >= ${done.length} {`, ' allDone = 1', ' send \"completed\"', ' }', ' }', '}')\n }\n return out.join('\\n')\n}\n\n/** Block keywords that belong to FlatINK itself — a source opening with one of these is a program. */\nconst FLATINK_BLOCKS = new Set(['scene', 'object', 'symbol', 'layer', 'group', 'match', 'each', 'states', 'params', 'when', 'every', 'repeat', 'fn', 'at'])\n\n/**\n * Expand a sugar source into `.flatink`.\n *\n * Plain FlatInk passes through untouched. A block nobody claims RAISES rather than passing through: a\n * silent fall-through sent the author's block downstream as if it were FlatInk, to fail a hundred lines\n * later on messages that only talk about FlatInk.\n *\n * A document may hold SEVERAL blocks. They are laid out in the order they are written, each keeps its own\n * state under its own name, and each emits `part` when its portion is finished; `completed` fires once,\n * when every block is done.\n *\n * ```ts\n * import { desugar } from '@flatkit/sugarflat'\n * import { checkProgram } from '@flatkit/compiler'\n *\n * const { flatink, meta } = desugar(srcFromAnLLM)\n * const { ok, report } = checkProgram(flatink) // the expansion is the artefact of record\n * ```\n */\nexport function desugar(src: string, opts: DesugarOptions = {}): DesugarResult {\n const doc = opts.document ?? DEFAULT_DOCUMENT\n const gestures = opts.gestures ?? GESTURES\n\n const found = findBlocks(src, gestures)\n if (!found.length) {\n // Plain FlatInk, plus any `raw { … }` used on its own. `raw scene` has no generated scene to splice\n // into here, so it would silently vanish -- say so instead.\n const parts = takeRaw(src)\n if (parts.over.length || parts.under.length) {\n throw new Error('`raw scene { … }` needs a gesture block to splice into — this source has none. Write a plain `scene { … }` yourself.')\n }\n const out = [parts.rest.trim(), ...(parts.top.length ? [RAW_NOTE, ...parts.top] : [])].filter(Boolean).join('\\n')\n return { flatink: parts.top.length ? out : src, kind: parts.top.length ? 'raw' : null, expanded: parts.top.length > 0, meta: [] }\n }\n\n const seen = new Set<string>()\n for (const b of found) {\n const key = ident(b.name)\n if (seen.has(key)) throw new DuplicateBlockError(b.name)\n seen.add(key)\n }\n\n // Everything OUTSIDE the blocks travels with them: `raw` in its three forms, and any plain FlatInk the\n // author wrote beside them. Dropping it made the escape hatch a no-op -- decor was written, the\n // expansion compiled, `checkProgram` said ok, and nothing was there.\n const outside: RawParts = { top: [], over: [], under: [], rest: '' }\n const absorb = (text: string) => {\n const part = takeRaw(text)\n outside.top.push(...part.top)\n outside.over.push(...part.over)\n outside.under.push(...part.under)\n outside.rest += part.rest\n }\n let cursor = 0\n for (const b of found) { absorb(src.slice(cursor, b.start)); cursor = b.end }\n absorb(src.slice(cursor))\n\n const blocks = found.map((b, index) => {\n const prefix = `${ident(b.name)}_`\n return { expansion: b.gesture.expand(b.name, b.body, doc, { index, prefix, doneVar: `${prefix}done` }) }\n })\n\n // Top-level content goes in the HEADER position, wherever the author wrote it: `var` (like `asset`,\n // `use`, `def`) is a header declaration and a parse error after `scene`, while `object`/`fn` are legal\n // on either side. Moving an `object` up changes nothing -- behavior binds by name, not by position.\n const header = [outside.rest.trim(), ...(outside.top.length ? [RAW_NOTE, ...outside.top] : [])].filter(Boolean).join('\\n')\n const program = assemble(blocks, outside.under, outside.over, doc)\n return {\n flatink: ensureHeader(header ? `${header}\\n\\n${program}` : program, doc),\n kind: found.map((b) => b.gesture.keyword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AAM,EAAE,QAAQ,OAAO,EAAE,KAAK,GAAG;AAAA,IAClD,UAAU;AAAA,IACV,MAAM,OAAO,IAAI,CAAC,MAAM,EAAE,UAAU,IAAI;AAAA,EAC1C;AACF;","names":["gestures"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flatkit/sugarflat",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Declarative sugar for FlatInk: a compact block expands into inspectable .flatink. An authoring tool, never a runtime.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Zwyk Studio",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@flatkit/
|
|
44
|
-
"@flatkit/
|
|
43
|
+
"@flatkit/player": "0.26.0",
|
|
44
|
+
"@flatkit/types": "0.26.0"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"build": "tsup",
|