@flatkit/compiler 0.33.0 → 0.33.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.
@@ -207,7 +207,9 @@ sane start: big enough never to stall a real gesture, small enough that skipping
207
207
  impossible.
208
208
 
209
209
  **Restarting**: assign the progress variable (`progress = 0`) — the trace re-seats itself on what the scene
210
- wrote, and the entry end opens again. There is no other reset, on purpose: the variable is the truth.
210
+ wrote, and the entry end opens again. There is no other reset, on purpose: the variable is the truth. The
211
+ same rule **restores** a session: seed the progress (in `doc.variables`, or `setVar` from the host) and the
212
+ ink, the marker and the finger all resume together — see [host integration](host-integration.md#saving-and-restoring-a-session).
211
213
 
212
214
  ### Drawing what a `trace` traced
213
215
 
@@ -298,6 +300,10 @@ the grid is as monotone as the fraction, and both agree. (The array is yours to
298
300
  coverage behind it has no reset — so each new grab re-syncs the array from the interactor's own state,
299
301
  rather than letting a scene show an intact cell over a zone counted as cleared.)
300
302
 
303
+ The array reads **both ways**: seed it at load and the veil comes back scratched exactly where it was,
304
+ `erase` included, with the fraction recomputed from it — how a reader resumes a half-scratched image (see
305
+ [host integration](host-integration.md#saving-and-restoring-a-session)).
306
+
301
307
  Declare the array at exactly `cols * rows` — `flatc --check` states the geometry and the exact
302
308
  `var … = fill(N, 0)` to write whenever the sizes disagree, because a short array drops the writes past its
303
309
  end in silence.
@@ -90,6 +90,30 @@ player.allVars() // snapshot of everything, for debugging/s
90
90
  `getVar`/`allVars` return **copies**: mutating the result never touches the running scene. Symmetrically
91
91
  `setVar` clones what you pass in.
92
92
 
93
+ ### Saving and restoring a session
94
+
95
+ `allVars()` is the save file, and a document's `variables` (or `setVar`) is how you put it back — a reader
96
+ returning to a half-finished activity finds it where they left it:
97
+
98
+ ```js
99
+ const saved = player.allVars() // …persist it however you like
100
+ player.load({ ...doc, variables: saved }) // …and the activity resumes
101
+ ```
102
+
103
+ The gestures that keep state **beside** the variables re-seat themselves on what you seed, so a restored
104
+ scene is coherent and not merely correct-looking:
105
+
106
+ - a **continuous [`trace`](behavior-and-interactions.md#a-cursor-or-a-trace-step)** picks its progress back
107
+ up from its own variable — the ink, the pen-tip marker and the finger all resume at the same place
108
+ (rather than the stroke being drawn to three quarters while the next touch starts from zero);
109
+ - a **[`reveal … cells`](behavior-and-interactions.md#seeing-where-it-was-scratched-reveal--cells)** grid
110
+ is restored from the array it writes: seed that array and the veil comes back scratched exactly where it
111
+ was, `erase` included, with the fraction recomputed from it. The same format both directions.
112
+
113
+ This happens once per `load()` (and at construction), before the first paint. Writing the variable later —
114
+ from the host with `setVar`, or from the scene with an assignment — re-seats it just the same: the two are
115
+ the same path on purpose.
116
+
93
117
  Playback control mirrors the DSL actions: `play()`, `pause()`, `toggle()`, `stop()`, `seek(frame)`,
94
118
  plus the read-only `currentFrame`, `isPlaying`, `fps`, `duration`. `load(doc)` swaps the document in
95
119
  place, and `render()` forces a repaint (useful after a late font settles).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flatkit/compiler",
3
- "version": "0.33.0",
3
+ "version": "0.33.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.33.0",
61
- "@flatkit/types": "0.33.0",
62
- "@flatkit/player": "0.33.0"
60
+ "@flatkit/engine": "0.33.1",
61
+ "@flatkit/types": "0.33.1",
62
+ "@flatkit/player": "0.33.1"
63
63
  },
64
64
  "peerDependencies": {
65
65
  "skia-canvas": "^3.0.8"
@@ -197,7 +197,8 @@ link <endX>,<endY>,<target> to <Group> // elastic thread → target
197
197
  `trace avance along Chemin` on one, `draw "avance"` on the other — the ink follows the finger by arc
198
198
  length. Add **`step <px>`** or the drill is free: without it the progress is where the finger PROJECTS, so
199
199
  one press near the finish completes it. With it, the run must start at an end and pass through everything
200
- (and it resumes across a lift, since a child stops mid-letter). Restart with `avance = 0`. **A scratch card is `reveal cleared { brush 28 · erase }` on a grey rectangle** — nothing else: `erase`
200
+ (and it resumes across a lift, since a child stops mid-letter). Restart with `avance = 0` — and the same variable RESTORES a session: seed it (or the `cells` array of a
201
+ `reveal`) and the gesture resumes where the reader left it. **A scratch card is `reveal cleared { brush 28 · erase }` on a grey rectangle** — nothing else: `erase`
201
202
  makes the runtime rub the veil out under the finger (a `mask` layer CANNOT do it, its matter is an even-odd
202
203
  clip path where two overlapping stamps cancel). **`reveal … cells grille`** is the other half, for a scene
203
204
  that must REACT to the uncovered area: it writes `grille[i] = 1` for each cleared cell (`i = row * cols + col`,