@xenolithengine/graph-solid 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 +54 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/package.json +63 -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,54 @@
|
|
|
1
|
+
# @xenolithengine/graph-solid
|
|
2
|
+
|
|
3
|
+
[](https://github.com/XenolithEngine/xenolith-graph#status)
|
|
4
|
+
[](https://github.com/XenolithEngine/xenolith-graph/blob/main/LICENSE)
|
|
5
|
+
|
|
6
|
+
Solid adapter for XenolithGraph — the `use:xenolith` directive.
|
|
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
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pnpm add @xenolithengine/graph-solid pixi.js
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Peer deps: `solid-js >= 1.8`, `pixi.js@^8.6.0`. WebGL/client-only.
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
import { xenolith } from '@xenolithengine/graph-solid'
|
|
24
|
+
import savedGraph from './graph.json'
|
|
25
|
+
|
|
26
|
+
// Re-import is required for Solid to pick up the directive in JSX.
|
|
27
|
+
xenolith
|
|
28
|
+
|
|
29
|
+
export function Editor() {
|
|
30
|
+
const props = () => ({ graph: savedGraph, minimap: true })
|
|
31
|
+
return (
|
|
32
|
+
<div
|
|
33
|
+
use:xenolith={props()}
|
|
34
|
+
on:node:click={(e) => console.log(e.detail.nodeId)}
|
|
35
|
+
on:selection:changed={(e) => console.log(e.detail)}
|
|
36
|
+
style="width: 100%; height: 100vh"
|
|
37
|
+
/>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Editor events are re-dispatched as same-named `CustomEvent`s — Solid's `on:` binds colon names directly.
|
|
43
|
+
|
|
44
|
+
## What's exported
|
|
45
|
+
|
|
46
|
+
- `xenolith` — the Solid directive (`use:xenolith={props}`)
|
|
47
|
+
- `createXenolithGraph(el, props)` — imperative primitive returning an `EditorBinding`
|
|
48
|
+
|
|
49
|
+
## Docs
|
|
50
|
+
|
|
51
|
+
- [API reference](https://xenolithengine.github.io/xenolith-graph/guides/api/) — every method exposed by `XenolithEditor`
|
|
52
|
+
- [GitHub](https://github.com/XenolithEngine/xenolith-graph)
|
|
53
|
+
|
|
54
|
+
MIT © XenolithEngine
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type EditorBinding, type XenolithProps } from '@xenolithengine/graph-adapter-core';
|
|
2
|
+
/**
|
|
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).
|
|
6
|
+
*
|
|
7
|
+
* Solid calls a directive as `xenolith(el, accessor)`, where `accessor()` is the bound value.
|
|
8
|
+
*/
|
|
9
|
+
export declare function xenolith(el: HTMLElement, accessor: () => XenolithProps | undefined): void;
|
|
10
|
+
/** Imperative primitive for hosts that prefer it over the directive. Returns the binding promise;
|
|
11
|
+
* the caller owns teardown (call `destroy()` from `onCleanup`). */
|
|
12
|
+
export declare function createXenolithGraph(el: HTMLElement, props?: XenolithProps): Promise<EditorBinding>;
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createEffect, onCleanup } from 'solid-js';
|
|
2
|
+
import { createEditorBinding, EDITOR_EVENT_NAMES, } from '@xenolithengine/graph-adapter-core';
|
|
3
|
+
/**
|
|
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).
|
|
7
|
+
*
|
|
8
|
+
* Solid calls a directive as `xenolith(el, accessor)`, where `accessor()` is the bound value.
|
|
9
|
+
*/
|
|
10
|
+
export function xenolith(el, accessor) {
|
|
11
|
+
let binding = null;
|
|
12
|
+
let destroyed = false;
|
|
13
|
+
const offs = [];
|
|
14
|
+
void createEditorBinding(el, accessor() ?? {}).then((b) => {
|
|
15
|
+
if (destroyed) {
|
|
16
|
+
b.destroy();
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
binding = b;
|
|
20
|
+
for (const ev of EDITOR_EVENT_NAMES) {
|
|
21
|
+
offs.push(b.on(ev, (detail) => el.dispatchEvent(new CustomEvent(ev, { detail }))));
|
|
22
|
+
}
|
|
23
|
+
b.setProps(accessor() ?? {});
|
|
24
|
+
});
|
|
25
|
+
// Re-run whenever the bound props signal changes.
|
|
26
|
+
createEffect(() => { const p = accessor(); if (p)
|
|
27
|
+
binding?.setProps(p); });
|
|
28
|
+
onCleanup(() => { destroyed = true; for (const off of offs)
|
|
29
|
+
off(); binding?.destroy(); binding = null; });
|
|
30
|
+
}
|
|
31
|
+
/** Imperative primitive for hosts that prefer it over the directive. Returns the binding promise;
|
|
32
|
+
* the caller owns teardown (call `destroy()` from `onCleanup`). */
|
|
33
|
+
export function createXenolithGraph(el, props = {}) {
|
|
34
|
+
return createEditorBinding(el, props);
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAClD,OAAO,EACL,mBAAmB,EACnB,kBAAkB,GAGnB,MAAM,oCAAoC,CAAA;AAE3C;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAC,EAAe,EAAE,QAAyC;IACjF,IAAI,OAAO,GAAyB,IAAI,CAAA;IACxC,IAAI,SAAS,GAAG,KAAK,CAAA;IACrB,MAAM,IAAI,GAAsB,EAAE,CAAA;IAElC,KAAK,mBAAmB,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;QACxD,IAAI,SAAS,EAAE,CAAC;YAAC,CAAC,CAAC,OAAO,EAAE,CAAC;YAAC,OAAM;QAAC,CAAC;QACtC,OAAO,GAAG,CAAC,CAAA;QACX,KAAK,MAAM,EAAE,IAAI,kBAAkB,EAAE,CAAC;YACpC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;QACpF,CAAC;QACD,CAAC,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;IAC9B,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"}
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xenolithengine/graph-solid",
|
|
3
|
+
"version": "0.7.0-beta.0",
|
|
4
|
+
"description": "Solid adapter for XenolithGraph — the use:xenolith directive.",
|
|
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-adapter-core": "0.7.0-beta.0",
|
|
23
|
+
"@xenolithengine/graph-editor": "0.7.0-beta.0"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"pixi.js": "^8.6.0",
|
|
27
|
+
"solid-js": ">=1.8"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"jsdom": "^25.0.0",
|
|
31
|
+
"pixi.js": "^8.6.0",
|
|
32
|
+
"solid-js": "^1.8.0",
|
|
33
|
+
"typescript": "^5.7.0",
|
|
34
|
+
"vitest": "^3.0.0"
|
|
35
|
+
},
|
|
36
|
+
"keywords": [
|
|
37
|
+
"solid",
|
|
38
|
+
"solidjs",
|
|
39
|
+
"node-editor",
|
|
40
|
+
"node-graph",
|
|
41
|
+
"graph-editor"
|
|
42
|
+
],
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public"
|
|
45
|
+
},
|
|
46
|
+
"repository": {
|
|
47
|
+
"type": "git",
|
|
48
|
+
"url": "git+https://github.com/XenolithEngine/xenolith-graph.git",
|
|
49
|
+
"directory": "packages/solid"
|
|
50
|
+
},
|
|
51
|
+
"homepage": "https://xenolithengine.github.io/xenolith-graph/",
|
|
52
|
+
"bugs": {
|
|
53
|
+
"url": "https://github.com/XenolithEngine/xenolith-graph/issues"
|
|
54
|
+
},
|
|
55
|
+
"author": "XenolithEngine",
|
|
56
|
+
"scripts": {
|
|
57
|
+
"build": "tsc -b",
|
|
58
|
+
"dev": "tsc -b --watch",
|
|
59
|
+
"test": "vitest run --passWithNoTests",
|
|
60
|
+
"lint": "eslint src",
|
|
61
|
+
"typecheck": "tsc --noEmit"
|
|
62
|
+
}
|
|
63
|
+
}
|