@flatkit/compiler 0.34.0 → 0.34.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -29,6 +29,16 @@
29
29
  ("one action per line — unexpected `=`"), with the column pointing at the second `=`.
30
30
  A swallowed statement is named now — `score = score + 1 send "ok", 1` reports *"two statements on one
31
31
  line — `send …` was swallowed into the expression before it"*, not `unexpected character """`.
32
+ - **The space between a keyword and its literal is NOT significant.** `send"win"`, `send "win"` and
33
+ `send\t"win"` are one and the same statement, and so are `object"R"` / `object "R"`, `layer"c"`,
34
+ `text"Hi"`, `font"sans-serif"`. The grammar is tokenized: it never sees the whitespace. (Everything
35
+ round-trips to the canonical one-space spelling, which is what `flatc` prints.)
36
+ ⚠️ **So do not police a program with a regex.** A guard looking for `send\s+"…"` misses `send"…"` by one
37
+ character — and, worse, misses an event emitted through a function: a fragment that never types `send`
38
+ can call a `fn` the rest of the program defines, and the event fires. To decide what a program is allowed
39
+ to DO, read its structure: `manifestEvents(doc)` (from `@flatkit/compiler`) returns every event any
40
+ action emits, procedures, `if`/`repeat` bodies and timeline hooks included. See
41
+ [Tooling](tooling.md#what-does-this-program-do).
32
42
  - **`send` footgun (fixed)**: `send "evt", x = 1` (with a comma) used to capture `x = 1` as
33
43
  the *payload*. It is now a dedicated error. A `send` carries at most one payload:
34
44
  `send "evt"`, `send "evt", <expr>`, `send "evt", text("textId")`, or the record form
package/docs/tooling.md CHANGED
@@ -250,6 +250,31 @@ In the player, `player.startRecording()` / `stopRecording(): Gesture[]` capture
250
250
  hand into a script that `--play` replays. (Authoring/CI helpers live in `@flatkit/player/debug`.)
251
251
  Pointer only — key presses are not captured; add the `key` gestures to the recorded script yourself.
252
252
 
253
+ ## What does this program DO?
254
+
255
+ Merging DSL you did not write (a generated skin, a themed layer) raises a question a compiler answers and
256
+ a regex cannot: *what is this fragment allowed to do?* Read the structure, never the source text:
257
+
258
+ ```js
259
+ import { parseProgramFull } from '@flatkit/engine/flatFormat'
260
+ import { manifestEvents } from '@flatkit/compiler'
261
+
262
+ const emitted = manifestEvents(parseProgramFull(merged)) // every `send`, wherever it hides
263
+ const introduced = emitted.filter((e) => !ownEvents.includes(e))
264
+ if (introduced.length) throw new Error(`the skin emits ${introduced.join(', ')}`)
265
+ ```
266
+
267
+ `manifestEvents` walks every action of the document — inside `if` / `repeat` bodies, inside procedures,
268
+ inside the timeline hooks — so it sees what a pattern over the source cannot:
269
+
270
+ - `send"win"` with no space (the grammar does not require one — see the [gotchas](dsl-gotchas.md));
271
+ - an event emitted **through a function**: a fragment that never writes `send` at all can call a `fn` the
272
+ rest of the program defines, and the event fires.
273
+
274
+ Symmetrically, it does not fire on the word `send` sitting in a comment or inside a string a text draws —
275
+ which a pattern would reject. `manifestVars` and `docToManifest` answer the same kind of question for the
276
+ variables a program reads and the contract its objects carry.
277
+
253
278
  ## Teaching the language to a model
254
279
 
255
280
  Three pieces, all pure functions — no filesystem, no canvas — so they work in a browser as well as in CI:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flatkit/compiler",
3
- "version": "0.34.0",
3
+ "version": "0.34.1",
4
4
  "description": "The FlatInk language (parser + AST) and compiler (.flatink → .flatpack). Ships the flatc CLI.",
5
5
  "license": "MIT",
6
6
  "author": "Zwyk Studio",
@@ -57,9 +57,9 @@
57
57
  "docs"
58
58
  ],
59
59
  "dependencies": {
60
- "@flatkit/engine": "0.34.0",
61
- "@flatkit/player": "0.34.0",
62
- "@flatkit/types": "0.34.0"
60
+ "@flatkit/engine": "0.34.1",
61
+ "@flatkit/player": "0.34.1",
62
+ "@flatkit/types": "0.34.1"
63
63
  },
64
64
  "peerDependencies": {
65
65
  "skia-canvas": "^3.0.8"