@xenolithengine/graph-adapter-core 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/dist/controlled-diff.d.ts +11 -0
- package/dist/controlled-diff.d.ts.map +1 -0
- package/dist/controlled-diff.js +35 -0
- package/dist/controlled-diff.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { GraphChanges, GraphMirror, Node } from '@xenolithengine/graph-editor';
|
|
2
|
+
/** Incremental node diff for the write side of the controlled triple (E5 / ADR 0006) — shared
|
|
3
|
+
* by every adapter's `setNodes`: builds ONE `GraphChanges` batch from a live mirror and the
|
|
4
|
+
* next nodes array, so the whole update lands on the editor as a single undo step.
|
|
5
|
+
*
|
|
6
|
+
* Diffing is deliberately shallow, matching React Flow migrant expectations: position by
|
|
7
|
+
* coordinates (a fresh object with identical x/y is NOT a change), state by reference. Not to
|
|
8
|
+
* be confused with `documentReplacedChanges` (editor) — that one is the full remove-all +
|
|
9
|
+
* add-all burst for document swaps and would balloon the undo payload of an incremental edit. */
|
|
10
|
+
export declare function diffNodesToChanges(live: GraphMirror, nextNodes: readonly Node[]): GraphChanges;
|
|
11
|
+
//# sourceMappingURL=controlled-diff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controlled-diff.d.ts","sourceRoot":"","sources":["../src/controlled-diff.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAA;AAEnF;;;;;;;kGAOkG;AAClG,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,IAAI,EAAE,GAAG,YAAY,CAuB9F"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** Incremental node diff for the write side of the controlled triple (E5 / ADR 0006) — shared
|
|
2
|
+
* by every adapter's `setNodes`: builds ONE `GraphChanges` batch from a live mirror and the
|
|
3
|
+
* next nodes array, so the whole update lands on the editor as a single undo step.
|
|
4
|
+
*
|
|
5
|
+
* Diffing is deliberately shallow, matching React Flow migrant expectations: position by
|
|
6
|
+
* coordinates (a fresh object with identical x/y is NOT a change), state by reference. Not to
|
|
7
|
+
* be confused with `documentReplacedChanges` (editor) — that one is the full remove-all +
|
|
8
|
+
* add-all burst for document swaps and would balloon the undo payload of an incremental edit. */
|
|
9
|
+
export function diffNodesToChanges(live, nextNodes) {
|
|
10
|
+
const changes = { nodes: [], edges: [], unsupported: [] };
|
|
11
|
+
const byId = new Map(live.nodes.map((n) => [n.id, n]));
|
|
12
|
+
const seen = new Set();
|
|
13
|
+
for (const n of nextNodes) {
|
|
14
|
+
const id = n.id;
|
|
15
|
+
seen.add(id);
|
|
16
|
+
const prev = byId.get(id);
|
|
17
|
+
if (!prev) {
|
|
18
|
+
changes.nodes.push({ type: 'add', node: n });
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
if (prev.position.x !== n.position.x || prev.position.y !== n.position.y) {
|
|
22
|
+
changes.nodes.push({ type: 'position', id: n.id, position: { ...n.position } });
|
|
23
|
+
}
|
|
24
|
+
if (prev.state !== n.state) {
|
|
25
|
+
changes.nodes.push({ type: 'data', id: n.id, state: { ...n.state } });
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
for (const prev of live.nodes) {
|
|
30
|
+
if (!seen.has(prev.id))
|
|
31
|
+
changes.nodes.push({ type: 'remove', id: prev.id });
|
|
32
|
+
}
|
|
33
|
+
return changes;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=controlled-diff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controlled-diff.js","sourceRoot":"","sources":["../src/controlled-diff.ts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O,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;YACvE,CAAC;QACH,CAAC;IACH,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QAC9B,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAY,CAAC;YAAE,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAA;IACvF,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,10 +2,11 @@ import { XenolithEditor, type EditorEvents } from '@xenolithengine/graph-editor'
|
|
|
2
2
|
import { type XenolithProps } from './props.js';
|
|
3
3
|
export type { XenolithProps } from './props.js';
|
|
4
4
|
export { applyProps, type EditorLike } from './props.js';
|
|
5
|
+
export { diffNodesToChanges } from './controlled-diff.js';
|
|
5
6
|
/** The canonical public editor event names. Every adapter derives its idiomatic surface from this
|
|
6
7
|
* single list (React `onNodeClick`, Vue `@node-click`, DOM `node:click`, …). Includes the four
|
|
7
8
|
* preventable `-ing` variants — adapter users can cancel them from idiomatic adapter code. */
|
|
8
|
-
export declare const EDITOR_EVENT_NAMES: readonly ["node:added", "node:removed", "node:removing", "node:moved", "node:click", "node:clicking", "node:drop", "edge:connected", "edge:disconnected", "edge:connecting", "edge:disconnecting", "selection:changed", "viewport:changed", "widget:changed", "widget:action", "graph:loaded", "history:changed", "dive:changed", "sidebar:opened", "sidebar:closed", "livemode:changed", "node:contextmenu", "edge:contextmenu", "canvas:contextmenu"];
|
|
9
|
+
export declare const EDITOR_EVENT_NAMES: readonly ["node:added", "node:removed", "node:removing", "node:moved", "node:click", "node:clicking", "node:drop", "edge:connected", "edge:disconnected", "edge:connecting", "edge:disconnecting", "selection:changed", "graph:changed", "viewport:changed", "widget:changed", "widget:action", "graph:loaded", "history:changed", "dive:changed", "sidebar:opened", "sidebar:closed", "livemode:changed", "node:contextmenu", "edge:contextmenu", "canvas:contextmenu"];
|
|
9
10
|
export interface EditorBinding {
|
|
10
11
|
readonly editor: XenolithEditor;
|
|
11
12
|
/** Subscribe to a public editor event. Returns an unsubscribe fn. */
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA8B,KAAK,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAC5G,OAAO,EAAc,KAAK,aAAa,EAAE,MAAM,YAAY,CAAA;AAE3D,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA8B,KAAK,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAC5G,OAAO,EAAc,KAAK,aAAa,EAAE,MAAM,YAAY,CAAA;AAE3D,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAA;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAEzD;;+FAE+F;AAC/F,eAAO,MAAM,kBAAkB,0cAUuB,CAAA;AActD,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAA;IAC/B,qEAAqE;IACrE,EAAE,CAAC,CAAC,SAAS,MAAM,YAAY,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI,CAAA;IACnG,oFAAoF;IACpF,QAAQ,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI,CAAA;IACnC,0DAA0D;IAC1D,OAAO,IAAI,IAAI,CAAA;CAChB;AAcD;;wFAEwF;AACxF,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,MAAM,GAAG,WAAW,EAC5B,KAAK,GAAE,aAAkB,GACxB,OAAO,CAAC,aAAa,CAAC,CAexB"}
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { XenolithEditor } from '@xenolithengine/graph-editor';
|
|
2
2
|
import { applyProps } from './props.js';
|
|
3
3
|
export { applyProps } from './props.js';
|
|
4
|
+
export { diffNodesToChanges } from './controlled-diff.js';
|
|
4
5
|
/** The canonical public editor event names. Every adapter derives its idiomatic surface from this
|
|
5
6
|
* single list (React `onNodeClick`, Vue `@node-click`, DOM `node:click`, …). Includes the four
|
|
6
7
|
* preventable `-ing` variants — adapter users can cancel them from idiomatic adapter code. */
|
|
7
8
|
export const EDITOR_EVENT_NAMES = [
|
|
8
9
|
'node:added', 'node:removed', 'node:removing', 'node:moved', 'node:click', 'node:clicking', 'node:drop',
|
|
9
10
|
'edge:connected', 'edge:disconnected', 'edge:connecting', 'edge:disconnecting',
|
|
10
|
-
'selection:changed',
|
|
11
|
+
'selection:changed',
|
|
12
|
+
'graph:changed', 'viewport:changed',
|
|
11
13
|
'widget:changed', 'widget:action',
|
|
12
14
|
'graph:loaded', 'history:changed', 'dive:changed',
|
|
13
15
|
'sidebar:opened', 'sidebar:closed',
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAiD,MAAM,8BAA8B,CAAA;AAC5G,OAAO,EAAE,UA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-core",
|
|
3
|
-
"version": "0.7.0-beta.
|
|
3
|
+
"version": "0.7.0-beta.7",
|
|
4
4
|
"description": "Framework-agnostic binding for XenolithGraph — mount, reactive props, events. Foundation for the Web Component and React/Vue/Svelte/Solid adapters.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
],
|
|
20
20
|
"sideEffects": false,
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@xenolithengine/graph-
|
|
23
|
-
"@xenolithengine/graph-
|
|
24
|
-
"@xenolithengine/graph-
|
|
22
|
+
"@xenolithengine/graph-core": "0.7.0-beta.7",
|
|
23
|
+
"@xenolithengine/graph-editor": "0.7.0-beta.7",
|
|
24
|
+
"@xenolithengine/graph-render-pixi": "0.7.0-beta.7"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"pixi.js": "^8.6.0"
|