@particle-academy/fancy-3d 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/README.md +84 -0
- package/dist/babylon.cjs +773 -0
- package/dist/babylon.cjs.map +1 -0
- package/dist/babylon.d.cts +229 -0
- package/dist/babylon.d.ts +229 -0
- package/dist/babylon.js +754 -0
- package/dist/babylon.js.map +1 -0
- package/dist/dom.cjs +225 -0
- package/dist/dom.cjs.map +1 -0
- package/dist/dom.d.cts +16 -0
- package/dist/dom.d.ts +16 -0
- package/dist/dom.js +223 -0
- package/dist/dom.js.map +1 -0
- package/dist/index.cjs +16 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +188 -0
- package/dist/index.d.ts +188 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/react.cjs +311 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +60 -0
- package/dist/react.d.ts +60 -0
- package/dist/react.js +307 -0
- package/dist/react.js.map +1 -0
- package/docs/babylon-adapter.md +127 -0
- package/docs/dom-adapter.md +97 -0
- package/docs/primitives.md +168 -0
- package/docs/scene.md +122 -0
- package/docs/screen.md +97 -0
- package/package.json +104 -0
package/dist/dom.js
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { useRef, useEffect } from 'react';
|
|
2
|
+
import { Card, Badge, Timeline, Action, Switch, Callout, Profile } from '@particle-academy/react-fancy';
|
|
3
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
// src/dom.tsx
|
|
6
|
+
function ScreenWidget({ spec }) {
|
|
7
|
+
const ref = useRef(null);
|
|
8
|
+
const t = spec.bezelThickness ?? 14;
|
|
9
|
+
const on = spec.on ?? true;
|
|
10
|
+
const brightness = spec.brightness ?? (on ? 1 : 0.06);
|
|
11
|
+
const bezel = spec.bezel ?? "#0b0f17";
|
|
12
|
+
const bg = spec.background ?? "#020617";
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (spec.content.type !== "paint") return;
|
|
15
|
+
const cv = ref.current;
|
|
16
|
+
if (!cv) return;
|
|
17
|
+
const dpr = window.devicePixelRatio ?? 1;
|
|
18
|
+
const rect = cv.getBoundingClientRect();
|
|
19
|
+
cv.width = rect.width * dpr;
|
|
20
|
+
cv.height = rect.height * dpr;
|
|
21
|
+
const ctx = cv.getContext("2d");
|
|
22
|
+
if (!ctx) return;
|
|
23
|
+
ctx.scale(dpr, dpr);
|
|
24
|
+
ctx.clearRect(0, 0, rect.width, rect.height);
|
|
25
|
+
spec.content.paint(ctx, rect.width, rect.height);
|
|
26
|
+
}, [spec.content]);
|
|
27
|
+
return /* @__PURE__ */ jsxs(
|
|
28
|
+
"div",
|
|
29
|
+
{
|
|
30
|
+
className: "relative h-full w-full overflow-hidden rounded-2xl",
|
|
31
|
+
style: { background: bezel, padding: t },
|
|
32
|
+
children: [
|
|
33
|
+
/* @__PURE__ */ jsxs(
|
|
34
|
+
"div",
|
|
35
|
+
{
|
|
36
|
+
className: "relative h-full w-full overflow-hidden rounded-md",
|
|
37
|
+
style: { background: bg, opacity: brightness },
|
|
38
|
+
children: [
|
|
39
|
+
spec.content.type === "label" && /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col items-center justify-center text-center", children: [
|
|
40
|
+
/* @__PURE__ */ jsx("div", { className: "text-lg font-bold text-zinc-100", children: spec.content.title }),
|
|
41
|
+
spec.content.subtitle && /* @__PURE__ */ jsx("div", { className: "mt-1 text-xs text-zinc-400", children: spec.content.subtitle })
|
|
42
|
+
] }),
|
|
43
|
+
spec.content.type === "image" && /* @__PURE__ */ jsx("img", { src: spec.content.src, alt: spec.content.alt ?? "", className: "h-full w-full object-cover" }),
|
|
44
|
+
spec.content.type === "paint" && /* @__PURE__ */ jsx("canvas", { ref, className: "block h-full w-full" }),
|
|
45
|
+
/* @__PURE__ */ jsx("div", { className: "pointer-events-none absolute inset-0 bg-gradient-to-b from-white/5 to-transparent" })
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
),
|
|
49
|
+
/* @__PURE__ */ jsx(
|
|
50
|
+
"span",
|
|
51
|
+
{
|
|
52
|
+
className: "absolute bottom-2 right-2 h-1.5 w-1.5 rounded-full",
|
|
53
|
+
style: { background: on ? "#10b981" : "#475569" }
|
|
54
|
+
}
|
|
55
|
+
)
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
function Sparkline({ values, variant, color = "#6366f1" }) {
|
|
61
|
+
const w = 100;
|
|
62
|
+
const h = 40;
|
|
63
|
+
const max = Math.max(...values, 1);
|
|
64
|
+
const min = Math.min(...values, 0);
|
|
65
|
+
const range = max - min || 1;
|
|
66
|
+
const step = w / Math.max(values.length - 1, 1);
|
|
67
|
+
const points = values.map((v, i) => [i * step, h - (v - min) / range * h]);
|
|
68
|
+
if (variant === "bar") {
|
|
69
|
+
const bw = w / values.length - 2;
|
|
70
|
+
return /* @__PURE__ */ jsx("svg", { viewBox: `0 0 ${w} ${h}`, preserveAspectRatio: "none", className: "h-full w-full", children: values.map((v, i) => {
|
|
71
|
+
const bh = (v - min) / range * h;
|
|
72
|
+
return /* @__PURE__ */ jsx("rect", { x: i * (bw + 2), y: h - bh, width: bw, height: Math.max(bh, 0.5), fill: color, rx: 1 }, i);
|
|
73
|
+
}) });
|
|
74
|
+
}
|
|
75
|
+
const path = points.map(([x, y], i) => `${i === 0 ? "M" : "L"}${x},${y}`).join(" ");
|
|
76
|
+
const areaPath = `${path} L${w},${h} L0,${h} Z`;
|
|
77
|
+
return /* @__PURE__ */ jsxs("svg", { viewBox: `0 0 ${w} ${h}`, preserveAspectRatio: "none", className: "h-full w-full", children: [
|
|
78
|
+
variant === "area" && /* @__PURE__ */ jsx("path", { d: areaPath, fill: color, fillOpacity: 0.18 }),
|
|
79
|
+
/* @__PURE__ */ jsx("path", { d: path, fill: "none", stroke: color, strokeWidth: 1.5, vectorEffect: "non-scaling-stroke" })
|
|
80
|
+
] });
|
|
81
|
+
}
|
|
82
|
+
function actionColorFor(b) {
|
|
83
|
+
if (b.variant === "primary") return "indigo";
|
|
84
|
+
return void 0;
|
|
85
|
+
}
|
|
86
|
+
function actionVariantFor(b) {
|
|
87
|
+
return b.variant === "ghost" ? "ghost" : "default";
|
|
88
|
+
}
|
|
89
|
+
function renderWidget(spec) {
|
|
90
|
+
switch (spec.kind) {
|
|
91
|
+
case "kpi":
|
|
92
|
+
return /* @__PURE__ */ jsx(Card, { className: "h-full", children: /* @__PURE__ */ jsxs(Card.Body, { children: [
|
|
93
|
+
/* @__PURE__ */ jsx("div", { className: "text-xs font-medium tracking-wide text-zinc-500 uppercase", children: spec.label }),
|
|
94
|
+
/* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-baseline gap-2", children: [
|
|
95
|
+
/* @__PURE__ */ jsx("div", { className: "text-2xl font-bold text-zinc-900 dark:text-zinc-100", children: spec.value }),
|
|
96
|
+
spec.delta && /* @__PURE__ */ jsx(
|
|
97
|
+
"span",
|
|
98
|
+
{
|
|
99
|
+
className: spec.trend === "up" ? "text-xs font-medium text-emerald-600" : spec.trend === "down" ? "text-xs font-medium text-rose-600" : "text-xs font-medium text-zinc-500",
|
|
100
|
+
children: spec.delta
|
|
101
|
+
}
|
|
102
|
+
)
|
|
103
|
+
] })
|
|
104
|
+
] }) });
|
|
105
|
+
case "chart":
|
|
106
|
+
return /* @__PURE__ */ jsx(Card, { className: "h-full", children: /* @__PURE__ */ jsxs(Card.Body, { className: "flex h-full flex-col", children: [
|
|
107
|
+
/* @__PURE__ */ jsx("div", { className: "mb-2 text-xs font-medium tracking-wide text-zinc-500 uppercase", children: spec.title }),
|
|
108
|
+
/* @__PURE__ */ jsx("div", { className: "min-h-0 flex-1", children: /* @__PURE__ */ jsx(Sparkline, { values: spec.series, variant: spec.variant, color: spec.color }) })
|
|
109
|
+
] }) });
|
|
110
|
+
case "kanban":
|
|
111
|
+
return /* @__PURE__ */ jsx(Card, { className: "h-full", children: /* @__PURE__ */ jsx(Card.Body, { className: "flex h-full gap-2", children: spec.columns.map((col) => /* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col rounded-lg bg-zinc-50 p-2 dark:bg-zinc-800/50", children: [
|
|
112
|
+
/* @__PURE__ */ jsx("div", { className: "mb-2 text-[10px] font-semibold tracking-wider text-zinc-500 uppercase", children: col.title }),
|
|
113
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1.5", children: col.cards.map((c) => /* @__PURE__ */ jsx("div", { className: "rounded border border-zinc-200 bg-white px-2 py-1.5 text-xs dark:border-zinc-700 dark:bg-zinc-900", children: c }, c)) })
|
|
114
|
+
] }, col.title)) }) });
|
|
115
|
+
case "table":
|
|
116
|
+
return /* @__PURE__ */ jsx(Card, { className: "h-full", children: /* @__PURE__ */ jsxs(Card.Body, { className: "flex h-full flex-col", children: [
|
|
117
|
+
/* @__PURE__ */ jsx("div", { className: "mb-2 text-xs font-medium tracking-wide text-zinc-500 uppercase", children: spec.title }),
|
|
118
|
+
/* @__PURE__ */ jsx("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ jsxs("table", { className: "w-full text-xs", children: [
|
|
119
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { className: "text-left text-zinc-500", children: spec.columns.map((c) => /* @__PURE__ */ jsx("th", { className: "border-b border-zinc-200 py-1.5 font-medium dark:border-zinc-700", children: c }, c)) }) }),
|
|
120
|
+
/* @__PURE__ */ jsx("tbody", { children: spec.rows.map((row, i) => /* @__PURE__ */ jsx("tr", { className: "text-zinc-700 dark:text-zinc-300", children: row.map((cell, j) => /* @__PURE__ */ jsx("td", { className: "border-b border-zinc-100 py-1.5 dark:border-zinc-800", children: cell }, j)) }, i)) })
|
|
121
|
+
] }) })
|
|
122
|
+
] }) });
|
|
123
|
+
case "profile":
|
|
124
|
+
return /* @__PURE__ */ jsx(Card, { className: "h-full", children: /* @__PURE__ */ jsx(Card.Body, { children: /* @__PURE__ */ jsx(
|
|
125
|
+
Profile,
|
|
126
|
+
{
|
|
127
|
+
name: spec.name,
|
|
128
|
+
subtitle: spec.role,
|
|
129
|
+
fallback: spec.initials,
|
|
130
|
+
status: spec.status === "online" ? "online" : spec.status === "away" ? "away" : void 0
|
|
131
|
+
}
|
|
132
|
+
) }) });
|
|
133
|
+
case "callout": {
|
|
134
|
+
const color = spec.tone === "danger" ? "red" : spec.tone === "warning" ? "amber" : spec.tone === "success" ? "green" : "blue";
|
|
135
|
+
return /* @__PURE__ */ jsxs(Callout, { color, children: [
|
|
136
|
+
/* @__PURE__ */ jsx("div", { className: "text-sm font-semibold", children: spec.title }),
|
|
137
|
+
/* @__PURE__ */ jsx("div", { className: "mt-0.5 text-xs", children: spec.body })
|
|
138
|
+
] });
|
|
139
|
+
}
|
|
140
|
+
case "form":
|
|
141
|
+
return /* @__PURE__ */ jsx(Card, { className: "h-full", children: /* @__PURE__ */ jsxs(Card.Body, { className: "flex h-full flex-col gap-2", children: [
|
|
142
|
+
/* @__PURE__ */ jsx("div", { className: "text-xs font-medium tracking-wide text-zinc-500 uppercase", children: spec.title }),
|
|
143
|
+
spec.fields.map((f) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
|
|
144
|
+
/* @__PURE__ */ jsx("label", { className: "text-xs text-zinc-600 dark:text-zinc-400", children: f.label }),
|
|
145
|
+
f.type === "switch" ? /* @__PURE__ */ jsx(Switch, { defaultChecked: true }) : /* @__PURE__ */ jsx(
|
|
146
|
+
"input",
|
|
147
|
+
{
|
|
148
|
+
type: f.type === "number" ? "number" : "text",
|
|
149
|
+
className: "w-28 rounded border border-zinc-200 bg-white px-2 py-1 text-xs dark:border-zinc-700 dark:bg-zinc-900",
|
|
150
|
+
placeholder: f.label
|
|
151
|
+
}
|
|
152
|
+
)
|
|
153
|
+
] }, f.id))
|
|
154
|
+
] }) });
|
|
155
|
+
case "action":
|
|
156
|
+
return /* @__PURE__ */ jsx(Card, { className: "h-full", children: /* @__PURE__ */ jsxs(Card.Body, { children: [
|
|
157
|
+
/* @__PURE__ */ jsx("div", { className: "mb-2 text-xs font-medium tracking-wide text-zinc-500 uppercase", children: spec.title }),
|
|
158
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: spec.buttons.map((b) => /* @__PURE__ */ jsx(
|
|
159
|
+
Action,
|
|
160
|
+
{
|
|
161
|
+
variant: actionVariantFor(b),
|
|
162
|
+
color: actionColorFor(b),
|
|
163
|
+
size: "sm",
|
|
164
|
+
children: b.label
|
|
165
|
+
},
|
|
166
|
+
b.label
|
|
167
|
+
)) })
|
|
168
|
+
] }) });
|
|
169
|
+
case "timeline":
|
|
170
|
+
return /* @__PURE__ */ jsx(Card, { className: "h-full", children: /* @__PURE__ */ jsxs(Card.Body, { className: "flex h-full flex-col", children: [
|
|
171
|
+
/* @__PURE__ */ jsx("div", { className: "mb-2 text-xs font-medium tracking-wide text-zinc-500 uppercase", children: spec.title }),
|
|
172
|
+
/* @__PURE__ */ jsx("div", { className: "min-h-0 flex-1 overflow-auto", children: /* @__PURE__ */ jsx(Timeline, { events: spec.events.map((e) => ({ date: e.at, title: e.label })) }) })
|
|
173
|
+
] }) });
|
|
174
|
+
case "code":
|
|
175
|
+
return /* @__PURE__ */ jsx(Card, { className: "h-full", children: /* @__PURE__ */ jsxs(Card.Body, { className: "flex h-full flex-col", children: [
|
|
176
|
+
/* @__PURE__ */ jsxs("div", { className: "mb-2 flex items-center justify-between", children: [
|
|
177
|
+
/* @__PURE__ */ jsx("div", { className: "text-xs font-medium tracking-wide text-zinc-500 uppercase", children: spec.title }),
|
|
178
|
+
/* @__PURE__ */ jsx(Badge, { size: "sm", children: spec.language })
|
|
179
|
+
] }),
|
|
180
|
+
/* @__PURE__ */ jsx("pre", { className: "min-h-0 flex-1 overflow-auto rounded bg-zinc-900 p-2 font-mono text-[11px] leading-relaxed text-zinc-100", children: spec.code })
|
|
181
|
+
] }) });
|
|
182
|
+
case "image":
|
|
183
|
+
return /* @__PURE__ */ jsxs(Card, { className: "h-full overflow-hidden", children: [
|
|
184
|
+
/* @__PURE__ */ jsx("img", { src: spec.src, alt: spec.alt, className: "h-full w-full object-cover" }),
|
|
185
|
+
spec.caption && /* @__PURE__ */ jsx(Card.Body, { className: "text-xs text-zinc-500", children: spec.caption })
|
|
186
|
+
] });
|
|
187
|
+
case "text":
|
|
188
|
+
return /* @__PURE__ */ jsx(Card, { className: "h-full", children: /* @__PURE__ */ jsxs(Card.Body, { children: [
|
|
189
|
+
/* @__PURE__ */ jsx("div", { className: "text-sm font-semibold text-zinc-900 dark:text-zinc-100", children: spec.heading }),
|
|
190
|
+
/* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-zinc-600 dark:text-zinc-400", children: spec.body })
|
|
191
|
+
] }) });
|
|
192
|
+
case "screen":
|
|
193
|
+
return /* @__PURE__ */ jsx(ScreenWidget, { spec });
|
|
194
|
+
case "demoPage":
|
|
195
|
+
return /* @__PURE__ */ jsxs(Card, { className: "flex h-full flex-col overflow-hidden", children: [
|
|
196
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-3 py-2", style: { background: spec.accent }, children: [
|
|
197
|
+
/* @__PURE__ */ jsx("span", { className: "rounded-full bg-white/20 px-2 py-0.5 text-[10px] font-bold tracking-wider text-white uppercase", children: spec.category }),
|
|
198
|
+
/* @__PURE__ */ jsx("span", { className: "font-mono text-[10px] text-white/85", children: spec.path })
|
|
199
|
+
] }),
|
|
200
|
+
/* @__PURE__ */ jsxs(Card.Body, { className: "flex flex-1 flex-col", children: [
|
|
201
|
+
/* @__PURE__ */ jsx("div", { className: "text-base font-extrabold text-zinc-900 dark:text-zinc-100", children: spec.name }),
|
|
202
|
+
/* @__PURE__ */ jsx("p", { className: "mt-1 flex-1 text-xs text-zinc-500", children: spec.description }),
|
|
203
|
+
/* @__PURE__ */ jsx("span", { className: "mt-2 inline-flex items-center self-start rounded-md px-2 py-1 text-[11px] font-semibold", style: { background: spec.accent, color: "#0f172a" }, children: "Open demo \u2192" })
|
|
204
|
+
] })
|
|
205
|
+
] });
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
var domAdapter = {
|
|
209
|
+
render(spec, ctx) {
|
|
210
|
+
return /* @__PURE__ */ jsx(
|
|
211
|
+
"div",
|
|
212
|
+
{
|
|
213
|
+
className: ctx.selected ? "h-full w-full rounded-xl ring-2 ring-indigo-500 ring-offset-2 ring-offset-zinc-50 dark:ring-offset-zinc-950" : "h-full w-full",
|
|
214
|
+
onMouseDown: () => ctx.onSelect?.(ctx.nodeId),
|
|
215
|
+
children: renderWidget(spec)
|
|
216
|
+
}
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
export { domAdapter };
|
|
222
|
+
//# sourceMappingURL=dom.js.map
|
|
223
|
+
//# sourceMappingURL=dom.js.map
|
package/dist/dom.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/dom.tsx"],"names":[],"mappings":";;;;;AAcA,SAAS,YAAA,CAAa,EAAE,IAAA,EAAK,EAAyB;AACpD,EAAA,MAAM,GAAA,GAAM,OAAiC,IAAI,CAAA;AACjD,EAAA,MAAM,CAAA,GAAI,KAAK,cAAA,IAAkB,EAAA;AACjC,EAAA,MAAM,EAAA,GAAK,KAAK,EAAA,IAAM,IAAA;AACtB,EAAA,MAAM,UAAA,GAAa,IAAA,CAAK,UAAA,KAAe,EAAA,GAAK,CAAA,GAAI,IAAA,CAAA;AAChD,EAAA,MAAM,KAAA,GAAQ,KAAK,KAAA,IAAS,SAAA;AAC5B,EAAA,MAAM,EAAA,GAAK,KAAK,UAAA,IAAc,SAAA;AAE9B,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,IAAA,CAAK,OAAA,CAAQ,IAAA,KAAS,OAAA,EAAS;AACnC,IAAA,MAAM,KAAK,GAAA,CAAI,OAAA;AACf,IAAA,IAAI,C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,IAAA,CAAC,IAAA,CAAK,IAAA,EAAL,EAAU,WAAU,sBAAA,EACnB,QAAA,EAAA;AAAA,0BAAA,GAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,2DAAA,EAA6D,QAAA,EAAA,IAAA,CAAK,IAAA,EAAK,CAAA;AAAA,0BACtF,GAAA,CAAC,GAAA,EAAA,EAAE,SAAA,EAAU,mCAAA,EAAqC,eAAK,WAAA,EAAY,CAAA;AAAA,0BACnE,GAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,yFAAA,EAA0F,KAAA,EAAO,EAAE,UAAA,EAAY,IAAA,CAAK,MAAA,EAAQ,KAAA,EAAO,SAAA,EAAU,EAAG,QAAA,EAAA,kBAAA,EAEhK;AAAA,SAAA,EACF;AAAA,OAAA,EACF,CAAA;AAAA;AAGR;AAEO,IAAM,UAAA,GAAuC;AAAA,EAClD,MAAA,CAAO,MAAM,GAAA,EAAqB;AAChC,IAAA,uBACE,GAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,SAAA,EACE,GAAA,CAAI,QAAA,GACA,6GAAA,GACA,eAAA;AAAA,QAEN,WAAA,EAAa,MAAM,GAAA,CAAI,QAAA,GAAW,IAAI,MAAM,CAAA;AAAA,QAE3C,uBAAa,IAAI;AAAA;AAAA,KACpB;AAAA,EAEJ;AACF","file":"dom.js","sourcesContent":["/**\r\n * DOM adapter for `@particle-academy/fancy-3d`.\r\n *\r\n * Renders an engine-agnostic `Scene` to React elements composed from\r\n * `@particle-academy/react-fancy` components. This is the reference 2D\r\n * adapter — siblings include `./babylon` for 3D.\r\n *\r\n * `@particle-academy/react-fancy` is an OPTIONAL peer dependency.\r\n */\r\nimport { useEffect, useRef, type ReactNode } from \"react\";\r\nimport { Action, Badge, Card, Callout, Profile, Switch, Timeline } from \"@particle-academy/react-fancy\";\r\nimport type { ActionColor } from \"@particle-academy/react-fancy\";\r\nimport type { AdapterContext, ActionSpec, ScreenSpec, WidgetAdapter, WidgetSpec } from \"./scene\";\r\n\r\nfunction ScreenWidget({ spec }: { spec: ScreenSpec }) {\r\n const ref = useRef<HTMLCanvasElement | null>(null);\r\n const t = spec.bezelThickness ?? 14;\r\n const on = spec.on ?? true;\r\n const brightness = spec.brightness ?? (on ? 1 : 0.06);\r\n const bezel = spec.bezel ?? \"#0b0f17\";\r\n const bg = spec.background ?? \"#020617\";\r\n\r\n useEffect(() => {\r\n if (spec.content.type !== \"paint\") return;\r\n const cv = ref.current;\r\n if (!cv) return;\r\n const dpr = window.devicePixelRatio ?? 1;\r\n const rect = cv.getBoundingClientRect();\r\n cv.width = rect.width * dpr;\r\n cv.height = rect.height * dpr;\r\n const ctx = cv.getContext(\"2d\");\r\n if (!ctx) return;\r\n ctx.scale(dpr, dpr);\r\n ctx.clearRect(0, 0, rect.width, rect.height);\r\n spec.content.paint(ctx, rect.width, rect.height);\r\n }, [spec.content]);\r\n\r\n return (\r\n <div\r\n className=\"relative h-full w-full overflow-hidden rounded-2xl\"\r\n style={{ background: bezel, padding: t }}\r\n >\r\n <div\r\n className=\"relative h-full w-full overflow-hidden rounded-md\"\r\n style={{ background: bg, opacity: brightness }}\r\n >\r\n {spec.content.type === \"label\" && (\r\n <div className=\"flex h-full w-full flex-col items-center justify-center text-center\">\r\n <div className=\"text-lg font-bold text-zinc-100\">{spec.content.title}</div>\r\n {spec.content.subtitle && (\r\n <div className=\"mt-1 text-xs text-zinc-400\">{spec.content.subtitle}</div>\r\n )}\r\n </div>\r\n )}\r\n {spec.content.type === \"image\" && (\r\n <img src={spec.content.src} alt={spec.content.alt ?? \"\"} className=\"h-full w-full object-cover\" />\r\n )}\r\n {spec.content.type === \"paint\" && <canvas ref={ref} className=\"block h-full w-full\" />}\r\n <div className=\"pointer-events-none absolute inset-0 bg-gradient-to-b from-white/5 to-transparent\" />\r\n </div>\r\n <span\r\n className=\"absolute bottom-2 right-2 h-1.5 w-1.5 rounded-full\"\r\n style={{ background: on ? \"#10b981\" : \"#475569\" }}\r\n />\r\n </div>\r\n );\r\n}\r\n\r\nfunction Sparkline({ values, variant, color = \"#6366f1\" }: { values: number[]; variant: \"line\" | \"bar\" | \"area\"; color?: string }) {\r\n const w = 100;\r\n const h = 40;\r\n const max = Math.max(...values, 1);\r\n const min = Math.min(...values, 0);\r\n const range = max - min || 1;\r\n const step = w / Math.max(values.length - 1, 1);\r\n const points = values.map((v, i) => [i * step, h - ((v - min) / range) * h] as const);\r\n\r\n if (variant === \"bar\") {\r\n const bw = w / values.length - 2;\r\n return (\r\n <svg viewBox={`0 0 ${w} ${h}`} preserveAspectRatio=\"none\" className=\"h-full w-full\">\r\n {values.map((v, i) => {\r\n const bh = ((v - min) / range) * h;\r\n return <rect key={i} x={i * (bw + 2)} y={h - bh} width={bw} height={Math.max(bh, 0.5)} fill={color} rx={1} />;\r\n })}\r\n </svg>\r\n );\r\n }\r\n\r\n const path = points.map(([x, y], i) => `${i === 0 ? \"M\" : \"L\"}${x},${y}`).join(\" \");\r\n const areaPath = `${path} L${w},${h} L0,${h} Z`;\r\n\r\n return (\r\n <svg viewBox={`0 0 ${w} ${h}`} preserveAspectRatio=\"none\" className=\"h-full w-full\">\r\n {variant === \"area\" && <path d={areaPath} fill={color} fillOpacity={0.18} />}\r\n <path d={path} fill=\"none\" stroke={color} strokeWidth={1.5} vectorEffect=\"non-scaling-stroke\" />\r\n </svg>\r\n );\r\n}\r\n\r\nfunction actionColorFor(b: ActionSpec[\"buttons\"][number]): ActionColor | undefined {\r\n if (b.variant === \"primary\") return \"indigo\";\r\n return undefined;\r\n}\r\n\r\nfunction actionVariantFor(b: ActionSpec[\"buttons\"][number]): \"default\" | \"ghost\" {\r\n return b.variant === \"ghost\" ? \"ghost\" : \"default\";\r\n}\r\n\r\nfunction renderWidget(spec: WidgetSpec): ReactNode {\r\n switch (spec.kind) {\r\n case \"kpi\":\r\n return (\r\n <Card className=\"h-full\">\r\n <Card.Body>\r\n <div className=\"text-xs font-medium tracking-wide text-zinc-500 uppercase\">{spec.label}</div>\r\n <div className=\"mt-1 flex items-baseline gap-2\">\r\n <div className=\"text-2xl font-bold text-zinc-900 dark:text-zinc-100\">{spec.value}</div>\r\n {spec.delta && (\r\n <span\r\n className={\r\n spec.trend === \"up\"\r\n ? \"text-xs font-medium text-emerald-600\"\r\n : spec.trend === \"down\"\r\n ? \"text-xs font-medium text-rose-600\"\r\n : \"text-xs font-medium text-zinc-500\"\r\n }\r\n >\r\n {spec.delta}\r\n </span>\r\n )}\r\n </div>\r\n </Card.Body>\r\n </Card>\r\n );\r\n\r\n case \"chart\":\r\n return (\r\n <Card className=\"h-full\">\r\n <Card.Body className=\"flex h-full flex-col\">\r\n <div className=\"mb-2 text-xs font-medium tracking-wide text-zinc-500 uppercase\">{spec.title}</div>\r\n <div className=\"min-h-0 flex-1\">\r\n <Sparkline values={spec.series} variant={spec.variant} color={spec.color} />\r\n </div>\r\n </Card.Body>\r\n </Card>\r\n );\r\n\r\n case \"kanban\":\r\n return (\r\n <Card className=\"h-full\">\r\n <Card.Body className=\"flex h-full gap-2\">\r\n {spec.columns.map((col) => (\r\n <div key={col.title} className=\"flex flex-1 flex-col rounded-lg bg-zinc-50 p-2 dark:bg-zinc-800/50\">\r\n <div className=\"mb-2 text-[10px] font-semibold tracking-wider text-zinc-500 uppercase\">{col.title}</div>\r\n <div className=\"flex flex-col gap-1.5\">\r\n {col.cards.map((c) => (\r\n <div key={c} className=\"rounded border border-zinc-200 bg-white px-2 py-1.5 text-xs dark:border-zinc-700 dark:bg-zinc-900\">\r\n {c}\r\n </div>\r\n ))}\r\n </div>\r\n </div>\r\n ))}\r\n </Card.Body>\r\n </Card>\r\n );\r\n\r\n case \"table\":\r\n return (\r\n <Card className=\"h-full\">\r\n <Card.Body className=\"flex h-full flex-col\">\r\n <div className=\"mb-2 text-xs font-medium tracking-wide text-zinc-500 uppercase\">{spec.title}</div>\r\n <div className=\"min-h-0 flex-1 overflow-auto\">\r\n <table className=\"w-full text-xs\">\r\n <thead>\r\n <tr className=\"text-left text-zinc-500\">\r\n {spec.columns.map((c) => (\r\n <th key={c} className=\"border-b border-zinc-200 py-1.5 font-medium dark:border-zinc-700\">\r\n {c}\r\n </th>\r\n ))}\r\n </tr>\r\n </thead>\r\n <tbody>\r\n {spec.rows.map((row, i) => (\r\n <tr key={i} className=\"text-zinc-700 dark:text-zinc-300\">\r\n {row.map((cell, j) => (\r\n <td key={j} className=\"border-b border-zinc-100 py-1.5 dark:border-zinc-800\">\r\n {cell}\r\n </td>\r\n ))}\r\n </tr>\r\n ))}\r\n </tbody>\r\n </table>\r\n </div>\r\n </Card.Body>\r\n </Card>\r\n );\r\n\r\n case \"profile\":\r\n return (\r\n <Card className=\"h-full\">\r\n <Card.Body>\r\n <Profile\r\n name={spec.name}\r\n subtitle={spec.role}\r\n fallback={spec.initials}\r\n status={spec.status === \"online\" ? \"online\" : spec.status === \"away\" ? \"away\" : undefined}\r\n />\r\n </Card.Body>\r\n </Card>\r\n );\r\n\r\n case \"callout\": {\r\n const color = spec.tone === \"danger\" ? \"red\" : spec.tone === \"warning\" ? \"amber\" : spec.tone === \"success\" ? \"green\" : \"blue\";\r\n return (\r\n <Callout color={color}>\r\n <div className=\"text-sm font-semibold\">{spec.title}</div>\r\n <div className=\"mt-0.5 text-xs\">{spec.body}</div>\r\n </Callout>\r\n );\r\n }\r\n\r\n case \"form\":\r\n return (\r\n <Card className=\"h-full\">\r\n <Card.Body className=\"flex h-full flex-col gap-2\">\r\n <div className=\"text-xs font-medium tracking-wide text-zinc-500 uppercase\">{spec.title}</div>\r\n {spec.fields.map((f) => (\r\n <div key={f.id} className=\"flex items-center justify-between gap-2\">\r\n <label className=\"text-xs text-zinc-600 dark:text-zinc-400\">{f.label}</label>\r\n {f.type === \"switch\" ? (\r\n <Switch defaultChecked />\r\n ) : (\r\n <input\r\n type={f.type === \"number\" ? \"number\" : \"text\"}\r\n className=\"w-28 rounded border border-zinc-200 bg-white px-2 py-1 text-xs dark:border-zinc-700 dark:bg-zinc-900\"\r\n placeholder={f.label}\r\n />\r\n )}\r\n </div>\r\n ))}\r\n </Card.Body>\r\n </Card>\r\n );\r\n\r\n case \"action\":\r\n return (\r\n <Card className=\"h-full\">\r\n <Card.Body>\r\n <div className=\"mb-2 text-xs font-medium tracking-wide text-zinc-500 uppercase\">{spec.title}</div>\r\n <div className=\"flex flex-wrap gap-2\">\r\n {spec.buttons.map((b) => (\r\n <Action\r\n key={b.label}\r\n variant={actionVariantFor(b)}\r\n color={actionColorFor(b)}\r\n size=\"sm\"\r\n >\r\n {b.label}\r\n </Action>\r\n ))}\r\n </div>\r\n </Card.Body>\r\n </Card>\r\n );\r\n\r\n case \"timeline\":\r\n return (\r\n <Card className=\"h-full\">\r\n <Card.Body className=\"flex h-full flex-col\">\r\n <div className=\"mb-2 text-xs font-medium tracking-wide text-zinc-500 uppercase\">{spec.title}</div>\r\n <div className=\"min-h-0 flex-1 overflow-auto\">\r\n <Timeline events={spec.events.map((e) => ({ date: e.at, title: e.label }))} />\r\n </div>\r\n </Card.Body>\r\n </Card>\r\n );\r\n\r\n case \"code\":\r\n return (\r\n <Card className=\"h-full\">\r\n <Card.Body className=\"flex h-full flex-col\">\r\n <div className=\"mb-2 flex items-center justify-between\">\r\n <div className=\"text-xs font-medium tracking-wide text-zinc-500 uppercase\">{spec.title}</div>\r\n <Badge size=\"sm\">{spec.language}</Badge>\r\n </div>\r\n <pre className=\"min-h-0 flex-1 overflow-auto rounded bg-zinc-900 p-2 font-mono text-[11px] leading-relaxed text-zinc-100\">\r\n {spec.code}\r\n </pre>\r\n </Card.Body>\r\n </Card>\r\n );\r\n\r\n case \"image\":\r\n return (\r\n <Card className=\"h-full overflow-hidden\">\r\n <img src={spec.src} alt={spec.alt} className=\"h-full w-full object-cover\" />\r\n {spec.caption && <Card.Body className=\"text-xs text-zinc-500\">{spec.caption}</Card.Body>}\r\n </Card>\r\n );\r\n\r\n case \"text\":\r\n return (\r\n <Card className=\"h-full\">\r\n <Card.Body>\r\n <div className=\"text-sm font-semibold text-zinc-900 dark:text-zinc-100\">{spec.heading}</div>\r\n <p className=\"mt-1 text-xs text-zinc-600 dark:text-zinc-400\">{spec.body}</p>\r\n </Card.Body>\r\n </Card>\r\n );\r\n\r\n case \"screen\":\r\n return <ScreenWidget spec={spec} />;\r\n\r\n case \"demoPage\":\r\n return (\r\n <Card className=\"flex h-full flex-col overflow-hidden\">\r\n <div className=\"flex items-center justify-between px-3 py-2\" style={{ background: spec.accent }}>\r\n <span className=\"rounded-full bg-white/20 px-2 py-0.5 text-[10px] font-bold tracking-wider text-white uppercase\">\r\n {spec.category}\r\n </span>\r\n <span className=\"font-mono text-[10px] text-white/85\">{spec.path}</span>\r\n </div>\r\n <Card.Body className=\"flex flex-1 flex-col\">\r\n <div className=\"text-base font-extrabold text-zinc-900 dark:text-zinc-100\">{spec.name}</div>\r\n <p className=\"mt-1 flex-1 text-xs text-zinc-500\">{spec.description}</p>\r\n <span className=\"mt-2 inline-flex items-center self-start rounded-md px-2 py-1 text-[11px] font-semibold\" style={{ background: spec.accent, color: \"#0f172a\" }}>\r\n Open demo →\r\n </span>\r\n </Card.Body>\r\n </Card>\r\n );\r\n }\r\n}\r\n\r\nexport const domAdapter: WidgetAdapter<ReactNode> = {\r\n render(spec, ctx: AdapterContext) {\r\n return (\r\n <div\r\n className={\r\n ctx.selected\r\n ? \"h-full w-full rounded-xl ring-2 ring-indigo-500 ring-offset-2 ring-offset-zinc-50 dark:ring-offset-zinc-950\"\r\n : \"h-full w-full\"\r\n }\r\n onMouseDown={() => ctx.onSelect?.(ctx.nodeId)}\r\n >\r\n {renderWidget(spec)}\r\n </div>\r\n );\r\n },\r\n};\r\n"]}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/scene.ts
|
|
4
|
+
var _seq = 1e3;
|
|
5
|
+
function nextId(prefix) {
|
|
6
|
+
_seq += 1;
|
|
7
|
+
return `${prefix}-${_seq}`;
|
|
8
|
+
}
|
|
9
|
+
function renderScene(scene, adapter, ctxFor) {
|
|
10
|
+
return scene.nodes.map((node) => ({ node, rendered: adapter.render(node.widget, ctxFor(node)) }));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
exports.nextId = nextId;
|
|
14
|
+
exports.renderScene = renderScene;
|
|
15
|
+
//# sourceMappingURL=index.cjs.map
|
|
16
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/scene.ts"],"names":[],"mappings":";;;AAqLA,IAAI,IAAA,GAAO,GAAA;AACJ,SAAS,OAAO,MAAA,EAAwB;AAC7C,EAAA,IAAA,IAAQ,CAAA;AACR,EAAA,OAAO,CAAA,EAAG,MAAM,CAAA,CAAA,EAAI,IAAI,CAAA,CAAA;AAC1B;AASO,SAAS,WAAA,CACd,KAAA,EACA,OAAA,EACA,MAAA,EACoC;AACpC,EAAA,OAAO,MAAM,KAAA,CAAM,GAAA,CAAI,CAAC,IAAA,MAAU,EAAE,IAAA,EAAM,QAAA,EAAU,OAAA,CAAQ,MAAA,CAAO,KAAK,MAAA,EAAQ,MAAA,CAAO,IAAI,CAAC,GAAE,CAAE,CAAA;AAClG","file":"index.cjs","sourcesContent":["/**\r\n * Engine-agnostic scene description.\r\n *\r\n * A scene is plain JSON-serializable data. Adapters consume it to render the\r\n * scene into a concrete engine — DOM, BabylonJS, three.js, native canvas, etc.\r\n * The same `Scene` should produce a recognizably similar result on every\r\n * supported engine.\r\n */\r\n\r\nexport type WidgetSpec =\r\n | KpiSpec\r\n | ChartSpec\r\n | KanbanSpec\r\n | TableSpec\r\n | ProfileSpec\r\n | CalloutSpec\r\n | FormSpec\r\n | ActionSpec\r\n | TimelineSpec\r\n | CodeSpec\r\n | ImageSpec\r\n | TextSpec\r\n | DemoPageSpec\r\n | ScreenSpec;\r\n\r\nexport interface KpiSpec {\r\n kind: \"kpi\";\r\n label: string;\r\n value: string;\r\n delta?: string;\r\n trend?: \"up\" | \"down\" | \"flat\";\r\n}\r\n\r\nexport interface ChartSpec {\r\n kind: \"chart\";\r\n title: string;\r\n variant: \"line\" | \"bar\" | \"area\";\r\n series: number[];\r\n color?: string;\r\n}\r\n\r\nexport interface KanbanSpec {\r\n kind: \"kanban\";\r\n columns: { title: string; cards: string[] }[];\r\n}\r\n\r\nexport interface TableSpec {\r\n kind: \"table\";\r\n title: string;\r\n columns: string[];\r\n rows: (string | number)[][];\r\n}\r\n\r\nexport interface ProfileSpec {\r\n kind: \"profile\";\r\n name: string;\r\n role: string;\r\n initials: string;\r\n status?: \"online\" | \"away\" | \"offline\";\r\n}\r\n\r\nexport interface CalloutSpec {\r\n kind: \"callout\";\r\n tone: \"info\" | \"success\" | \"warning\" | \"danger\";\r\n title: string;\r\n body: string;\r\n}\r\n\r\nexport interface FormSpec {\r\n kind: \"form\";\r\n title: string;\r\n fields: { id: string; label: string; type: \"text\" | \"switch\" | \"number\" }[];\r\n}\r\n\r\nexport interface ActionSpec {\r\n kind: \"action\";\r\n title: string;\r\n buttons: { label: string; variant?: \"primary\" | \"secondary\" | \"ghost\" }[];\r\n}\r\n\r\nexport interface TimelineSpec {\r\n kind: \"timeline\";\r\n title: string;\r\n events: { at: string; label: string }[];\r\n}\r\n\r\nexport interface CodeSpec {\r\n kind: \"code\";\r\n title: string;\r\n language: string;\r\n code: string;\r\n}\r\n\r\nexport interface ImageSpec {\r\n kind: \"image\";\r\n src: string;\r\n alt: string;\r\n caption?: string;\r\n}\r\n\r\nexport interface TextSpec {\r\n kind: \"text\";\r\n heading: string;\r\n body: string;\r\n}\r\n\r\nexport interface DemoPageSpec {\r\n kind: \"demoPage\";\r\n name: string;\r\n description: string;\r\n path: string;\r\n accent: string;\r\n category: string;\r\n}\r\n\r\n/**\r\n * A 3D-native widget — a screen-shaped panel with a bezel frame, status LED,\r\n * and optional 2D content drawn into the screen surface. Designed to feel\r\n * like a hardware display in a 3D scene.\r\n */\r\nexport interface ScreenSpec {\r\n kind: \"screen\";\r\n /** Screen contents — either a static label or a paint callback that draws\r\n * onto a 2D context sized to the screen's inner area. */\r\n content:\r\n | { type: \"label\"; title: string; subtitle?: string }\r\n | { type: \"image\"; src: string; alt?: string }\r\n | { type: \"paint\"; paint: (ctx: CanvasRenderingContext2D, w: number, h: number) => void };\r\n /** Bezel color (CSS hex). Defaults to a dark frame. */\r\n bezel?: string;\r\n /** Bezel thickness in pixels, scaled with the screen's pixel size. */\r\n bezelThickness?: number;\r\n /** Power state — controls the LED + screen brightness. */\r\n on?: boolean;\r\n /** Background fill color when the content does not fill the screen. */\r\n background?: string;\r\n /** Brightness multiplier, 0..1. Defaults to 1 when on, 0.05 when off. */\r\n brightness?: number;\r\n}\r\n\r\nexport interface SceneNode {\r\n id: string;\r\n position: { x: number; y: number; z?: number };\r\n size?: { w: number; h: number };\r\n widget: WidgetSpec;\r\n}\r\n\r\nexport interface SceneEdge {\r\n id: string;\r\n from: string;\r\n to: string;\r\n label?: string;\r\n curve?: \"bezier\" | \"step\" | \"straight\";\r\n animated?: boolean;\r\n}\r\n\r\nexport interface Scene {\r\n nodes: SceneNode[];\r\n edges: SceneEdge[];\r\n}\r\n\r\n/**\r\n * A WidgetAdapter renders one WidgetSpec for one engine. Each engine ships\r\n * its own adapter; the scene data does not change.\r\n *\r\n * The DOM adapter returns a React element. A BabylonJS adapter returns a\r\n * `Mesh`. A three.js adapter would return an `Object3D`.\r\n */\r\nexport interface WidgetAdapter<T> {\r\n render(spec: WidgetSpec, ctx: AdapterContext): T;\r\n}\r\n\r\nexport interface AdapterContext {\r\n /** Notify the host when the widget requests selection. */\r\n onSelect?: (id: string) => void;\r\n /** The id of the node this widget belongs to. */\r\n nodeId: string;\r\n /** Whether the node is currently selected — adapters may render an outline. */\r\n selected: boolean;\r\n}\r\n\r\nlet _seq = 1000;\r\nexport function nextId(prefix: string): string {\r\n _seq += 1;\r\n return `${prefix}-${_seq}`;\r\n}\r\n\r\n/**\r\n * Convenience: walk a Scene and call the adapter on every node.\r\n *\r\n * Engine-agnostic — every adapter (DOM, Babylon, three) can share it. The\r\n * host is responsible for placing the returned render results inside its\r\n * scene graph.\r\n */\r\nexport function renderScene<T>(\r\n scene: Scene,\r\n adapter: WidgetAdapter<T>,\r\n ctxFor: (node: SceneNode) => AdapterContext\r\n): { node: SceneNode; rendered: T }[] {\r\n return scene.nodes.map((node) => ({ node, rendered: adapter.render(node.widget, ctxFor(node)) }));\r\n}\r\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Engine-agnostic scene description.
|
|
3
|
+
*
|
|
4
|
+
* A scene is plain JSON-serializable data. Adapters consume it to render the
|
|
5
|
+
* scene into a concrete engine — DOM, BabylonJS, three.js, native canvas, etc.
|
|
6
|
+
* The same `Scene` should produce a recognizably similar result on every
|
|
7
|
+
* supported engine.
|
|
8
|
+
*/
|
|
9
|
+
type WidgetSpec = KpiSpec | ChartSpec | KanbanSpec | TableSpec | ProfileSpec | CalloutSpec | FormSpec | ActionSpec | TimelineSpec | CodeSpec | ImageSpec | TextSpec | DemoPageSpec | ScreenSpec;
|
|
10
|
+
interface KpiSpec {
|
|
11
|
+
kind: "kpi";
|
|
12
|
+
label: string;
|
|
13
|
+
value: string;
|
|
14
|
+
delta?: string;
|
|
15
|
+
trend?: "up" | "down" | "flat";
|
|
16
|
+
}
|
|
17
|
+
interface ChartSpec {
|
|
18
|
+
kind: "chart";
|
|
19
|
+
title: string;
|
|
20
|
+
variant: "line" | "bar" | "area";
|
|
21
|
+
series: number[];
|
|
22
|
+
color?: string;
|
|
23
|
+
}
|
|
24
|
+
interface KanbanSpec {
|
|
25
|
+
kind: "kanban";
|
|
26
|
+
columns: {
|
|
27
|
+
title: string;
|
|
28
|
+
cards: string[];
|
|
29
|
+
}[];
|
|
30
|
+
}
|
|
31
|
+
interface TableSpec {
|
|
32
|
+
kind: "table";
|
|
33
|
+
title: string;
|
|
34
|
+
columns: string[];
|
|
35
|
+
rows: (string | number)[][];
|
|
36
|
+
}
|
|
37
|
+
interface ProfileSpec {
|
|
38
|
+
kind: "profile";
|
|
39
|
+
name: string;
|
|
40
|
+
role: string;
|
|
41
|
+
initials: string;
|
|
42
|
+
status?: "online" | "away" | "offline";
|
|
43
|
+
}
|
|
44
|
+
interface CalloutSpec {
|
|
45
|
+
kind: "callout";
|
|
46
|
+
tone: "info" | "success" | "warning" | "danger";
|
|
47
|
+
title: string;
|
|
48
|
+
body: string;
|
|
49
|
+
}
|
|
50
|
+
interface FormSpec {
|
|
51
|
+
kind: "form";
|
|
52
|
+
title: string;
|
|
53
|
+
fields: {
|
|
54
|
+
id: string;
|
|
55
|
+
label: string;
|
|
56
|
+
type: "text" | "switch" | "number";
|
|
57
|
+
}[];
|
|
58
|
+
}
|
|
59
|
+
interface ActionSpec {
|
|
60
|
+
kind: "action";
|
|
61
|
+
title: string;
|
|
62
|
+
buttons: {
|
|
63
|
+
label: string;
|
|
64
|
+
variant?: "primary" | "secondary" | "ghost";
|
|
65
|
+
}[];
|
|
66
|
+
}
|
|
67
|
+
interface TimelineSpec {
|
|
68
|
+
kind: "timeline";
|
|
69
|
+
title: string;
|
|
70
|
+
events: {
|
|
71
|
+
at: string;
|
|
72
|
+
label: string;
|
|
73
|
+
}[];
|
|
74
|
+
}
|
|
75
|
+
interface CodeSpec {
|
|
76
|
+
kind: "code";
|
|
77
|
+
title: string;
|
|
78
|
+
language: string;
|
|
79
|
+
code: string;
|
|
80
|
+
}
|
|
81
|
+
interface ImageSpec {
|
|
82
|
+
kind: "image";
|
|
83
|
+
src: string;
|
|
84
|
+
alt: string;
|
|
85
|
+
caption?: string;
|
|
86
|
+
}
|
|
87
|
+
interface TextSpec {
|
|
88
|
+
kind: "text";
|
|
89
|
+
heading: string;
|
|
90
|
+
body: string;
|
|
91
|
+
}
|
|
92
|
+
interface DemoPageSpec {
|
|
93
|
+
kind: "demoPage";
|
|
94
|
+
name: string;
|
|
95
|
+
description: string;
|
|
96
|
+
path: string;
|
|
97
|
+
accent: string;
|
|
98
|
+
category: string;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* A 3D-native widget — a screen-shaped panel with a bezel frame, status LED,
|
|
102
|
+
* and optional 2D content drawn into the screen surface. Designed to feel
|
|
103
|
+
* like a hardware display in a 3D scene.
|
|
104
|
+
*/
|
|
105
|
+
interface ScreenSpec {
|
|
106
|
+
kind: "screen";
|
|
107
|
+
/** Screen contents — either a static label or a paint callback that draws
|
|
108
|
+
* onto a 2D context sized to the screen's inner area. */
|
|
109
|
+
content: {
|
|
110
|
+
type: "label";
|
|
111
|
+
title: string;
|
|
112
|
+
subtitle?: string;
|
|
113
|
+
} | {
|
|
114
|
+
type: "image";
|
|
115
|
+
src: string;
|
|
116
|
+
alt?: string;
|
|
117
|
+
} | {
|
|
118
|
+
type: "paint";
|
|
119
|
+
paint: (ctx: CanvasRenderingContext2D, w: number, h: number) => void;
|
|
120
|
+
};
|
|
121
|
+
/** Bezel color (CSS hex). Defaults to a dark frame. */
|
|
122
|
+
bezel?: string;
|
|
123
|
+
/** Bezel thickness in pixels, scaled with the screen's pixel size. */
|
|
124
|
+
bezelThickness?: number;
|
|
125
|
+
/** Power state — controls the LED + screen brightness. */
|
|
126
|
+
on?: boolean;
|
|
127
|
+
/** Background fill color when the content does not fill the screen. */
|
|
128
|
+
background?: string;
|
|
129
|
+
/** Brightness multiplier, 0..1. Defaults to 1 when on, 0.05 when off. */
|
|
130
|
+
brightness?: number;
|
|
131
|
+
}
|
|
132
|
+
interface SceneNode {
|
|
133
|
+
id: string;
|
|
134
|
+
position: {
|
|
135
|
+
x: number;
|
|
136
|
+
y: number;
|
|
137
|
+
z?: number;
|
|
138
|
+
};
|
|
139
|
+
size?: {
|
|
140
|
+
w: number;
|
|
141
|
+
h: number;
|
|
142
|
+
};
|
|
143
|
+
widget: WidgetSpec;
|
|
144
|
+
}
|
|
145
|
+
interface SceneEdge {
|
|
146
|
+
id: string;
|
|
147
|
+
from: string;
|
|
148
|
+
to: string;
|
|
149
|
+
label?: string;
|
|
150
|
+
curve?: "bezier" | "step" | "straight";
|
|
151
|
+
animated?: boolean;
|
|
152
|
+
}
|
|
153
|
+
interface Scene {
|
|
154
|
+
nodes: SceneNode[];
|
|
155
|
+
edges: SceneEdge[];
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* A WidgetAdapter renders one WidgetSpec for one engine. Each engine ships
|
|
159
|
+
* its own adapter; the scene data does not change.
|
|
160
|
+
*
|
|
161
|
+
* The DOM adapter returns a React element. A BabylonJS adapter returns a
|
|
162
|
+
* `Mesh`. A three.js adapter would return an `Object3D`.
|
|
163
|
+
*/
|
|
164
|
+
interface WidgetAdapter<T> {
|
|
165
|
+
render(spec: WidgetSpec, ctx: AdapterContext): T;
|
|
166
|
+
}
|
|
167
|
+
interface AdapterContext {
|
|
168
|
+
/** Notify the host when the widget requests selection. */
|
|
169
|
+
onSelect?: (id: string) => void;
|
|
170
|
+
/** The id of the node this widget belongs to. */
|
|
171
|
+
nodeId: string;
|
|
172
|
+
/** Whether the node is currently selected — adapters may render an outline. */
|
|
173
|
+
selected: boolean;
|
|
174
|
+
}
|
|
175
|
+
declare function nextId(prefix: string): string;
|
|
176
|
+
/**
|
|
177
|
+
* Convenience: walk a Scene and call the adapter on every node.
|
|
178
|
+
*
|
|
179
|
+
* Engine-agnostic — every adapter (DOM, Babylon, three) can share it. The
|
|
180
|
+
* host is responsible for placing the returned render results inside its
|
|
181
|
+
* scene graph.
|
|
182
|
+
*/
|
|
183
|
+
declare function renderScene<T>(scene: Scene, adapter: WidgetAdapter<T>, ctxFor: (node: SceneNode) => AdapterContext): {
|
|
184
|
+
node: SceneNode;
|
|
185
|
+
rendered: T;
|
|
186
|
+
}[];
|
|
187
|
+
|
|
188
|
+
export { type ActionSpec, type AdapterContext, type CalloutSpec, type ChartSpec, type CodeSpec, type DemoPageSpec, type FormSpec, type ImageSpec, type KanbanSpec, type KpiSpec, type ProfileSpec, type Scene, type SceneEdge, type SceneNode, type ScreenSpec, type TableSpec, type TextSpec, type TimelineSpec, type WidgetAdapter, type WidgetSpec, nextId, renderScene };
|