@vibecook/ice 0.2.0 → 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/dist/react.js CHANGED
@@ -13,6 +13,7 @@ import {
13
13
  useBreakpoint,
14
14
  useCanvasEngine,
15
15
  useCommit,
16
+ useFrameFreeze,
16
17
  useOps,
17
18
  usePresencePeers,
18
19
  useSelected,
@@ -23,9 +24,9 @@ import {
23
24
  useWidgetProps,
24
25
  useWorld,
25
26
  useWorldComponent
26
- } from "./chunk-5SJYHQI4.js";
27
- import "./chunk-IASTQMU5.js";
28
- import "./chunk-DXU3RZZS.js";
27
+ } from "./chunk-2GUYATUM.js";
28
+ import "./chunk-PKK6GLSA.js";
29
+ import "./chunk-5QY7HK6G.js";
29
30
  import "./chunk-OR5FNVUE.js";
30
31
  export {
31
32
  EngineProvider,
@@ -42,6 +43,7 @@ export {
42
43
  useBreakpoint,
43
44
  useCanvasEngine,
44
45
  useCommit,
46
+ useFrameFreeze,
45
47
  useOps,
46
48
  usePresencePeers,
47
49
  useSelected,
@@ -39,12 +39,36 @@ export declare const ActiveTool: import("@vibecook/strata-ecs").Resource<import(
39
39
  * NOT a full step-pause: a menu panel floats over a still-visible canvas,
40
40
  * and a frozen world would leave undo/collab visually stale (rev-2 decision,
41
41
  * recorded — a stricter frozen-world mode would be a separate concept).
42
+ * That separate concept is now BUILT (2026-08-04): see {@link FrameMode}.
43
+ * Holds keep their exact meaning — nothing here stretched.
42
44
  */
43
45
  export declare const StageMode: import("@vibecook/strata-ecs").Resource<import("@vibecook/strata-ecs").ValueOf<{
44
46
  readonly backgroundHolds: import("@vibecook/strata-ecs").FieldSpec<"u32", true>;
45
47
  }>, {
46
48
  readonly backgroundHolds: import("@vibecook/strata-ecs").FieldSpec<"u32", true>;
47
49
  }>;
50
+ /**
51
+ * Frame gate mirror (2026-08-04) — the stricter sibling {@link StageMode}'s
52
+ * rev-2 decision named and left for later.
53
+ *
54
+ * A background hold is presentation policy over a LIVE world. A freeze
55
+ * (`engine.frame.freeze(name)`) stops the host loop outright: no step, so no
56
+ * systems, no publish, no notify, no reflectors, no rAF — for chrome that
57
+ * COVERS the canvas, where every frame drawn behind it is work nobody can see.
58
+ * This resource is the world-truth mirror of that refcount; the tokens live on
59
+ * the control, out of ECS, exactly as stage holds do.
60
+ *
61
+ * Reading it tells you the engine is frozen. It cannot tell you a frame is
62
+ * coming, because while the count is non-zero none is — and for the same
63
+ * reason nothing can OBSERVE it while frozen (a parked world fires no
64
+ * observers). It exists for inspection: devtools, tests, and consumers that
65
+ * want the fact in hand on thaw.
66
+ */
67
+ export declare const FrameMode: import("@vibecook/strata-ecs").Resource<import("@vibecook/strata-ecs").ValueOf<{
68
+ readonly freezeHolds: import("@vibecook/strata-ecs").FieldSpec<"u32", true>;
69
+ }>, {
70
+ readonly freezeHolds: import("@vibecook/strata-ecs").FieldSpec<"u32", true>;
71
+ }>;
48
72
  /** Global snap toggle + threshold in screen px (scaled by zoom at use, design-003 §5.2). */
49
73
  export declare const SnapConfig: import("@vibecook/strata-ecs").Resource<import("@vibecook/strata-ecs").ValueOf<{
50
74
  readonly enabled: import("@vibecook/strata-ecs").FieldSpec<"bool", true>;
@@ -101,9 +125,9 @@ export declare const SelectionBox: import("@vibecook/strata-ecs").Component<impo
101
125
  }>;
102
126
  /** A resize handle's anchor (the one chrome kind behaviors capture). */
103
127
  export declare const HandleSpec: import("@vibecook/strata-ecs").Component<import("@vibecook/strata-ecs").ValueOf<{
104
- readonly anchor: import("@vibecook/strata-ecs").EnumType<"s" | "w" | "n" | "e" | "nw" | "ne" | "se" | "sw">;
128
+ readonly anchor: import("@vibecook/strata-ecs").EnumType<"s" | "w" | "nw" | "n" | "ne" | "e" | "se" | "sw">;
105
129
  }>, {
106
- readonly anchor: import("@vibecook/strata-ecs").EnumType<"s" | "w" | "n" | "e" | "nw" | "ne" | "se" | "sw">;
130
+ readonly anchor: import("@vibecook/strata-ecs").EnumType<"s" | "w" | "nw" | "n" | "ne" | "e" | "se" | "sw">;
107
131
  }>;
108
132
  /** A snap guide line along one axis. `from == to` ⇒ full-viewport line (v1's full-canvas alignment look — design-003 §6). */
109
133
  export declare const GuideLine: import("@vibecook/strata-ecs").Component<import("@vibecook/strata-ecs").ValueOf<{
@@ -115,7 +115,7 @@ export declare const WheelZoom: import("@vibecook/strata-ecs").Component<import(
115
115
  * `Sequence`/`RequiresFail` edge. NEVER reaped; exempt from integrity's watched-pointer
116
116
  * count (a pending multi-tap legitimately outlives its lifted touch pointer).
117
117
  */
118
- export declare const GesturePhases: import("..").PhaseSet<"Possible" | "Active" | "Pending" | "Recognized" | "Ended" | "Failed" | "Cancelled">;
118
+ export declare const GesturePhases: import("..").PhaseSet<"Active" | "Possible" | "Pending" | "Recognized" | "Ended" | "Failed" | "Cancelled">;
119
119
  /** Recognizer alive, not yet claiming. */
120
120
  export declare const GesturePossible: import("@vibecook/strata-ecs").Tag;
121
121
  /** Continuous kinds' claiming phase + per-frame work gate. */
@@ -1,3 +1,37 @@
1
+ /**
2
+ * The autosave kit (design-005 §6.6; design-001 §6.5 envelope-at-rest).
3
+ *
4
+ * Persists a `DocSession` to app-owned storage on a debounce (default 800 ms)
5
+ * with a max-wait ceiling (default 10 s), DEFERRED while the user is mid-gesture
6
+ * so a save never captures a half-applied interaction. What it writes is an
7
+ * ENVELOPE (`session.exportEnvelope(savedAt)`) — never raw Loro bytes — so the
8
+ * restore path can read the header and gate/quarantine BEFORE any import.
9
+ *
10
+ * CHANGE-SUBSCRIPTION SURFACE: two triggers, plus an initial arm.
11
+ * - `DurableStore.subscribeOutbound` (durable-store.ts) fires SYNCHRONOUSLY on
12
+ * each sealed LOCAL commit and never on remote imports.
13
+ * - `DocSession.subscribeRemote` (doc-kit) fires after each successful
14
+ * `applyRemote`. The original design left remote changes to "whichever peer
15
+ * originated them" — but that peer persists to ITS storage, not this one's:
16
+ * a joiner that received edits and closed restored a STALE local backup
17
+ * (2026-07-13 review). Local autosave must reflect the last-seen document.
18
+ * - Autosave starts DIRTY: state that predates startAutosave() (a seeded or
19
+ * freshly-joined doc) reaches storage after the first debounce, not only
20
+ * after the next edit (same review — a seeded doc could close unsaved).
21
+ * No polling — the design's `store.exportSnapshot()` length/frontier poll is
22
+ * the last-resort fallback and is not needed here.
23
+ *
24
+ * Clock and scheduler are injectable so tests are deterministic with NO real
25
+ * timers; the design's `requestIdleCallback` optimization is just an alternate
26
+ * `schedule` an app can pass. `flush()` forces an awaited save; `close()`
27
+ * captures and durably serializes the final revision; `stop()` explicitly
28
+ * discards pending state.
29
+ *
30
+ * RESTORE (`restoreAutosave`): reads storage → `openDocSession`. Incompatible or
31
+ * corrupt bytes NEVER throw and NEVER brick boot (the M5 exit criterion) —
32
+ * they come back as `{ status: "quarantined", reason, bytes }` so the app can
33
+ * stash the bytes aside and start fresh.
34
+ */
1
35
  import type { World } from "@vibecook/strata-ecs";
2
36
  import { type DocSession, type DocSessionOpts } from "./doc-kit";
3
37
  import type { DocVersionReport } from "./version-gate";
@@ -21,6 +21,7 @@
21
21
  */
22
22
  import type { World } from "@vibecook/strata-ecs";
23
23
  import type { AnySystem } from "./pipeline";
24
+ import { type FrameControl } from "./frame-control";
24
25
  import { type PhaseGroup } from "./pipeline";
25
26
  import { type ReflectorDef } from "./reflectors";
26
27
  export type PublishHook = (world: World) => void;
@@ -54,6 +55,16 @@ export interface Engine {
54
55
  onPublish(hook: PublishHook): () => void;
55
56
  /** Run one full frame. `now` in ms (rAF timestamp or a test counter). */
56
57
  step(now: number): void;
58
+ /**
59
+ * The frame gate (2026-08-04): freeze/thaw plus the settle protocol a host
60
+ * loop consults before each frame. It lives HERE, next to the step it
61
+ * governs, so every host gets it without a new argument — and so a
62
+ * subsystem holding only the `Engine` (the GL compositor) can report itself
63
+ * busy. `step()` itself stays unconditional: the gate governs the loop, not
64
+ * the primitive, which keeps headless hosts and traces driving frames by
65
+ * hand exactly as before.
66
+ */
67
+ readonly frame: FrameControl;
57
68
  /** Arm per-system run/skip + µs collection (idempotent; costs timer calls per system). */
58
69
  enableTelemetry(): void;
59
70
  /** The most recent completed frame's readout (undefined until telemetry armed + one step). */
@@ -0,0 +1,71 @@
1
+ /**
2
+ * The frame gate (design-002 §1 amendment, 2026-08-04) — the frozen-world mode
3
+ * design-005 §7 named and deliberately left unbuilt.
4
+ *
5
+ * Stage holds are PRESENTATION policy: `StageMode.backgroundHolds` freezes the
6
+ * compositor on its retained textures while the world keeps stepping, which is
7
+ * exactly what makes a hold safe under a PARTIAL overlay — a menu panel floats
8
+ * over a still-live canvas, undo reflects, collab applies, tweens land. The
9
+ * rev-2 decision recorded that a stricter mode "would be a SEPARATE concept".
10
+ * This is that concept: while a freeze is held the host loop stops calling
11
+ * `step` at all — no systems, no publish, no notify, no reflectors, no rAF
12
+ * callback. It is for chrome that COVERS the canvas outright, where every
13
+ * frame drawn behind it is work nobody can see.
14
+ *
15
+ * THE SETTLE — why a freeze does not park on the spot. Parking the instant a
16
+ * freeze is taken would strand the canvas mid-churn: a cancelled gesture that
17
+ * has not reached its commit tick, islands still owed a first paint, a
18
+ * reflector holding a write that landed this frame. So a freeze walks the loop
19
+ * to QUIET — every registered settle reporter idle — then takes ONE further
20
+ * step so the quiet state itself reflects, and only then closes the gate. The
21
+ * walk is bounded by {@link SETTLE_CAP}: a reporter that never goes quiet makes
22
+ * a freeze park LATE, never never.
23
+ *
24
+ * Core stays scheduler-free (design-002 §1). This module owns no timer and
25
+ * starts nothing — it answers {@link FrameControl.claimStep} and announces
26
+ * transitions. The DOM package's rAF loop is what actually parks and restarts;
27
+ * `engine.step(now)` itself stays callable by hand (headless hosts, traces),
28
+ * because the gate governs the LOOP, not the primitive.
29
+ */
30
+ import type { World } from "@vibecook/strata-ecs";
31
+ /**
32
+ * Frames a freeze may spend walking to quiet before it parks regardless.
33
+ * Two seconds at 60 Hz: comfortably longer than a cancelled gesture's path to
34
+ * its commit tick or a cold board's first paints, short enough that a wedged
35
+ * reporter reads as a hiccup rather than a hang.
36
+ */
37
+ export declare const SETTLE_CAP = 120;
38
+ export interface FrameControl {
39
+ /**
40
+ * Take a named freeze. Returns an IDEMPOTENT thaw — the disposer pattern
41
+ * that makes overlay lifecycles leak-proof (release on unmount), the name
42
+ * that makes "why is the engine parked?" answerable. Refcounted: the loop
43
+ * resumes when the LAST freeze thaws.
44
+ */
45
+ freeze(name: string): () => void;
46
+ /** A freeze is held — the loop is settling or already parked. */
47
+ isFrozen(): boolean;
48
+ /** The settle finished and the gate closed: no further steps are being run. */
49
+ isParked(): boolean;
50
+ /** Live freeze names, in take order (debug/devtools). */
51
+ holds(): readonly string[];
52
+ /**
53
+ * Register a settle reporter: while `busy()` is true, a taken freeze keeps
54
+ * stepping instead of parking. This is how a subsystem that owes visible
55
+ * work — the GL compositor's pending first paints, a gesture walking to its
56
+ * commit — keeps a freeze from landing on a half-finished image. Returns an
57
+ * idempotent unregister.
58
+ */
59
+ settleWhile(name: string, busy: () => boolean): () => void;
60
+ /** Reporters answering busy right now ("why hasn't it parked yet?"). */
61
+ settling(): readonly string[];
62
+ /**
63
+ * The loop gate. CONSUMING — each call advances the settle walk, so it is
64
+ * for frame hosts only, never a predicate to poll. Use {@link isFrozen} /
65
+ * {@link isParked} to ask questions.
66
+ */
67
+ claimStep(): boolean;
68
+ /** Wake on any freeze/thaw transition (the host loop restarts here). */
69
+ onChange(fn: () => void): () => void;
70
+ }
71
+ export declare function createFrameControl(world: World): FrameControl;
@@ -20,6 +20,7 @@
20
20
  */
21
21
  import type { Entity, World } from "@vibecook/strata-ecs";
22
22
  import { type Engine } from "../engine/engine";
23
+ import type { FrameControl } from "../engine/frame-control";
23
24
  import { type InteractionStack } from "../interaction/install";
24
25
  import { type NavOpts, type NestedCanvas } from "../nav/nested-canvas";
25
26
  import { type ArrangeOpts } from "../ops/arrange";
@@ -173,6 +174,14 @@ export interface CanvasEngine {
173
174
  readonly ops: CanvasOps;
174
175
  readonly docs: CanvasDocs;
175
176
  readonly stage: StageControl;
177
+ /**
178
+ * The frame gate (2026-08-04) — `stage`'s stricter sibling. A background
179
+ * hold is presentation policy over a LIVE world; a freeze stops the host
180
+ * loop outright. Reach for `stage` when chrome RECEDES the canvas, `frame`
181
+ * when chrome COVERS it. Passthrough of `engine.frame`, so there is one gate
182
+ * whether you hold the facade or the raw engine.
183
+ */
184
+ readonly frame: FrameControl;
176
185
  readonly budgets: {
177
186
  readonly keepMounted: number;
178
187
  readonly fboBytes: number;
@@ -14,6 +14,7 @@ export { FrameInfo, setFrameInfo } from "./engine/frame-info";
14
14
  export { createPipelineRegistry, PHASE_GROUPS, type AnySystem, type PhaseGroup, type PipelineRegistry } from "./engine/pipeline";
15
15
  export { createReflectorRegistry, type ReflectorDef, type ReflectorObserve, type ReflectorQuerySpec, type ReflectorRegistry, } from "./engine/reflectors";
16
16
  export { createEngine, type Engine, type EngineOpts, type FrameTelemetry, type PublishHook, type SystemRunRecord, } from "./engine/engine";
17
+ export { createFrameControl, SETTLE_CAP, type FrameControl } from "./engine/frame-control";
17
18
  export { devGuardsEnabled, setDevGuards } from "./guards/dev";
18
19
  export { createLiveWriter, type LiveWriter, type LiveWriterOpts } from "./guards/live-writer";
19
20
  export { guardedTransaction, type GuardedTx, type GuardedTxOpts } from "./guards/guarded-tx";
@@ -32,6 +33,7 @@ export { portSlots, portSlotOf } from "./ops/port-geometry";
32
33
  export { createInputQueue, NO_MODS, type InputEvent, type InputEventKind, type InputMods, type InputQueue } from "./input/queue";
33
34
  export { createRecordingCommitSink, type CommitIntent, type CommitCreate, type CommitOrder, type CommitReparent, type CommitSink, type CommitWrite, } from "./engine/commit-sink";
34
35
  export { ensureCanvasSurface, installInteractionCore, installInteractionStack, type InteractionCore, type InteractionCoreOpts, type InteractionStack, } from "./interaction/install";
36
+ export { anyGestureNonTerminal, isMidGesture } from "./interaction/gesture-status";
35
37
  export type { MarqueeBuffer } from "./systems/l3-marquee";
36
38
  export { DEFAULT_SPAWN_PROFILES, type SingleKindName, type SpawnProfiles } from "./systems/l2-recognize";
37
39
  export { createCursorSync } from "./systems/l4-cursor";
@@ -0,0 +1,13 @@
1
+ import type { World } from "@vibecook/strata-ecs";
2
+ /**
3
+ * Any recognizer NOT in a terminal phase ⇒ a gesture is in flight (mirrors the
4
+ * cleanup.ts terminal definition: Failed/Cancelled/Ended, plus Recognized-Tap).
5
+ */
6
+ export declare function anyGestureNonTerminal(world: World): boolean;
7
+ /**
8
+ * The full mid-interaction read: a live camera gesture (pan/zoom, which writes
9
+ * `Camera.gesturing` without a recognizer entity of its own) OR any recognizer
10
+ * still walking its phases. Either means runtime edits are outstanding and the
11
+ * durable transaction that will carry them has not been sealed yet.
12
+ */
13
+ export declare function isMidGesture(world: World): boolean;
@@ -6,6 +6,17 @@
6
6
  * timestamp straight into the frame clock (so FrameInfo.dt is real wall time,
7
7
  * clamped in core). The returned stop fn cancels the pending frame AND latches
8
8
  * so a frame already in flight cannot re-schedule — calling it is idempotent.
9
+ *
10
+ * THE FREEZE GATE (2026-08-04). Before each frame the loop claims a step from
11
+ * `engine.frame`. While a freeze is held the gate walks its settle and then
12
+ * refuses, at which point the loop PARKS: it stops scheduling rAF at all
13
+ * rather than spinning a callback that does nothing — "the engine is stopped"
14
+ * should mean the browser has no work queued for it either. Thaw arrives
15
+ * through the gate's change subscription, which schedules the next frame.
16
+ *
17
+ * The dt clamp is what makes resume safe: a freeze that lasted an hour hands
18
+ * `step` an enormous `now`, and core clamps the delta (frame-info.ts), so
19
+ * tweens advance by one ordinary frame instead of teleporting to their end.
9
20
  */
10
21
  import type { Engine } from "@ice/core";
11
22
  export declare function startRafLoop(engine: Engine): () => void;
@@ -30,6 +30,19 @@ export declare function useOps(): CanvasOps;
30
30
  * SIBLINGS of <InfiniteCanvas>, outside the provider.
31
31
  */
32
32
  export declare function useStageHold(engine: CanvasEngine, active: boolean, name: string): void;
33
+ /**
34
+ * Freeze the engine while `active` (ce.frame, 2026-08-04) — {@link useStageHold}'s
35
+ * stricter sibling, same lifecycle sugar: the effect cleanup IS the thaw, so an
36
+ * overlay that unmounts (or crashes) can never wedge the engine parked.
37
+ *
38
+ * WHICH ONE. A stage hold quiets discretionary rendering over a world that
39
+ * keeps stepping — right for chrome that RECEDES the canvas, where undo,
40
+ * collab and tweens must still land visibly behind a partial overlay. A freeze
41
+ * stops the loop outright — right for chrome that COVERS the canvas, where
42
+ * every frame behind it is work nobody can see. Reaching for a freeze under a
43
+ * partial overlay will look broken: the canvas is a photograph until thaw.
44
+ */
45
+ export declare function useFrameFreeze(engine: CanvasEngine, active: boolean, name: string): void;
33
46
  /**
34
47
  * Escape hatch — the raw {@link World} for READS and Tier-3 OBSERVATION only.
35
48
  * Mutation goes through {@link useOps}/{@link useCommit} (a gesture-claimed,
@@ -6,7 +6,7 @@
6
6
  export declare const REACT_VERSION = "0.0.0";
7
7
  export { WidgetHiddenContext, useBreakpoint, useSelected, useWidgetProps, useWorldComponent, } from "./hooks";
8
8
  export { WidgetRoot, type WidgetComponentProps, type WidgetHosts, type WidgetRootProps } from "./widget-root";
9
- export { EngineProvider, useCanvasEngine, useOps, useStageHold, useWorld, type EngineProviderProps, } from "./engine-context";
9
+ export { EngineProvider, useCanvasEngine, useFrameFreeze, useOps, useStageHold, useWorld, type EngineProviderProps, } from "./engine-context";
10
10
  export { useCommit, useUndoStatus, type Commit, type UndoStatus } from "./use-commit";
11
11
  export { WidgetPreview, type WidgetPreviewProps } from "./widget-preview";
12
12
  export { getPreviewSnapshot, hasPreviewSnapshot, setPreviewSnapshot, subscribePreviewSnapshots, type PreviewImage, } from "./preview-snapshots";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibecook/ice",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "ICE — infinite canvas engine. Figma-grade infinite-canvas UX as a framework: defineWidget turns React/R3F components into canvas citizens — selectable, movable, resizable, wired into node graphs, CRDT-synced, undoable per gesture.",
5
5
  "license": "MIT",
6
6
  "author": "James Yong <me@jamesyong42.com>",
@@ -26,47 +26,25 @@
26
26
  "three",
27
27
  "gestures"
28
28
  ],
29
- "files": [
30
- "dist"
31
- ],
29
+ "files": ["dist"],
32
30
  "main": "./dist/index.js",
33
31
  "types": "./dist/types/packages/ice/src/index.d.ts",
34
32
  "exports": {
35
- ".": {
36
- "types": "./dist/types/packages/ice/src/index.d.ts",
37
- "default": "./dist/index.js"
38
- },
39
- "./kernel": {
40
- "types": "./dist/types/packages/ice/src/kernel.d.ts",
41
- "default": "./dist/kernel.js"
42
- },
43
- "./dom": {
44
- "types": "./dist/types/packages/ice/src/dom.d.ts",
45
- "default": "./dist/dom.js"
46
- },
47
- "./react": {
48
- "types": "./dist/types/packages/ice/src/react.d.ts",
49
- "default": "./dist/react.js"
50
- },
51
- "./r3f": {
52
- "types": "./dist/types/packages/ice/src/r3f.d.ts",
53
- "default": "./dist/r3f.js"
54
- },
55
- "./ground": {
56
- "types": "./dist/types/packages/ice/src/ground.d.ts",
57
- "default": "./dist/ground.js"
58
- },
59
- "./devtools": {
60
- "types": "./dist/types/packages/ice/src/devtools.d.ts",
61
- "default": "./dist/devtools.js"
62
- },
33
+ ".": { "types": "./dist/types/packages/ice/src/index.d.ts", "default": "./dist/index.js" },
34
+ "./kernel": { "types": "./dist/types/packages/ice/src/kernel.d.ts", "default": "./dist/kernel.js" },
35
+ "./dom": { "types": "./dist/types/packages/ice/src/dom.d.ts", "default": "./dist/dom.js" },
36
+ "./react": { "types": "./dist/types/packages/ice/src/react.d.ts", "default": "./dist/react.js" },
37
+ "./r3f": { "types": "./dist/types/packages/ice/src/r3f.d.ts", "default": "./dist/r3f.js" },
38
+ "./ground": { "types": "./dist/types/packages/ice/src/ground.d.ts", "default": "./dist/ground.js" },
39
+ "./devtools": { "types": "./dist/types/packages/ice/src/devtools.d.ts", "default": "./dist/devtools.js" },
63
40
  "./package.json": "./package.json"
64
41
  },
65
- "engines": {
66
- "node": ">=20"
67
- },
68
- "publishConfig": {
69
- "access": "public"
42
+ "engines": { "node": ">=20" },
43
+ "publishConfig": { "access": "public" },
44
+ "scripts": {
45
+ "typecheck": "tsc --noEmit",
46
+ "build": "tsup && tsc -p tsconfig.dts.json",
47
+ "prepack": "pnpm run build"
70
48
  },
71
49
  "dependencies": {
72
50
  "@vibecook/strata-ecs": "0.11.0",
@@ -81,20 +59,18 @@
81
59
  "three": ">=0.160.0"
82
60
  },
83
61
  "peerDependenciesMeta": {
84
- "@react-three/fiber": {
85
- "optional": true
86
- },
87
- "react": {
88
- "optional": true
89
- },
90
- "react-dom": {
91
- "optional": true
92
- },
93
- "three": {
94
- "optional": true
95
- }
62
+ "@react-three/fiber": { "optional": true },
63
+ "react": { "optional": true },
64
+ "react-dom": { "optional": true },
65
+ "three": { "optional": true }
96
66
  },
97
67
  "devDependencies": {
68
+ "@ice/core": "workspace:*",
69
+ "@ice/devtools": "workspace:*",
70
+ "@ice/dom": "workspace:*",
71
+ "@ice/kernel": "workspace:*",
72
+ "@ice/r3f": "workspace:*",
73
+ "@ice/react": "workspace:*",
98
74
  "@react-three/fiber": "^9",
99
75
  "@types/rbush": "^3.0.3",
100
76
  "@types/react": "^19",
@@ -102,16 +78,6 @@
102
78
  "@types/three": "^0.185.0",
103
79
  "react": "^19",
104
80
  "react-dom": "^19",
105
- "three": "^0.185.0",
106
- "@ice/core": "0.0.0",
107
- "@ice/devtools": "0.0.0",
108
- "@ice/dom": "0.0.0",
109
- "@ice/r3f": "0.0.0",
110
- "@ice/react": "0.0.0",
111
- "@ice/kernel": "0.0.0"
112
- },
113
- "scripts": {
114
- "typecheck": "tsc --noEmit",
115
- "build": "tsup && tsc -p tsconfig.dts.json"
81
+ "three": "^0.185.0"
116
82
  }
117
- }
83
+ }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../react/src/hooks.ts","../../react/src/widget-root.tsx","../../react/src/engine-context.tsx","../../react/src/use-commit.ts","../../react/src/preview-snapshots.ts","../../react/src/widget-preview.tsx","../../react/src/use-tool.ts","../../react/src/use-presence.ts","../../react/src/keymap.ts","../../react/src/infinite-canvas.tsx","../../react/src/index.ts"],"sourcesContent":["/**\n * React hooks over the engine's Tier-3 reactivity (design-005 §2 hooks;\n * design-004 §2 frozen-hidden rule).\n *\n * Implemented directly on `world.reactive.observeValue` + `useSyncExternalStore`\n * rather than strata's own react module: core is react-free by law, so\n * strata/react cannot be re-exported through it — and the adapter is ~20\n * lines. Value semantics are strata Tier-3: equality-suppressed, fired at\n * notify(), never during the tick.\n *\n * FROZEN-HIDDEN: a widget inside a hidden (culled-but-kept-mounted) host must\n * not re-render on doc edits — `useWidgetProps` reads {@link WidgetHiddenContext}\n * (provided per-portal by WidgetRoot) and suspends its subscription while\n * hidden, serving the last snapshot; on show it resubscribes and refreshes.\n */\nimport {\n Selected,\n WidgetBreakpoint,\n defineQuery,\n widgets,\n type Component,\n type Entity,\n type World,\n} from \"@ice/core\";\nimport { createContext, useCallback, useContext, useMemo, useRef, useSyncExternalStore } from \"react\";\n\n/** Per-portal hidden flag (WidgetRoot provides it; defaults to live). */\nexport const WidgetHiddenContext = createContext(false);\n\nconst selectedQ = defineQuery([Selected]);\n\n/** Shallow field equality — strata cells are flat field records. */\nfunction shallowEq(a: unknown, b: unknown): boolean {\n if (Object.is(a, b)) return true;\n if (typeof a !== \"object\" || typeof b !== \"object\" || a === null || b === null) return false;\n const ka = Object.keys(a);\n const kb = Object.keys(b);\n if (ka.length !== kb.length) return false;\n for (const k of ka) {\n if (!Object.is((a as Record<string, unknown>)[k], (b as Record<string, unknown>)[k])) return false;\n }\n return true;\n}\n\n/**\n * Tier-3 component value subscription (equality-suppressed). Snapshot\n * STABILITY is load-bearing: strata's `get()` materializes a fresh object per\n * read (SoA columns), and `useSyncExternalStore` treats a new reference as a\n * new snapshot — so reads go through a shallow-equality cache and only a real\n * field change yields a new reference.\n */\nexport function useWorldComponent<S>(world: World, entity: Entity, component: Component<S>): S | undefined {\n const hidden = useContext(WidgetHiddenContext);\n const last = useRef<S | undefined>(undefined);\n const subscribe = useCallback(\n (onChange: () => void) => {\n if (hidden) return () => {}; // frozen while hidden — no wakeups, no renders\n return world.reactive.observeValue(entity, component, onChange);\n },\n [world, entity, component, hidden],\n );\n const getSnapshot = useCallback(() => {\n if (hidden) return last.current; // stable snapshot while frozen\n const v = world.isAlive(entity) ? world.get(entity, component) : undefined;\n if (!shallowEq(v, last.current)) last.current = v;\n return last.current;\n }, [world, entity, component, hidden]);\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n\n/**\n * Typed props for one conflict group of a widget (design-005 §2). Group\n * component values come back whole; `p.json` fields are parsed. Identity is\n * stable per underlying group value (memo on the raw reference).\n */\nexport function useWidgetProps<T extends Record<string, unknown>>(\n world: World,\n entity: Entity,\n type: string,\n group = \"props\",\n): T | undefined {\n const widget = widgets.get(type);\n const g = widget?.groups.find((x) => x.name === group);\n if (widget === undefined || g === undefined) {\n throw new Error(`ice: useWidgetProps — unknown widget type/group \"${type}\"/\"${group}\".`);\n }\n const raw = useWorldComponent(world, entity, g.component) as Record<string, unknown> | undefined;\n return useMemo(() => {\n if (raw === undefined) return undefined;\n const out: Record<string, unknown> = {};\n for (const [name, spec] of Object.entries(g.fields)) {\n const v = raw[name];\n out[name] = spec.kind === \"json\" && typeof v === \"string\" ? parseJsonCell(v, spec.default) : v;\n }\n return out as T;\n }, [raw, g]);\n}\n\n/**\n * A json cell is one CRDT string a remote peer may have written malformed —\n * decoding must never throw mid-render (2026-07-13 review). Fall back to the\n * spec's serialized default (engine-derived, always valid JSON), then null.\n */\nfunction parseJsonCell(cell: string, serializedDefault: string | undefined): unknown {\n try {\n return JSON.parse(cell);\n } catch {\n try {\n return JSON.parse(serializedDefault ?? \"null\");\n } catch {\n return null;\n }\n }\n}\n\n/**\n * Selection membership (Tier-1 wake on Selected churn; O(1) snapshot).\n * Frozen-hidden like every widget hook: a selection change must not re-render\n * 256 hidden trees (review finding — design-004 §2 applies to ALL hooks).\n */\nexport function useSelected(world: World, entity: Entity): boolean {\n const hidden = useContext(WidgetHiddenContext);\n const last = useRef(false);\n const subscribe = useCallback(\n (onChange: () => void) => {\n if (hidden) return () => {};\n return world.reactive.observeQuery(selectedQ, onChange);\n },\n [world, hidden],\n );\n const getSnapshot = useCallback(() => {\n if (hidden) return last.current;\n last.current = world.isAlive(entity) && world.hasTag(entity, Selected);\n return last.current;\n }, [world, entity, hidden]);\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n\n/** LOD tier (design-004 §8); \"normal\" until the breakpoint system stamps one. */\nexport function useBreakpoint(world: World, entity: Entity): string {\n const bp = useWorldComponent(world, entity, WidgetBreakpoint);\n return (bp as { tier?: string } | undefined)?.tier ?? \"normal\";\n}\n","/**\n * WidgetRoot — portals from ONE app root (design-004 §2).\n *\n * Portal-list membership (mount/unmount/evict) is owned HERE, by React,\n * subscribed to the engine's mount store via `useSyncExternalStore`; the\n * imperative dom-widgets reflector owns only the host DIVs. Eviction is\n * decided engine-side (LRU derive) and merely consumed. Each mounted entry\n * portals its widget type's component (from the defineWidget registry) into\n * the host's content element; hidden entries stay mounted (React state\n * preserved — cull ≠ unmount) inside a `WidgetHiddenContext` so their prop\n * subscriptions freeze (design-004 §2).\n *\n * A host div may not exist yet on the very first snapshot after mount (the\n * host reflector runs in the same post-notify pass, ordered by reflector\n * registration) — entries without a host render nothing this pass and pick\n * up on the next notification.\n */\nimport { PrefabId, widgets, type Entity, type World, type WidgetMountStore } from \"@ice/core\";\nimport { createElement, type ComponentType, type ReactElement } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { useSyncExternalStore } from \"react\";\nimport { WidgetHiddenContext } from \"./hooks\";\n\nexport interface WidgetHosts {\n /** The dom-widgets reflector's lookup (content element per entity). */\n hostFor(entity: Entity): HTMLElement | undefined;\n}\n\nexport interface WidgetRootProps {\n readonly world: World;\n readonly store: WidgetMountStore;\n readonly hosts: WidgetHosts;\n}\n\nexport interface WidgetComponentProps {\n readonly entity: Entity;\n readonly world: World;\n}\n\nexport function WidgetRoot({ world, store, hosts }: WidgetRootProps): ReactElement {\n const entries = useSyncExternalStore(store.subscribe, store.getSnapshot, store.getSnapshot);\n\n const portals: ReactElement[] = [];\n for (const entry of entries) {\n if (!world.isAlive(entry.entity)) continue;\n const type = world.get(entry.entity, PrefabId)?.id;\n const widget = typeof type === \"string\" ? widgets.get(type) : undefined;\n if (widget === undefined) continue;\n // dom widgets portal their component; gl widgets portal their optional\n // DOM CHROME — the host div lives in the content plane (P1), which stacks\n // UNDER the GL canvas (P2), so the card body renders beneath the island's\n // 3D content (v1's CardChrome sandwich — shared CSS with DOM cards).\n const view = widget.surface === \"dom\" ? widget.component : widget.chrome;\n if (view == null) continue;\n const target = hosts.hostFor(entry.entity);\n if (target === undefined) continue; // host lands next pass\n const View = view as ComponentType<WidgetComponentProps>;\n portals.push(\n createPortal(\n createElement(\n WidgetHiddenContext.Provider,\n { value: entry.hidden },\n createElement(View, { entity: entry.entity, world }),\n ),\n target,\n String(entry.entity),\n ),\n );\n }\n return createElement(\"div\", { \"data-ice-widget-root\": \"\" }, portals);\n}\n","/**\n * `<EngineProvider>` + engine access hooks (design-005 §5; the M6 field\n * amendment 2026-07-10 gap — grep \"useCommit\" in design-005).\n *\n * The whole React surface reaches the running canvas through ONE context\n * carrying the {@link CanvasEngine} facade (world + engine + stack + runtime +\n * ops + docs). Widgets never hand-roll store plumbing again: {@link useOps}\n * gives the engine-owned write paths, {@link useCommit} (its own module) the\n * sanctioned durable commit seam, and {@link useWorld} the read/observe escape\n * hatch. `<InfiniteCanvas>` provides this automatically; apps that mount\n * WidgetRoot themselves wrap it in `<EngineProvider>`.\n */\nimport { devGuardsEnabled, type CanvasEngine, type CanvasOps, type World } from \"@ice/core\";\nimport { createContext, useContext, useEffect, type ReactElement, type ReactNode } from \"react\";\n\nconst EngineContext = createContext<CanvasEngine | null>(null);\n\nexport interface EngineProviderProps {\n readonly engine: CanvasEngine;\n readonly children?: ReactNode;\n}\n\n/** Publish the canvas engine to the React subtree (WidgetRoot + userland hooks). */\nexport function EngineProvider({ engine, children }: EngineProviderProps): ReactElement {\n return <EngineContext.Provider value={engine}>{children}</EngineContext.Provider>;\n}\n\n/** The canvas engine for this subtree; throws with guidance outside a provider. */\nexport function useCanvasEngine(): CanvasEngine {\n const engine = useContext(EngineContext);\n if (engine === null) {\n throw new Error(\n \"ice: useCanvasEngine — no <EngineProvider>. Render widgets inside <InfiniteCanvas> (which provides it) or wrap your tree in <EngineProvider engine={...}>.\",\n );\n }\n return engine;\n}\n\n/** The engine-owned write paths (design-005 §4): setTool, deleteSelection, etc. */\nexport function useOps(): CanvasOps {\n return useCanvasEngine().ops;\n}\n\n/**\n * Take a stage background hold while `active` (ce.stage, 2026-07-19): the\n * overlay-lifecycle sugar — the disposer releases on deactivate AND unmount,\n * so a crashed/unmounted overlay can never wedge the canvas backgrounded.\n * `engine` is an explicit param (not context): overlays typically render as\n * SIBLINGS of <InfiniteCanvas>, outside the provider.\n */\nexport function useStageHold(engine: CanvasEngine, active: boolean, name: string): void {\n useEffect(() => {\n if (!active) return undefined;\n return engine.stage.background(name);\n }, [engine, active, name]);\n}\n\nlet warnedUseWorld = false;\n\n/**\n * Escape hatch — the raw {@link World} for READS and Tier-3 OBSERVATION only.\n * Mutation goes through {@link useOps}/{@link useCommit} (a gesture-claimed,\n * one-tx-per-gesture durable write; direct world writes bypass sovereignty and\n * the guards). DEV-warns once on first use.\n */\nexport function useWorld(): World {\n const engine = useCanvasEngine();\n if (devGuardsEnabled() && !warnedUseWorld) {\n warnedUseWorld = true;\n console.warn(\n \"ice: useWorld() is a READ/OBSERVE escape hatch — never write to the world directly. Use useOps()/useCommit() for mutation (design-005 §5).\",\n );\n }\n return engine.world;\n}\n","/**\n * `useCommit` + `useUndoStatus` — the sanctioned widget durable-write path and\n * the undo/redo status subscription (design-005 §2 M6 field amendment,\n * 2026-07-10: \"widgets also need a SANCTIONED commit path\").\n *\n * A widget commits a prop edit through {@link useCommit}: it resolves the\n * CURRENT doc session (`engine.docs.current()`) and runs a\n * {@link guardedTransaction} against that session's store — one transaction per\n * call, eligibility-guarded, absolute writes only. The session is resolved at\n * CALL time (not hook time) so a widget rendered doc-less that gains a doc later\n * commits correctly without re-mounting.\n */\nimport { DurableUndoStatus, guardedTransaction, type GuardedTx, type GuardedTxOpts } from \"@ice/core\";\nimport { useCallback, useRef, useSyncExternalStore } from \"react\";\nimport { useCanvasEngine } from \"./engine-context\";\n\n/** A durable commit: run `fn` against the current doc session's store, one tx. */\nexport type Commit = (fn: (tx: GuardedTx) => void, opts?: GuardedTxOpts) => void;\n\n/**\n * The widget commit seam. The returned function throws with guidance when no\n * document is attached (commits need a durable store — call\n * `engine.docs.create()/open()/join()` first).\n */\nexport function useCommit(): Commit {\n const engine = useCanvasEngine();\n return useCallback(\n (fn, opts) => {\n const session = engine.docs.current();\n if (session === undefined) {\n throw new Error(\n \"ice: useCommit — no active document. Attach one with engine.docs.create()/open()/join() before committing widget edits.\",\n );\n }\n if (session.readOnly) {\n // The version gate said read-only: a raw store write here would edit —\n // and broadcast — a document the gate refused (2026-07-13 review).\n throw new Error(\"ice: useCommit — the document is read-only (version gate); widget edits are disabled.\");\n }\n guardedTransaction(session.store, engine.world, fn, opts);\n },\n [engine],\n );\n}\n\nexport interface UndoStatus {\n readonly canUndo: boolean;\n readonly canRedo: boolean;\n}\n\nconst NO_UNDO: UndoStatus = { canUndo: false, canRedo: false };\n\n/**\n * Undo/redo availability for the current document (drives toolbar\n * disablement) — the design-005 §5 path: the `DurableUndoStatus` RESOURCE\n * (strata plan-undo U2, re-exported through @ice/core) via\n * `observeResource`. A resource subscription is WORLD-level, so it survives\n * document swaps — no remount needed, the earlier onHistoryChange-per-store\n * caveat is gone. Fires at notify(), equality-suppressed; snapshot identity\n * is stable while the flags are unchanged.\n */\nexport function useUndoStatus(): UndoStatus {\n const engine = useCanvasEngine();\n const last = useRef<UndoStatus>(NO_UNDO);\n const subscribe = useCallback(\n (onChange: () => void) => engine.world.reactive.observeResource(DurableUndoStatus, onChange),\n [engine],\n );\n const getSnapshot = useCallback(() => {\n const status = engine.world.getResource(DurableUndoStatus);\n const canUndo = status?.canUndo ?? false;\n const canRedo = status?.canRedo ?? false;\n if (last.current.canUndo !== canUndo || last.current.canRedo !== canRedo) {\n last.current = { canUndo, canRedo };\n }\n return last.current;\n }, [engine]);\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n","/**\n * The GL preview snapshot store (design-005 §2 preview contract, P2 —\n * 2026-07-19). react stays three-free by LAW, so the capture pipeline lives\n * in @ice/r3f and meets `<WidgetPreview>` HERE, at a dumb data seam: a\n * module-level map of widget type → captured image, with subscription so an\n * open palette re-renders the moment a capture lands.\n *\n * `PreviewImage` accepts a canvas alongside ImageBitmap so tests (and any\n * app-side prebuilt-cache policy — the P3 seam) can inject without a GPU.\n */\nexport type PreviewImage = ImageBitmap | HTMLCanvasElement;\n\nconst images = new Map<string, PreviewImage>();\nconst listeners = new Set<() => void>();\n\nexport function setPreviewSnapshot(type: string, image: PreviewImage): void {\n images.set(type, image);\n for (const l of listeners) l();\n}\n\nexport function getPreviewSnapshot(type: string): PreviewImage | undefined {\n return images.get(type);\n}\n\nexport function hasPreviewSnapshot(type: string): boolean {\n return images.has(type);\n}\n\nexport function subscribePreviewSnapshots(listener: () => void): () => void {\n listeners.add(listener);\n return () => listeners.delete(listener);\n}\n\n/** TEST-ONLY wipe (not on the barrel). */\nexport function __resetPreviewSnapshotsForTests(): void {\n images.clear();\n}\n","/**\n * `<WidgetPreview>` — the framework answer to \"give me the preview for type\n * X\" (design-005 §2 amendment, 2026-07-19). Palettes/trays stay app chrome\n * (design-004); THIS is the seam they consume, owning the whole fallback\n * chain so every app and every `defineWidget` author gets the same behavior:\n *\n * 1. the def's DECLARED preview (engine-free by contract — no world, no\n * entity, no ops; authored at `defaultSize`, scaled here);\n * 2. dom surfaces with no declaration: the REAL component with default (or\n * `preview.props`-curated) props, mounted against the framework's\n * internal preview sandbox — truthful by construction;\n * 3. the `fallback` prop (the app's silhouette), else a neutral placeholder.\n *\n * Every branch renders INERT (`inert` + pointer-events none) inside an error\n * boundary — a broken preview degrades to the fallback, it never kills the\n * palette. GL surfaces without a declared preview go straight to fallback in\n * P1 (the r3f snapshot pipeline is P2; a DOM mockup declaration is the\n * sanctioned escape hatch meanwhile).\n *\n * The sandbox: one lazy module-level engine (own in-memory doc, no adapters,\n * never stepped past two settle ticks) spawning ONE entity per previewed\n * type ON DEMAND. Preview entities never receive Selected/Grab/overlap tags,\n * so chrome renders permanently at rest — \"static\" is a property of the\n * sandbox, not a discipline widget authors must follow.\n */\nimport {\n createCanvasEngine,\n widgets,\n type CanvasEngine,\n type Entity,\n type WidgetType,\n type World,\n} from \"@ice/core\";\nimport {\n Component,\n useEffect,\n useRef,\n useSyncExternalStore,\n type ComponentType,\n type CSSProperties,\n type ReactElement,\n type ReactNode,\n} from \"react\";\nimport { EngineProvider } from \"./engine-context\";\nimport { getPreviewSnapshot, subscribePreviewSnapshots, type PreviewImage } from \"./preview-snapshots\";\n\n// --- the preview sandbox -----------------------------------------------------\n\ninterface PreviewSandbox {\n readonly ce: CanvasEngine;\n readonly entities: Map<string, Entity>;\n}\n\nlet sandbox: PreviewSandbox | null = null;\n\nfunction ensurePreviewEntity(def: WidgetType): Entity | undefined {\n if (sandbox === null) {\n const ce = createCanvasEngine();\n ce.docs.create();\n ce.world.sync();\n ce.step(16);\n sandbox = { ce, entities: new Map() };\n }\n const existing = sandbox.entities.get(def.type);\n if (existing !== undefined) return existing;\n try {\n const e = sandbox.ce.ops.spawnWidget(def.type, {\n x: 0,\n y: 0,\n undoable: false,\n ...(def.previewProps !== undefined ? { props: def.previewProps } : {}),\n });\n sandbox.ce.world.sync();\n sandbox.ce.step(32); // settle tick: equip stamps land before first render\n sandbox.entities.set(def.type, e);\n return e;\n } catch (err) {\n console.warn(`ice: WidgetPreview(\"${def.type}\") sandbox spawn failed — falling back.`, err);\n return undefined;\n }\n}\n\n/** TEST-ONLY sandbox wipe (mirrors __resetWidgetsForTests; not on the barrel). */\nexport function __resetPreviewSandboxForTests(): void {\n sandbox?.ce.dispose();\n sandbox = null;\n}\n\n// --- error containment ---------------------------------------------------------\n\nclass PreviewBoundary extends Component<{ fallback: ReactNode; children: ReactNode }, { failed: boolean }> {\n override state = { failed: false };\n static getDerivedStateFromError(): { failed: boolean } {\n return { failed: true };\n }\n override componentDidCatch(error: unknown): void {\n console.warn(\"ice: a widget preview threw while rendering — showing the fallback.\", error);\n }\n override render(): ReactNode {\n return this.state.failed ? this.props.fallback : this.props.children;\n }\n}\n\n// --- the host ------------------------------------------------------------------\n\nexport interface WidgetPreviewProps {\n readonly type: string;\n /** The available box; the preview renders aspect-FITTED inside it. */\n readonly width: number;\n readonly height: number;\n /** App silhouette shown when no preview path applies (or one throws). */\n readonly fallback?: ReactNode;\n readonly className?: string;\n readonly style?: CSSProperties;\n}\n\n/** Draws a captured snapshot (P2 pipeline / injected cache) at natural size. */\nfunction SnapshotLayer({ image }: { image: PreviewImage }): ReactElement {\n const ref = useRef<HTMLCanvasElement>(null);\n useEffect(() => {\n const canvas = ref.current;\n if (canvas === null) return;\n canvas.width = image.width;\n canvas.height = image.height;\n try {\n canvas.getContext(\"2d\")?.drawImage(image, 0, 0);\n } catch {\n // a torn-down ImageBitmap or a contextless test DOM — the layer stays blank\n }\n }, [image]);\n return (\n <canvas\n ref={ref}\n data-preview-snapshot=\"\"\n style={{ position: \"absolute\", inset: 0, width: \"100%\", height: \"100%\" }}\n />\n );\n}\n\nfunction defaultPlaceholder(label: string): ReactElement {\n return (\n <div\n style={{\n width: \"100%\",\n height: \"100%\",\n borderRadius: 12,\n background: \"rgba(127, 127, 127, 0.12)\",\n boxShadow: \"inset 0 0 0 1px rgba(127, 127, 127, 0.25)\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n fontSize: 11,\n color: \"rgba(127, 127, 127, 0.8)\",\n overflow: \"hidden\",\n }}\n >\n {label}\n </div>\n );\n}\n\nexport function WidgetPreview({ type, width, height, fallback, className, style }: WidgetPreviewProps): ReactElement {\n // Subscribed BEFORE any early return (hook order): an open palette\n // re-renders the moment the P2 capture pipeline lands this type's snapshot.\n const snapshot = useSyncExternalStore(subscribePreviewSnapshots, () => getPreviewSnapshot(type));\n const def = widgets.get(type);\n const safeFallback = fallback ?? defaultPlaceholder(type);\n if (def === undefined || def.defaultSize.w <= 0 || def.defaultSize.h <= 0) {\n return (\n <div className={className} style={{ width, height, ...style }}>\n {safeFallback}\n </div>\n );\n }\n\n const s = Math.min(width / def.defaultSize.w, height / def.defaultSize.h);\n const fitW = def.defaultSize.w * s;\n const fitH = def.defaultSize.h * s;\n\n // The inert, natural-size stage every preview branch renders on: authors\n // (and the real component) write at defaultSize; the host scales.\n const stage = (content: ReactNode): ReactElement => (\n <div className={className} style={{ width: fitW, height: fitH, overflow: \"hidden\", ...style }}>\n <div\n inert\n style={{\n width: def.defaultSize.w,\n height: def.defaultSize.h,\n transform: `scale(${s})`,\n transformOrigin: \"0 0\",\n pointerEvents: \"none\",\n userSelect: \"none\",\n }}\n >\n <PreviewBoundary fallback={safeFallback}>{content}</PreviewBoundary>\n </div>\n </div>\n );\n\n // 1. Author-declared preview: engine-free by contract — rendered bare.\n if (def.previewComponent !== null && def.previewComponent !== undefined) {\n const Declared = def.previewComponent as ComponentType;\n return stage(<Declared />);\n }\n\n // 2. gl surface with a captured snapshot (the P2 pipeline / an injected\n // cache): the widget's DOM chrome (if any) renders UNDERNEATH via the\n // sandbox — the live card's chrome-beneath-canvas sandwich, reproduced —\n // and the transparent 3D capture layers on top. ONE capture serves both\n // themes: the 3D content is theme-independent; theme lives in the chrome's\n // CSS.\n if (def.surface === \"gl\" && snapshot !== undefined) {\n let chromeLayer: ReactNode = null;\n if (def.chrome !== null && def.chrome !== undefined) {\n const entity = ensurePreviewEntity(def);\n if (entity !== undefined && sandbox !== null) {\n const Chrome = def.chrome as ComponentType<{ entity: Entity; world: World }>;\n chromeLayer = (\n <EngineProvider engine={sandbox.ce}>\n <div style={{ position: \"absolute\", inset: 0 }}>\n <Chrome entity={entity} world={sandbox.ce.world} />\n </div>\n </EngineProvider>\n );\n }\n }\n return stage(\n <div style={{ position: \"relative\", width: \"100%\", height: \"100%\" }}>\n {chromeLayer}\n <SnapshotLayer image={snapshot} />\n </div>,\n );\n }\n\n // 3. dom surface: the real component + default/curated props in the sandbox.\n if (def.surface === \"dom\" && def.component !== null && def.component !== undefined) {\n const entity = ensurePreviewEntity(def);\n if (entity !== undefined && sandbox !== null) {\n const View = def.component as ComponentType<{ entity: Entity; world: World }>;\n return stage(\n <EngineProvider engine={sandbox.ce}>\n <View entity={entity} world={sandbox.ce.world} />\n </EngineProvider>,\n );\n }\n }\n\n // 4. No path (gl before its capture lands, broken spawn): the fallback.\n return (\n <div className={className} style={{ width: fitW, height: fitH, ...style }}>\n {safeFallback}\n </div>\n );\n}\n","/**\n * `useTool` + `useToolState` — the active-tool subscription (design-005 §5).\n *\n * The active tool is the `ActiveTool` runtime resource (design-005 §4). Reads go\n * through strata's Tier-3 `observeResource` (fires only when the id actually\n * changes, at notify()); the setter is `ops.setTool`, which cancels active\n * gestures before the switch (the strata-example lesson, design-003 §8) — never\n * a raw resource write. The snapshot is a primitive string, so identity is\n * inherently stable.\n */\nimport { ActiveTool } from \"@ice/core\";\nimport { useCallback, useSyncExternalStore } from \"react\";\nimport { useCanvasEngine } from \"./engine-context\";\n\n/** `[activeToolId, setTool]`. `setTool` routes through `ops.setTool`. */\nexport function useTool(): [string, (id: string) => void] {\n const engine = useCanvasEngine();\n const subscribe = useCallback(\n (onChange: () => void) => engine.world.reactive.observeResource(ActiveTool, onChange),\n [engine],\n );\n const getSnapshot = useCallback(() => engine.world.getResource(ActiveTool)?.id ?? \"select\", [engine]);\n const active = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n const setTool = useCallback((id: string) => engine.ops.setTool(id), [engine]);\n return [active, setTool];\n}\n\n/** Sugar: is tool `id` the active one? (toolbar button pressed-state). */\nexport function useToolState(id: string): boolean {\n const [active] = useTool();\n return active === id;\n}\n","/**\n * `usePresencePeers` — the remote-collaborator roster (design-005 §5:\n * \"Not(Local) presence query\").\n *\n * Queries `PresencePeer` entities that are NOT `Local` (the local peer carries\n * `Local`, auto-applied by the ephemeral store and never transmitted) and pairs\n * each with its `PresenceInfo` (name/color). Wakes on Tier-1 query membership\n * churn (`observeQuery`) — peers joining/leaving. The snapshot is\n * MEMBERSHIP-KEYED: identity stays stable across unrelated re-renders, and info\n * is sampled when membership changes (steady-state presence info is set once at\n * join; a mid-session rename reflects on the next membership change).\n */\nimport { Local, Not, PresenceInfo, PresencePeer, defineQuery, type Entity } from \"@ice/core\";\nimport { useCallback, useRef, useSyncExternalStore } from \"react\";\nimport { useCanvasEngine } from \"./engine-context\";\n\nconst remotePeersQ = defineQuery([PresencePeer, Not(Local)]);\n\nexport interface PresencePeerView {\n readonly entity: Entity;\n /** The peer's `PresenceInfo` (strata \"string\" fields are nullable until set). */\n readonly info: { readonly name: string | null; readonly color: string | null } | undefined;\n}\n\n/** Remote presence peers (excludes the local peer); stable identity by membership. */\nexport function usePresencePeers(): readonly PresencePeerView[] {\n const engine = useCanvasEngine();\n const cache = useRef<{ key: string; value: readonly PresencePeerView[] }>({ key: \"\u0000\", value: [] });\n const subscribe = useCallback(\n (onChange: () => void) => engine.world.reactive.observeQuery(remotePeersQ, onChange),\n [engine],\n );\n const getSnapshot = useCallback(() => {\n const world = engine.world;\n const ids: Entity[] = [];\n world.query(remotePeersQ).each((b) => {\n for (const r of b) ids.push(b.entity(r));\n });\n const key = ids.join(\",\");\n if (key !== cache.current.key) {\n cache.current = {\n key,\n value: ids.map((entity) => ({ entity, info: world.get(entity, PresenceInfo) })),\n };\n }\n return cache.current.value;\n }, [engine]);\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n","/**\n * The default keymap (design-005 §4 \"Keymap\"; design-003 §2 — NO system-side\n * keyboard logic, every entry resolves to an `ops.*`/`docs.*` call).\n *\n * Locked defaults:\n * ⌫/Delete → ops.deleteSelection\n * ⌘Z / Ctrl-Z → docs.undo\n * ⇧⌘Z / ⇧Ctrl-Z → docs.redo\n * ⌘D → ops.duplicateSelection\n * ⌘A → ops.selectAll\n * Esc → ops.cancelActiveGestures\n * Arrows → nudge the selection ±1px (⇧ = ±10px) — ONE tx per press\n * tool shortcuts → ops.setTool (v/h/c + any registered tool's shortcut)\n *\n * Space-hold pan is ALREADY owned by the pointer adapter (design-003 §2) — it is\n * NOT rebound here. A keystroke is IGNORED when the event target is editable\n * (input/textarea/select/contenteditable) so typing into widget fields never\n * triggers a shortcut. `mod` = ⌘ on macOS, Ctrl elsewhere (metaKey || ctrlKey).\n *\n * Overrides replace a default by its key-signature `key|mod|shift`; a signature\n * with no default is added. A matched entry `preventDefault()`s (the target was\n * already filtered to non-editable, so no typing is swallowed).\n */\nimport { Position, guardedTransaction, selectedEntities, tools, type CanvasEngine } from \"@ice/core\";\n\nexport interface KeymapEntry {\n /** `event.key` to match (case-insensitive; e.g. \"z\", \"Backspace\", \"ArrowUp\"). */\n readonly key: string;\n /** Require ⌘/Ctrl (default false → must NOT be held). */\n readonly mod?: boolean;\n /** Require ⇧ (default false → must NOT be held). */\n readonly shift?: boolean;\n /** Resolve to an engine write path — no keyboard logic beyond dispatch. */\n run(engine: CanvasEngine): void;\n}\n\ntype KeyTarget = Pick<Window, \"addEventListener\" | \"removeEventListener\">;\n\nconst signature = (key: string, mod?: boolean, shift?: boolean): string =>\n `${key.toLowerCase()}|${mod ? 1 : 0}|${shift ? 1 : 0}`;\n\nfunction isEditableTarget(target: EventTarget | null): boolean {\n if (target === null || !(target instanceof HTMLElement)) return false;\n const tag = target.tagName;\n return tag === \"INPUT\" || tag === \"TEXTAREA\" || tag === \"SELECT\" || target.isContentEditable;\n}\n\n/** One nudge = one gesture-equivalent transaction (absolute Position writes). */\nfunction nudgeSelection(engine: CanvasEngine, dx: number, dy: number): void {\n const session = engine.docs.current();\n if (session === undefined) return;\n const selection = selectedEntities(engine.world).filter((e) => session.store.keyOf(e) !== undefined);\n if (selection.length === 0) return;\n guardedTransaction(session.store, engine.world, (tx) => {\n for (const e of selection) {\n const p = engine.world.get(e, Position);\n if (p === undefined) continue;\n tx.edit(e).set(Position, { x: p.x + dx, y: p.y + dy });\n }\n });\n}\n\nconst ARROWS: readonly [key: string, dx: number, dy: number][] = [\n [\"ArrowLeft\", -1, 0],\n [\"ArrowRight\", 1, 0],\n [\"ArrowUp\", 0, -1],\n [\"ArrowDown\", 0, 1],\n];\n\n/** The locked defaults + tool shortcuts (read from the registry at attach time). */\nfunction defaultEntries(): KeymapEntry[] {\n const entries: KeymapEntry[] = [\n { key: \"Backspace\", run: (e) => e.ops.deleteSelection() },\n { key: \"Delete\", run: (e) => e.ops.deleteSelection() },\n { key: \"z\", mod: true, run: (e) => e.docs.undo() },\n { key: \"z\", mod: true, shift: true, run: (e) => e.docs.redo() },\n { key: \"d\", mod: true, run: (e) => e.ops.duplicateSelection() },\n { key: \"a\", mod: true, run: (e) => e.ops.selectAll() },\n { key: \"Escape\", run: (e) => e.ops.cancelActiveGestures() },\n ];\n for (const [key, dx, dy] of ARROWS) {\n entries.push({ key, run: (e) => nudgeSelection(e, dx, dy) });\n entries.push({ key, shift: true, run: (e) => nudgeSelection(e, dx * 10, dy * 10) });\n }\n for (const tool of tools.all()) {\n if (tool.shortcut !== undefined) {\n const id = tool.id;\n entries.push({ key: tool.shortcut, run: (e) => e.ops.setTool(id) });\n }\n }\n return entries;\n}\n\nfunction resolveTarget(target?: KeyTarget): KeyTarget | undefined {\n if (target !== undefined) return target;\n return typeof window !== \"undefined\" ? window : undefined;\n}\n\n/**\n * Attach the default keymap (plus `overrides`) to `target` (default: `window`).\n * Returns a detach function. No-op (returns a no-op detach) when there is no\n * target — e.g. a headless environment with no `window`.\n */\nexport function attachKeymap(\n engine: CanvasEngine,\n target?: KeyTarget,\n overrides: readonly KeymapEntry[] = [],\n): () => void {\n const el = resolveTarget(target);\n if (el === undefined) return () => {};\n\n const map = new Map<string, KeymapEntry>();\n for (const entry of defaultEntries()) map.set(signature(entry.key, entry.mod, entry.shift), entry);\n for (const entry of overrides) map.set(signature(entry.key, entry.mod, entry.shift), entry);\n\n const onKeyDown = (event: KeyboardEvent): void => {\n if (isEditableTarget(event.target)) return;\n const mod = event.metaKey || event.ctrlKey;\n const entry = map.get(signature(event.key, mod, event.shiftKey));\n if (entry === undefined) return;\n event.preventDefault();\n entry.run(engine);\n };\n\n el.addEventListener(\"keydown\", onKeyDown as EventListener);\n return () => el.removeEventListener(\"keydown\", onKeyDown as EventListener);\n}\n","/**\n * `<InfiniteCanvas>` — the one-line canvas mount (design-005 §5): planes +\n * adapters + reflectors + portal root, wired in node-board's PROVEN boot order\n * (apps/nodeboard/src/app.tsx). The app supplies a constructed {@link\n * CanvasEngine} (via `createCanvasEngine`); this component owns only the DOM\n * host, the reflector registrations, the pointer/keymap adapters, the rAF loop,\n * and the viewport sync — everything that must live next to a real container.\n *\n * Boot order (registration order = reflector flush order, mirrored exactly):\n * host → planes → reflectors[ planeTransform · ground(P0, app-injected) ·\n * domWidgets(P1/P3) · chrome(P4) · cursor · remoteCursors(P5) ] →\n * pointer adapter → measurement (optional) → keymap → rAF loop → viewport RO.\n *\n * The dom-widgets reflector is BOTH a reflector and the host lookup WidgetRoot\n * portals into; it is created before mount and stored in state so WidgetRoot\n * renders once the hosts exist.\n *\n * Lifecycle: this component does NOT own the engine — it never calls\n * `engine.dispose()` (the engine outlives the mount; the app owns it). Unmount\n * detaches every adapter, unregisters every reflector, stops the loop, and\n * disposes the host.\n *\n * Not handled here (by design):\n * - GL / R3F: the `@ice/r3f` wall forbids `@ice/react` importing three, so a\n * GL layer (GLViews) mounts APP-SIDE. Use {@link onReady} to receive the host\n * + planes and mount it yourself (like apps/glboard).\n * - The GROUND layer (P0: dot grid, wires, snap guides — @ice/ground, three's\n * WebGPURenderer) rides the same wall: pass its factory through the OPAQUE\n * {@link InfiniteCanvasProps.ground} prop (`ground={ground({...})}`); this\n * component types it structurally and never imports the package. No factory\n * ⇒ no ground layer (headless/test boots).\n * - Devtools: the import wall forbids `@ice/react` importing `@ice/devtools`.\n * Wire the panel app-side against `engine.engine` (also via {@link onReady}).\n * - Measurement: auto-sized widgets need a `MeasureQueue` passed to BOTH\n * `createCanvasEngine({ measureQueue })` (ingest side) and this component's\n * `measureQueue` prop (ResizeObserver side). Absent ⇒ measurement is skipped.\n */\nimport {\n Viewport,\n writeRuntimeResource,\n type CanvasEngine,\n type GridConfig,\n type MeasureQueue,\n type ReflectorDef,\n type WirePreviewBuffer,\n type World,\n} from \"@ice/core\";\nimport {\n attachPointerAdapter,\n createCanvasHost,\n createChromeReflector,\n createCursorReflector,\n createDomWidgetsReflector,\n createPlaneTransformReflector,\n createPlanes,\n createRemoteCursorsReflector,\n startRafLoop,\n wireMeasurement,\n type CanvasHost,\n type DomWidgetsReflector,\n type GLRoute,\n type Planes,\n} from \"@ice/dom\";\nimport { useEffect, useRef, useState, type CSSProperties, type ReactElement, type ReactNode } from \"react\";\nimport { EngineProvider } from \"./engine-context\";\nimport { attachKeymap } from \"./keymap\";\nimport { WidgetRoot } from \"./widget-root\";\n\n/** Handed to {@link InfiniteCanvasProps.onReady} for app-side GL/devtools wiring. */\nexport interface InfiniteCanvasHandle {\n readonly engine: CanvasEngine;\n readonly host: CanvasHost;\n readonly planes: Planes;\n}\n\n/**\n * STRUCTURAL mirror of `@ice/ground`'s GroundLayer/GroundFactory (the\n * `WidgetDef.component`-style opaque seam: react never imports the package —\n * the wall forbids three here). `@ice/ground.ground(...)` returns a function\n * assignable to this type.\n */\nexport interface GroundLayerHandle {\n readonly reflector: ReflectorDef & { available(): boolean };\n configureGrid(cfg: Partial<GridConfig>): void;\n dispose(): void;\n}\n\nexport type GroundLayerFactory = (ctx: {\n readonly host: { readonly container: HTMLElement; readonly contentPlane: HTMLElement };\n readonly world: World;\n readonly readWirePreview: () => WirePreviewBuffer;\n}) => GroundLayerHandle;\n\nexport interface InfiniteCanvasProps {\n /** A constructed engine (`createCanvasEngine(...)`); NOT disposed on unmount. */\n readonly engine: CanvasEngine;\n /**\n * The ResizeObserver side of widget measurement. Pass the SAME queue given to\n * `createCanvasEngine({ measureQueue })`. Absent ⇒ measurement skipped.\n */\n readonly measureQueue?: MeasureQueue;\n /** Called once after the host/reflectors/loop are live (app-side GL/devtools). */\n readonly onReady?: (handle: InfiniteCanvasHandle) => void;\n /**\n * The P0 ground layer (dot grid, wires, snap guides — one WebGPU canvas).\n * Pass `ground(opts)` from `@ice/ground`; received opaquely (see\n * {@link GroundLayerFactory}). Memoize in the caller — a new identity\n * re-boots the canvas mount effect. Absent ⇒ no ground layer renders.\n */\n readonly ground?: GroundLayerFactory;\n /**\n * Dot-grid tuning (theme dot color, spacing, fades). Applied live via the\n * ground layer's `configureGrid` — changing it never re-boots the canvas\n * (memoize in the caller to avoid redundant same-value redraws). No-op\n * when {@link ground} is absent.\n */\n readonly grid?: Partial<GridConfig>;\n /**\n * GL pointer routing (event-time island pick — @ice/r3f's\n * createGLPointerRouter). Provide from the FIRST render (a stub delegating\n * to a ref is fine — the real router usually arrives in onReady); the prop\n * is read through a ref, so later identity changes take effect without\n * re-attaching the adapter.\n */\n readonly glRoute?: GLRoute;\n readonly className?: string;\n readonly style?: CSSProperties;\n /** Overlays inside the viewport (toolbars, HUD) — rendered under the EngineProvider. */\n readonly children?: ReactNode;\n}\n\nexport function InfiniteCanvas({\n engine,\n measureQueue,\n onReady,\n ground,\n grid: gridConfig,\n glRoute,\n className,\n style,\n children,\n}: InfiniteCanvasProps): ReactElement {\n const containerRef = useRef<HTMLDivElement>(null);\n const [hosts, setHosts] = useState<DomWidgetsReflector | undefined>(undefined);\n // Keep onReady out of the effect deps (identity churn must not re-boot).\n const onReadyRef = useRef(onReady);\n onReadyRef.current = onReady;\n // The live ground handle (set by the mount effect); the grid-config effect\n // below re-tunes it without re-booting the canvas.\n const groundRef = useRef<GroundLayerHandle | null>(null);\n const gridConfigRef = useRef(gridConfig);\n gridConfigRef.current = gridConfig;\n // glRoute reads through a ref: the adapter captures ONE function at attach,\n // and the app's real router typically arrives post-mount (onReady).\n const glRouteRef = useRef(glRoute);\n glRouteRef.current = glRoute;\n\n useEffect(() => {\n const container = containerRef.current;\n if (container === null) return;\n const { world, engine: core, stack, runtime } = engine;\n\n const host = createCanvasHost(container);\n const planes = createPlanes(host);\n const planeArgs = { contentPlane: planes.content, liftedPlane: planes.lifted };\n const domWidgets = createDomWidgetsReflector(planeArgs, world, runtime.store);\n const remoteCursors = createRemoteCursorsReflector(host, world);\n\n // Handles kept for teardown: unregistering only stops flushes — the DOM\n // these factories inserted (ground canvas, chrome plane) must be disposed\n // too, or a StrictMode remount stacks duplicates (the double-grid field\n // report, 2026-07-11).\n const groundLayer =\n ground?.({ host, world, readWirePreview: () => stack.wirePreview }) ?? null;\n groundRef.current = groundLayer;\n if (groundLayer !== null && gridConfigRef.current !== undefined) {\n groundLayer.configureGrid(gridConfigRef.current);\n }\n const chrome = createChromeReflector(host, world, stack.marqueeBuffer);\n\n // Registration order = flush order — node-board's proven sequence.\n const unregister = [\n core.registerReflector(createPlaneTransformReflector(planeArgs)),\n ...(groundLayer !== null ? [core.registerReflector(groundLayer.reflector)] : []),\n core.registerReflector(domWidgets),\n core.registerReflector(chrome),\n core.registerReflector(createCursorReflector(host, stack.readCursor)),\n core.registerReflector(remoteCursors.reflector),\n ];\n\n const detachPointer = attachPointerAdapter(\n host,\n stack.queue,\n glRouteRef.current !== undefined\n ? // Pass the verdict through UNCOERCED: a rich GLRouteVerdict return\n // (hover-time overInteractive, 2026-07-18) must survive this seam.\n { glRoute: (kind, x, y, e) => glRouteRef.current?.(kind, x, y, e) ?? false }\n : {},\n );\n const detachMeasure =\n measureQueue !== undefined ? wireMeasurement(runtime.store, domWidgets, measureQueue) : undefined;\n const detachKeymap = attachKeymap(engine);\n\n const syncViewport = (): void => {\n const rect = container.getBoundingClientRect();\n const dpr = typeof window !== \"undefined\" ? window.devicePixelRatio : 1;\n writeRuntimeResource(world, Viewport, { w: rect.width, h: rect.height, dpr });\n };\n syncViewport();\n let resizeObserver: ResizeObserver | undefined;\n if (typeof ResizeObserver !== \"undefined\") {\n resizeObserver = new ResizeObserver(syncViewport);\n resizeObserver.observe(container);\n }\n\n const stopLoop = startRafLoop(core);\n setHosts(domWidgets);\n onReadyRef.current?.({ engine, host, planes });\n\n return () => {\n stopLoop();\n detachKeymap();\n detachMeasure?.();\n detachPointer();\n resizeObserver?.disconnect();\n for (const unreg of unregister) unreg();\n remoteCursors.destroy();\n groundLayer?.dispose();\n groundRef.current = null;\n domWidgets.dispose();\n chrome.dispose();\n planes.dispose();\n host.dispose();\n setHosts(undefined);\n };\n }, [engine, measureQueue, ground]);\n\n // Live grid re-tune — never re-boots the canvas (the mount effect above\n // deliberately omits `gridConfig` from its deps; initial config rides the\n // ref at creation).\n useEffect(() => {\n if (gridConfig !== undefined) groundRef.current?.configureGrid(gridConfig);\n }, [gridConfig]);\n\n return (\n <EngineProvider engine={engine}>\n <div ref={containerRef} className={className} style={{ width: \"100%\", height: \"100%\", ...style }} data-ice-canvas=\"\">\n {hosts !== undefined ? (\n <WidgetRoot world={engine.world} store={engine.runtime.store} hosts={hosts} />\n ) : null}\n {children}\n </div>\n </EngineProvider>\n );\n}\n","/**\n * @ice/react — widget content layer: portals from one root + Tier-3 hooks.\n * Import wall: @ice/dom → @ice/core down only — never three/@react-three\n * (enforced). react/react-dom are peers.\n */\nexport const REACT_VERSION = \"0.0.0\";\n\nexport {\n WidgetHiddenContext,\n useBreakpoint,\n useSelected,\n useWidgetProps,\n useWorldComponent,\n} from \"./hooks\";\nexport { WidgetRoot, type WidgetComponentProps, type WidgetHosts, type WidgetRootProps } from \"./widget-root\";\n\n// M10 React facade (design-005 §5): engine context, commit seam, hooks, keymap,\n// and the <InfiniteCanvas> mount.\nexport {\n EngineProvider,\n useCanvasEngine,\n useOps,\n useStageHold,\n useWorld,\n type EngineProviderProps,\n} from \"./engine-context\";\nexport { useCommit, useUndoStatus, type Commit, type UndoStatus } from \"./use-commit\";\nexport { WidgetPreview, type WidgetPreviewProps } from \"./widget-preview\";\nexport {\n getPreviewSnapshot,\n hasPreviewSnapshot,\n setPreviewSnapshot,\n subscribePreviewSnapshots,\n type PreviewImage,\n} from \"./preview-snapshots\";\nexport { useTool, useToolState } from \"./use-tool\";\nexport { usePresencePeers, type PresencePeerView } from \"./use-presence\";\nexport { attachKeymap, type KeymapEntry } from \"./keymap\";\nexport {\n InfiniteCanvas,\n type GroundLayerFactory,\n type GroundLayerHandle,\n type InfiniteCanvasHandle,\n type InfiniteCanvasProps,\n} from \"./infinite-canvas\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,SAAS,eAAe,aAAa,YAAY,SAAS,QAAQ,4BAA4B;AAGvF,IAAM,sBAAsB,cAAc,KAAK;AAEtD,IAAM,YAAY,YAAY,CAAC,QAAQ,CAAC;AAGxC,SAAS,UAAU,GAAY,GAAqB;AAClD,MAAI,OAAO,GAAG,GAAG,CAAC,EAAG,QAAO;AAC5B,MAAI,OAAO,MAAM,YAAY,OAAO,MAAM,YAAY,MAAM,QAAQ,MAAM,KAAM,QAAO;AACvF,QAAM,KAAK,OAAO,KAAK,CAAC;AACxB,QAAM,KAAK,OAAO,KAAK,CAAC;AACxB,MAAI,GAAG,WAAW,GAAG,OAAQ,QAAO;AACpC,aAAW,KAAK,IAAI;AAClB,QAAI,CAAC,OAAO,GAAI,EAA8B,CAAC,GAAI,EAA8B,CAAC,CAAC,EAAG,QAAO;AAAA,EAC/F;AACA,SAAO;AACT;AASO,SAAS,kBAAqB,OAAc,QAAgB,WAAwC;AACzG,QAAM,SAAS,WAAW,mBAAmB;AAC7C,QAAM,OAAO,OAAsB,MAAS;AAC5C,QAAM,YAAY;AAAA,IAChB,CAAC,aAAyB;AACxB,UAAI,OAAQ,QAAO,MAAM;AAAA,MAAC;AAC1B,aAAO,MAAM,SAAS,aAAa,QAAQ,WAAW,QAAQ;AAAA,IAChE;AAAA,IACA,CA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,0BAAAC,MAAC,SAAI,KAAK,cAAc,WAAsB,OAAO,EAAE,OAAO,QAAQ,QAAQ,QAAQ,GAAG,MAAM,GAAG,mBAAgB,IAC/G;AAAA,cAAU,SACT,gBAAAD,KAAC,cAAW,OAAO,OAAO,OAAO,OAAO,OAAO,QAAQ,OAAO,OAAc,IAC1E;AAAA,IACH;AAAA,KACH,GACF;AAEJ;;;ACzPO,IAAM,gBAAgB;","names":["useSyncExternalStore","useSyncExternalStore","createContext","useContext","useCallback","useRef","useSyncExternalStore","useCallback","useRef","useSyncExternalStore","useEffect","useRef","useSyncExternalStore","jsx","useRef","useEffect","jsx","useSyncExternalStore","useCallback","useSyncExternalStore","useCallback","useSyncExternalStore","useCallback","useRef","useSyncExternalStore","useRef","useCallback","useSyncExternalStore","useEffect","useRef","jsx","jsxs","useRef","useEffect"]}