@typicalday/firegraph 0.1.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 +27 -0
- package/README.md +527 -0
- package/bin/firegraph.mjs +129 -0
- package/dist/chunk-KFA7G37W.js +443 -0
- package/dist/chunk-KFA7G37W.js.map +1 -0
- package/dist/chunk-YLGXLEUE.js +47 -0
- package/dist/chunk-YLGXLEUE.js.map +1 -0
- package/dist/client-Bk2Cm6xv.d.cts +131 -0
- package/dist/client-Bk2Cm6xv.d.ts +131 -0
- package/dist/codegen/index.cjs +81 -0
- package/dist/codegen/index.cjs.map +1 -0
- package/dist/codegen/index.d.cts +2 -0
- package/dist/codegen/index.d.ts +2 -0
- package/dist/codegen/index.js +7 -0
- package/dist/codegen/index.js.map +1 -0
- package/dist/editor/client/assets/index-DJJ_b0jI.js +411 -0
- package/dist/editor/client/assets/index-Q0QBYrMV.css +1 -0
- package/dist/editor/client/index.html +16 -0
- package/dist/editor/server/index.mjs +49597 -0
- package/dist/index-CG3R68Hu.d.cts +414 -0
- package/dist/index-CG3R68Hu.d.ts +414 -0
- package/dist/index.cjs +1953 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +186 -0
- package/dist/index.d.ts +186 -0
- package/dist/index.js +1569 -0
- package/dist/index.js.map +1 -0
- package/dist/query-client/index.cjs +484 -0
- package/dist/query-client/index.cjs.map +1 -0
- package/dist/query-client/index.d.cts +15 -0
- package/dist/query-client/index.d.ts +15 -0
- package/dist/query-client/index.js +17 -0
- package/dist/query-client/index.js.map +1 -0
- package/dist/react.cjs +85 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +44 -0
- package/dist/react.d.ts +44 -0
- package/dist/react.js +60 -0
- package/dist/react.js.map +1 -0
- package/dist/svelte.cjs +90 -0
- package/dist/svelte.cjs.map +1 -0
- package/dist/svelte.d.cts +46 -0
- package/dist/svelte.d.ts +46 -0
- package/dist/svelte.js +65 -0
- package/dist/svelte.js.map +1 -0
- package/dist/views-DL60k0cf.d.cts +91 -0
- package/dist/views-DL60k0cf.d.ts +91 -0
- package/package.json +122 -0
package/dist/react.cjs
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/react.ts
|
|
21
|
+
var react_exports = {};
|
|
22
|
+
__export(react_exports, {
|
|
23
|
+
wrapReact: () => wrapReact
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(react_exports);
|
|
26
|
+
function getBaseClass() {
|
|
27
|
+
const g = globalThis;
|
|
28
|
+
return g.HTMLElement ?? class {
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function wrapReact(Component, meta) {
|
|
32
|
+
let React = null;
|
|
33
|
+
let ReactDOM = null;
|
|
34
|
+
let loaded = false;
|
|
35
|
+
async function ensureReact() {
|
|
36
|
+
if (loaded) return;
|
|
37
|
+
const [r, rd] = await Promise.all([
|
|
38
|
+
Function('return import("react")')(),
|
|
39
|
+
Function('return import("react-dom/client")')()
|
|
40
|
+
]);
|
|
41
|
+
React = r;
|
|
42
|
+
ReactDOM = rd;
|
|
43
|
+
loaded = true;
|
|
44
|
+
}
|
|
45
|
+
const Base = getBaseClass();
|
|
46
|
+
const Cls = class extends Base {
|
|
47
|
+
static viewName = meta.viewName;
|
|
48
|
+
static description = meta.description;
|
|
49
|
+
_data = {};
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
51
|
+
_root = null;
|
|
52
|
+
_mounted = false;
|
|
53
|
+
set data(v) {
|
|
54
|
+
this._data = v;
|
|
55
|
+
this._render();
|
|
56
|
+
}
|
|
57
|
+
get data() {
|
|
58
|
+
return this._data;
|
|
59
|
+
}
|
|
60
|
+
connectedCallback() {
|
|
61
|
+
this._mounted = true;
|
|
62
|
+
this._render();
|
|
63
|
+
}
|
|
64
|
+
disconnectedCallback() {
|
|
65
|
+
this._mounted = false;
|
|
66
|
+
this._root?.unmount();
|
|
67
|
+
this._root = null;
|
|
68
|
+
}
|
|
69
|
+
async _render() {
|
|
70
|
+
if (!this._mounted) return;
|
|
71
|
+
await ensureReact();
|
|
72
|
+
if (!this._mounted) return;
|
|
73
|
+
if (!this._root) {
|
|
74
|
+
this._root = ReactDOM.createRoot(this);
|
|
75
|
+
}
|
|
76
|
+
this._root.render(React.createElement(Component, { data: this._data }));
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
return Cls;
|
|
80
|
+
}
|
|
81
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
82
|
+
0 && (module.exports = {
|
|
83
|
+
wrapReact
|
|
84
|
+
});
|
|
85
|
+
//# sourceMappingURL=react.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/react.ts"],"sourcesContent":["/**\n * React adapter for firegraph views.\n *\n * Wraps a React function component into a Web Component (HTMLElement) that\n * satisfies the firegraph `ViewComponentClass` contract. Import from\n * `firegraph/react`:\n *\n * @example\n * ```tsx\n * import { wrapReact } from 'firegraph/react';\n *\n * const TaskCard = wrapReact(({ data }) => (\n * <div style={{ padding: 12 }}>\n * <strong>{String(data.title ?? '')}</strong>\n * </div>\n * ), { viewName: 'card', description: 'Compact task card' });\n *\n * export default [TaskCard];\n * ```\n */\n\nimport type { ViewComponentClass } from './views.js';\n\n/** Metadata required for every firegraph view. */\nexport interface ViewMeta {\n /** Short identifier (e.g. 'card', 'detail'). */\n viewName: string;\n /** Optional human-readable description. */\n description?: string;\n}\n\n/** A React function component that receives entity data. */\nexport type ReactViewComponent = (props: { data: Record<string, unknown> }) => unknown;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyClass = { new (...args: any[]): any };\n\n/**\n * Get HTMLElement from the runtime environment.\n * Returns a base class for view elements — works in both browser and Node.js\n * (where HTMLElement may be shimmed by the editor server).\n */\nfunction getBaseClass(): AnyClass {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const g = globalThis as any;\n return g.HTMLElement ?? class {};\n}\n\n/**\n * Wrap a React function component into a firegraph `ViewComponentClass`.\n *\n * The returned class extends `HTMLElement` and lazily imports `react` and\n * `react-dom/client` at render time. React is resolved from the project's\n * own `node_modules` — firegraph does not bundle or depend on React itself.\n */\nexport function wrapReact(\n Component: ReactViewComponent,\n meta: ViewMeta,\n): ViewComponentClass {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let React: any = null;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let ReactDOM: any = null;\n let loaded = false;\n\n async function ensureReact() {\n if (loaded) return;\n // Dynamic imports — resolved from project's node_modules at runtime\n const [r, rd] = await Promise.all([\n Function('return import(\"react\")')() as Promise<unknown>,\n Function('return import(\"react-dom/client\")')() as Promise<unknown>,\n ]);\n React = r;\n ReactDOM = rd;\n loaded = true;\n }\n\n const Base = getBaseClass();\n\n const Cls = class extends Base {\n static viewName = meta.viewName;\n static description = meta.description;\n\n _data: Record<string, unknown> = {};\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n _root: any = null;\n _mounted = false;\n\n set data(v: Record<string, unknown>) {\n this._data = v;\n this._render();\n }\n\n get data() {\n return this._data;\n }\n\n connectedCallback() {\n this._mounted = true;\n this._render();\n }\n\n disconnectedCallback() {\n this._mounted = false;\n this._root?.unmount();\n this._root = null;\n }\n\n async _render() {\n if (!this._mounted) return;\n await ensureReact();\n if (!this._mounted) return; // may have disconnected while awaiting\n\n if (!this._root) {\n this._root = ReactDOM.createRoot(this);\n }\n this._root.render(React.createElement(Component, { data: this._data }));\n }\n };\n\n return Cls as unknown as ViewComponentClass;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA0CA,SAAS,eAAyB;AAEhC,QAAM,IAAI;AACV,SAAO,EAAE,eAAe,MAAM;AAAA,EAAC;AACjC;AASO,SAAS,UACd,WACA,MACoB;AAEpB,MAAI,QAAa;AAEjB,MAAI,WAAgB;AACpB,MAAI,SAAS;AAEb,iBAAe,cAAc;AAC3B,QAAI,OAAQ;AAEZ,UAAM,CAAC,GAAG,EAAE,IAAI,MAAM,QAAQ,IAAI;AAAA,MAChC,SAAS,wBAAwB,EAAE;AAAA,MACnC,SAAS,mCAAmC,EAAE;AAAA,IAChD,CAAC;AACD,YAAQ;AACR,eAAW;AACX,aAAS;AAAA,EACX;AAEA,QAAM,OAAO,aAAa;AAE1B,QAAM,MAAM,cAAc,KAAK;AAAA,IAC7B,OAAO,WAAW,KAAK;AAAA,IACvB,OAAO,cAAc,KAAK;AAAA,IAE1B,QAAiC,CAAC;AAAA;AAAA,IAElC,QAAa;AAAA,IACb,WAAW;AAAA,IAEX,IAAI,KAAK,GAA4B;AACnC,WAAK,QAAQ;AACb,WAAK,QAAQ;AAAA,IACf;AAAA,IAEA,IAAI,OAAO;AACT,aAAO,KAAK;AAAA,IACd;AAAA,IAEA,oBAAoB;AAClB,WAAK,WAAW;AAChB,WAAK,QAAQ;AAAA,IACf;AAAA,IAEA,uBAAuB;AACrB,WAAK,WAAW;AAChB,WAAK,OAAO,QAAQ;AACpB,WAAK,QAAQ;AAAA,IACf;AAAA,IAEA,MAAM,UAAU;AACd,UAAI,CAAC,KAAK,SAAU;AACpB,YAAM,YAAY;AAClB,UAAI,CAAC,KAAK,SAAU;AAEpB,UAAI,CAAC,KAAK,OAAO;AACf,aAAK,QAAQ,SAAS,WAAW,IAAI;AAAA,MACvC;AACA,WAAK,MAAM,OAAO,MAAM,cAAc,WAAW,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC;AAAA,IACxE;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
package/dist/react.d.cts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { V as ViewComponentClass } from './views-DL60k0cf.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* React adapter for firegraph views.
|
|
5
|
+
*
|
|
6
|
+
* Wraps a React function component into a Web Component (HTMLElement) that
|
|
7
|
+
* satisfies the firegraph `ViewComponentClass` contract. Import from
|
|
8
|
+
* `firegraph/react`:
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* import { wrapReact } from 'firegraph/react';
|
|
13
|
+
*
|
|
14
|
+
* const TaskCard = wrapReact(({ data }) => (
|
|
15
|
+
* <div style={{ padding: 12 }}>
|
|
16
|
+
* <strong>{String(data.title ?? '')}</strong>
|
|
17
|
+
* </div>
|
|
18
|
+
* ), { viewName: 'card', description: 'Compact task card' });
|
|
19
|
+
*
|
|
20
|
+
* export default [TaskCard];
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/** Metadata required for every firegraph view. */
|
|
25
|
+
interface ViewMeta {
|
|
26
|
+
/** Short identifier (e.g. 'card', 'detail'). */
|
|
27
|
+
viewName: string;
|
|
28
|
+
/** Optional human-readable description. */
|
|
29
|
+
description?: string;
|
|
30
|
+
}
|
|
31
|
+
/** A React function component that receives entity data. */
|
|
32
|
+
type ReactViewComponent = (props: {
|
|
33
|
+
data: Record<string, unknown>;
|
|
34
|
+
}) => unknown;
|
|
35
|
+
/**
|
|
36
|
+
* Wrap a React function component into a firegraph `ViewComponentClass`.
|
|
37
|
+
*
|
|
38
|
+
* The returned class extends `HTMLElement` and lazily imports `react` and
|
|
39
|
+
* `react-dom/client` at render time. React is resolved from the project's
|
|
40
|
+
* own `node_modules` — firegraph does not bundle or depend on React itself.
|
|
41
|
+
*/
|
|
42
|
+
declare function wrapReact(Component: ReactViewComponent, meta: ViewMeta): ViewComponentClass;
|
|
43
|
+
|
|
44
|
+
export { type ReactViewComponent, type ViewMeta, wrapReact };
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { V as ViewComponentClass } from './views-DL60k0cf.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* React adapter for firegraph views.
|
|
5
|
+
*
|
|
6
|
+
* Wraps a React function component into a Web Component (HTMLElement) that
|
|
7
|
+
* satisfies the firegraph `ViewComponentClass` contract. Import from
|
|
8
|
+
* `firegraph/react`:
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* import { wrapReact } from 'firegraph/react';
|
|
13
|
+
*
|
|
14
|
+
* const TaskCard = wrapReact(({ data }) => (
|
|
15
|
+
* <div style={{ padding: 12 }}>
|
|
16
|
+
* <strong>{String(data.title ?? '')}</strong>
|
|
17
|
+
* </div>
|
|
18
|
+
* ), { viewName: 'card', description: 'Compact task card' });
|
|
19
|
+
*
|
|
20
|
+
* export default [TaskCard];
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/** Metadata required for every firegraph view. */
|
|
25
|
+
interface ViewMeta {
|
|
26
|
+
/** Short identifier (e.g. 'card', 'detail'). */
|
|
27
|
+
viewName: string;
|
|
28
|
+
/** Optional human-readable description. */
|
|
29
|
+
description?: string;
|
|
30
|
+
}
|
|
31
|
+
/** A React function component that receives entity data. */
|
|
32
|
+
type ReactViewComponent = (props: {
|
|
33
|
+
data: Record<string, unknown>;
|
|
34
|
+
}) => unknown;
|
|
35
|
+
/**
|
|
36
|
+
* Wrap a React function component into a firegraph `ViewComponentClass`.
|
|
37
|
+
*
|
|
38
|
+
* The returned class extends `HTMLElement` and lazily imports `react` and
|
|
39
|
+
* `react-dom/client` at render time. React is resolved from the project's
|
|
40
|
+
* own `node_modules` — firegraph does not bundle or depend on React itself.
|
|
41
|
+
*/
|
|
42
|
+
declare function wrapReact(Component: ReactViewComponent, meta: ViewMeta): ViewComponentClass;
|
|
43
|
+
|
|
44
|
+
export { type ReactViewComponent, type ViewMeta, wrapReact };
|
package/dist/react.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// src/react.ts
|
|
2
|
+
function getBaseClass() {
|
|
3
|
+
const g = globalThis;
|
|
4
|
+
return g.HTMLElement ?? class {
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
function wrapReact(Component, meta) {
|
|
8
|
+
let React = null;
|
|
9
|
+
let ReactDOM = null;
|
|
10
|
+
let loaded = false;
|
|
11
|
+
async function ensureReact() {
|
|
12
|
+
if (loaded) return;
|
|
13
|
+
const [r, rd] = await Promise.all([
|
|
14
|
+
Function('return import("react")')(),
|
|
15
|
+
Function('return import("react-dom/client")')()
|
|
16
|
+
]);
|
|
17
|
+
React = r;
|
|
18
|
+
ReactDOM = rd;
|
|
19
|
+
loaded = true;
|
|
20
|
+
}
|
|
21
|
+
const Base = getBaseClass();
|
|
22
|
+
const Cls = class extends Base {
|
|
23
|
+
static viewName = meta.viewName;
|
|
24
|
+
static description = meta.description;
|
|
25
|
+
_data = {};
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
|
+
_root = null;
|
|
28
|
+
_mounted = false;
|
|
29
|
+
set data(v) {
|
|
30
|
+
this._data = v;
|
|
31
|
+
this._render();
|
|
32
|
+
}
|
|
33
|
+
get data() {
|
|
34
|
+
return this._data;
|
|
35
|
+
}
|
|
36
|
+
connectedCallback() {
|
|
37
|
+
this._mounted = true;
|
|
38
|
+
this._render();
|
|
39
|
+
}
|
|
40
|
+
disconnectedCallback() {
|
|
41
|
+
this._mounted = false;
|
|
42
|
+
this._root?.unmount();
|
|
43
|
+
this._root = null;
|
|
44
|
+
}
|
|
45
|
+
async _render() {
|
|
46
|
+
if (!this._mounted) return;
|
|
47
|
+
await ensureReact();
|
|
48
|
+
if (!this._mounted) return;
|
|
49
|
+
if (!this._root) {
|
|
50
|
+
this._root = ReactDOM.createRoot(this);
|
|
51
|
+
}
|
|
52
|
+
this._root.render(React.createElement(Component, { data: this._data }));
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
return Cls;
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
wrapReact
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=react.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/react.ts"],"sourcesContent":["/**\n * React adapter for firegraph views.\n *\n * Wraps a React function component into a Web Component (HTMLElement) that\n * satisfies the firegraph `ViewComponentClass` contract. Import from\n * `firegraph/react`:\n *\n * @example\n * ```tsx\n * import { wrapReact } from 'firegraph/react';\n *\n * const TaskCard = wrapReact(({ data }) => (\n * <div style={{ padding: 12 }}>\n * <strong>{String(data.title ?? '')}</strong>\n * </div>\n * ), { viewName: 'card', description: 'Compact task card' });\n *\n * export default [TaskCard];\n * ```\n */\n\nimport type { ViewComponentClass } from './views.js';\n\n/** Metadata required for every firegraph view. */\nexport interface ViewMeta {\n /** Short identifier (e.g. 'card', 'detail'). */\n viewName: string;\n /** Optional human-readable description. */\n description?: string;\n}\n\n/** A React function component that receives entity data. */\nexport type ReactViewComponent = (props: { data: Record<string, unknown> }) => unknown;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyClass = { new (...args: any[]): any };\n\n/**\n * Get HTMLElement from the runtime environment.\n * Returns a base class for view elements — works in both browser and Node.js\n * (where HTMLElement may be shimmed by the editor server).\n */\nfunction getBaseClass(): AnyClass {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const g = globalThis as any;\n return g.HTMLElement ?? class {};\n}\n\n/**\n * Wrap a React function component into a firegraph `ViewComponentClass`.\n *\n * The returned class extends `HTMLElement` and lazily imports `react` and\n * `react-dom/client` at render time. React is resolved from the project's\n * own `node_modules` — firegraph does not bundle or depend on React itself.\n */\nexport function wrapReact(\n Component: ReactViewComponent,\n meta: ViewMeta,\n): ViewComponentClass {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let React: any = null;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let ReactDOM: any = null;\n let loaded = false;\n\n async function ensureReact() {\n if (loaded) return;\n // Dynamic imports — resolved from project's node_modules at runtime\n const [r, rd] = await Promise.all([\n Function('return import(\"react\")')() as Promise<unknown>,\n Function('return import(\"react-dom/client\")')() as Promise<unknown>,\n ]);\n React = r;\n ReactDOM = rd;\n loaded = true;\n }\n\n const Base = getBaseClass();\n\n const Cls = class extends Base {\n static viewName = meta.viewName;\n static description = meta.description;\n\n _data: Record<string, unknown> = {};\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n _root: any = null;\n _mounted = false;\n\n set data(v: Record<string, unknown>) {\n this._data = v;\n this._render();\n }\n\n get data() {\n return this._data;\n }\n\n connectedCallback() {\n this._mounted = true;\n this._render();\n }\n\n disconnectedCallback() {\n this._mounted = false;\n this._root?.unmount();\n this._root = null;\n }\n\n async _render() {\n if (!this._mounted) return;\n await ensureReact();\n if (!this._mounted) return; // may have disconnected while awaiting\n\n if (!this._root) {\n this._root = ReactDOM.createRoot(this);\n }\n this._root.render(React.createElement(Component, { data: this._data }));\n }\n };\n\n return Cls as unknown as ViewComponentClass;\n}\n"],"mappings":";AA0CA,SAAS,eAAyB;AAEhC,QAAM,IAAI;AACV,SAAO,EAAE,eAAe,MAAM;AAAA,EAAC;AACjC;AASO,SAAS,UACd,WACA,MACoB;AAEpB,MAAI,QAAa;AAEjB,MAAI,WAAgB;AACpB,MAAI,SAAS;AAEb,iBAAe,cAAc;AAC3B,QAAI,OAAQ;AAEZ,UAAM,CAAC,GAAG,EAAE,IAAI,MAAM,QAAQ,IAAI;AAAA,MAChC,SAAS,wBAAwB,EAAE;AAAA,MACnC,SAAS,mCAAmC,EAAE;AAAA,IAChD,CAAC;AACD,YAAQ;AACR,eAAW;AACX,aAAS;AAAA,EACX;AAEA,QAAM,OAAO,aAAa;AAE1B,QAAM,MAAM,cAAc,KAAK;AAAA,IAC7B,OAAO,WAAW,KAAK;AAAA,IACvB,OAAO,cAAc,KAAK;AAAA,IAE1B,QAAiC,CAAC;AAAA;AAAA,IAElC,QAAa;AAAA,IACb,WAAW;AAAA,IAEX,IAAI,KAAK,GAA4B;AACnC,WAAK,QAAQ;AACb,WAAK,QAAQ;AAAA,IACf;AAAA,IAEA,IAAI,OAAO;AACT,aAAO,KAAK;AAAA,IACd;AAAA,IAEA,oBAAoB;AAClB,WAAK,WAAW;AAChB,WAAK,QAAQ;AAAA,IACf;AAAA,IAEA,uBAAuB;AACrB,WAAK,WAAW;AAChB,WAAK,OAAO,QAAQ;AACpB,WAAK,QAAQ;AAAA,IACf;AAAA,IAEA,MAAM,UAAU;AACd,UAAI,CAAC,KAAK,SAAU;AACpB,YAAM,YAAY;AAClB,UAAI,CAAC,KAAK,SAAU;AAEpB,UAAI,CAAC,KAAK,OAAO;AACf,aAAK,QAAQ,SAAS,WAAW,IAAI;AAAA,MACvC;AACA,WAAK,MAAM,OAAO,MAAM,cAAc,WAAW,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC;AAAA,IACxE;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
package/dist/svelte.cjs
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/svelte.ts
|
|
21
|
+
var svelte_exports = {};
|
|
22
|
+
__export(svelte_exports, {
|
|
23
|
+
wrapSvelte: () => wrapSvelte
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(svelte_exports);
|
|
26
|
+
function getBaseClass() {
|
|
27
|
+
const g = globalThis;
|
|
28
|
+
return g.HTMLElement ?? class {
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function wrapSvelte(Component, meta) {
|
|
32
|
+
const Base = getBaseClass();
|
|
33
|
+
const Cls = class extends Base {
|
|
34
|
+
static viewName = meta.viewName;
|
|
35
|
+
static description = meta.description;
|
|
36
|
+
_data = {};
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
38
|
+
_instance = null;
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
|
+
_props = null;
|
|
41
|
+
_mounted = false;
|
|
42
|
+
set data(v) {
|
|
43
|
+
this._data = v;
|
|
44
|
+
if (this._props) {
|
|
45
|
+
this._props.data = v;
|
|
46
|
+
} else if (this._mounted) {
|
|
47
|
+
this._mount();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
get data() {
|
|
51
|
+
return this._data;
|
|
52
|
+
}
|
|
53
|
+
connectedCallback() {
|
|
54
|
+
this._mounted = true;
|
|
55
|
+
this._mount();
|
|
56
|
+
}
|
|
57
|
+
disconnectedCallback() {
|
|
58
|
+
this._mounted = false;
|
|
59
|
+
if (this._instance) {
|
|
60
|
+
Function('return import("svelte")')().then(
|
|
61
|
+
({ unmount }) => {
|
|
62
|
+
if (this._instance) {
|
|
63
|
+
unmount(this._instance);
|
|
64
|
+
this._instance = null;
|
|
65
|
+
this._props = null;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async _mount() {
|
|
72
|
+
const svelte = await Function('return import("svelte")')();
|
|
73
|
+
if (!this._mounted) return;
|
|
74
|
+
if (this._instance) {
|
|
75
|
+
svelte.unmount(this._instance);
|
|
76
|
+
}
|
|
77
|
+
this._props = { data: this._data };
|
|
78
|
+
this._instance = svelte.mount(Component, {
|
|
79
|
+
target: this,
|
|
80
|
+
props: this._props
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
return Cls;
|
|
85
|
+
}
|
|
86
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
87
|
+
0 && (module.exports = {
|
|
88
|
+
wrapSvelte
|
|
89
|
+
});
|
|
90
|
+
//# sourceMappingURL=svelte.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/svelte.ts"],"sourcesContent":["/**\n * Svelte 5 adapter for firegraph views.\n *\n * Wraps a Svelte component into a Web Component (HTMLElement) that satisfies\n * the firegraph `ViewComponentClass` contract. Import from `firegraph/svelte`:\n *\n * @example\n * ```ts\n * import { wrapSvelte } from 'firegraph/svelte';\n * import TaskCard from './TaskCard.svelte';\n *\n * export default [\n * wrapSvelte(TaskCard, { viewName: 'card', description: 'Compact task card' }),\n * ];\n * ```\n */\n\nimport type { ViewComponentClass } from './views.js';\n\n/** Metadata required for every firegraph view. */\nexport interface ViewMeta {\n /** Short identifier (e.g. 'card', 'detail'). */\n viewName: string;\n /** Optional human-readable description. */\n description?: string;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyClass = { new (...args: any[]): any };\n\n/**\n * Get HTMLElement from the runtime environment.\n * Returns a base class for view elements — works in both browser and Node.js\n * (where HTMLElement may be shimmed by the editor server).\n */\nfunction getBaseClass(): AnyClass {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const g = globalThis as any;\n return g.HTMLElement ?? class {};\n}\n\n/**\n * Wrap a Svelte 5 component into a firegraph `ViewComponentClass`.\n *\n * The returned class extends `HTMLElement` and lazily imports `svelte` at\n * mount time. Svelte is resolved from the project's own `node_modules` —\n * firegraph does not bundle or depend on Svelte itself.\n *\n * The Svelte component should accept a `data` prop:\n * ```svelte\n * <script>\n * let { data } = $props();\n * </script>\n * ```\n *\n * Props are updated by mutating the props object — Svelte 5's reactivity\n * system picks up the changes automatically.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function wrapSvelte(Component: any, meta: ViewMeta): ViewComponentClass {\n const Base = getBaseClass();\n\n const Cls = class extends Base {\n static viewName = meta.viewName;\n static description = meta.description;\n\n _data: Record<string, unknown> = {};\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n _instance: any = null;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n _props: any = null;\n _mounted = false;\n\n set data(v: Record<string, unknown>) {\n this._data = v;\n if (this._props) {\n // Svelte 5: mutating the props object triggers reactivity\n this._props.data = v;\n } else if (this._mounted) {\n this._mount();\n }\n }\n\n get data() {\n return this._data;\n }\n\n connectedCallback() {\n this._mounted = true;\n this._mount();\n }\n\n disconnectedCallback() {\n this._mounted = false;\n if (this._instance) {\n // Dynamic import — resolved from project's node_modules at runtime\n (Function('return import(\"svelte\")')() as Promise<{ unmount: Function }>).then(\n ({ unmount }) => {\n if (this._instance) {\n unmount(this._instance);\n this._instance = null;\n this._props = null;\n }\n },\n );\n }\n }\n\n async _mount() {\n // Dynamic import — resolved from project's node_modules at runtime\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const svelte: any = await (Function('return import(\"svelte\")')() as Promise<unknown>);\n if (!this._mounted) return; // disconnected while awaiting\n\n // Clean up previous instance\n if (this._instance) {\n svelte.unmount(this._instance);\n }\n\n // Svelte 5: pass a props object — mutating it later triggers re-renders\n this._props = { data: this._data };\n this._instance = svelte.mount(Component, {\n target: this,\n props: this._props,\n });\n }\n };\n\n return Cls as unknown as ViewComponentClass;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAmCA,SAAS,eAAyB;AAEhC,QAAM,IAAI;AACV,SAAO,EAAE,eAAe,MAAM;AAAA,EAAC;AACjC;AAoBO,SAAS,WAAW,WAAgB,MAAoC;AAC7E,QAAM,OAAO,aAAa;AAE1B,QAAM,MAAM,cAAc,KAAK;AAAA,IAC7B,OAAO,WAAW,KAAK;AAAA,IACvB,OAAO,cAAc,KAAK;AAAA,IAE1B,QAAiC,CAAC;AAAA;AAAA,IAElC,YAAiB;AAAA;AAAA,IAEjB,SAAc;AAAA,IACd,WAAW;AAAA,IAEX,IAAI,KAAK,GAA4B;AACnC,WAAK,QAAQ;AACb,UAAI,KAAK,QAAQ;AAEf,aAAK,OAAO,OAAO;AAAA,MACrB,WAAW,KAAK,UAAU;AACxB,aAAK,OAAO;AAAA,MACd;AAAA,IACF;AAAA,IAEA,IAAI,OAAO;AACT,aAAO,KAAK;AAAA,IACd;AAAA,IAEA,oBAAoB;AAClB,WAAK,WAAW;AAChB,WAAK,OAAO;AAAA,IACd;AAAA,IAEA,uBAAuB;AACrB,WAAK,WAAW;AAChB,UAAI,KAAK,WAAW;AAElB,QAAC,SAAS,yBAAyB,EAAE,EAAqC;AAAA,UACxE,CAAC,EAAE,QAAQ,MAAM;AACf,gBAAI,KAAK,WAAW;AAClB,sBAAQ,KAAK,SAAS;AACtB,mBAAK,YAAY;AACjB,mBAAK,SAAS;AAAA,YAChB;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IAEA,MAAM,SAAS;AAGb,YAAM,SAAc,MAAO,SAAS,yBAAyB,EAAE;AAC/D,UAAI,CAAC,KAAK,SAAU;AAGpB,UAAI,KAAK,WAAW;AAClB,eAAO,QAAQ,KAAK,SAAS;AAAA,MAC/B;AAGA,WAAK,SAAS,EAAE,MAAM,KAAK,MAAM;AACjC,WAAK,YAAY,OAAO,MAAM,WAAW;AAAA,QACvC,QAAQ;AAAA,QACR,OAAO,KAAK;AAAA,MACd,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { V as ViewComponentClass } from './views-DL60k0cf.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Svelte 5 adapter for firegraph views.
|
|
5
|
+
*
|
|
6
|
+
* Wraps a Svelte component into a Web Component (HTMLElement) that satisfies
|
|
7
|
+
* the firegraph `ViewComponentClass` contract. Import from `firegraph/svelte`:
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { wrapSvelte } from 'firegraph/svelte';
|
|
12
|
+
* import TaskCard from './TaskCard.svelte';
|
|
13
|
+
*
|
|
14
|
+
* export default [
|
|
15
|
+
* wrapSvelte(TaskCard, { viewName: 'card', description: 'Compact task card' }),
|
|
16
|
+
* ];
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/** Metadata required for every firegraph view. */
|
|
21
|
+
interface ViewMeta {
|
|
22
|
+
/** Short identifier (e.g. 'card', 'detail'). */
|
|
23
|
+
viewName: string;
|
|
24
|
+
/** Optional human-readable description. */
|
|
25
|
+
description?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Wrap a Svelte 5 component into a firegraph `ViewComponentClass`.
|
|
29
|
+
*
|
|
30
|
+
* The returned class extends `HTMLElement` and lazily imports `svelte` at
|
|
31
|
+
* mount time. Svelte is resolved from the project's own `node_modules` —
|
|
32
|
+
* firegraph does not bundle or depend on Svelte itself.
|
|
33
|
+
*
|
|
34
|
+
* The Svelte component should accept a `data` prop:
|
|
35
|
+
* ```svelte
|
|
36
|
+
* <script>
|
|
37
|
+
* let { data } = $props();
|
|
38
|
+
* </script>
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* Props are updated by mutating the props object — Svelte 5's reactivity
|
|
42
|
+
* system picks up the changes automatically.
|
|
43
|
+
*/
|
|
44
|
+
declare function wrapSvelte(Component: any, meta: ViewMeta): ViewComponentClass;
|
|
45
|
+
|
|
46
|
+
export { type ViewMeta, wrapSvelte };
|
package/dist/svelte.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { V as ViewComponentClass } from './views-DL60k0cf.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Svelte 5 adapter for firegraph views.
|
|
5
|
+
*
|
|
6
|
+
* Wraps a Svelte component into a Web Component (HTMLElement) that satisfies
|
|
7
|
+
* the firegraph `ViewComponentClass` contract. Import from `firegraph/svelte`:
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { wrapSvelte } from 'firegraph/svelte';
|
|
12
|
+
* import TaskCard from './TaskCard.svelte';
|
|
13
|
+
*
|
|
14
|
+
* export default [
|
|
15
|
+
* wrapSvelte(TaskCard, { viewName: 'card', description: 'Compact task card' }),
|
|
16
|
+
* ];
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/** Metadata required for every firegraph view. */
|
|
21
|
+
interface ViewMeta {
|
|
22
|
+
/** Short identifier (e.g. 'card', 'detail'). */
|
|
23
|
+
viewName: string;
|
|
24
|
+
/** Optional human-readable description. */
|
|
25
|
+
description?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Wrap a Svelte 5 component into a firegraph `ViewComponentClass`.
|
|
29
|
+
*
|
|
30
|
+
* The returned class extends `HTMLElement` and lazily imports `svelte` at
|
|
31
|
+
* mount time. Svelte is resolved from the project's own `node_modules` —
|
|
32
|
+
* firegraph does not bundle or depend on Svelte itself.
|
|
33
|
+
*
|
|
34
|
+
* The Svelte component should accept a `data` prop:
|
|
35
|
+
* ```svelte
|
|
36
|
+
* <script>
|
|
37
|
+
* let { data } = $props();
|
|
38
|
+
* </script>
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* Props are updated by mutating the props object — Svelte 5's reactivity
|
|
42
|
+
* system picks up the changes automatically.
|
|
43
|
+
*/
|
|
44
|
+
declare function wrapSvelte(Component: any, meta: ViewMeta): ViewComponentClass;
|
|
45
|
+
|
|
46
|
+
export { type ViewMeta, wrapSvelte };
|
package/dist/svelte.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// src/svelte.ts
|
|
2
|
+
function getBaseClass() {
|
|
3
|
+
const g = globalThis;
|
|
4
|
+
return g.HTMLElement ?? class {
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
function wrapSvelte(Component, meta) {
|
|
8
|
+
const Base = getBaseClass();
|
|
9
|
+
const Cls = class extends Base {
|
|
10
|
+
static viewName = meta.viewName;
|
|
11
|
+
static description = meta.description;
|
|
12
|
+
_data = {};
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
+
_instance = null;
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
+
_props = null;
|
|
17
|
+
_mounted = false;
|
|
18
|
+
set data(v) {
|
|
19
|
+
this._data = v;
|
|
20
|
+
if (this._props) {
|
|
21
|
+
this._props.data = v;
|
|
22
|
+
} else if (this._mounted) {
|
|
23
|
+
this._mount();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
get data() {
|
|
27
|
+
return this._data;
|
|
28
|
+
}
|
|
29
|
+
connectedCallback() {
|
|
30
|
+
this._mounted = true;
|
|
31
|
+
this._mount();
|
|
32
|
+
}
|
|
33
|
+
disconnectedCallback() {
|
|
34
|
+
this._mounted = false;
|
|
35
|
+
if (this._instance) {
|
|
36
|
+
Function('return import("svelte")')().then(
|
|
37
|
+
({ unmount }) => {
|
|
38
|
+
if (this._instance) {
|
|
39
|
+
unmount(this._instance);
|
|
40
|
+
this._instance = null;
|
|
41
|
+
this._props = null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async _mount() {
|
|
48
|
+
const svelte = await Function('return import("svelte")')();
|
|
49
|
+
if (!this._mounted) return;
|
|
50
|
+
if (this._instance) {
|
|
51
|
+
svelte.unmount(this._instance);
|
|
52
|
+
}
|
|
53
|
+
this._props = { data: this._data };
|
|
54
|
+
this._instance = svelte.mount(Component, {
|
|
55
|
+
target: this,
|
|
56
|
+
props: this._props
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
return Cls;
|
|
61
|
+
}
|
|
62
|
+
export {
|
|
63
|
+
wrapSvelte
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=svelte.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/svelte.ts"],"sourcesContent":["/**\n * Svelte 5 adapter for firegraph views.\n *\n * Wraps a Svelte component into a Web Component (HTMLElement) that satisfies\n * the firegraph `ViewComponentClass` contract. Import from `firegraph/svelte`:\n *\n * @example\n * ```ts\n * import { wrapSvelte } from 'firegraph/svelte';\n * import TaskCard from './TaskCard.svelte';\n *\n * export default [\n * wrapSvelte(TaskCard, { viewName: 'card', description: 'Compact task card' }),\n * ];\n * ```\n */\n\nimport type { ViewComponentClass } from './views.js';\n\n/** Metadata required for every firegraph view. */\nexport interface ViewMeta {\n /** Short identifier (e.g. 'card', 'detail'). */\n viewName: string;\n /** Optional human-readable description. */\n description?: string;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyClass = { new (...args: any[]): any };\n\n/**\n * Get HTMLElement from the runtime environment.\n * Returns a base class for view elements — works in both browser and Node.js\n * (where HTMLElement may be shimmed by the editor server).\n */\nfunction getBaseClass(): AnyClass {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const g = globalThis as any;\n return g.HTMLElement ?? class {};\n}\n\n/**\n * Wrap a Svelte 5 component into a firegraph `ViewComponentClass`.\n *\n * The returned class extends `HTMLElement` and lazily imports `svelte` at\n * mount time. Svelte is resolved from the project's own `node_modules` —\n * firegraph does not bundle or depend on Svelte itself.\n *\n * The Svelte component should accept a `data` prop:\n * ```svelte\n * <script>\n * let { data } = $props();\n * </script>\n * ```\n *\n * Props are updated by mutating the props object — Svelte 5's reactivity\n * system picks up the changes automatically.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function wrapSvelte(Component: any, meta: ViewMeta): ViewComponentClass {\n const Base = getBaseClass();\n\n const Cls = class extends Base {\n static viewName = meta.viewName;\n static description = meta.description;\n\n _data: Record<string, unknown> = {};\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n _instance: any = null;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n _props: any = null;\n _mounted = false;\n\n set data(v: Record<string, unknown>) {\n this._data = v;\n if (this._props) {\n // Svelte 5: mutating the props object triggers reactivity\n this._props.data = v;\n } else if (this._mounted) {\n this._mount();\n }\n }\n\n get data() {\n return this._data;\n }\n\n connectedCallback() {\n this._mounted = true;\n this._mount();\n }\n\n disconnectedCallback() {\n this._mounted = false;\n if (this._instance) {\n // Dynamic import — resolved from project's node_modules at runtime\n (Function('return import(\"svelte\")')() as Promise<{ unmount: Function }>).then(\n ({ unmount }) => {\n if (this._instance) {\n unmount(this._instance);\n this._instance = null;\n this._props = null;\n }\n },\n );\n }\n }\n\n async _mount() {\n // Dynamic import — resolved from project's node_modules at runtime\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const svelte: any = await (Function('return import(\"svelte\")')() as Promise<unknown>);\n if (!this._mounted) return; // disconnected while awaiting\n\n // Clean up previous instance\n if (this._instance) {\n svelte.unmount(this._instance);\n }\n\n // Svelte 5: pass a props object — mutating it later triggers re-renders\n this._props = { data: this._data };\n this._instance = svelte.mount(Component, {\n target: this,\n props: this._props,\n });\n }\n };\n\n return Cls as unknown as ViewComponentClass;\n}\n"],"mappings":";AAmCA,SAAS,eAAyB;AAEhC,QAAM,IAAI;AACV,SAAO,EAAE,eAAe,MAAM;AAAA,EAAC;AACjC;AAoBO,SAAS,WAAW,WAAgB,MAAoC;AAC7E,QAAM,OAAO,aAAa;AAE1B,QAAM,MAAM,cAAc,KAAK;AAAA,IAC7B,OAAO,WAAW,KAAK;AAAA,IACvB,OAAO,cAAc,KAAK;AAAA,IAE1B,QAAiC,CAAC;AAAA;AAAA,IAElC,YAAiB;AAAA;AAAA,IAEjB,SAAc;AAAA,IACd,WAAW;AAAA,IAEX,IAAI,KAAK,GAA4B;AACnC,WAAK,QAAQ;AACb,UAAI,KAAK,QAAQ;AAEf,aAAK,OAAO,OAAO;AAAA,MACrB,WAAW,KAAK,UAAU;AACxB,aAAK,OAAO;AAAA,MACd;AAAA,IACF;AAAA,IAEA,IAAI,OAAO;AACT,aAAO,KAAK;AAAA,IACd;AAAA,IAEA,oBAAoB;AAClB,WAAK,WAAW;AAChB,WAAK,OAAO;AAAA,IACd;AAAA,IAEA,uBAAuB;AACrB,WAAK,WAAW;AAChB,UAAI,KAAK,WAAW;AAElB,QAAC,SAAS,yBAAyB,EAAE,EAAqC;AAAA,UACxE,CAAC,EAAE,QAAQ,MAAM;AACf,gBAAI,KAAK,WAAW;AAClB,sBAAQ,KAAK,SAAS;AACtB,mBAAK,YAAY;AACjB,mBAAK,SAAS;AAAA,YAChB;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IAEA,MAAM,SAAS;AAGb,YAAM,SAAc,MAAO,SAAS,yBAAyB,EAAE;AAC/D,UAAI,CAAC,KAAK,SAAU;AAGpB,UAAI,KAAK,WAAW;AAClB,eAAO,QAAQ,KAAK,SAAS;AAAA,MAC/B;AAGA,WAAK,SAAS,EAAE,MAAM,KAAK,MAAM;AACjC,WAAK,YAAY,OAAO,MAAM,WAAW;AAAA,QACvC,QAAQ;AAAA,QACR,OAAO,KAAK;AAAA,MACd,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model Views — framework-agnostic view definitions for graph entities.
|
|
3
|
+
*
|
|
4
|
+
* Projects define Web Components that render entity data in purpose-driven
|
|
5
|
+
* ways. Each view class declares a static `viewName`, and receives the
|
|
6
|
+
* entity's `data` payload via a `data` property setter.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { defineViews } from 'firegraph';
|
|
11
|
+
*
|
|
12
|
+
* class UserCard extends HTMLElement {
|
|
13
|
+
* static viewName = 'card';
|
|
14
|
+
* static description = 'Compact user card';
|
|
15
|
+
* private _data: Record<string, unknown> = {};
|
|
16
|
+
* set data(v: Record<string, unknown>) { this._data = v; this.render(); }
|
|
17
|
+
* connectedCallback() { this.render(); }
|
|
18
|
+
* private render() {
|
|
19
|
+
* this.innerHTML = `<strong>${this._data.displayName ?? ''}</strong>`;
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
*
|
|
23
|
+
* export default defineViews({
|
|
24
|
+
* nodes: { user: { views: [UserCard] } },
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* A Web Component class used as a view. The class must have a static
|
|
30
|
+
* `viewName` and must be constructable. It will be registered as a custom
|
|
31
|
+
* element via `customElements.define()` in browser environments.
|
|
32
|
+
*
|
|
33
|
+
* Note: this interface avoids referencing `HTMLElement` directly so the
|
|
34
|
+
* library can compile without DOM lib types. Consumer code (which has DOM)
|
|
35
|
+
* will satisfy this constraint naturally.
|
|
36
|
+
*/
|
|
37
|
+
interface ViewComponentClass {
|
|
38
|
+
new (...args: any[]): {
|
|
39
|
+
data: Record<string, unknown>;
|
|
40
|
+
};
|
|
41
|
+
/** Short identifier for this view (e.g. 'card', 'profile'). */
|
|
42
|
+
viewName: string;
|
|
43
|
+
/** Optional human-readable description. */
|
|
44
|
+
description?: string;
|
|
45
|
+
}
|
|
46
|
+
/** Configuration for all views of a single entity type. */
|
|
47
|
+
interface EntityViewConfig {
|
|
48
|
+
/** View component classes to register. */
|
|
49
|
+
views: ViewComponentClass[];
|
|
50
|
+
/**
|
|
51
|
+
* Optional sample data for the gallery. A single object matching
|
|
52
|
+
* the entity's JSON Schema — shared across all views.
|
|
53
|
+
*/
|
|
54
|
+
sampleData?: Record<string, unknown>;
|
|
55
|
+
}
|
|
56
|
+
/** Input shape accepted by `defineViews()`. */
|
|
57
|
+
interface ViewRegistryInput {
|
|
58
|
+
/** Node views keyed by aType (e.g. 'user', 'tour'). */
|
|
59
|
+
nodes?: Record<string, EntityViewConfig>;
|
|
60
|
+
/** Edge views keyed by axbType (e.g. 'hasDeparture'). */
|
|
61
|
+
edges?: Record<string, EntityViewConfig>;
|
|
62
|
+
}
|
|
63
|
+
/** Serialisable metadata for a single view. */
|
|
64
|
+
interface ViewMeta {
|
|
65
|
+
/** Custom element tag name (e.g. 'fg-user-card'). */
|
|
66
|
+
tagName: string;
|
|
67
|
+
/** Short identifier matching the component's static viewName. */
|
|
68
|
+
viewName: string;
|
|
69
|
+
/** Optional human-readable description. */
|
|
70
|
+
description?: string;
|
|
71
|
+
}
|
|
72
|
+
/** Serialisable metadata for all views of a single entity type. */
|
|
73
|
+
interface EntityViewMeta {
|
|
74
|
+
views: ViewMeta[];
|
|
75
|
+
sampleData?: Record<string, unknown>;
|
|
76
|
+
}
|
|
77
|
+
/** The resolved view registry returned by `defineViews()`. */
|
|
78
|
+
interface ViewRegistry {
|
|
79
|
+
nodes: Record<string, EntityViewMeta>;
|
|
80
|
+
edges: Record<string, EntityViewMeta>;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Build a `ViewRegistry` from component classes.
|
|
84
|
+
*
|
|
85
|
+
* In the browser the components are registered as custom elements with
|
|
86
|
+
* deterministic tag names (`fg-{entityType}-{viewName}`). On the server
|
|
87
|
+
* (Node.js) only metadata is returned — no custom element registration.
|
|
88
|
+
*/
|
|
89
|
+
declare function defineViews(input: ViewRegistryInput): ViewRegistry;
|
|
90
|
+
|
|
91
|
+
export { type EntityViewConfig as E, type ViewComponentClass as V, type EntityViewMeta as a, type ViewMeta as b, type ViewRegistry as c, type ViewRegistryInput as d, defineViews as e };
|