@xenolithengine/graph-adapter-core 0.7.0-beta.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/LICENSE +21 -0
- package/README.md +56 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +55 -0
- package/dist/index.js.map +1 -0
- package/dist/props.d.ts +37 -0
- package/dist/props.d.ts.map +1 -0
- package/dist/props.js +26 -0
- package/dist/props.js.map +1 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 strelok2012
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# @xenolithengine/graph-adapter-core
|
|
2
|
+
|
|
3
|
+
[](https://github.com/XenolithEngine/xenolith-graph#status)
|
|
4
|
+
[](https://github.com/XenolithEngine/xenolith-graph/blob/main/LICENSE)
|
|
5
|
+
|
|
6
|
+
Framework-agnostic binding for XenolithGraph — mount, reactive props, events. Foundation for the Web Component and React / Vue / Svelte / Solid / Angular adapters.
|
|
7
|
+
|
|
8
|
+
> **Beta** — public API in `STABLE-API.md` is the surface we plan to freeze, but it is **NOT frozen yet** — breaking changes can land at any point before v1.0. If you adopt now, pin an exact version.
|
|
9
|
+
|
|
10
|
+
Part of [XenolithGraph](https://github.com/XenolithEngine/xenolith-graph) — an AI-native, embeddable node-graph editor for the web with its own visual design language (Xen).
|
|
11
|
+
|
|
12
|
+
Most application hosts should use `@xenolithengine/graph-editor` (vanilla) or one of the framework adapters. This package is the primitive every adapter is built on; reach for it only if you're writing a new adapter.
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm add @xenolithengine/graph-adapter-core
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Peer dependency: `pixi.js@^8.6.0`.
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { createEditorBinding } from '@xenolithengine/graph-adapter-core'
|
|
26
|
+
|
|
27
|
+
const binding = await createEditorBinding('#graph', {
|
|
28
|
+
theme: 'xen',
|
|
29
|
+
graph: someGraphJson,
|
|
30
|
+
fitOnLoad: true,
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
const off = binding.on('node:click', (p) => console.log('clicked', p))
|
|
34
|
+
|
|
35
|
+
binding.setProps({ theme: 'liquid-glass' }) // diffed; only changed refs touch the editor
|
|
36
|
+
|
|
37
|
+
// later
|
|
38
|
+
off()
|
|
39
|
+
binding.destroy()
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## What's exported
|
|
43
|
+
|
|
44
|
+
- `createEditorBinding(target, props)` — async; resolves to an `EditorBinding`
|
|
45
|
+
- `EditorBinding` — `{ editor, on, setProps, destroy }`
|
|
46
|
+
- `XenolithProps` — the canonical props shape consumed by every adapter
|
|
47
|
+
- `applyProps`, `EditorLike` — for hand-rolled reconciliation
|
|
48
|
+
- `EDITOR_EVENT_NAMES` — the canonical event-name list every adapter derives its idiomatic surface from
|
|
49
|
+
|
|
50
|
+
## Docs
|
|
51
|
+
|
|
52
|
+
- [Full guide](https://xenolithengine.github.io/xenolith-graph/guides/api/)
|
|
53
|
+
- [API reference](https://xenolithengine.github.io/xenolith-graph/guides/api/) — every method exposed by `XenolithEditor`
|
|
54
|
+
- [GitHub](https://github.com/XenolithEngine/xenolith-graph)
|
|
55
|
+
|
|
56
|
+
MIT © XenolithEngine
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { XenolithEditor, type EditorEvents } from '@xenolithengine/graph-editor';
|
|
2
|
+
import { type XenolithProps } from './props.js';
|
|
3
|
+
export type { XenolithProps } from './props.js';
|
|
4
|
+
export { applyProps, type EditorLike } from './props.js';
|
|
5
|
+
/** The canonical public editor event names. Every adapter derives its idiomatic surface from this
|
|
6
|
+
* single list (React `onNodeClick`, Vue `@node-click`, DOM `node:click`, …). Includes the four
|
|
7
|
+
* 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 interface EditorBinding {
|
|
10
|
+
readonly editor: XenolithEditor;
|
|
11
|
+
/** Subscribe to a public editor event. Returns an unsubscribe fn. */
|
|
12
|
+
on<E extends keyof EditorEvents>(event: E, handler: (payload: EditorEvents[E]) => void): () => void;
|
|
13
|
+
/** Apply a new props object; only changed (by reference) props touch the editor. */
|
|
14
|
+
setProps(next: XenolithProps): void;
|
|
15
|
+
/** Tear down the editor and release its WebGL context. */
|
|
16
|
+
destroy(): void;
|
|
17
|
+
}
|
|
18
|
+
/** Mount a XenolithGraph editor into `target` and wrap it in a framework-agnostic binding. This is
|
|
19
|
+
* the single foundation every adapter (Web Component, React, Vue, Svelte, Solid) builds on:
|
|
20
|
+
* props in (reactively, via {@link EditorBinding.setProps}), events out (via `on`). */
|
|
21
|
+
export declare function createEditorBinding(target: string | HTMLElement, props?: XenolithProps): Promise<EditorBinding>;
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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;AAExD;;+FAE+F;AAC/F,eAAO,MAAM,kBAAkB,ybASuB,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
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { XenolithEditor } from '@xenolithengine/graph-editor';
|
|
2
|
+
import { applyProps } from './props.js';
|
|
3
|
+
export { applyProps } from './props.js';
|
|
4
|
+
/** The canonical public editor event names. Every adapter derives its idiomatic surface from this
|
|
5
|
+
* single list (React `onNodeClick`, Vue `@node-click`, DOM `node:click`, …). Includes the four
|
|
6
|
+
* preventable `-ing` variants — adapter users can cancel them from idiomatic adapter code. */
|
|
7
|
+
export const EDITOR_EVENT_NAMES = [
|
|
8
|
+
'node:added', 'node:removed', 'node:removing', 'node:moved', 'node:click', 'node:clicking', 'node:drop',
|
|
9
|
+
'edge:connected', 'edge:disconnected', 'edge:connecting', 'edge:disconnecting',
|
|
10
|
+
'selection:changed', 'viewport:changed',
|
|
11
|
+
'widget:changed', 'widget:action',
|
|
12
|
+
'graph:loaded', 'history:changed', 'dive:changed',
|
|
13
|
+
'sidebar:opened', 'sidebar:closed',
|
|
14
|
+
'livemode:changed',
|
|
15
|
+
'node:contextmenu', 'edge:contextmenu', 'canvas:contextmenu',
|
|
16
|
+
];
|
|
17
|
+
const _eventsCovered = true;
|
|
18
|
+
void _eventsCovered;
|
|
19
|
+
function toInitOptions(props) {
|
|
20
|
+
const opts = {};
|
|
21
|
+
if (props.theme !== undefined)
|
|
22
|
+
opts.theme = props.theme;
|
|
23
|
+
if (props.zoomBounds !== undefined)
|
|
24
|
+
opts.zoomBounds = props.zoomBounds;
|
|
25
|
+
if (props.minimap !== undefined)
|
|
26
|
+
opts.minimap = props.minimap;
|
|
27
|
+
if (props.disableGrid !== undefined)
|
|
28
|
+
opts.disableGrid = props.disableGrid;
|
|
29
|
+
if (props.snap !== undefined)
|
|
30
|
+
opts.snap = props.snap;
|
|
31
|
+
if (props.resizeToWindow !== undefined)
|
|
32
|
+
opts.resizeToWindow = props.resizeToWindow;
|
|
33
|
+
if (props.isValidConnection !== undefined)
|
|
34
|
+
opts.isValidConnection = props.isValidConnection;
|
|
35
|
+
return opts;
|
|
36
|
+
}
|
|
37
|
+
/** Mount a XenolithGraph editor into `target` and wrap it in a framework-agnostic binding. This is
|
|
38
|
+
* the single foundation every adapter (Web Component, React, Vue, Svelte, Solid) builds on:
|
|
39
|
+
* props in (reactively, via {@link EditorBinding.setProps}), events out (via `on`). */
|
|
40
|
+
export async function createEditorBinding(target, props = {}) {
|
|
41
|
+
const editor = await XenolithEditor.init(target, toInitOptions(props));
|
|
42
|
+
let current = props;
|
|
43
|
+
if (props.graph != null) {
|
|
44
|
+
editor.loadJSON(props.graph);
|
|
45
|
+
if (props.fitOnLoad)
|
|
46
|
+
editor.fitView();
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
editor,
|
|
50
|
+
on: (event, handler) => editor.on(event, handler),
|
|
51
|
+
setProps(next) { applyProps(editor, current, next); current = next; },
|
|
52
|
+
destroy() { editor.destroy(); },
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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,UAAU,EAAsB,MAAM,YAAY,CAAA;AAG3D,OAAO,EAAE,UAAU,EAAmB,MAAM,YAAY,CAAA;AAExD;;+FAE+F;AAC/F,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,WAAW;IACvG,gBAAgB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,oBAAoB;IAC9E,mBAAmB,EAAE,kBAAkB;IACvC,gBAAgB,EAAE,eAAe;IACjC,cAAc,EAAE,iBAAiB,EAAE,cAAc;IACjD,gBAAgB,EAAE,gBAAgB;IAClC,kBAAkB;IAClB,kBAAkB,EAAE,kBAAkB,EAAE,oBAAoB;CACR,CAAA;AAWtD,MAAM,cAAc,GAAsB,IAAI,CAAA;AAC9C,KAAK,cAAc,CAAA;AAYnB,SAAS,aAAa,CAAC,KAAoB;IACzC,MAAM,IAAI,GAA0B,EAAE,CAAA;IACtC,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS;QAAE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAA;IACvD,IAAI,KAAK,CAAC,UAAU,KAAK,SAAS;QAAE,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CAAA;IACtE,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS;QAAE,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAA;IAC7D,IAAI,KAAK,CAAC,WAAW,KAAK,SAAS;QAAE,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW,CAAA;IACzE,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS;QAAE,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAA;IACpD,IAAI,KAAK,CAAC,cAAc,KAAK,SAAS;QAAE,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC,cAAc,CAAA;IAClF,IAAI,KAAK,CAAC,iBAAiB,KAAK,SAAS;QAAE,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC,iBAAiB,CAAA;IAC3F,OAAO,IAAI,CAAA;AACb,CAAC;AAED;;wFAEwF;AACxF,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,MAA4B,EAC5B,QAAuB,EAAE;IAEzB,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC,CAAA;IACtE,IAAI,OAAO,GAAkB,KAAK,CAAA;IAElC,IAAI,KAAK,CAAC,KAAK,IAAI,IAAI,EAAE,CAAC;QACxB,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QAC5B,IAAI,KAAK,CAAC,SAAS;YAAE,MAAM,CAAC,OAAO,EAAE,CAAA;IACvC,CAAC;IAED,OAAO;QACL,MAAM;QACN,EAAE,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC;QACjD,QAAQ,CAAC,IAAI,IAAI,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,OAAO,GAAG,IAAI,CAAA,CAAC,CAAC;QACpE,OAAO,KAAK,MAAM,CAAC,OAAO,EAAE,CAAA,CAAC,CAAC;KAC/B,CAAA;AACH,CAAC"}
|
package/dist/props.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { XenolithEditorOptions, MinimapPosition } from '@xenolithengine/graph-editor';
|
|
2
|
+
/** Reactive props an adapter (Web Component, React, …) feeds into the editor. A subset is also the
|
|
3
|
+
* initial-mount config; the rest are applied imperatively on change via {@link applyProps}. */
|
|
4
|
+
export interface XenolithProps {
|
|
5
|
+
theme?: XenolithEditorOptions['theme'];
|
|
6
|
+
/** xenolith.v1 graph JSON. Reloaded whenever the reference changes (treat as immutable). */
|
|
7
|
+
graph?: unknown;
|
|
8
|
+
zoomBounds?: XenolithEditorOptions['zoomBounds'];
|
|
9
|
+
minimap?: XenolithEditorOptions['minimap'];
|
|
10
|
+
disableGrid?: boolean;
|
|
11
|
+
snap?: number;
|
|
12
|
+
/** When false (recommended for embedded panels / framework islands), the editor fits its host
|
|
13
|
+
* element via a ResizeObserver instead of the window. Defaults to window-fit. */
|
|
14
|
+
resizeToWindow?: boolean;
|
|
15
|
+
/** Frame the graph after each (re)load. */
|
|
16
|
+
fitOnLoad?: boolean;
|
|
17
|
+
/** Custom connection guard (on top of the type check). Return false to reject a wire. */
|
|
18
|
+
isValidConnection?: XenolithEditorOptions['isValidConnection'];
|
|
19
|
+
}
|
|
20
|
+
/** The slice of the editor surface that {@link applyProps} drives — kept minimal so it can be
|
|
21
|
+
* exercised with a mock in unit tests without a WebGL context. */
|
|
22
|
+
export interface EditorLike {
|
|
23
|
+
setTheme(theme: NonNullable<XenolithProps['theme']>): void;
|
|
24
|
+
loadJSON(data: unknown): void;
|
|
25
|
+
fitView(opts?: {
|
|
26
|
+
padding?: number;
|
|
27
|
+
maxZoom?: number;
|
|
28
|
+
minZoom?: number;
|
|
29
|
+
}): void;
|
|
30
|
+
setMinimapVisible(visible: boolean): void;
|
|
31
|
+
setMinimapPosition(position: MinimapPosition): void;
|
|
32
|
+
setIsValidConnection(fn: NonNullable<XenolithProps['isValidConnection']> | null): void;
|
|
33
|
+
}
|
|
34
|
+
/** Diff `prev` → `next` and call the matching editor methods. Reference equality is the change
|
|
35
|
+
* signal (props are treated as immutable), so adapters can call this on every render cheaply. */
|
|
36
|
+
export declare function applyProps(editor: EditorLike, prev: XenolithProps, next: XenolithProps): void;
|
|
37
|
+
//# sourceMappingURL=props.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../src/props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAE1F;gGACgG;AAChG,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,qBAAqB,CAAC,OAAO,CAAC,CAAA;IACtC,4FAA4F;IAC5F,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,UAAU,CAAC,EAAE,qBAAqB,CAAC,YAAY,CAAC,CAAA;IAChD,OAAO,CAAC,EAAE,qBAAqB,CAAC,SAAS,CAAC,CAAA;IAC1C,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;sFACkF;IAClF,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,2CAA2C;IAC3C,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,yFAAyF;IACzF,iBAAiB,CAAC,EAAE,qBAAqB,CAAC,mBAAmB,CAAC,CAAA;CAC/D;AAED;mEACmE;AACnE,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,GAAG,IAAI,CAAA;IAC1D,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAAA;IAC7B,OAAO,CAAC,IAAI,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAA;IAC9E,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAA;IACzC,kBAAkB,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI,CAAA;IACnD,oBAAoB,CAAC,EAAE,EAAE,WAAW,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC,GAAG,IAAI,GAAG,IAAI,CAAA;CACvF;AASD;kGACkG;AAClG,wBAAgB,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,aAAa,GAAG,IAAI,CAe7F"}
|
package/dist/props.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
function minimapEnabled(m) {
|
|
2
|
+
return m === true || (typeof m === 'object' && m !== null);
|
|
3
|
+
}
|
|
4
|
+
function minimapPosition(m) {
|
|
5
|
+
return typeof m === 'object' && m !== null ? m.position : undefined;
|
|
6
|
+
}
|
|
7
|
+
/** Diff `prev` → `next` and call the matching editor methods. Reference equality is the change
|
|
8
|
+
* signal (props are treated as immutable), so adapters can call this on every render cheaply. */
|
|
9
|
+
export function applyProps(editor, prev, next) {
|
|
10
|
+
if (next.theme && next.theme !== prev.theme)
|
|
11
|
+
editor.setTheme(next.theme);
|
|
12
|
+
if (next.graph != null && next.graph !== prev.graph) {
|
|
13
|
+
editor.loadJSON(next.graph);
|
|
14
|
+
if (next.fitOnLoad)
|
|
15
|
+
editor.fitView();
|
|
16
|
+
}
|
|
17
|
+
if (minimapEnabled(next.minimap) !== minimapEnabled(prev.minimap)) {
|
|
18
|
+
editor.setMinimapVisible(minimapEnabled(next.minimap));
|
|
19
|
+
}
|
|
20
|
+
const pos = minimapPosition(next.minimap);
|
|
21
|
+
if (pos !== undefined && pos !== minimapPosition(prev.minimap))
|
|
22
|
+
editor.setMinimapPosition(pos);
|
|
23
|
+
if (next.isValidConnection !== prev.isValidConnection)
|
|
24
|
+
editor.setIsValidConnection(next.isValidConnection ?? null);
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.js","sourceRoot":"","sources":["../src/props.ts"],"names":[],"mappings":"AAgCA,SAAS,cAAc,CAAC,CAA2B;IACjD,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,CAAC,CAAA;AAC5D,CAAC;AACD,SAAS,eAAe,CAAC,CAA2B;IAClD,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAA;AACrE,CAAC;AAED;kGACkG;AAClG,MAAM,UAAU,UAAU,CAAC,MAAkB,EAAE,IAAmB,EAAE,IAAmB;IACrF,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK;QAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAExE,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,IAAI,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC;QACpD,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QAC3B,IAAI,IAAI,CAAC,SAAS;YAAE,MAAM,CAAC,OAAO,EAAE,CAAA;IACtC,CAAC;IAED,IAAI,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QAClE,MAAM,CAAC,iBAAiB,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA;IACxD,CAAC;IACD,MAAM,GAAG,GAAG,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACzC,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC;QAAE,MAAM,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAA;IAE9F,IAAI,IAAI,CAAC,iBAAiB,KAAK,IAAI,CAAC,iBAAiB;QAAE,MAAM,CAAC,oBAAoB,CAAC,IAAI,CAAC,iBAAiB,IAAI,IAAI,CAAC,CAAA;AACpH,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xenolithengine/graph-adapter-core",
|
|
3
|
+
"version": "0.7.0-beta.0",
|
|
4
|
+
"description": "Framework-agnostic binding for XenolithGraph — mount, reactive props, events. Foundation for the Web Component and React/Vue/Svelte/Solid adapters.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
20
|
+
"sideEffects": false,
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@xenolithengine/graph-editor": "0.7.0-beta.0",
|
|
23
|
+
"@xenolithengine/graph-render-pixi": "0.7.0-beta.0",
|
|
24
|
+
"@xenolithengine/graph-core": "0.7.0-beta.0"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"pixi.js": "^8.6.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"pixi.js": "^8.6.0",
|
|
31
|
+
"typescript": "^5.7.0",
|
|
32
|
+
"vitest": "^3.0.0"
|
|
33
|
+
},
|
|
34
|
+
"keywords": [
|
|
35
|
+
"node-editor",
|
|
36
|
+
"framework-adapter",
|
|
37
|
+
"internal"
|
|
38
|
+
],
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "git+https://github.com/XenolithEngine/xenolith-graph.git",
|
|
45
|
+
"directory": "packages/adapter-core"
|
|
46
|
+
},
|
|
47
|
+
"homepage": "https://xenolithengine.github.io/xenolith-graph/",
|
|
48
|
+
"bugs": {
|
|
49
|
+
"url": "https://github.com/XenolithEngine/xenolith-graph/issues"
|
|
50
|
+
},
|
|
51
|
+
"author": "XenolithEngine",
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "tsc -b",
|
|
54
|
+
"dev": "tsc -b --watch",
|
|
55
|
+
"test": "vitest run --passWithNoTests",
|
|
56
|
+
"lint": "eslint src",
|
|
57
|
+
"typecheck": "tsc --noEmit"
|
|
58
|
+
}
|
|
59
|
+
}
|