@xenolithengine/graph-solid 0.7.0-beta.5 → 0.7.0-beta.7

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
@@ -41,13 +41,17 @@ export function Editor() {
41
41
 
42
42
  Editor events are re-dispatched as same-named `CustomEvent`s — Solid's `on:` binds colon names directly.
43
43
 
44
+ Editor events are re-dispatched as same-named `CustomEvent`s — Solid's `on:` binds colon names directly. `on:ready` (detail: the live `XenolithEditor`) fires once on mount.
45
+
44
46
  ## What's exported
45
47
 
46
- - `xenolith` — the Solid directive (`use:xenolith={props}`)
48
+ - `xenolith` — the Solid directive (`use:xenolith={props}`); typed via `JSX.Directives` augmentation, dispatches `on:ready` + every editor event as colon-named CustomEvents
49
+ - `createXenolithStores()` — per-editor bag of signal-backed accessors: `setEditor`/`editor`, `nodes`, `edges`, `selection`, `viewport`, `graphJSON`, `undoRedo` (`canUndo`/`canRedo`/`undo`/`redo`), and the controlled triple `nodesState()` (commit-time mirror + one-undo-step `setNodes`); disposal rides the owning root's cleanup
47
50
  - `createXenolithGraph(el, props)` — imperative primitive returning an `EditorBinding`
48
51
 
49
52
  ## Docs
50
53
 
54
+ - [Solid guide](https://graph.xenolith.studio/guides/solid/) — directive, stores, controlled state
51
55
  - [API reference](https://graph.xenolith.studio/guides/api/) — every method exposed by `XenolithEditor`
52
56
  - [GitHub](https://github.com/XenolithEngine/xenolith-graph)
53
57
 
package/dist/index.d.ts CHANGED
@@ -1,8 +1,20 @@
1
1
  import { type EditorBinding, type XenolithProps } from '@xenolithengine/graph-adapter-core';
2
+ export { createXenolithStores, type XenolithStores, type XenolithNodesState } from './stores.js';
3
+ declare module 'solid-js' {
4
+ namespace JSX {
5
+ interface Directives {
6
+ xenolith: XenolithProps;
7
+ }
8
+ }
9
+ }
2
10
  /**
3
- * Solid directive: `<div use:xenolith={props} on:node:click={…} on:selection:changed={…} />`.
4
- * Mounts the editor into the element, syncs props reactively, and re-dispatches every editor event
5
- * off the element as a same-named CustomEvent (Solid's `on:` binds colon names). Client-only (WebGL).
11
+ * Solid directive: `<div use:xenolith={props} on:ready on:node:click on:selection:changed … />`.
12
+ * Mounts the editor into the element, syncs props reactively (the bound expression is tracked),
13
+ * dispatches `ready` (detail: the live `XenolithEditor`) once mounted, and re-dispatches every
14
+ * editor event off the element as a same-named CustomEvent — Solid's `on:` binds colon names,
15
+ * so `on:node:click` / `on:selection:changed` map 1:1 to the editor's event surface with their
16
+ * payloads in `event.detail`. Client-only (WebGL). Wire reactive stores from `on:ready`:
17
+ * `stores.setEditor(e.detail)` — see `createXenolithStores`.
6
18
  *
7
19
  * Solid calls a directive as `xenolith(el, accessor)`, where `accessor()` is the bound value.
8
20
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,aAAa,EACnB,MAAM,oCAAoC,CAAA;AAE3C;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,aAAa,GAAG,SAAS,GAAG,IAAI,CAkBzF;AAED;oEACoE;AACpE,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,WAAW,EAAE,KAAK,GAAE,aAAkB,GAAG,OAAO,CAAC,aAAa,CAAC,CAEtG"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,aAAa,EACnB,MAAM,oCAAoC,CAAA;AAE3C,OAAO,EAAE,oBAAoB,EAAE,KAAK,cAAc,EAAE,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAKhG,OAAO,QAAQ,UAAU,CAAC;IAExB,UAAU,GAAG,CAAC;QACZ,UAAU,UAAU;YAClB,QAAQ,EAAE,aAAa,CAAA;SACxB;KACF;CACF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,aAAa,GAAG,SAAS,GAAG,IAAI,CAmBzF;AAED;oEACoE;AACpE,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,WAAW,EAAE,KAAK,GAAE,aAAkB,GAAG,OAAO,CAAC,aAAa,CAAC,CAEtG"}
package/dist/index.js CHANGED
@@ -1,9 +1,14 @@
1
1
  import { createEffect, onCleanup } from 'solid-js';
2
2
  import { createEditorBinding, EDITOR_EVENT_NAMES, } from '@xenolithengine/graph-adapter-core';
3
+ export { createXenolithStores } from './stores.js';
3
4
  /**
4
- * Solid directive: `<div use:xenolith={props} on:node:click={…} on:selection:changed={…} />`.
5
- * Mounts the editor into the element, syncs props reactively, and re-dispatches every editor event
6
- * off the element as a same-named CustomEvent (Solid's `on:` binds colon names). Client-only (WebGL).
5
+ * Solid directive: `<div use:xenolith={props} on:ready on:node:click on:selection:changed … />`.
6
+ * Mounts the editor into the element, syncs props reactively (the bound expression is tracked),
7
+ * dispatches `ready` (detail: the live `XenolithEditor`) once mounted, and re-dispatches every
8
+ * editor event off the element as a same-named CustomEvent — Solid's `on:` binds colon names,
9
+ * so `on:node:click` / `on:selection:changed` map 1:1 to the editor's event surface with their
10
+ * payloads in `event.detail`. Client-only (WebGL). Wire reactive stores from `on:ready`:
11
+ * `stores.setEditor(e.detail)` — see `createXenolithStores`.
7
12
  *
8
13
  * Solid calls a directive as `xenolith(el, accessor)`, where `accessor()` is the bound value.
9
14
  */
@@ -21,6 +26,7 @@ export function xenolith(el, accessor) {
21
26
  offs.push(b.on(ev, (detail) => el.dispatchEvent(new CustomEvent(ev, { detail }))));
22
27
  }
23
28
  b.setProps(accessor() ?? {});
29
+ el.dispatchEvent(new CustomEvent('ready', { detail: b.editor }));
24
30
  });
25
31
  // Re-run whenever the bound props signal changes.
26
32
  createEffect(() => { const p = accessor(); if (p)
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1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AAE,CAAC,CAAA;QAC5B,EAAE,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;IAClE,CAAC,CAAC,CAAA;IAEF,kDAAkD;IAClD,YAAY,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,GAAG,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC;QAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAA,CAAC,CAAC,CAAC,CAAA;IAEzE,SAAS,CAAC,GAAG,EAAE,GAAG,SAAS,GAAG,IAAI,CAAC,CAAC,KAAK,MAAM,GAAG,IAAI,IAAI;QAAE,GAAG,EAAE,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,GAAG,IAAI,CAAA,CAAC,CAAC,CAAC,CAAA;AAC1G,CAAC;AAED;oEACoE;AACpE,MAAM,UAAU,mBAAmB,CAAC,EAAe,EAAE,QAAuB,EAAE;IAC5E,OAAO,mBAAmB,CAAC,EAAE,EAAE,KAAK,CAAC,CAAA;AACvC,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { type Accessor } from 'solid-js';
2
+ import type { XenolithEditor, ViewportState, Node, Edge, NodeId, XenolithGraphV1, GraphChanges } from '@xenolithengine/graph-editor';
3
+ /** The controlled-state triple (E5 / ADR 0006), Solid edition — see the React `useNodesState`
4
+ * docs for semantics: mirror folded from commit-time `graph:changed` arrays; `setNodes` diffs
5
+ * onto the editor as ONE undo step; positions arrive at COMMIT, never per frame. Each
6
+ * `nodesState()` call creates an independent mirror — one per consumer. */
7
+ export interface XenolithNodesState {
8
+ nodes: Accessor<readonly Node[]>;
9
+ edges: Accessor<readonly Edge[]>;
10
+ applyChanges: (changes: GraphChanges) => void;
11
+ setNodes: (next: readonly Node[] | ((prev: readonly Node[]) => readonly Node[])) => void;
12
+ }
13
+ /** Bag of signal-backed accessors bound to one editor — Solid's counterpart of the React/Vue
14
+ * hook set and the Svelte store bag (ADAPTER-CONTRACT §2). Same event lists, same commit-time
15
+ * semantics, same microtask coalescing. */
16
+ export interface XenolithStores {
17
+ /** Wire the live editor in from the directive's `on:ready` event. Swapping re-binds every
18
+ * accessor; passing `null` resets them to fallbacks. */
19
+ setEditor: (editor: XenolithEditor | null) => void;
20
+ /** Current editor, or `null` before wiring / after reset. */
21
+ editor: Accessor<XenolithEditor | null>;
22
+ /** Live nodes; re-fires on add/remove/move, load, undo/redo. */
23
+ nodes: Accessor<readonly Node[]>;
24
+ /** Live edges; re-fires on connect/disconnect, node removal, load, undo/redo. */
25
+ edges: Accessor<readonly Edge[]>;
26
+ /** Live selection (node ids); re-fires on `selection:changed`. */
27
+ selection: Accessor<readonly NodeId[]>;
28
+ /** Live viewport (`x`, `y`, `zoom`); re-fires on pan/zoom. */
29
+ viewport: Accessor<ViewportState>;
30
+ /** Live serialized graph (xenolith.v1); recomputes on any mutation, load, undo/redo. */
31
+ graphJSON: Accessor<XenolithGraphV1 | null>;
32
+ /** `{ canUndo, canRedo }` live accessors + stable `undo()` / `redo()` handles. */
33
+ undoRedo: {
34
+ canUndo: Accessor<boolean>;
35
+ canRedo: Accessor<boolean>;
36
+ undo: () => boolean;
37
+ redo: () => boolean;
38
+ };
39
+ /** The controlled-state triple — each call creates an independent mirror. */
40
+ nodesState(): XenolithNodesState;
41
+ }
42
+ export declare function createXenolithStores(): XenolithStores;
43
+ //# sourceMappingURL=stores.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stores.d.ts","sourceRoot":"","sources":["../src/stores.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8D,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAA;AACpG,OAAO,KAAK,EACI,cAAc,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,eAAe,EAChF,YAAY,EACb,MAAM,8BAA8B,CAAA;AAqBrC;;;4EAG4E;AAC5E,MAAM,WAAW,kBAAkB;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/dist/stores.js ADDED
@@ -0,0 +1,110 @@
1
+ import { createEffect, createMemo, createSignal, onCleanup, untrack } from 'solid-js';
2
+ import { reduceGraphChanges, snapshotGraph } from '@xenolithengine/graph-editor';
3
+ import { diffNodesToChanges } from '@xenolithengine/graph-adapter-core';
4
+ // Solid's reactive fabric is signals + effects under an owner root. `createXenolithStores()`
5
+ // must be called inside one — a component's setup IS a root, so the idiomatic call site owns
6
+ // the lifetime: every subscription rides `onCleanup` of the enclosing root (or of the rebind
7
+ // effect), and disposing the component tears everything down. No manual dispose.
8
+ const NODE_EVENTS = ['node:added', 'node:removed', 'node:moved', 'graph:loaded', 'history:changed'];
9
+ const EDGE_EVENTS = ['edge:connected', 'edge:disconnected', 'node:removed', 'graph:loaded', 'history:changed'];
10
+ const GRAPH_EVENTS = [
11
+ 'node:added', 'node:removed', 'node:moved', 'edge:connected', 'edge:disconnected',
12
+ 'widget:changed', 'graph:loaded', 'history:changed',
13
+ ];
14
+ const EMPTY_NODES = Object.freeze([]);
15
+ const EMPTY_EDGES = Object.freeze([]);
16
+ const EMPTY_SELECTION = Object.freeze([]);
17
+ const DEFAULT_VIEWPORT = Object.freeze({ x: 0, y: 0, zoom: 1 });
18
+ export function createXenolithStores() {
19
+ const [editor, setEditor] = createSignal(null);
20
+ // The rebind effect: tracks the editor signal; per-run `onCleanup` releases the previous
21
+ // editor's event subscriptions, so a swap (or root disposal) never leaks. The value signals
22
+ // are written with `untrack` + explicit `() => v` setters so reads stay reference-compared
23
+ // and nothing in `compute()` is accidentally tracked.
24
+ function eventAccessor(events, compute, fallback) {
25
+ const [value, setValue] = createSignal(fallback, { equals: false });
26
+ createEffect(() => {
27
+ const e = editor();
28
+ let offs = [];
29
+ onCleanup(() => { for (const off of offs)
30
+ off(); });
31
+ if (!e) {
32
+ untrack(() => setValue(() => fallback));
33
+ return;
34
+ }
35
+ untrack(() => setValue(() => compute(e)));
36
+ let scheduled = false;
37
+ const update = () => {
38
+ if (scheduled)
39
+ return;
40
+ scheduled = true;
41
+ queueMicrotask(() => {
42
+ scheduled = false;
43
+ if (untrack(editor) === e)
44
+ setValue(() => compute(e));
45
+ });
46
+ };
47
+ offs = events.map((ev) => e.on(ev, update));
48
+ });
49
+ return value;
50
+ }
51
+ const nodes = eventAccessor(NODE_EVENTS, (e) => Object.freeze(Array.from(e.graphNodes())), EMPTY_NODES);
52
+ const edges = eventAccessor(EDGE_EVENTS, (e) => Object.freeze(Array.from(e.graphEdges())), EMPTY_EDGES);
53
+ const selection = eventAccessor(['selection:changed'], (e) => Object.freeze([...e.selection.ids()]), EMPTY_SELECTION);
54
+ const viewport = eventAccessor(['viewport:changed'], (e) => e.view.state, DEFAULT_VIEWPORT);
55
+ const graphJSON = eventAccessor(GRAPH_EVENTS, (e) => e.getGraphReadonly(), null);
56
+ const undoRedoFactory = () => {
57
+ const [canUndo, setCanUndo] = createSignal(false, { equals: false });
58
+ const [canRedo, setCanRedo] = createSignal(false, { equals: false });
59
+ createEffect(() => {
60
+ const e = editor();
61
+ let off = null;
62
+ onCleanup(() => { off?.(); });
63
+ if (!e) {
64
+ untrack(() => { setCanUndo(() => false); setCanRedo(() => false); });
65
+ return;
66
+ }
67
+ const sync = () => { setCanUndo(() => e.history.canUndo); setCanRedo(() => e.history.canRedo); };
68
+ untrack(sync);
69
+ off = e.on('history:changed', sync);
70
+ });
71
+ return {
72
+ canUndo, canRedo,
73
+ undo: () => untrack(editor)?.history.undo() ?? false,
74
+ redo: () => untrack(editor)?.history.redo() ?? false,
75
+ };
76
+ };
77
+ const undoRedo = undoRedoFactory();
78
+ function nodesState() {
79
+ const [mirror, setMirror] = createSignal({ nodes: [], edges: [] }, { equals: false });
80
+ const nodesAcc = createMemo(() => mirror().nodes);
81
+ const edgesAcc = createMemo(() => mirror().edges);
82
+ createEffect(() => {
83
+ const e = editor();
84
+ let off = null;
85
+ onCleanup(() => { off?.(); });
86
+ if (!e) {
87
+ untrack(() => setMirror(() => ({ nodes: [], edges: [] })));
88
+ return;
89
+ }
90
+ untrack(() => setMirror(() => snapshotGraph(e.graphNodes(), e.graphEdges())));
91
+ off = e.on('graph:changed', ({ changes }) => {
92
+ setMirror((prev) => reduceGraphChanges(prev, changes));
93
+ });
94
+ });
95
+ const applyChanges = (changes) => { untrack(editor)?.applyChanges(changes); };
96
+ const setNodes = (next) => {
97
+ const e = untrack(editor);
98
+ if (!e)
99
+ return;
100
+ const live = snapshotGraph(e.graphNodes(), e.graphEdges());
101
+ const nextNodes = typeof next === 'function' ? next(live.nodes) : next;
102
+ const changes = diffNodesToChanges(live, nextNodes);
103
+ if (changes.nodes.length > 0)
104
+ e.applyChanges(changes);
105
+ };
106
+ return { nodes: nodesAcc, edges: edgesAcc, applyChanges, setNodes };
107
+ }
108
+ return { setEditor, editor, nodes, edges, selection, viewport, graphJSON, undoRedo, nodesState };
109
+ }
110
+ //# sourceMappingURL=stores.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stores.js","sourceRoot":"","sources":["../src/stores.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAiB,MAAM,UAAU,CAAA;AAKpG,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAA;AAEvE,6FAA6F;AAC7F,6FAA6F;AAC7F,6FAA6F;AAC7F,iFAAiF;AAEjF,MAAM,WAAW,GAAI,CAAC,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,cAAc,EAAE,iBAAiB,CAAU,CAAA;AAC7G,MAAM,WAAW,GAAI,CAAC,gBAAgB,EAAE,mBAAmB,EAAE,cAAc,EAAE,cAAc,EAAE,iBAAiB,CAAU,CAAA;AACxH,MAAM,YAAY,GAAG;IACnB,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,gBAAgB,EAAE,mBAAmB;IACjF,gBAAgB,EAAE,cAAc,EAAE,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- "version": "0.7.0-beta.5",
3
+ "version": "0.7.0-beta.7",
4
4
  "description": "Solid adapter for XenolithGraph — the use:xenolith directive.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -19,8 +19,8 @@
19
19
  ],
20
20
  "sideEffects": false,
21
21
  "dependencies": {
22
- "@xenolithengine/graph-adapter-core": "0.7.0-beta.5",
23
- "@xenolithengine/graph-editor": "0.7.0-beta.5"
22
+ "@xenolithengine/graph-adapter-core": "0.7.0-beta.7",
23
+ "@xenolithengine/graph-editor": "0.7.0-beta.7"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "pixi.js": "^8.6.0",