@floegence/floe-webapp-core 0.36.15 → 0.36.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ui/InfiniteCanvas.d.ts +1 -0
- package/dist/components/ui/InfiniteCanvas.js +94 -84
- package/dist/components/ui/index.d.ts +1 -0
- package/dist/components/ui/pointerSession.d.ts +35 -0
- package/dist/components/ui/pointerSession.js +85 -0
- package/dist/components/workbench/WorkbenchCanvas.d.ts +3 -0
- package/dist/components/workbench/WorkbenchCanvas.js +51 -28
- package/dist/components/workbench/WorkbenchCanvasField.d.ts +2 -0
- package/dist/components/workbench/WorkbenchCanvasField.js +18 -6
- package/dist/components/workbench/WorkbenchFilterBar.js +119 -117
- package/dist/components/workbench/WorkbenchHud.d.ts +9 -0
- package/dist/components/workbench/WorkbenchHud.js +24 -10
- package/dist/components/workbench/WorkbenchSurface.js +68 -49
- package/dist/components/workbench/WorkbenchThemeSelector.d.ts +6 -0
- package/dist/components/workbench/WorkbenchThemeSelector.js +77 -0
- package/dist/components/workbench/WorkbenchWidget.d.ts +2 -0
- package/dist/components/workbench/WorkbenchWidget.js +211 -167
- package/dist/components/workbench/index.d.ts +2 -0
- package/dist/components/workbench/types.d.ts +2 -0
- package/dist/components/workbench/useWorkbenchModel.d.ts +5 -0
- package/dist/components/workbench/useWorkbenchModel.js +83 -77
- package/dist/components/workbench/workbenchHelpers.js +53 -50
- package/dist/components/workbench/workbenchThemes.d.ts +32 -0
- package/dist/components/workbench/workbenchThemes.js +82 -0
- package/dist/full.js +71 -69
- package/dist/styles.css +1 -1
- package/dist/ui.js +26 -24
- package/dist/workbench-themes.css +1106 -0
- package/dist/workbench.css +492 -96
- package/dist/workbench.js +35 -27
- package/package.json +1 -1
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { createSignal as N, createMemo as
|
|
2
|
-
import { ArrowUp as
|
|
3
|
-
import { getTopZIndex as
|
|
4
|
-
import { resolveWorkbenchWidgetDefinitions as
|
|
5
|
-
function
|
|
6
|
-
const [W, x] = N(null), [U,
|
|
7
|
-
let
|
|
8
|
-
const l = c.state,
|
|
9
|
-
() =>
|
|
1
|
+
import { createSignal as N, createMemo as r, onCleanup as Ct } from "solid-js";
|
|
2
|
+
import { ArrowUp as pt, Copy as kt, Trash as Ft } from "../icons/index.js";
|
|
3
|
+
import { getTopZIndex as bt, createContextMenuPosition as It, createWorkbenchId as Mt, createWorkbenchViewportCenteredOnWidget as L, findNearestWidget as Xt, clampScale as vt, WORKBENCH_CANVAS_ZOOM_STEP as $, WORKBENCH_MIN_SCALE as yt, createWorkbenchViewportFitForWidget as Yt, WORKBENCH_CONTEXT_MENU_WIDTH_PX as Ot, estimateContextMenuHeight as zt } from "./workbenchHelpers.js";
|
|
4
|
+
import { resolveWorkbenchWidgetDefinitions as _t, getWidgetEntry as j, createWorkbenchFilterState as Vt } from "./widgets/widgetRegistry.js";
|
|
5
|
+
function Kt(c) {
|
|
6
|
+
const [W, x] = N(null), [U, T] = N(null), [D, G] = N({ width: 0, height: 0 });
|
|
7
|
+
let d = null, S = null;
|
|
8
|
+
const l = c.state, m = r(() => l().widgets), u = r(() => l().viewport), J = r(() => l().locked), H = r(() => l().filters), F = r(() => l().selectedWidgetId), Q = r(() => l().theme), b = r(() => bt(m())), tt = r(() => `${Math.round(u().scale * 100)}%`), et = () => typeof c.widgetDefinitions == "function" ? c.widgetDefinitions() : c.widgetDefinitions, w = r(
|
|
9
|
+
() => _t(et())
|
|
10
10
|
), I = (t, e) => {
|
|
11
|
-
const n = Number.isFinite(t) && t > 0 ? t : 0, i = Number.isFinite(e) && e > 0 ? e : 0, o = { width: n, height: i }, s =
|
|
11
|
+
const n = Number.isFinite(t) && t > 0 ? t : 0, i = Number.isFinite(e) && e > 0 ? e : 0, o = { width: n, height: i }, s = D();
|
|
12
12
|
return s.width === n && s.height === i ? s : (G(o), o);
|
|
13
|
-
},
|
|
13
|
+
}, R = () => {
|
|
14
14
|
S?.disconnect(), S = null;
|
|
15
|
-
}, a = () =>
|
|
16
|
-
if (
|
|
15
|
+
}, a = () => d ? I(d.clientWidth, d.clientHeight) : I(0, 0), nt = (t) => {
|
|
16
|
+
if (d === (t ?? null)) {
|
|
17
17
|
a();
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
R(), d = t ?? null, a(), !(!d || typeof ResizeObserver > "u") && (S = new ResizeObserver((e) => {
|
|
21
21
|
const n = e[0];
|
|
22
22
|
I(
|
|
23
|
-
n?.contentRect.width ??
|
|
24
|
-
n?.contentRect.height ??
|
|
23
|
+
n?.contentRect.width ?? d?.clientWidth ?? 0,
|
|
24
|
+
n?.contentRect.height ?? d?.clientHeight ?? 0
|
|
25
25
|
);
|
|
26
|
-
}), S.observe(
|
|
26
|
+
}), S.observe(d));
|
|
27
27
|
};
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
Ct(() => {
|
|
29
|
+
R(), d = null;
|
|
30
30
|
});
|
|
31
|
-
const
|
|
31
|
+
const it = (t) => {
|
|
32
32
|
x({
|
|
33
33
|
clientX: t.clientX,
|
|
34
34
|
clientY: t.clientY,
|
|
35
35
|
worldX: t.worldX,
|
|
36
36
|
worldY: t.worldY
|
|
37
37
|
});
|
|
38
|
-
},
|
|
38
|
+
}, ot = (t, e) => {
|
|
39
39
|
f(e.id), x({
|
|
40
40
|
clientX: t.clientX,
|
|
41
41
|
clientY: t.clientY,
|
|
@@ -43,16 +43,16 @@ function Pt(c) {
|
|
|
43
43
|
worldY: e.y,
|
|
44
44
|
widgetId: e.id
|
|
45
45
|
});
|
|
46
|
-
}, h = () => x(null),
|
|
46
|
+
}, h = () => x(null), ct = (t) => l().widgets.find((e) => e.id === t) ?? null, M = (t) => l().widgets.find((e) => e.type === t) ?? null, E = r(() => {
|
|
47
47
|
const t = W();
|
|
48
48
|
if (!t) return [];
|
|
49
49
|
if (t.widgetId) {
|
|
50
|
-
const e =
|
|
50
|
+
const e = m().find((i) => i.id === t.widgetId), n = [];
|
|
51
51
|
return e && (n.push({
|
|
52
52
|
id: "bring-to-front",
|
|
53
53
|
kind: "action",
|
|
54
54
|
label: "Bring to Front",
|
|
55
|
-
icon:
|
|
55
|
+
icon: pt,
|
|
56
56
|
onSelect: () => {
|
|
57
57
|
f(e.id), h();
|
|
58
58
|
}
|
|
@@ -60,7 +60,7 @@ function Pt(c) {
|
|
|
60
60
|
id: "duplicate",
|
|
61
61
|
kind: "action",
|
|
62
62
|
label: "Duplicate",
|
|
63
|
-
icon:
|
|
63
|
+
icon: kt,
|
|
64
64
|
onSelect: () => {
|
|
65
65
|
B(e.type, e.x + 32, e.y + 32), h();
|
|
66
66
|
}
|
|
@@ -68,14 +68,14 @@ function Pt(c) {
|
|
|
68
68
|
id: "delete",
|
|
69
69
|
kind: "action",
|
|
70
70
|
label: "Delete",
|
|
71
|
-
icon:
|
|
71
|
+
icon: Ft,
|
|
72
72
|
destructive: !0,
|
|
73
73
|
onSelect: () => {
|
|
74
74
|
t.widgetId && y(t.widgetId), h();
|
|
75
75
|
}
|
|
76
76
|
}), n;
|
|
77
77
|
}
|
|
78
|
-
return
|
|
78
|
+
return w().map((e) => ({
|
|
79
79
|
id: `add-${e.type}`,
|
|
80
80
|
kind: "action",
|
|
81
81
|
label: `Add ${e.label}`,
|
|
@@ -84,22 +84,22 @@ function Pt(c) {
|
|
|
84
84
|
v(e.type, t.worldX, t.worldY), h();
|
|
85
85
|
}
|
|
86
86
|
}));
|
|
87
|
-
}),
|
|
87
|
+
}), st = r(() => {
|
|
88
88
|
const t = W();
|
|
89
89
|
if (!t) return;
|
|
90
90
|
const e = E(), n = e.filter((o) => o.kind === "action").length, i = e.filter((o) => o.kind === "separator").length;
|
|
91
|
-
return
|
|
91
|
+
return It({
|
|
92
92
|
clientX: t.clientX,
|
|
93
93
|
clientY: t.clientY,
|
|
94
|
-
menuWidth:
|
|
95
|
-
menuHeight:
|
|
94
|
+
menuWidth: Ot,
|
|
95
|
+
menuHeight: zt(n, i)
|
|
96
96
|
});
|
|
97
97
|
}), X = (t, e, n) => {
|
|
98
|
-
const i = j(t,
|
|
98
|
+
const i = j(t, w()), o = i.singleton ? M(t) : null;
|
|
99
99
|
if (o)
|
|
100
100
|
return p(o, { centerViewport: !0 });
|
|
101
101
|
const s = i.defaultSize, g = {
|
|
102
|
-
id:
|
|
102
|
+
id: Mt(),
|
|
103
103
|
type: t,
|
|
104
104
|
title: i.defaultTitle,
|
|
105
105
|
x: e,
|
|
@@ -115,7 +115,7 @@ function Pt(c) {
|
|
|
115
115
|
selectedWidgetId: g.id
|
|
116
116
|
})), g;
|
|
117
117
|
}, v = (t, e, n) => {
|
|
118
|
-
const i = j(t,
|
|
118
|
+
const i = j(t, w()).defaultSize;
|
|
119
119
|
return X(t, e - i.width / 2, n - i.height / 2);
|
|
120
120
|
}, B = (t, e, n) => X(t, e, n), y = (t) => {
|
|
121
121
|
c.setState((e) => ({
|
|
@@ -123,25 +123,25 @@ function Pt(c) {
|
|
|
123
123
|
widgets: e.widgets.filter((n) => n.id !== t),
|
|
124
124
|
selectedWidgetId: e.selectedWidgetId === t ? null : e.selectedWidgetId
|
|
125
125
|
}));
|
|
126
|
-
},
|
|
127
|
-
|
|
126
|
+
}, rt = (t) => {
|
|
127
|
+
T(t);
|
|
128
128
|
}, f = (t) => {
|
|
129
|
-
|
|
130
|
-
const e = b(), n =
|
|
129
|
+
T(t);
|
|
130
|
+
const e = b(), n = m().find((i) => i.id === t);
|
|
131
131
|
n && n.z_index < e && c.setState((i) => ({
|
|
132
132
|
...i,
|
|
133
133
|
widgets: i.widgets.map(
|
|
134
134
|
(o) => o.id === t ? { ...o, z_index: e + 1 } : o
|
|
135
135
|
)
|
|
136
136
|
}));
|
|
137
|
-
},
|
|
137
|
+
}, dt = (t, e) => {
|
|
138
138
|
c.setState((n) => ({
|
|
139
139
|
...n,
|
|
140
140
|
widgets: n.widgets.map(
|
|
141
141
|
(i) => i.id === t ? { ...i, x: e.x, y: e.y } : i
|
|
142
142
|
)
|
|
143
143
|
}));
|
|
144
|
-
},
|
|
144
|
+
}, lt = (t, e) => {
|
|
145
145
|
c.setState((n) => ({
|
|
146
146
|
...n,
|
|
147
147
|
widgets: n.widgets.map(
|
|
@@ -151,7 +151,7 @@ function Pt(c) {
|
|
|
151
151
|
}, Y = (t) => {
|
|
152
152
|
c.setState((e) => ({ ...e, viewport: t }));
|
|
153
153
|
}, q = (t) => {
|
|
154
|
-
const e = u(), n = a(), i = (n.width / 2 - e.x) / e.scale, o = (n.height / 2 - e.y) / e.scale, s =
|
|
154
|
+
const e = u(), n = a(), i = (n.width / 2 - e.x) / e.scale, o = (n.height / 2 - e.y) / e.scale, s = vt(
|
|
155
155
|
t === "in" ? e.scale * $ : e.scale / $
|
|
156
156
|
), g = {
|
|
157
157
|
x: n.width / 2 - i * s,
|
|
@@ -159,22 +159,22 @@ function Pt(c) {
|
|
|
159
159
|
scale: s
|
|
160
160
|
};
|
|
161
161
|
Y(g);
|
|
162
|
-
},
|
|
162
|
+
}, at = () => {
|
|
163
163
|
c.setState((t) => ({ ...t, locked: !t.locked }));
|
|
164
|
-
},
|
|
164
|
+
}, gt = (t) => {
|
|
165
165
|
c.setState((e) => ({
|
|
166
166
|
...e,
|
|
167
167
|
filters: { ...e.filters, [t]: !e.filters[t] }
|
|
168
168
|
}));
|
|
169
|
-
},
|
|
169
|
+
}, ut = (t) => {
|
|
170
170
|
c.setState((e) => {
|
|
171
171
|
const n = { ...e.filters };
|
|
172
172
|
for (const i of Object.keys(n))
|
|
173
173
|
n[i] = i === t;
|
|
174
174
|
return { ...e, filters: n };
|
|
175
175
|
});
|
|
176
|
-
},
|
|
177
|
-
const t =
|
|
176
|
+
}, ht = () => {
|
|
177
|
+
const t = Vt(w());
|
|
178
178
|
c.setState((e) => ({
|
|
179
179
|
...e,
|
|
180
180
|
filters: t
|
|
@@ -185,7 +185,7 @@ function Pt(c) {
|
|
|
185
185
|
c.setState(
|
|
186
186
|
(t) => t.selectedWidgetId === null ? t : { ...t, selectedWidgetId: null }
|
|
187
187
|
);
|
|
188
|
-
},
|
|
188
|
+
}, ft = () => {
|
|
189
189
|
const t = a(), e = u();
|
|
190
190
|
return {
|
|
191
191
|
worldX: t.width > 0 ? (t.width / 2 - e.x) / e.scale : 240,
|
|
@@ -193,12 +193,12 @@ function Pt(c) {
|
|
|
193
193
|
};
|
|
194
194
|
};
|
|
195
195
|
let O = 0;
|
|
196
|
-
const
|
|
196
|
+
const mt = () => {
|
|
197
197
|
O += 1;
|
|
198
198
|
}, z = (t) => {
|
|
199
|
-
const e = u(), n = e.x, i = e.y, o = e.scale, s = performance.now(), g = 360, k = ++O,
|
|
199
|
+
const e = u(), n = e.x, i = e.y, o = e.scale, s = performance.now(), g = 360, k = ++O, xt = (V) => 1 - Math.pow(1 - V, 3), Z = (V) => {
|
|
200
200
|
if (k !== O) return;
|
|
201
|
-
const
|
|
201
|
+
const St = V - s, K = Math.min(Math.max(St / g, 0), 1), A = xt(K);
|
|
202
202
|
Y({
|
|
203
203
|
x: n + (t.x - n) * A,
|
|
204
204
|
y: i + (t.y - i) * A,
|
|
@@ -216,36 +216,37 @@ function Pt(c) {
|
|
|
216
216
|
}));
|
|
217
217
|
}, wt = (t) => {
|
|
218
218
|
const e = a();
|
|
219
|
-
e.width === 0 || e.height === 0 || z(
|
|
219
|
+
e.width === 0 || e.height === 0 || z(Yt({
|
|
220
220
|
widget: t,
|
|
221
221
|
frameWidth: e.width,
|
|
222
222
|
frameHeight: e.height
|
|
223
223
|
}));
|
|
224
|
-
},
|
|
224
|
+
}, Wt = (t) => {
|
|
225
225
|
const e = a();
|
|
226
226
|
e.width === 0 || e.height === 0 || z(L({
|
|
227
227
|
widget: t,
|
|
228
|
-
scale:
|
|
228
|
+
scale: yt,
|
|
229
229
|
frameWidth: e.width,
|
|
230
230
|
frameHeight: e.height
|
|
231
231
|
}));
|
|
232
232
|
}, p = (t, e = {}) => (C(t.id), f(t.id), e.centerViewport !== !1 && _(t), t);
|
|
233
233
|
return {
|
|
234
|
-
widgets:
|
|
234
|
+
widgets: m,
|
|
235
235
|
viewport: u,
|
|
236
|
-
canvasFrameSize:
|
|
236
|
+
canvasFrameSize: D,
|
|
237
237
|
locked: J,
|
|
238
|
-
filters:
|
|
238
|
+
filters: H,
|
|
239
239
|
selectedWidgetId: F,
|
|
240
|
+
theme: Q,
|
|
240
241
|
topZIndex: b,
|
|
241
|
-
scaleLabel:
|
|
242
|
+
scaleLabel: tt,
|
|
242
243
|
optimisticFrontWidgetId: U,
|
|
243
|
-
widgetDefinitions:
|
|
244
|
-
setCanvasFrameRef:
|
|
244
|
+
widgetDefinitions: w,
|
|
245
|
+
setCanvasFrameRef: nt,
|
|
245
246
|
contextMenu: {
|
|
246
247
|
state: W,
|
|
247
248
|
items: E,
|
|
248
|
-
position:
|
|
249
|
+
position: st,
|
|
249
250
|
close: h,
|
|
250
251
|
retarget: (t) => {
|
|
251
252
|
t.preventDefault(), t.stopPropagation(), x({
|
|
@@ -257,43 +258,43 @@ function Pt(c) {
|
|
|
257
258
|
}
|
|
258
259
|
},
|
|
259
260
|
canvas: {
|
|
260
|
-
openCanvasContextMenu:
|
|
261
|
-
openWidgetContextMenu:
|
|
261
|
+
openCanvasContextMenu: it,
|
|
262
|
+
openWidgetContextMenu: ot,
|
|
262
263
|
selectWidget: C,
|
|
263
264
|
clearSelection: P,
|
|
264
|
-
startOptimisticFront:
|
|
265
|
+
startOptimisticFront: rt,
|
|
265
266
|
commitFront: f,
|
|
266
|
-
commitMove:
|
|
267
|
-
commitResize:
|
|
267
|
+
commitMove: dt,
|
|
268
|
+
commitResize: lt,
|
|
268
269
|
commitViewport: Y,
|
|
269
|
-
cancelViewportNavigation:
|
|
270
|
+
cancelViewportNavigation: mt
|
|
270
271
|
},
|
|
271
272
|
hud: {
|
|
272
273
|
zoomIn: () => q("in"),
|
|
273
274
|
zoomOut: () => q("out")
|
|
274
275
|
},
|
|
275
276
|
lock: {
|
|
276
|
-
toggle:
|
|
277
|
+
toggle: at
|
|
277
278
|
},
|
|
278
279
|
filter: {
|
|
279
|
-
toggle:
|
|
280
|
-
solo:
|
|
281
|
-
showAll:
|
|
280
|
+
toggle: gt,
|
|
281
|
+
solo: ut,
|
|
282
|
+
showAll: ht
|
|
282
283
|
},
|
|
283
284
|
navigation: {
|
|
284
285
|
handleArrowNavigation: (t) => {
|
|
285
|
-
const e =
|
|
286
|
-
|
|
286
|
+
const e = Xt(
|
|
287
|
+
m(),
|
|
287
288
|
F(),
|
|
288
289
|
t,
|
|
289
|
-
|
|
290
|
+
H()
|
|
290
291
|
);
|
|
291
292
|
e && p(e);
|
|
292
293
|
},
|
|
293
294
|
centerOnWidget: _,
|
|
294
295
|
focusWidget: p,
|
|
295
296
|
fitWidget: (t) => (C(t.id), f(t.id), wt(t), t),
|
|
296
|
-
overviewWidget: (t) => (C(t.id), f(t.id),
|
|
297
|
+
overviewWidget: (t) => (C(t.id), f(t.id), Wt(t), t)
|
|
297
298
|
},
|
|
298
299
|
selection: {
|
|
299
300
|
clear: P
|
|
@@ -311,7 +312,7 @@ function Pt(c) {
|
|
|
311
312
|
const n = M(t);
|
|
312
313
|
if (n)
|
|
313
314
|
return p(n, { centerViewport: e?.centerViewport ?? !0 });
|
|
314
|
-
const i =
|
|
315
|
+
const i = ft(), o = v(
|
|
315
316
|
t,
|
|
316
317
|
e?.worldX ?? i.worldX,
|
|
317
318
|
e?.worldY ?? i.worldY
|
|
@@ -321,7 +322,12 @@ function Pt(c) {
|
|
|
321
322
|
},
|
|
322
323
|
queries: {
|
|
323
324
|
findWidgetByType: M,
|
|
324
|
-
findWidgetById:
|
|
325
|
+
findWidgetById: ct
|
|
326
|
+
},
|
|
327
|
+
appearance: {
|
|
328
|
+
setTheme: (t) => {
|
|
329
|
+
l().theme !== t && c.setState((e) => ({ ...e, theme: t }));
|
|
330
|
+
}
|
|
325
331
|
},
|
|
326
332
|
handleCloseRequest: () => {
|
|
327
333
|
if (W()) {
|
|
@@ -333,5 +339,5 @@ function Pt(c) {
|
|
|
333
339
|
};
|
|
334
340
|
}
|
|
335
341
|
export {
|
|
336
|
-
|
|
342
|
+
Kt as useWorkbenchModel
|
|
337
343
|
};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { DEFAULT_WORKBENCH_VIEWPORT as y } from "./types.js";
|
|
2
|
-
import { resolveWorkbenchWidgetDefinitions as _, getWidgetEntry as W, createWorkbenchFilterState as w, isValidWorkbenchWidgetType as
|
|
3
|
-
|
|
2
|
+
import { resolveWorkbenchWidgetDefinitions as _, getWidgetEntry as W, createWorkbenchFilterState as w, isValidWorkbenchWidgetType as H } from "./widgets/widgetRegistry.js";
|
|
3
|
+
import { DEFAULT_WORKBENCH_THEME as b, isWorkbenchThemeId as N } from "./workbenchThemes.js";
|
|
4
|
+
function T() {
|
|
4
5
|
const e = globalThis.crypto;
|
|
5
6
|
return e && typeof e.randomUUID == "function" ? `wb-${e.randomUUID()}` : `wb-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
|
6
7
|
}
|
|
7
|
-
function
|
|
8
|
+
function A(e) {
|
|
8
9
|
return e.renderMode ?? "canvas_scaled";
|
|
9
10
|
}
|
|
10
|
-
function
|
|
11
|
+
function E(e) {
|
|
11
12
|
const t = Number.isFinite(e.viewport.scale) && e.viewport.scale > 0 ? e.viewport.scale : 1;
|
|
12
13
|
return {
|
|
13
14
|
widgetId: e.widgetId,
|
|
@@ -22,28 +23,28 @@ function N(e) {
|
|
|
22
23
|
viewportScale: t
|
|
23
24
|
};
|
|
24
25
|
}
|
|
25
|
-
function
|
|
26
|
+
function P(e) {
|
|
26
27
|
return {
|
|
27
28
|
ready: e.ready,
|
|
28
|
-
rect:
|
|
29
|
+
rect: E(e)
|
|
29
30
|
};
|
|
30
31
|
}
|
|
31
|
-
function
|
|
32
|
+
function F(e) {
|
|
32
33
|
return e ? {
|
|
33
34
|
x: Number.isFinite(e.x) ? e.x : 0,
|
|
34
35
|
y: Number.isFinite(e.y) ? e.y : 0,
|
|
35
36
|
scale: Number.isFinite(e.scale) && e.scale > 0 ? e.scale : 1
|
|
36
37
|
} : { ...y };
|
|
37
38
|
}
|
|
38
|
-
function
|
|
39
|
+
function I(e, t) {
|
|
39
40
|
return w(t, e);
|
|
40
41
|
}
|
|
41
|
-
function
|
|
42
|
-
const r = _(t.widgetDefinitions), d = t.createFallbackState ?? (() =>
|
|
42
|
+
function X(e, t = {}) {
|
|
43
|
+
const r = _(t.widgetDefinitions), d = t.createFallbackState ?? (() => z(r)), n = e;
|
|
43
44
|
if (!n || n.version !== 1 || !Array.isArray(n.widgets))
|
|
44
45
|
return d();
|
|
45
46
|
const a = n.widgets.filter(
|
|
46
|
-
(i) => !!i && typeof i.id == "string" &&
|
|
47
|
+
(i) => !!i && typeof i.id == "string" && H(i.type, r) && typeof i.title == "string"
|
|
47
48
|
).map((i) => {
|
|
48
49
|
const h = W(i.type, r);
|
|
49
50
|
return {
|
|
@@ -61,13 +62,14 @@ function T(e, t = {}) {
|
|
|
61
62
|
return {
|
|
62
63
|
version: 1,
|
|
63
64
|
widgets: a,
|
|
64
|
-
viewport:
|
|
65
|
+
viewport: F(n.viewport),
|
|
65
66
|
locked: typeof n.locked == "boolean" ? n.locked : !1,
|
|
66
|
-
filters:
|
|
67
|
-
selectedWidgetId: c
|
|
67
|
+
filters: I(n.filters, r),
|
|
68
|
+
selectedWidgetId: c,
|
|
69
|
+
theme: N(n.theme) ? n.theme : b
|
|
68
70
|
};
|
|
69
71
|
}
|
|
70
|
-
function
|
|
72
|
+
function z(e) {
|
|
71
73
|
const t = _(e), r = Date.now(), d = [
|
|
72
74
|
{ type: "terminal", title: "dev · terminal", x: 80, y: 80 },
|
|
73
75
|
{ type: "file-browser", title: "project · files", x: 600, y: 80 },
|
|
@@ -94,20 +96,21 @@ function I(e) {
|
|
|
94
96
|
viewport: { ...y },
|
|
95
97
|
locked: !1,
|
|
96
98
|
filters: w(t),
|
|
97
|
-
selectedWidgetId: n[0]?.id ?? null
|
|
99
|
+
selectedWidgetId: n[0]?.id ?? null,
|
|
100
|
+
theme: b
|
|
98
101
|
};
|
|
99
102
|
}
|
|
100
|
-
const
|
|
103
|
+
const B = 1.18, K = 200, m = 0.45, u = 2.2, p = 48;
|
|
101
104
|
function v(e) {
|
|
102
|
-
const t =
|
|
105
|
+
const t = M(e.scale, m, u);
|
|
103
106
|
return {
|
|
104
107
|
x: e.frameWidth / 2 - (e.widget.x + e.widget.width / 2) * t,
|
|
105
108
|
y: e.frameHeight / 2 - (e.widget.y + e.widget.height / 2) * t,
|
|
106
109
|
scale: t
|
|
107
110
|
};
|
|
108
111
|
}
|
|
109
|
-
function
|
|
110
|
-
const t = e.minScale ??
|
|
112
|
+
function U(e) {
|
|
113
|
+
const t = e.minScale ?? m, r = e.maxScale ?? u, d = e.paddingPx ?? p, n = Math.max(e.frameWidth - d * 2, 1), a = Math.max(e.frameHeight - d * 2, 1), c = M(
|
|
111
114
|
Math.min(
|
|
112
115
|
n / Math.max(e.widget.width, 1),
|
|
113
116
|
a / Math.max(e.widget.height, 1)
|
|
@@ -122,11 +125,11 @@ function X(e) {
|
|
|
122
125
|
frameHeight: e.frameHeight
|
|
123
126
|
});
|
|
124
127
|
}
|
|
125
|
-
function
|
|
128
|
+
function C(e, t) {
|
|
126
129
|
return e.z_index !== t.z_index ? e.z_index - t.z_index : e.created_at_unix_ms !== t.created_at_unix_ms ? e.created_at_unix_ms - t.created_at_unix_ms : e.id.localeCompare(t.id);
|
|
127
130
|
}
|
|
128
131
|
function V(e) {
|
|
129
|
-
const t = [...e].sort(
|
|
132
|
+
const t = [...e].sort(C), r = /* @__PURE__ */ new Map();
|
|
130
133
|
for (const [d, n] of t.entries())
|
|
131
134
|
r.set(n.id, d + 1);
|
|
132
135
|
return {
|
|
@@ -134,22 +137,22 @@ function V(e) {
|
|
|
134
137
|
topRenderLayer: Math.max(t.length, 1)
|
|
135
138
|
};
|
|
136
139
|
}
|
|
137
|
-
function
|
|
140
|
+
function L(e) {
|
|
138
141
|
const t = typeof window < "u" ? window.innerWidth : 1280, r = typeof window < "u" ? window.innerHeight : 800;
|
|
139
142
|
let d = e.clientX, n = e.clientY;
|
|
140
143
|
return d + e.menuWidth > t && (d = Math.max(0, t - e.menuWidth - 8)), n + e.menuHeight > r && (n = Math.max(0, r - e.menuHeight - 8)), { left: d, top: n };
|
|
141
144
|
}
|
|
142
|
-
function
|
|
145
|
+
function Y(e) {
|
|
143
146
|
return e.reduce((t, r) => Math.max(t, r.z_index), 1);
|
|
144
147
|
}
|
|
145
|
-
function
|
|
148
|
+
function $(e, t, r, d) {
|
|
146
149
|
const n = e.filter((o) => d[o.type]);
|
|
147
150
|
if (n.length === 0) return null;
|
|
148
151
|
if (!t) return n[0] ?? null;
|
|
149
152
|
const a = n.find((o) => o.id === t);
|
|
150
153
|
if (!a) return n[0] ?? null;
|
|
151
154
|
const c = a.x + a.width / 2, i = a.y + a.height / 2;
|
|
152
|
-
let h = null,
|
|
155
|
+
let h = null, g = 1 / 0;
|
|
153
156
|
for (const o of n) {
|
|
154
157
|
if (o.id === t) continue;
|
|
155
158
|
const s = o.x + o.width / 2 - c, l = o.y + o.height / 2 - i;
|
|
@@ -169,40 +172,40 @@ function U(e, t, r, d) {
|
|
|
169
172
|
break;
|
|
170
173
|
}
|
|
171
174
|
if (!f) continue;
|
|
172
|
-
const
|
|
175
|
+
const S = Math.sqrt(s * s + l * l), k = Math.atan2(
|
|
173
176
|
Math.abs(r === "up" || r === "down" ? s : l),
|
|
174
177
|
Math.abs(r === "up" || r === "down" ? l : s)
|
|
175
|
-
), x =
|
|
176
|
-
x <
|
|
178
|
+
), x = S * (1 + k * 1.5);
|
|
179
|
+
x < g && (g = x, h = o);
|
|
177
180
|
}
|
|
178
181
|
return h;
|
|
179
182
|
}
|
|
180
|
-
function
|
|
183
|
+
function M(e, t = m, r = u) {
|
|
181
184
|
return Math.max(t, Math.min(r, e));
|
|
182
185
|
}
|
|
183
|
-
function
|
|
186
|
+
function j(e, t = 0) {
|
|
184
187
|
return 16 + Math.max(1, e) * 32 + Math.max(0, t) * 9;
|
|
185
188
|
}
|
|
186
189
|
export {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
190
|
+
B as WORKBENCH_CANVAS_ZOOM_STEP,
|
|
191
|
+
K as WORKBENCH_CONTEXT_MENU_WIDTH_PX,
|
|
192
|
+
u as WORKBENCH_MAX_SCALE,
|
|
193
|
+
m as WORKBENCH_MIN_SCALE,
|
|
194
|
+
p as WORKBENCH_VIEWPORT_FIT_PADDING_PX,
|
|
195
|
+
M as clampScale,
|
|
196
|
+
L as createContextMenuPosition,
|
|
197
|
+
z as createDefaultWorkbenchState,
|
|
198
|
+
T as createWorkbenchId,
|
|
199
|
+
E as createWorkbenchProjectedRect,
|
|
197
200
|
V as createWorkbenchRenderLayerMap,
|
|
198
201
|
v as createWorkbenchViewportCenteredOnWidget,
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
202
|
+
U as createWorkbenchViewportFitForWidget,
|
|
203
|
+
P as createWorkbenchWidgetSurfaceMetrics,
|
|
204
|
+
j as estimateContextMenuHeight,
|
|
205
|
+
$ as findNearestWidget,
|
|
206
|
+
Y as getTopZIndex,
|
|
207
|
+
A as resolveWorkbenchWidgetRenderMode,
|
|
208
|
+
I as sanitizeFilters,
|
|
209
|
+
F as sanitizeViewport,
|
|
210
|
+
X as sanitizeWorkbenchState
|
|
208
211
|
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workbench theme catalog.
|
|
3
|
+
*
|
|
4
|
+
* Themes customise the canvas surface, atmosphere, grid, widget chrome,
|
|
5
|
+
* body treatment, dock, typography, and focus accent via `data-workbench-theme`
|
|
6
|
+
* on `.workbench-surface`. Theme-specific CSS overrides live in
|
|
7
|
+
* `workbench-themes.css`.
|
|
8
|
+
*
|
|
9
|
+
* The `default` theme is a no-op: it inherits the app's global theme tokens
|
|
10
|
+
* (`--background`, `--card`, `--border`, `--primary`, ...), so swapping to
|
|
11
|
+
* `default` reproduces the look before this theme system existed.
|
|
12
|
+
*/
|
|
13
|
+
export declare const WORKBENCH_THEME_IDS: readonly ["default", "vibrancy", "mica", "midnight", "aurora", "terminal"];
|
|
14
|
+
export type WorkbenchThemeId = (typeof WORKBENCH_THEME_IDS)[number];
|
|
15
|
+
export interface WorkbenchThemePreview {
|
|
16
|
+
/** CSS value applied to the theme swatch's outer frame (represents canvas). */
|
|
17
|
+
canvas: string;
|
|
18
|
+
/** CSS value for the swatch's inner card (represents a widget). */
|
|
19
|
+
widget: string;
|
|
20
|
+
/** Solid CSS color for the selected/active indicator in the preview. */
|
|
21
|
+
accent: string;
|
|
22
|
+
}
|
|
23
|
+
export interface WorkbenchThemeMeta {
|
|
24
|
+
id: WorkbenchThemeId;
|
|
25
|
+
label: string;
|
|
26
|
+
description: string;
|
|
27
|
+
preview: WorkbenchThemePreview;
|
|
28
|
+
}
|
|
29
|
+
export declare const WORKBENCH_THEMES: readonly WorkbenchThemeMeta[];
|
|
30
|
+
export declare const DEFAULT_WORKBENCH_THEME: WorkbenchThemeId;
|
|
31
|
+
export declare function isWorkbenchThemeId(value: unknown): value is WorkbenchThemeId;
|
|
32
|
+
export declare function workbenchThemeMeta(id: WorkbenchThemeId): WorkbenchThemeMeta;
|