@flatkit/sugarflat 0.2.2 → 0.3.0

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 CHANGED
@@ -58,8 +58,27 @@ raw scene { layer "backdrop" { rect 0 0 760 620 fill linear(90, 0:#1b2a4a, 1:#4a
58
58
  raw { object "TChest" { opacity = 0.9 } }
59
59
  ```
60
60
 
61
- One gesture per document: each emits its own `scene`, and a second block is refused with
62
- `MultipleGesturesError` rather than dropped.
61
+ ## Several blocks in one document
62
+
63
+ ```
64
+ place words { prompt "…" target Nouns at 200,200 item cat -> Nouns at 120,80 }
65
+ compose coins { prompt "…" total 150 chip 50 at 200,500 chip 100 at 420,500 }
66
+
67
+ raw scene under { layer "bg" { rect 0 0 760 620 fill #112233 } }
68
+ ```
69
+
70
+ Blocks are laid out in the order you write them, and the decor sits behind all of them. Two things the
71
+ assembly decides:
72
+
73
+ - **Names are prefixed by the block's name, always** — `words_TNouns`, `coins_C0` — including when a
74
+ document holds one block. Prefixing only on collision would mean the same source compiles to different
75
+ names depending on whether a sibling exists, so a skin written against one block would break the day a
76
+ second arrived. Every id is in `meta[].objects`; nothing has to be guessed.
77
+ - **`completed` belongs to the DOCUMENT.** Each block emits `part` with its own index when its portion is
78
+ finished, and `completed` fires once, when every block is done. With a single block the two coincide,
79
+ which is what `completed` always meant.
80
+
81
+ Two blocks sharing a name raise `DuplicateBlockError` — every name they emit would collide.
63
82
 
64
83
  ## What it guarantees
65
84
 
@@ -97,8 +116,9 @@ draws them:
97
116
 
98
117
  ```ts
99
118
  const { flatink, meta } = desugar(src)
100
- meta.prompt // "Put each word under its part of speech" — the learner's instruction
101
- meta.items[2] // the label behind `{ item = 2 }`
119
+ meta[0].prompt // the learner's instruction for the first block
120
+ meta[0].items[2] // the label behind `{ block = 0, item = 2 }`
121
+ meta[0].objects // every id it emitted, prefixed — what a skin binds to
102
122
  ```
103
123
 
104
124
  For prompting a model, `sugarCard()` assembles the grammar, the canvas and the **footprints** of every
package/dist/index.d.ts CHANGED
@@ -90,18 +90,36 @@ declare function sugarCard(opts?: GestureOptions & {
90
90
  */
91
91
  type GestureMeta = {
92
92
  keyword: string;
93
- /** The block's name. */
93
+ /** The block's name — also the prefix on every name it emits. */
94
94
  name: string;
95
95
  /** The learner's instruction, verbatim. Drawn by the host or a theme — never by the gesture. */
96
96
  prompt: string;
97
- /** Labels in payload order: `{ item = 2 }` is `items[2]`. */
97
+ /** Labels in payload order: `{ block = b, item = 2 }` is `blocks[b].items[2]`. */
98
98
  items: string[];
99
99
  /** Target labels, in the order they were declared. Empty when the gesture has none. */
100
100
  targets: string[];
101
+ /** Every object id it emitted, prefixed — what a skin binds to, without having to guess the scheme. */
102
+ objects: string[];
103
+ /** The variable that turns 1 when this block is finished. */
104
+ doneVar: string;
101
105
  };
102
- /** What a gesture returns: the DSL, and what it understood. */
106
+ /** Where a block sits in the document. Names are prefixed so two blocks never collide. */
107
+ type GestureContext = {
108
+ /** 0-based position, and the `block` field of every payload it sends. */
109
+ index: number;
110
+ /** `<name>_` — put it in front of every var and every object id. */
111
+ prefix: string;
112
+ /** The variable to set to 1 when the block is done; the document watches it. */
113
+ doneVar: string;
114
+ };
115
+ /** What a gesture returns: PARTS, never a finished program — a document has exactly one `scene`. */
103
116
  type Expansion = {
104
- flatink: string;
117
+ /** `var` declarations. They go in the header, where `var` is legal. */
118
+ vars: string[];
119
+ /** Layer statements, indented for the inside of `scene { … }`. */
120
+ layers: string[];
121
+ /** `object` blocks and scene-wide handlers. */
122
+ behavior: string[];
105
123
  meta: GestureMeta;
106
124
  };
107
125
  /** A sugar block: the keyword that opens it, and how it expands. */
@@ -111,7 +129,7 @@ type Gesture = {
111
129
  /** One line, for diagnostics and for the reference a model is prompted with. */
112
130
  summary: string;
113
131
  /** `body` is the text between the braces; `name` the block's name. */
114
- expand: (name: string, body: string, doc: DocumentSpec) => Expansion;
132
+ expand: (name: string, body: string, doc: DocumentSpec, ctx: GestureContext) => Expansion;
115
133
  };
116
134
  type DesugarOptions = {
117
135
  /** The canvas + timeline the expansion targets. */
@@ -125,9 +143,9 @@ type DesugarResult = {
125
143
  /** Which gesture matched — `raw` for an escape-only source, `null` for plain FlatInk. */
126
144
  kind: string | null;
127
145
  expanded: boolean;
128
- /** What the gesture understood: the prompt and the labels behind the payload indices. `null` when
146
+ /** What each block understood, in document order: `{ block = 2 }` refers to `meta[2]`. Empty when
129
147
  * nothing was expanded, since there is no block to have understood anything from. */
130
- meta: GestureMeta | null;
148
+ meta: GestureMeta[];
131
149
  };
132
150
  /** Raised when a source opens a block that looks like sugar but no gesture claims it. */
133
151
  declare class UnknownSugarError extends Error {
@@ -136,25 +154,29 @@ declare class UnknownSugarError extends Error {
136
154
  }
137
155
  /** The gestures this package ships, drawn by the default theme. Each entry is a public promise. */
138
156
  declare const GESTURES: Gesture[];
139
- /** Raised when a source holds more than one gesture block. */
140
- declare class MultipleGesturesError extends Error {
141
- constructor(first: string, second: string);
157
+ /** Raised when two blocks share a name — every name they emit would collide. */
158
+ declare class DuplicateBlockError extends Error {
159
+ constructor(name: string);
142
160
  }
143
161
  /**
144
162
  * Expand a sugar source into `.flatink`.
145
163
  *
146
- * Plain FlatInk passes through untouched. A source whose first block matches no gesture RAISES rather
147
- * than passing through: a silent fall-through sent the author's block downstream as if it were FlatInk,
148
- * to fail a hundred lines later on messages that only talk about FlatInk.
164
+ * Plain FlatInk passes through untouched. A block nobody claims RAISES rather than passing through: a
165
+ * silent fall-through sent the author's block downstream as if it were FlatInk, to fail a hundred lines
166
+ * later on messages that only talk about FlatInk.
167
+ *
168
+ * A document may hold SEVERAL blocks. They are laid out in the order they are written, each keeps its own
169
+ * state under its own name, and each emits `part` when its portion is finished; `completed` fires once,
170
+ * when every block is done.
149
171
  *
150
172
  * ```ts
151
173
  * import { desugar } from '@flatkit/sugarflat'
152
174
  * import { checkProgram } from '@flatkit/compiler'
153
175
  *
154
- * const { flatink } = desugar(srcFromAnLLM)
176
+ * const { flatink, meta } = desugar(srcFromAnLLM)
155
177
  * const { ok, report } = checkProgram(flatink) // the expansion is the artefact of record
156
178
  * ```
157
179
  */
158
180
  declare function desugar(src: string, opts?: DesugarOptions): DesugarResult;
159
181
 
160
- export { BLANK, DEFAULT_DOCUMENT, type DesugarOptions, type DesugarResult, type DocumentSpec, type Expansion, GESTURES, GREYBOX, type Gesture, type GestureMeta, type GestureOptions, MultipleGesturesError, ROLES, type Role, type Theme, UnknownSugarError, desugar, ensureHeader, gestures, hasSizeHeader, hasTimelineHeader, ident, isIdent, sugarCard };
182
+ export { BLANK, DEFAULT_DOCUMENT, type DesugarOptions, type DesugarResult, type DocumentSpec, DuplicateBlockError, type Expansion, GESTURES, GREYBOX, type Gesture, type GestureContext, type GestureMeta, type GestureOptions, ROLES, type Role, type Theme, UnknownSugarError, desugar, ensureHeader, gestures, hasSizeHeader, hasTimelineHeader, ident, isIdent, sugarCard };
package/dist/index.js CHANGED
@@ -57,17 +57,17 @@ function container(name, x, y, art, hitbox) {
57
57
  return [` group "${name}" at ${x},${y} pivot 0,0${box} {`, ' layer "art" {', ...art.map((l) => ` ${l}`), " }", " }"];
58
58
  }
59
59
  var lines = (body) => body.split("\n").map((l) => l.replace(/\/\/.*$/, "").trim()).filter(Boolean);
60
- function parsePlace(name, body) {
60
+ function parsePlace(name, body, p) {
61
61
  const m = { prompt: "", targets: [], items: [] };
62
62
  for (const line of lines(body)) {
63
63
  let x;
64
64
  if (x = line.match(/^prompt\s+"(.*)"$/)) m.prompt = x[1];
65
65
  else if (x = line.match(/^target\s+(?:"([^"]+)"|(\S+))\s+at\s+(-?[\d.]+),(-?[\d.]+)$/)) {
66
66
  const label = x[1] ?? x[2];
67
- m.targets.push({ id: `T${ident(label)}`, label, x: x[3], y: x[4] });
67
+ m.targets.push({ id: `${p}T${ident(label)}`, label, x: x[3], y: x[4] });
68
68
  } else if (x = line.match(/^item\s+(?:"([^"]+)"|(\S+))\s*->\s*(?:"([^"]+)"|(\S+))\s+at\s+(-?[\d.]+),(-?[\d.]+)$/)) {
69
69
  const label = x[1] ?? x[2];
70
- m.items.push({ id: `I${ident(label)}`, label, target: `T${ident(x[3] ?? x[4])}`, x: x[5], y: x[6] });
70
+ m.items.push({ id: `${p}I${ident(label)}`, label, target: `${p}T${ident(x[3] ?? x[4])}`, x: x[5], y: x[6] });
71
71
  } else throw new Error(`place "${name}": unrecognised line: ${line}`);
72
72
  }
73
73
  if (!m.targets.length) throw new Error(`place "${name}": no target \u2014 an item has nowhere to go`);
@@ -78,43 +78,46 @@ function parsePlace(name, body) {
78
78
  }
79
79
  return m;
80
80
  }
81
- function expandPlace(name, body, theme) {
82
- const m = parsePlace(name, body);
81
+ function expandPlace(name, body, theme, ctx) {
82
+ const { prefix: p, index: b, doneVar } = ctx;
83
+ const m = parsePlace(name, body, p);
83
84
  const n = m.items.length;
84
- const out = [`// place "${q(name)}" \u2014 generated. The expansion is the artefact of record: edit it, or edit the block.`];
85
- if (m.prompt) out.push(`// prompt: ${q(m.prompt)}`);
86
- out.push("var progress = 0", "var done = 0");
87
- for (const it of m.items) out.push(`var ${it.id}X = ${it.x}`, `var ${it.id}Y = ${it.y}`, `var ${it.id}Placed = 0`);
88
- out.push("", "scene {", ' layer "targets" {');
89
- for (const t of m.targets) out.push(...container(t.id, t.x, t.y, theme.draw("target", t.label), theme.size("target")));
90
- out.push(" }", ' layer "items" {');
91
- for (const it of m.items) out.push(...container(it.id, it.x, it.y, theme.draw("item", it.label)));
92
- out.push(" }", "}", "");
85
+ const vars = [`// ${p}\u2014 place "${q(name)}"`, ...m.prompt ? [`// prompt: ${q(m.prompt)}`] : [], `var ${p}progress = 0`, `var ${doneVar} = 0`];
86
+ 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`);
87
+ const layers = [` layer "${p}targets" {`];
88
+ for (const t of m.targets) layers.push(...container(t.id, t.x, t.y, theme.draw("target", t.label), theme.size("target")));
89
+ layers.push(" }", ` layer "${p}items" {`);
90
+ for (const it of m.items) layers.push(...container(it.id, it.x, it.y, theme.draw("item", it.label)));
91
+ layers.push(" }");
92
+ const behavior = [];
93
93
  m.items.forEach((it, i) => {
94
- out.push(`object "${it.id}" {`);
95
- out.push(` drag ${it.id}X, ${it.id}Y { enabled ${it.id}Placed == 0 }`);
96
- out.push(` when dropped on ${it.target} at pointer {`);
97
- out.push(` if ${it.id}Placed < 0.5 {`);
98
- out.push(` ${it.id}Placed = 1`, " progress = progress + 1");
99
- out.push(` ${it.id}X = ${it.target}.x`, ` ${it.id}Y = ${it.target}.y`);
100
- out.push(` send "correct", { item = ${i} }`);
101
- out.push(` if progress == ${n} {`, " done = 1", ' send "completed"', " }");
102
- out.push(" }", " }");
94
+ behavior.push(`object "${it.id}" {`);
95
+ behavior.push(` drag ${it.id}X, ${it.id}Y { enabled ${it.id}Placed == 0 }`);
96
+ behavior.push(` when dropped on ${it.target} at pointer {`);
97
+ behavior.push(` if ${it.id}Placed < 0.5 {`);
98
+ behavior.push(` ${it.id}Placed = 1`, ` ${p}progress = ${p}progress + 1`);
99
+ behavior.push(` ${it.id}X = ${it.target}.x`, ` ${it.id}Y = ${it.target}.y`);
100
+ behavior.push(` send "correct", { block = ${b}, item = ${i} }`);
101
+ behavior.push(` if ${p}progress == ${n} {`, ` ${doneVar} = 1`, ` send "part", { block = ${b} }`, " }");
102
+ behavior.push(" }", " }");
103
103
  for (const t of m.targets) {
104
104
  if (t.id === it.target) continue;
105
- out.push(` when dropped on ${t.id} at pointer {`);
106
- out.push(` ${it.id}X = ${it.x}`, ` ${it.id}Y = ${it.y}`);
107
- out.push(` send "incorrect", { item = ${i} }`);
108
- out.push(" }");
105
+ behavior.push(` when dropped on ${t.id} at pointer {`);
106
+ behavior.push(` ${it.id}X = ${it.x}`, ` ${it.id}Y = ${it.y}`);
107
+ behavior.push(` send "incorrect", { block = ${b}, item = ${i} }`);
108
+ behavior.push(" }");
109
109
  }
110
- out.push(` x = ${it.id}X`, ` y = ${it.id}Y`, "}", "");
110
+ behavior.push(` x = ${it.id}X`, ` y = ${it.id}Y`, "}", "");
111
111
  });
112
112
  return {
113
- flatink: out.join("\n"),
114
- meta: { keyword: "place", name, prompt: m.prompt, items: m.items.map((i) => i.label), targets: m.targets.map((t) => t.label) }
113
+ vars,
114
+ layers,
115
+ behavior,
116
+ 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 }
115
117
  };
116
118
  }
117
- function expandCompose(name, body, theme) {
119
+ function expandCompose(name, body, theme, ctx) {
120
+ const { prefix: p, index: b, doneVar } = ctx;
118
121
  let target = 0;
119
122
  const chips = [];
120
123
  let prompt = "";
@@ -127,21 +130,29 @@ function expandCompose(name, body, theme) {
127
130
  }
128
131
  if (!target) throw new Error(`compose "${name}": no \`total <n>\` \u2014 there is nothing to reach`);
129
132
  if (!chips.length) throw new Error(`compose "${name}": no chip \u2014 nothing for the learner to tap`);
130
- const out = [`// compose "${q(name)}" \u2014 generated.`, ...prompt ? [`// prompt: ${q(prompt)}`] : [], "var total = 0", "var done = 0", "", "scene {", ' layer "chips" {'];
131
- chips.forEach((c, i) => out.push(...container(`C${i}`, c.x, c.y, theme.draw("chip", c.value), theme.size("chip"))));
132
- out.push(" }", "}", "");
133
+ const vars = [`// ${p}\u2014 compose "${q(name)}"`, ...prompt ? [`// prompt: ${q(prompt)}`] : [], `var ${p}total = 0`, `var ${doneVar} = 0`];
134
+ const layers = [` layer "${p}chips" {`];
135
+ chips.forEach((c, i) => layers.push(...container(`${p}C${i}`, c.x, c.y, theme.draw("chip", c.value), theme.size("chip"))));
136
+ layers.push(" }");
137
+ const behavior = [];
133
138
  chips.forEach((c, i) => {
134
- out.push(`object "C${i}" {`, " when clicked {", " if done < 0.5 {");
135
- out.push(` if total + ${c.value} > ${target} {`);
136
- out.push(" total = 0", ` send "incorrect", { chip = ${i} }`);
137
- out.push(" } else {");
138
- out.push(` total = total + ${c.value}`, ` send "correct", { chip = ${i} }`);
139
- out.push(` if total == ${target} {`, " done = 1", ' send "completed"', " }");
140
- out.push(" }", " }", " }", "}", "");
139
+ behavior.push(`object "${p}C${i}" {`, " when clicked {", ` if ${doneVar} < 0.5 {`);
140
+ behavior.push(` if ${p}total + ${c.value} > ${target} {`);
141
+ behavior.push(` ${p}total = 0`, ` send "incorrect", { block = ${b}, item = ${i} }`);
142
+ behavior.push(" } else {");
143
+ behavior.push(` ${p}total = ${p}total + ${c.value}`, ` send "correct", { block = ${b}, item = ${i} }`);
144
+ behavior.push(` if ${p}total == ${target} {`, ` ${doneVar} = 1`, ` send "part", { block = ${b} }`, " }");
145
+ behavior.push(" }", " }", " }", "}", "");
141
146
  });
142
- return { flatink: out.join("\n"), meta: { keyword: "compose", name, prompt, items: chips.map((c) => c.value), targets: [] } };
147
+ return {
148
+ vars,
149
+ layers,
150
+ behavior,
151
+ meta: { keyword: "compose", name, prompt, items: chips.map((c) => c.value), targets: [], objects: chips.map((_c, i) => `${p}C${i}`), doneVar }
152
+ };
143
153
  }
144
- function expandSteps(name, body, theme) {
154
+ function expandSteps(name, body, theme, ctx) {
155
+ const { prefix: p, index: b, doneVar } = ctx;
145
156
  let prompt = "";
146
157
  const steps = [];
147
158
  for (const line of lines(body)) {
@@ -151,16 +162,23 @@ function expandSteps(name, body, theme) {
151
162
  else throw new Error(`steps "${name}": unrecognised line: ${line}`);
152
163
  }
153
164
  if (!steps.length) throw new Error(`steps "${name}": no step \u2014 the sequence is empty`);
154
- const out = [`// steps "${q(name)}" \u2014 generated.`, ...prompt ? [`// prompt: ${q(prompt)}`] : [], "var step = 0", "", "scene {", ' layer "steps" {'];
155
- steps.forEach((s, i) => out.push(...container(`S${i}`, s.x, s.y, theme.draw("card", s.label), theme.size("card"))));
156
- out.push(" }", "}", "");
165
+ const vars = [`// ${p}\u2014 steps "${q(name)}"`, ...prompt ? [`// prompt: ${q(prompt)}`] : [], `var ${p}step = 0`, `var ${doneVar} = 0`];
166
+ const layers = [` layer "${p}steps" {`];
167
+ steps.forEach((s, i) => layers.push(...container(`${p}S${i}`, s.x, s.y, theme.draw("card", s.label), theme.size("card"))));
168
+ layers.push(" }");
169
+ const behavior = [];
157
170
  steps.forEach((_s, i) => {
158
- out.push(`object "S${i}" {`, " when clicked {", ` if step == ${i} {`, ` step = step + 1`, ` send "step", { index = ${i} }`);
159
- if (i === steps.length - 1) out.push(' send "completed"');
160
- out.push(" }", " }");
161
- out.push(` opacity = step == ${i} ? 1 : 0.45`, "}", "");
171
+ behavior.push(`object "${p}S${i}" {`, " when clicked {", ` if ${p}step == ${i} {`, ` ${p}step = ${p}step + 1`, ` send "step", { block = ${b}, item = ${i} }`);
172
+ if (i === steps.length - 1) behavior.push(` ${doneVar} = 1`, ` send "part", { block = ${b} }`);
173
+ behavior.push(" }", " }");
174
+ behavior.push(` opacity = ${p}step == ${i} ? 1 : 0.45`, "}", "");
162
175
  });
163
- return { flatink: out.join("\n"), meta: { keyword: "steps", name, prompt, items: steps.map((s2) => s2.label), targets: [] } };
176
+ return {
177
+ vars,
178
+ layers,
179
+ behavior,
180
+ meta: { keyword: "steps", name, prompt, items: steps.map((s) => s.label), targets: [], objects: steps.map((_s, i) => `${p}S${i}`), doneVar }
181
+ };
164
182
  }
165
183
  var footprint = (theme, role) => {
166
184
  const { w, h } = theme.size(role);
@@ -172,17 +190,17 @@ function gestures(opts = {}) {
172
190
  {
173
191
  keyword: "place",
174
192
  summary: `place <name> { prompt "\u2026" target <T> at x,y item <i> -> <T> at x,y } \u2014 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`,
175
- expand: (name, body) => expandPlace(name, body, theme)
193
+ expand: (name, body, _doc, ctx) => expandPlace(name, body, theme, ctx)
176
194
  },
177
195
  {
178
196
  keyword: "compose",
179
197
  summary: `compose <name> { prompt "\u2026" total <n> chip <v> at x,y } \u2014 tap values until they add up; overshooting resets. Footprint: chip ${footprint(theme, "chip")}`,
180
- expand: (name, body) => expandCompose(name, body, theme)
198
+ expand: (name, body, _doc, ctx) => expandCompose(name, body, theme, ctx)
181
199
  },
182
200
  {
183
201
  keyword: "steps",
184
202
  summary: `steps <name> { prompt "\u2026" step "\u2026" at x,y } \u2014 a gated sequence; out-of-order taps do nothing. Footprint: card ${footprint(theme, "card")}`,
185
- expand: (name, body) => expandSteps(name, body, theme)
203
+ expand: (name, body, _doc, ctx) => expandSteps(name, body, theme, ctx)
186
204
  }
187
205
  ];
188
206
  }
@@ -190,29 +208,33 @@ function sugarCard(opts = {}) {
190
208
  const theme = opts.theme ?? GREYBOX;
191
209
  const doc = opts.document ?? { width: 760, height: 620 };
192
210
  return [
193
- "# FlatInk sugar \u2014 one block, one activity",
211
+ "# FlatInk sugar \u2014 a document is one or more blocks",
194
212
  "",
195
- `Canvas: ${doc.width}x${doc.height}, origin top-left. Write ONE block, nothing else. Coordinates are the`,
196
- "CENTRE of each thing. Anything you do not describe is not drawn.",
213
+ `Canvas: ${doc.width}x${doc.height}, origin top-left. Coordinates are the CENTRE of each thing.`,
214
+ "Anything you do not describe is not drawn.",
197
215
  "",
198
216
  "## Blocks",
199
217
  ...gestures({ theme }).map((g) => `- ${g.summary}`),
200
218
  "",
219
+ "Several blocks may share a document; give each a DISTINCT name. They are laid out in the order you",
220
+ "write them, each keeps its own state, and each emits `part` when its own portion is finished. The",
221
+ "document emits `completed` once, when every block is done.",
222
+ "",
201
223
  "## Footprints \u2014 respect them or two things overlap and the drop becomes ambiguous",
202
224
  ...ROLES.map((role) => `- ${role}: ${footprint(theme, role)}`),
203
225
  "",
204
226
  `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))}.`,
205
- "Leave a gap the size of the thing itself between two centres.",
227
+ "Leave a gap the size of the thing itself between two centres. Two blocks must not share the same area.",
206
228
  "",
207
229
  "## Escape hatch \u2014 three forms, and they are not interchangeable",
208
- "The block draws NOTHING beyond the pieces above. Everything else goes through one of these:",
230
+ "The blocks draw NOTHING beyond the pieces above. Everything else goes through one of these:",
209
231
  "",
210
- 'raw scene under { layer "bg" { \u2026 } } <- BACKGROUND and decor. Drawn BEHIND the activity.',
232
+ 'raw scene under { layer "bg" { \u2026 } } <- BACKGROUND and decor. Drawn BEHIND everything.',
211
233
  'raw scene { layer "banner" { \u2026 } } <- overlays drawn ON TOP: a title, a frame, a caption.',
212
234
  'raw { var lives = 3 object "X" { \u2026 } } <- header and behavior: var, fn, asset, object blocks.',
213
235
  "",
214
236
  "A `layer` written in a plain `raw { \u2026 }` lands OUTSIDE the scene and is a compile error \u2014 anything",
215
- "that is drawn belongs in one of the two `raw scene` forms. Either may be written on one line."
237
+ "that is drawn belongs in one of the two `raw scene` forms. Any of them may be written on one line."
216
238
  ].join("\n");
217
239
  }
218
240
 
@@ -258,81 +280,99 @@ function blockEnd(text, openBrace) {
258
280
  return -1;
259
281
  }
260
282
  var RAW_NOTE = "// -- raw (escape hatch: verbatim FlatInk) --";
261
- function spliceIntoScene(flatink, under, over) {
262
- if (!under.length && !over.length) return flatink;
263
- const at = flatink.search(/^scene[ \t]*\{/m);
264
- if (at < 0) throw new Error("`raw scene { \u2026 }` has nowhere to go: this expansion emits no `scene` block \u2014 use a plain `raw { \u2026 }` instead.");
265
- const openBrace = flatink.indexOf("{", at);
266
- const close = blockEnd(flatink, openBrace);
267
- const head = under.length ? `
268
- // -- raw scene under (verbatim, drawn BEHIND the gesture) --
269
- ${under.join("\n")}` : "";
270
- const tail = over.length ? ` // -- raw scene (verbatim, drawn ON TOP of the gesture) --
271
- ${over.join("\n")}
272
- ` : "";
273
- return `${flatink.slice(0, openBrace + 1)}${head}${flatink.slice(openBrace + 1, close)}${tail}${flatink.slice(close)}`;
274
- }
275
- var MultipleGesturesError = class extends Error {
276
- constructor(first, second) {
277
- super(
278
- `two gesture blocks in one source ("${first}" and "${second}") \u2014 a document holds ONE. Each gesture emits its own \`scene\`, and a program may only have one, so the second cannot be merged in. Split them into two documents, or write the extra part by hand in \`raw { \u2026 }\` / \`raw scene { \u2026 }\`.`
279
- );
280
- this.name = "MultipleGesturesError";
283
+ var DuplicateBlockError = class extends Error {
284
+ constructor(name) {
285
+ super(`two blocks are both named "${name}" \u2014 the name prefixes every variable and object a block emits, so they would overwrite each other. Give each block its own name.`);
286
+ this.name = "DuplicateBlockError";
281
287
  }
282
288
  };
283
- function desugar(src, opts = {}) {
284
- const doc = opts.document ?? DEFAULT_DOCUMENT;
285
- const gestures2 = opts.gestures ?? GESTURES;
286
- const open = BLOCK_OPEN.exec(src);
287
- const keyword = open?.[1];
288
- const gesture = keyword ? gestures2.find((g) => g.keyword === keyword) : void 0;
289
- if (gesture) {
290
- const name = open?.[2] ?? open?.[3] ?? gesture.keyword;
291
- const braceAt = open.index + open[0].length - 1;
292
- const body = blockBody(src, braceAt);
293
- const before = src.slice(0, open.index);
294
- const after = src.slice(braceAt + 1 + body.length + 1);
295
- const other = findGesture(before + "\n" + after, gestures2);
296
- if (other) throw new MultipleGesturesError(gesture.keyword, other);
297
- const { flatink, meta } = gesture.expand(name, body, doc);
298
- const head = takeRaw(before);
299
- const tail = takeRaw(after);
300
- const expanded = spliceIntoScene(flatink, [...head.under, ...tail.under], [...head.over, ...tail.over]);
301
- const topLevel = (p) => [p.rest.trim(), ...p.top.length ? [RAW_NOTE, ...p.top] : []].filter(Boolean).join("\n");
302
- const whole = [topLevel(head), topLevel(tail), expanded].filter(Boolean).join("\n\n");
303
- return { flatink: ensureHeader(whole, doc), kind: gesture.keyword, expanded: true, meta };
289
+ function findBlocks(src, gestures2) {
290
+ const re = new RegExp(BLOCK_OPEN.source, "gm");
291
+ const found = [];
292
+ for (let m = re.exec(src); m; m = re.exec(src)) {
293
+ const gesture = gestures2.find((g) => g.keyword === m[1]);
294
+ if (!gesture) {
295
+ if (m[1] !== "raw" && !FLATINK_BLOCKS.has(m[1])) throw new UnknownSugarError(m[1], gestures2.map((g) => g.keyword));
296
+ continue;
297
+ }
298
+ const braceAt = m.index + m[0].length - 1;
299
+ const close = blockEnd(src, braceAt);
300
+ if (close < 0) break;
301
+ found.push({ gesture, name: m[2] ?? m[3] ?? gesture.keyword, body: src.slice(braceAt + 1, close), start: m.index, end: close + 1 });
302
+ re.lastIndex = close + 1;
304
303
  }
305
- if (keyword && keyword !== "raw" && !FLATINK_BLOCKS.has(keyword)) throw new UnknownSugarError(keyword, gestures2.map((g) => g.keyword));
306
- const parts = takeRaw(src);
307
- if (parts.over.length || parts.under.length) {
308
- throw new Error("`raw scene { \u2026 }` needs a gesture block to splice into \u2014 this source has none. Write a plain `scene { \u2026 }` yourself.");
304
+ return found;
305
+ }
306
+ function assemble(blocks, under, over, doc) {
307
+ const out = [`size ${doc.width} ${doc.height}`, `timeline ${doc.fps} ${doc.durationFrames}`];
308
+ const done = blocks.map((b) => b.expansion.meta.doneVar);
309
+ if (done.length) out.push("var allDone = 0");
310
+ for (const b of blocks) out.push(...b.expansion.vars);
311
+ out.push("", "scene {");
312
+ if (under.length) out.push(" // -- raw scene under (verbatim, drawn BEHIND every block) --", ...under);
313
+ for (const b of blocks) out.push(...b.expansion.layers);
314
+ if (over.length) out.push(" // -- raw scene (verbatim, drawn ON TOP of every block) --", ...over);
315
+ out.push("}", "");
316
+ for (const b of blocks) out.push(...b.expansion.behavior);
317
+ if (done.length) {
318
+ out.push("every frame {", " if allDone < 0.5 {", ` if ${done.join(" + ")} >= ${done.length} {`, " allDone = 1", ' send "completed"', " }", " }", "}");
309
319
  }
310
- const out = [parts.rest.trim(), ...parts.top.length ? [RAW_NOTE, ...parts.top] : []].filter(Boolean).join("\n");
311
- return { flatink: parts.top.length ? out : src, kind: parts.top.length ? "raw" : null, expanded: parts.top.length > 0, meta: null };
320
+ return out.join("\n");
312
321
  }
313
322
  var FLATINK_BLOCKS = /* @__PURE__ */ new Set(["scene", "object", "symbol", "layer", "group", "match", "each", "states", "params", "when", "every", "repeat", "fn", "at"]);
314
- function findGesture(text, gestures2) {
315
- const re = new RegExp(BLOCK_OPEN.source, "gm");
316
- for (let m = re.exec(text); m; m = re.exec(text)) {
317
- if (gestures2.some((g) => g.keyword === m[1])) return m[1];
323
+ function desugar(src, opts = {}) {
324
+ const doc = opts.document ?? DEFAULT_DOCUMENT;
325
+ const gestures2 = opts.gestures ?? GESTURES;
326
+ const found = findBlocks(src, gestures2);
327
+ if (!found.length) {
328
+ const parts = takeRaw(src);
329
+ if (parts.over.length || parts.under.length) {
330
+ throw new Error("`raw scene { \u2026 }` needs a gesture block to splice into \u2014 this source has none. Write a plain `scene { \u2026 }` yourself.");
331
+ }
332
+ const out = [parts.rest.trim(), ...parts.top.length ? [RAW_NOTE, ...parts.top] : []].filter(Boolean).join("\n");
333
+ return { flatink: parts.top.length ? out : src, kind: parts.top.length ? "raw" : null, expanded: parts.top.length > 0, meta: [] };
318
334
  }
319
- return null;
320
- }
321
- function blockBody(src, openIndex) {
322
- let depth = 1;
323
- let i = openIndex + 1;
324
- for (; i < src.length && depth > 0; i++) {
325
- if (src[i] === "{") depth++;
326
- else if (src[i] === "}") depth--;
335
+ const seen = /* @__PURE__ */ new Set();
336
+ for (const b of found) {
337
+ const key = ident(b.name);
338
+ if (seen.has(key)) throw new DuplicateBlockError(b.name);
339
+ seen.add(key);
327
340
  }
328
- return src.slice(openIndex + 1, depth === 0 ? i - 1 : src.length);
341
+ const outside = { top: [], over: [], under: [], rest: "" };
342
+ const absorb = (text) => {
343
+ const part = takeRaw(text);
344
+ outside.top.push(...part.top);
345
+ outside.over.push(...part.over);
346
+ outside.under.push(...part.under);
347
+ outside.rest += part.rest;
348
+ };
349
+ let cursor = 0;
350
+ for (const b of found) {
351
+ absorb(src.slice(cursor, b.start));
352
+ cursor = b.end;
353
+ }
354
+ absorb(src.slice(cursor));
355
+ const blocks = found.map((b, index) => {
356
+ const prefix = `${ident(b.name)}_`;
357
+ return { expansion: b.gesture.expand(b.name, b.body, doc, { index, prefix, doneVar: `${prefix}done` }) };
358
+ });
359
+ const header = [outside.rest.trim(), ...outside.top.length ? [RAW_NOTE, ...outside.top] : []].filter(Boolean).join("\n");
360
+ const program = assemble(blocks, outside.under, outside.over, doc);
361
+ return {
362
+ flatink: ensureHeader(header ? `${header}
363
+
364
+ ${program}` : program, doc),
365
+ kind: found.map((b) => b.gesture.keyword).join("+"),
366
+ expanded: true,
367
+ meta: blocks.map((b) => b.expansion.meta)
368
+ };
329
369
  }
330
370
  export {
331
371
  BLANK,
332
372
  DEFAULT_DOCUMENT,
373
+ DuplicateBlockError,
333
374
  GESTURES,
334
375
  GREYBOX,
335
- MultipleGesturesError,
336
376
  ROLES,
337
377
  UnknownSugarError,
338
378
  desugar,
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 now the theme's business, so they collapse into a single `place`. Five public promises\n// became three.\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// ─────────────────────────────────────────────────────────────────────────────\nimport type { Expansion, Gesture } 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): 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: `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: `I${ident(label)}`, label, target: `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): Expansion {\n const m = parsePlace(name, body)\n const n = m.items.length\n const out: string[] = [`// place \"${q(name)}\" — generated. The expansion is the artefact of record: edit it, or edit the block.`]\n if (m.prompt) out.push(`// prompt: ${q(m.prompt)}`)\n\n out.push('var progress = 0', 'var done = 0')\n for (const it of m.items) out.push(`var ${it.id}X = ${it.x}`, `var ${it.id}Y = ${it.y}`, `var ${it.id}Placed = 0`)\n\n out.push('', 'scene {', ' layer \"targets\" {')\n for (const t of m.targets) out.push(...container(t.id, t.x, t.y, theme.draw('target', t.label), theme.size('target')))\n out.push(' }', ' layer \"items\" {')\n for (const it of m.items) out.push(...container(it.id, it.x, it.y, theme.draw('item', it.label)))\n out.push(' }', '}', '')\n\n m.items.forEach((it, i) => {\n out.push(`object \"${it.id}\" {`)\n out.push(` drag ${it.id}X, ${it.id}Y { enabled ${it.id}Placed == 0 }`)\n out.push(` when dropped on ${it.target} at pointer {`)\n out.push(` if ${it.id}Placed < 0.5 {`)\n out.push(` ${it.id}Placed = 1`, ' progress = 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 out.push(` ${it.id}X = ${it.target}.x`, ` ${it.id}Y = ${it.target}.y`)\n out.push(` send \"correct\", { item = ${i} }`)\n out.push(` if progress == ${n} {`, ' done = 1', ' send \"completed\"', ' }')\n out.push(' }', ' }')\n for (const t of m.targets) {\n if (t.id === it.target) continue\n out.push(` when dropped on ${t.id} at pointer {`)\n out.push(` ${it.id}X = ${it.x}`, ` ${it.id}Y = ${it.y}`) // back where it started\n out.push(` send \"incorrect\", { item = ${i} }`)\n out.push(' }')\n }\n out.push(` x = ${it.id}X`, ` y = ${it.id}Y`, '}', '')\n })\n return {\n flatink: out.join('\\n'),\n meta: { keyword: 'place', name, prompt: m.prompt, items: m.items.map((i) => i.label), targets: m.targets.map((t) => t.label) },\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): Expansion {\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 out: string[] = [`// compose \"${q(name)}\" — generated.`, ...(prompt ? [`// prompt: ${q(prompt)}`] : []), 'var total = 0', 'var done = 0', '', 'scene {', ' layer \"chips\" {']\n chips.forEach((c, i) => out.push(...container(`C${i}`, c.x, c.y, theme.draw('chip', c.value), theme.size('chip'))))\n out.push(' }', '}', '')\n chips.forEach((c, i) => {\n out.push(`object \"C${i}\" {`, ' when clicked {', ' if done < 0.5 {')\n out.push(` if total + ${c.value} > ${target} {`)\n out.push(' total = 0', ` send \"incorrect\", { chip = ${i} }`)\n out.push(' } else {')\n out.push(` total = total + ${c.value}`, ` send \"correct\", { chip = ${i} }`)\n out.push(` if total == ${target} {`, ' done = 1', ' send \"completed\"', ' }')\n out.push(' }', ' }', ' }', '}', '')\n })\n return { flatink: out.join('\\n'), meta: { keyword: 'compose', name, prompt, items: chips.map((c) => c.value), targets: [] } }\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): Expansion {\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 out: string[] = [`// steps \"${q(name)}\" — generated.`, ...(prompt ? [`// prompt: ${q(prompt)}`] : []), 'var step = 0', '', 'scene {', ' layer \"steps\" {']\n steps.forEach((s, i) => out.push(...container(`S${i}`, s.x, s.y, theme.draw('card', s.label), theme.size('card'))))\n out.push(' }', '}', '')\n steps.forEach((_s, i) => {\n out.push(`object \"S${i}\" {`, ' when clicked {', ` if step == ${i} {`, ` step = step + 1`, ` send \"step\", { index = ${i} }`)\n if (i === steps.length - 1) out.push(' send \"completed\"')\n out.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 out.push(` opacity = step == ${i} ? 1 : 0.45`, '}', '')\n })\n return { flatink: out.join('\\n'), meta: { keyword: 'steps', name, prompt, items: steps.map((s2) => s2.label), targets: [] } }\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) => expandPlace(name, body, theme),\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) => expandCompose(name, body, theme),\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) => expandSteps(name, body, theme),\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 — one block, one activity',\n '',\n `Canvas: ${doc.width}x${doc.height}, origin top-left. Write ONE block, nothing else. Coordinates are the`,\n 'CENTRE of each thing. Anything you do not describe is not drawn.',\n '',\n '## Blocks',\n ...gestures({ theme }).map((g) => `- ${g.summary}`),\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.',\n '',\n '## Escape hatch — three forms, and they are not interchangeable',\n 'The block draws NOTHING beyond the pieces above. Everything else goes through one of these:',\n '',\n 'raw scene under { layer \"bg\" { … } } <- BACKGROUND and decor. Drawn BEHIND the activity.',\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. Either 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'\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. */\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: `{ item = 2 }` is `items[2]`. */\n items: string[]\n /** Target labels, in the order they were declared. Empty when the gesture has none. */\n targets: string[]\n}\n\n/** What a gesture returns: the DSL, and what it understood. */\nexport type Expansion = { flatink: string; meta: GestureMeta }\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) => 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 the gesture understood: the prompt and the labels behind the payload indices. `null` when\n * nothing was expanded, since there is no block to have understood anything from. */\n meta: GestureMeta | null\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/** Splice verbatim bodies into the generated `scene`: `under` first (drawn behind), `over` last. */\nfunction spliceIntoScene(flatink: string, under: string[], over: string[]): string {\n if (!under.length && !over.length) return flatink\n const at = flatink.search(/^scene[ \\t]*\\{/m)\n if (at < 0) throw new Error('`raw scene { … }` has nowhere to go: this expansion emits no `scene` block — use a plain `raw { … }` instead.')\n const openBrace = flatink.indexOf('{', at)\n const close = blockEnd(flatink, openBrace)\n const head = under.length ? `\\n // -- raw scene under (verbatim, drawn BEHIND the gesture) --\\n${under.join('\\n')}` : ''\n const tail = over.length ? ` // -- raw scene (verbatim, drawn ON TOP of the gesture) --\\n${over.join('\\n')}\\n` : ''\n return `${flatink.slice(0, openBrace + 1)}${head}${flatink.slice(openBrace + 1, close)}${tail}${flatink.slice(close)}`\n}\n\n/** Raised when a source holds more than one gesture block. */\nexport class MultipleGesturesError extends Error {\n constructor(first: string, second: string) {\n super(\n `two gesture blocks in one source (\"${first}\" and \"${second}\") — a document holds ONE. Each gesture ` +\n 'emits its own `scene`, and a program may only have one, so the second cannot be merged in. ' +\n 'Split them into two documents, or write the extra part by hand in `raw { … }` / `raw scene { … }`.',\n )\n this.name = 'MultipleGesturesError'\n }\n}\n\n/**\n * Expand a sugar source into `.flatink`.\n *\n * Plain FlatInk passes through untouched. A source whose first block matches no gesture RAISES rather\n * than passing through: a silent fall-through sent the author's block downstream as if it were FlatInk,\n * to fail a hundred lines later on messages that only talk about FlatInk.\n *\n * ```ts\n * import { desugar } from '@flatkit/sugarflat'\n * import { checkProgram } from '@flatkit/compiler'\n *\n * const { flatink } = 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 open = BLOCK_OPEN.exec(src)\n const keyword = open?.[1]\n const gesture = keyword ? gestures.find((g) => g.keyword === keyword) : undefined\n\n if (gesture) {\n const name = open?.[2] ?? open?.[3] ?? gesture.keyword\n const braceAt = open!.index + open![0].length - 1\n const body = blockBody(src, braceAt)\n // Everything OUTSIDE the block travels with the expansion. Dropping it made the escape hatch — the\n // one guard-rail this package rests on — a no-op beside a gesture: an author wrote decor, the\n // expansion compiled, `checkProgram` said ok, and nothing was there.\n const before = src.slice(0, open!.index)\n const after = src.slice(braceAt + 1 + body.length + 1)\n const other = findGesture(before + '\\n' + after, gestures)\n if (other) throw new MultipleGesturesError(gesture.keyword, other)\n\n const { flatink, meta } = gesture.expand(name, body, doc)\n const head = takeRaw(before)\n const tail = takeRaw(after)\n const expanded = spliceIntoScene(flatink, [...head.under, ...tail.under], [...head.over, ...tail.over])\n // Everything top-level goes BEFORE the expansion, wherever the author wrote it. `var` (and `asset`,\n // `use`, `def`) are header declarations and are a parse error after `scene`, while `object`/`fn` are\n // accepted on either side -- so the header position is the only one where all of it is valid. Moving\n // an `object` up changes nothing: behavior binds by name, not by position.\n const topLevel = (p: RawParts) => [p.rest.trim(), ...(p.top.length ? [RAW_NOTE, ...p.top] : [])].filter(Boolean).join('\\n')\n const whole = [topLevel(head), topLevel(tail), expanded].filter(Boolean).join('\\n\\n')\n return { flatink: ensureHeader(whole, doc), kind: gesture.keyword, expanded: true, meta }\n }\n // A keyword that opens a block at column 0 and is NOT a FlatInk statement is a sugar block we do not\n // know — never a program. Say so here, with the list, rather than downstream in another vocabulary.\n // `raw` is this package's own keyword, handled below.\n if (keyword && keyword !== 'raw' && !FLATINK_BLOCKS.has(keyword)) throw new UnknownSugarError(keyword, gestures.map((g) => g.keyword))\n\n // No gesture: plain FlatInk, plus any `raw { … }` the author used on its own. `raw scene` has no\n // generated scene to splice 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: null }\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/** The keyword of the first gesture block in `text`, if any — used to refuse a second one loudly. */\nfunction findGesture(text: string, gestures: Gesture[]): string | null {\n const re = new RegExp(BLOCK_OPEN.source, 'gm')\n for (let m = re.exec(text); m; m = re.exec(text)) {\n if (gestures.some((g) => g.keyword === m![1])) return m[1]\n }\n return null\n}\n\n/** Text between the braces opened at `openIndex`, brace-counting so nested blocks survive. */\nfunction blockBody(src: string, openIndex: number): string {\n let depth = 1\n let i = openIndex + 1\n for (; i < src.length && depth > 0; i++) {\n if (src[i] === '{') depth++\n else if (src[i] === '}') depth--\n }\n return src.slice(openIndex + 1, depth === 0 ? i - 1 : src.length)\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,I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,CAAC,MAAM,IAAK;AAAA,aACX,IAAI,CAAC,MAAM,IAAK;AAAA,EAC3B;AACA,SAAO,IAAI,MAAM,YAAY,GAAG,UAAU,IAAI,IAAI,IAAI,IAAI,MAAM;AAClE;","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/** 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;AAC1F,QAAM,OAAiB,CAAC;AACxB,MAAI,CAAC,cAAc,OAAO,EAAG,MAAK,KAAK,QAAQ,IAAI,KAAK,IAAI,IAAI,MAAM,EAAE;AACxE,MAAI,CAAC,kBAAkB,OAAO,EAAG,MAAK,KAAK,YAAY,IAAI,GAAG,IAAI,IAAI,cAAc,EAAE;AACtF,SAAO,KAAK,SAAS,GAAG,KAAK,KAAK,IAAI,CAAC;AAAA,EAAK,OAAO,KAAK;AAC1D;;;ACzBO,SAAS,MAAM,OAAuB;AAC3C,QAAM,QAAQ,MAAM,UAAU,KAAK,EAAE,QAAQ,mBAAmB,EAAE,EAAE,QAAQ,kBAAkB,GAAG;AACjG,SAAO,SAAS,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK;AAC9C;AAGO,IAAM,UAAU,CAAC,UAA2B,MAAM,KAAK,MAAM,SAAS,MAAM,SAAS;;;ACQrF,IAAM,QAAgB,CAAC,QAAQ,UAAU,QAAQ,MAAM;AAE9D,IAAM,QAAgD;AAAA,EACpD,MAAM,EAAE,GAAG,IAAI,GAAG,GAAG;AAAA,EACrB,QAAQ,EAAE,GAAG,KAAK,GAAG,IAAI;AAAA,EACzB,MAAM,EAAE,GAAG,KAAK,GAAG,IAAI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zB,YAAQ,IAAI,KAAK,GAAG,KAAK,GAAG;AAC5B,YAAQ,KAAK,KAAK,GAAG,KAAK,IAAI;AAC9B,YAAQ,MAAM,KAAK,GAAG,KAAK,KAAK;AAChC,YAAQ,QAAQ,KAAK;AAAA,EACvB;AACA,MAAI,SAAS;AACb,aAAW,KAAK,OAAO;AAAE,WAAO,IAAI,MAAM,QAAQ,EAAE,KAAK,CAAC;AAAG,aAAS,EAAE;AAAA,EAAI;AAC5E,SAAO,IAAI,MAAM,MAAM,CAAC;AAExB,QAAM,SAAS,MAAM,IAAI,CAAC,GAAG,UAAU;AACrC,UAAM,SAAS,GAAG,MAAM,EAAE,IAAI,CAAC;AAC/B,WAAO,EAAE,WAAW,EAAE,QAAQ,OAAO,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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flatkit/sugarflat",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
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/player": "0.26.0",
44
- "@flatkit/types": "0.26.0"
43
+ "@flatkit/types": "0.26.0",
44
+ "@flatkit/player": "0.26.0"
45
45
  },
46
46
  "scripts": {
47
47
  "build": "tsup",