@floegence/floe-webapp-core 0.36.7 → 0.36.9
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/deck/DeckCell.d.ts +0 -5
- package/dist/components/deck/DeckCell.js +34 -45
- package/dist/components/deck/DeckGrid.d.ts +2 -16
- package/dist/components/deck/DeckGrid.js +83 -105
- package/dist/components/deck/WidgetResizeHandle.d.ts +3 -1
- package/dist/components/deck/WidgetResizeHandle.js +46 -80
- package/dist/components/deck/deckGridMetrics.d.ts +26 -0
- package/dist/components/deck/deckGridMetrics.js +32 -0
- package/dist/components/deck/deckPointerSession.d.ts +52 -0
- package/dist/components/deck/deckPointerSession.js +113 -0
- package/dist/components/editor/CodeEditor.d.ts +2 -0
- package/dist/components/editor/CodeEditor.js +24 -24
- package/dist/components/editor/index.d.ts +1 -0
- package/dist/components/editor/monacoStandaloneRuntime.d.ts +15 -3
- package/dist/components/editor/monacoStandaloneRuntime.js +45 -17
- package/dist/components/ui/InfiniteCanvas.d.ts +2 -0
- package/dist/components/ui/InfiniteCanvas.js +85 -84
- package/dist/components/ui/index.d.ts +1 -1
- package/dist/components/ui/localInteractionSurface.d.ts +19 -0
- package/dist/components/ui/localInteractionSurface.js +38 -23
- package/dist/components/workbench/WorkbenchCanvas.d.ts +4 -0
- package/dist/components/workbench/WorkbenchCanvas.js +176 -11
- package/dist/components/workbench/WorkbenchSurface.js +9 -6
- package/dist/components/workbench/WorkbenchWidget.d.ts +4 -1
- package/dist/components/workbench/WorkbenchWidget.js +153 -120
- package/dist/components/workbench/index.d.ts +1 -1
- package/dist/components/workbench/types.d.ts +19 -0
- package/dist/components/workbench/useWorkbenchModel.d.ts +4 -0
- package/dist/components/workbench/useWorkbenchModel.js +33 -32
- package/dist/components/workbench/workbenchHelpers.d.ts +14 -1
- package/dist/components/workbench/workbenchHelpers.js +117 -90
- package/dist/context/DeckContext.d.ts +1 -9
- package/dist/context/DeckContext.js +163 -168
- package/dist/deck.js +22 -21
- package/dist/editor.js +5 -2
- package/dist/full.js +528 -523
- package/dist/hooks/useDeckDrag.d.ts +4 -3
- package/dist/hooks/useDeckDrag.js +39 -72
- package/dist/index.js +54 -53
- package/dist/styles.css +1 -1
- package/dist/ui.js +97 -94
- package/dist/utils/gridCollision.d.ts +1 -0
- package/dist/utils/gridCollision.js +21 -17
- package/dist/workbench.css +16 -0
- package/dist/workbench.js +17 -14
- package/package.json +1 -1
|
@@ -1,45 +1,76 @@
|
|
|
1
|
-
import { spread as G, insert as u, createComponent as
|
|
2
|
-
import { createSignal as H, onCleanup as
|
|
3
|
-
import { startHotInteraction as
|
|
4
|
-
import { GripVertical as
|
|
5
|
-
import { WORKBENCH_WIDGET_SHELL_ATTR as
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { spread as G, insert as u, createComponent as _, memo as V, effect as K, setAttribute as T, style as q, template as O, use as U, delegateEvents as J } from "solid-js/web";
|
|
2
|
+
import { createSignal as H, onCleanup as Q, untrack as x, createMemo as y } from "solid-js";
|
|
3
|
+
import { startHotInteraction as A } from "../../utils/hotInteraction.js";
|
|
4
|
+
import { GripVertical as Z, X as p } from "../icons/index.js";
|
|
5
|
+
import { WORKBENCH_WIDGET_SHELL_ATTR as tt, resolveWorkbenchWidgetEventOwnership as et } from "../ui/localInteractionSurface.js";
|
|
6
|
+
import { createWorkbenchWidgetSurfaceMetrics as it } from "./workbenchHelpers.js";
|
|
7
|
+
var nt = /* @__PURE__ */ O('<article class=workbench-widget data-floe-dialog-surface-host=true tabindex=0><header class=workbench-widget__header><button type=button class=workbench-widget__drag aria-label="Drag widget"data-floe-canvas-interactive=true></button><div class=workbench-widget__title-area><span class=workbench-widget__title></span></div><button type=button class=workbench-widget__close aria-label="Remove widget"data-floe-canvas-interactive=true></button></header><div class=workbench-widget__body data-floe-canvas-interactive=true>'), ot = /* @__PURE__ */ O('<div class=workbench-widget__resize aria-label="Resize widget"data-floe-canvas-interactive=true><svg class=workbench-widget__resize-glyph viewBox="0 0 12 12"aria-hidden=true><path d="M12 0 L0 12"></path><path d="M12 4 L4 12"></path><path d="M12 8 L8 12">');
|
|
8
|
+
const at = 220, rt = 160, dt = '[data-floe-canvas-interactive="true"]', lt = '[data-floe-canvas-pan-surface="true"]';
|
|
9
|
+
function ft(t) {
|
|
10
|
+
const [f, C] = H(null), [v, M] = H(null);
|
|
10
11
|
let h, w, b;
|
|
11
|
-
|
|
12
|
-
h?.abort(), h = void 0, w?.abort(), w = void 0,
|
|
12
|
+
Q(() => {
|
|
13
|
+
h?.abort(), h = void 0, w?.abort(), w = void 0, x(f)?.stopInteraction(), x(v)?.stopInteraction();
|
|
13
14
|
});
|
|
14
|
-
const S = () => f() !== null,
|
|
15
|
-
target:
|
|
15
|
+
const S = () => f() !== null, W = () => v() !== null, $ = (i) => et({
|
|
16
|
+
target: i,
|
|
16
17
|
widgetRoot: b ?? null,
|
|
17
|
-
interactiveSelector:
|
|
18
|
-
panSurfaceSelector:
|
|
19
|
-
}),
|
|
20
|
-
|
|
18
|
+
interactiveSelector: dt,
|
|
19
|
+
panSurfaceSelector: lt
|
|
20
|
+
}), P = (i) => {
|
|
21
|
+
i.button === 0 && (t.onSelect(t.widgetId), t.onCommitFront(t.widgetId), $(i.target) === "widget_shell" && b?.focus({
|
|
21
22
|
preventScroll: !0
|
|
22
23
|
}));
|
|
23
|
-
},
|
|
24
|
-
const
|
|
25
|
-
return
|
|
26
|
-
x:
|
|
27
|
-
y:
|
|
24
|
+
}, m = y(() => {
|
|
25
|
+
const i = f();
|
|
26
|
+
return i ? {
|
|
27
|
+
x: i.worldX,
|
|
28
|
+
y: i.worldY
|
|
28
29
|
} : {
|
|
29
|
-
x:
|
|
30
|
-
y:
|
|
30
|
+
x: t.x,
|
|
31
|
+
y: t.y
|
|
31
32
|
};
|
|
32
|
-
}),
|
|
33
|
-
const
|
|
34
|
-
return
|
|
35
|
-
width: e.width,
|
|
36
|
-
height: e.height
|
|
37
|
-
} : {
|
|
33
|
+
}), I = y(() => {
|
|
34
|
+
const i = v();
|
|
35
|
+
return i ? {
|
|
38
36
|
width: i.width,
|
|
39
37
|
height: i.height
|
|
38
|
+
} : {
|
|
39
|
+
width: t.width,
|
|
40
|
+
height: t.height
|
|
41
|
+
};
|
|
42
|
+
}), k = y(() => {
|
|
43
|
+
if (!(t.layoutMode !== "projected_surface" || !t.projectedViewport))
|
|
44
|
+
return it({
|
|
45
|
+
widgetId: t.widgetId,
|
|
46
|
+
worldX: m().x,
|
|
47
|
+
worldY: m().y,
|
|
48
|
+
worldWidth: I().width,
|
|
49
|
+
worldHeight: I().height,
|
|
50
|
+
viewport: t.projectedViewport,
|
|
51
|
+
ready: t.surfaceReady ?? !0
|
|
52
|
+
});
|
|
53
|
+
}), j = y(() => {
|
|
54
|
+
const i = {
|
|
55
|
+
width: `${I().width}px`,
|
|
56
|
+
height: `${I().height}px`,
|
|
57
|
+
"z-index": S() || W() || t.optimisticFront ? `${t.topRenderLayer + 1}` : `${t.renderLayer}`
|
|
40
58
|
};
|
|
41
|
-
|
|
42
|
-
|
|
59
|
+
if (t.layoutMode === "projected_surface") {
|
|
60
|
+
const n = k()?.rect;
|
|
61
|
+
return {
|
|
62
|
+
...i,
|
|
63
|
+
left: `${n?.screenX ?? 0}px`,
|
|
64
|
+
top: `${n?.screenY ?? 0}px`,
|
|
65
|
+
"--floe-workbench-projected-scale": `${n?.viewportScale ?? Math.max(t.viewportScale, 1e-3)}`
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
...i,
|
|
70
|
+
transform: `translate(${m().x}px, ${m().y}px)`
|
|
71
|
+
};
|
|
72
|
+
}), E = (i) => {
|
|
73
|
+
const n = x(f);
|
|
43
74
|
if (!n) return;
|
|
44
75
|
const a = {
|
|
45
76
|
x: n.worldX,
|
|
@@ -47,146 +78,149 @@ function ht(i) {
|
|
|
47
78
|
}, r = {
|
|
48
79
|
x: n.startWorldX,
|
|
49
80
|
y: n.startWorldY
|
|
50
|
-
}, s =
|
|
51
|
-
|
|
52
|
-
},
|
|
53
|
-
if (
|
|
54
|
-
|
|
55
|
-
const n =
|
|
81
|
+
}, s = i && (Math.abs(a.x - r.x) > 1 || Math.abs(a.y - r.y) > 1);
|
|
82
|
+
t.onCommitFront(t.widgetId), s && t.onCommitMove(t.widgetId, a), n.stopInteraction(), C(null), h?.abort(), h = void 0;
|
|
83
|
+
}, N = (i) => {
|
|
84
|
+
if (i.button !== 0 || t.locked) return;
|
|
85
|
+
i.preventDefault(), i.stopPropagation(), h?.abort(), t.onStartOptimisticFront(t.widgetId);
|
|
86
|
+
const n = A({
|
|
56
87
|
kind: "drag",
|
|
57
88
|
cursor: "grabbing"
|
|
58
|
-
}), a = Math.max(
|
|
89
|
+
}), a = Math.max(t.viewportScale, 1e-3);
|
|
59
90
|
C({
|
|
60
|
-
pointerId:
|
|
61
|
-
startClientX:
|
|
62
|
-
startClientY:
|
|
63
|
-
startWorldX:
|
|
64
|
-
startWorldY:
|
|
65
|
-
worldX:
|
|
66
|
-
worldY:
|
|
91
|
+
pointerId: i.pointerId,
|
|
92
|
+
startClientX: i.clientX,
|
|
93
|
+
startClientY: i.clientY,
|
|
94
|
+
startWorldX: t.x,
|
|
95
|
+
startWorldY: t.y,
|
|
96
|
+
worldX: t.x,
|
|
97
|
+
worldY: t.y,
|
|
67
98
|
moved: !1,
|
|
68
99
|
scale: a,
|
|
69
100
|
stopInteraction: n
|
|
70
101
|
});
|
|
71
102
|
const r = (o) => {
|
|
72
|
-
C((
|
|
73
|
-
if (!
|
|
74
|
-
const
|
|
103
|
+
C((e) => {
|
|
104
|
+
if (!e || e.pointerId !== o.pointerId) return e;
|
|
105
|
+
const l = e.startWorldX + (o.clientX - e.startClientX) / e.scale, g = e.startWorldY + (o.clientY - e.startClientY) / e.scale;
|
|
75
106
|
return {
|
|
76
|
-
...
|
|
77
|
-
worldX:
|
|
107
|
+
...e,
|
|
108
|
+
worldX: l,
|
|
78
109
|
worldY: g,
|
|
79
|
-
moved:
|
|
110
|
+
moved: e.moved || Math.abs(l - e.startWorldX) > 2 || Math.abs(g - e.startWorldY) > 2
|
|
80
111
|
};
|
|
81
112
|
});
|
|
82
113
|
}, s = (o) => {
|
|
83
|
-
o.pointerId ===
|
|
114
|
+
o.pointerId === i.pointerId && E(!0);
|
|
84
115
|
}, c = (o) => {
|
|
85
|
-
o.pointerId ===
|
|
86
|
-
},
|
|
87
|
-
h =
|
|
88
|
-
signal:
|
|
116
|
+
o.pointerId === i.pointerId && E(!1);
|
|
117
|
+
}, d = new AbortController();
|
|
118
|
+
h = d, window.addEventListener("pointermove", r, {
|
|
119
|
+
signal: d.signal
|
|
89
120
|
}), window.addEventListener("pointerup", s, {
|
|
90
121
|
once: !0,
|
|
91
|
-
signal:
|
|
122
|
+
signal: d.signal
|
|
92
123
|
}), window.addEventListener("pointercancel", c, {
|
|
93
124
|
once: !0,
|
|
94
|
-
signal:
|
|
125
|
+
signal: d.signal
|
|
95
126
|
});
|
|
96
|
-
},
|
|
97
|
-
const n =
|
|
127
|
+
}, L = (i) => {
|
|
128
|
+
const n = x(v);
|
|
98
129
|
if (!n) return;
|
|
99
130
|
const a = {
|
|
100
131
|
width: n.width,
|
|
101
132
|
height: n.height
|
|
102
133
|
}, r = Math.abs(n.width - n.startWidth) > 1 || Math.abs(n.height - n.startHeight) > 1;
|
|
103
|
-
|
|
104
|
-
},
|
|
105
|
-
if (
|
|
106
|
-
|
|
107
|
-
const n =
|
|
134
|
+
i && r && t.onCommitResize(t.widgetId, a), n.stopInteraction(), M(null), w?.abort(), w = void 0;
|
|
135
|
+
}, F = (i) => {
|
|
136
|
+
if (i.button !== 0 || t.locked) return;
|
|
137
|
+
i.preventDefault(), i.stopPropagation(), w?.abort(), t.onStartOptimisticFront(t.widgetId);
|
|
138
|
+
const n = A({
|
|
108
139
|
kind: "drag",
|
|
109
140
|
cursor: "nwse-resize"
|
|
110
|
-
}), a = Math.max(
|
|
111
|
-
|
|
112
|
-
pointerId:
|
|
113
|
-
startClientX:
|
|
114
|
-
startClientY:
|
|
115
|
-
startWidth:
|
|
116
|
-
startHeight:
|
|
117
|
-
width:
|
|
118
|
-
height:
|
|
141
|
+
}), a = Math.max(t.viewportScale, 1e-3);
|
|
142
|
+
M({
|
|
143
|
+
pointerId: i.pointerId,
|
|
144
|
+
startClientX: i.clientX,
|
|
145
|
+
startClientY: i.clientY,
|
|
146
|
+
startWidth: t.width,
|
|
147
|
+
startHeight: t.height,
|
|
148
|
+
width: t.width,
|
|
149
|
+
height: t.height,
|
|
119
150
|
scale: a,
|
|
120
151
|
stopInteraction: n
|
|
121
152
|
});
|
|
122
153
|
const r = (o) => {
|
|
123
|
-
|
|
124
|
-
if (!
|
|
125
|
-
const
|
|
154
|
+
M((e) => {
|
|
155
|
+
if (!e || e.pointerId !== o.pointerId) return e;
|
|
156
|
+
const l = Math.max(at, e.startWidth + (o.clientX - e.startClientX) / e.scale), g = Math.max(rt, e.startHeight + (o.clientY - e.startClientY) / e.scale);
|
|
126
157
|
return {
|
|
127
|
-
...
|
|
128
|
-
width:
|
|
158
|
+
...e,
|
|
159
|
+
width: l,
|
|
129
160
|
height: g
|
|
130
161
|
};
|
|
131
162
|
});
|
|
132
163
|
}, s = (o) => {
|
|
133
|
-
o.pointerId ===
|
|
164
|
+
o.pointerId === i.pointerId && L(!0);
|
|
134
165
|
}, c = (o) => {
|
|
135
|
-
o.pointerId ===
|
|
136
|
-
},
|
|
137
|
-
w =
|
|
138
|
-
signal:
|
|
166
|
+
o.pointerId === i.pointerId && L(!1);
|
|
167
|
+
}, d = new AbortController();
|
|
168
|
+
w = d, window.addEventListener("pointermove", r, {
|
|
169
|
+
signal: d.signal
|
|
139
170
|
}), window.addEventListener("pointerup", s, {
|
|
140
171
|
once: !0,
|
|
141
|
-
signal:
|
|
172
|
+
signal: d.signal
|
|
142
173
|
}), window.addEventListener("pointercancel", c, {
|
|
143
174
|
once: !0,
|
|
144
|
-
signal:
|
|
175
|
+
signal: d.signal
|
|
145
176
|
});
|
|
146
177
|
};
|
|
147
178
|
return (() => {
|
|
148
|
-
var
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
},
|
|
152
|
-
|
|
153
|
-
}),
|
|
179
|
+
var i = nt(), n = i.firstChild, a = n.firstChild, r = a.nextSibling, s = r.firstChild, c = r.nextSibling, d = n.nextSibling;
|
|
180
|
+
i.$$contextmenu = (e) => {
|
|
181
|
+
$(e.target) === "widget_shell" && (e.preventDefault(), e.stopPropagation(), t.onContextMenu(e, t.itemSnapshot()));
|
|
182
|
+
}, i.addEventListener("focus", () => {
|
|
183
|
+
t.onSelect(t.widgetId);
|
|
184
|
+
}), i.$$pointerdown = P;
|
|
154
185
|
var o = b;
|
|
155
|
-
return typeof o == "function" ? U(o,
|
|
156
|
-
[
|
|
157
|
-
}, !1, !0), a.$$pointerdown =
|
|
186
|
+
return typeof o == "function" ? U(o, i) : b = i, G(n, {
|
|
187
|
+
[tt]: "true"
|
|
188
|
+
}, !1, !0), a.$$pointerdown = N, u(a, _(Z, {
|
|
158
189
|
class: "w-3.5 h-3.5"
|
|
159
190
|
})), u(r, () => {
|
|
160
|
-
const
|
|
161
|
-
return
|
|
191
|
+
const e = t.definition.icon;
|
|
192
|
+
return _(e, {
|
|
162
193
|
class: "w-3.5 h-3.5"
|
|
163
194
|
});
|
|
164
|
-
}, s), u(s, () =>
|
|
165
|
-
|
|
166
|
-
}, c.$$pointerdown = (
|
|
195
|
+
}, s), u(s, () => t.widgetTitle), c.$$click = (e) => {
|
|
196
|
+
e.stopPropagation(), e.preventDefault(), t.onRequestDelete(t.widgetId);
|
|
197
|
+
}, c.$$pointerdown = (e) => e.stopPropagation(), u(c, _(p, {
|
|
167
198
|
class: "w-3 h-3"
|
|
168
|
-
})), u(
|
|
169
|
-
const
|
|
170
|
-
return
|
|
199
|
+
})), u(d, () => {
|
|
200
|
+
const e = t.definition.body;
|
|
201
|
+
return _(e, {
|
|
171
202
|
get widgetId() {
|
|
172
|
-
return
|
|
203
|
+
return t.widgetId;
|
|
173
204
|
},
|
|
174
205
|
get title() {
|
|
175
|
-
return
|
|
206
|
+
return t.widgetTitle;
|
|
176
207
|
},
|
|
177
208
|
get type() {
|
|
178
|
-
return
|
|
209
|
+
return t.widgetType;
|
|
210
|
+
},
|
|
211
|
+
get surfaceMetrics() {
|
|
212
|
+
return k();
|
|
179
213
|
}
|
|
180
214
|
});
|
|
181
|
-
}), u(
|
|
182
|
-
var
|
|
183
|
-
return () =>
|
|
184
|
-
var
|
|
185
|
-
return
|
|
215
|
+
}), u(i, (() => {
|
|
216
|
+
var e = V(() => !!t.locked);
|
|
217
|
+
return () => e() ? null : (() => {
|
|
218
|
+
var l = ot();
|
|
219
|
+
return l.$$pointerdown = F, l;
|
|
186
220
|
})();
|
|
187
|
-
})(), null),
|
|
188
|
-
var
|
|
189
|
-
return
|
|
221
|
+
})(), null), K((e) => {
|
|
222
|
+
var l = !!t.selected, g = !!S(), R = !!W(), X = !!t.filtered, Y = t.layoutMode === "projected_surface", z = t.widgetId, D = t.layoutMode ?? "canvas_scaled", B = j();
|
|
223
|
+
return l !== e.e && i.classList.toggle("is-selected", e.e = l), g !== e.t && i.classList.toggle("is-dragging", e.t = g), R !== e.a && i.classList.toggle("is-resizing", e.a = R), X !== e.o && i.classList.toggle("is-filtered-out", e.o = X), Y !== e.i && i.classList.toggle("is-projected-surface", e.i = Y), z !== e.n && T(i, "data-floe-workbench-widget-id", e.n = z), D !== e.s && T(i, "data-floe-workbench-render-mode", e.s = D), e.h = q(i, B, e.h), e;
|
|
190
224
|
}, {
|
|
191
225
|
e: void 0,
|
|
192
226
|
t: void 0,
|
|
@@ -195,12 +229,11 @@ function ht(i) {
|
|
|
195
229
|
i: void 0,
|
|
196
230
|
n: void 0,
|
|
197
231
|
s: void 0,
|
|
198
|
-
h: void 0
|
|
199
|
-
|
|
200
|
-
}), e;
|
|
232
|
+
h: void 0
|
|
233
|
+
}), i;
|
|
201
234
|
})();
|
|
202
235
|
}
|
|
203
|
-
|
|
236
|
+
J(["pointerdown", "contextmenu", "click"]);
|
|
204
237
|
export {
|
|
205
|
-
|
|
238
|
+
ft as WorkbenchWidget
|
|
206
239
|
};
|
|
@@ -4,4 +4,4 @@ export { WorkbenchContextMenu, type WorkbenchContextMenuItem, type WorkbenchCont
|
|
|
4
4
|
export { useWorkbenchModel, type UseWorkbenchModelOptions } from './useWorkbenchModel';
|
|
5
5
|
export { WIDGET_REGISTRY, createWorkbenchFilterState, getWidgetEntry, isValidWorkbenchWidgetType, resolveWorkbenchWidgetDefinitions, type WidgetRegistryEntry, } from './widgets/widgetRegistry';
|
|
6
6
|
export * from './types';
|
|
7
|
-
export { sanitizeWorkbenchState, createDefaultWorkbenchState, createWorkbenchId, createWorkbenchRenderLayerMap, type WorkbenchRenderLayerMap, } from './workbenchHelpers';
|
|
7
|
+
export { sanitizeWorkbenchState, createDefaultWorkbenchState, createWorkbenchId, createWorkbenchProjectedRect, createWorkbenchRenderLayerMap, createWorkbenchWidgetSurfaceMetrics, resolveWorkbenchWidgetRenderMode, type WorkbenchRenderLayerMap, } from './workbenchHelpers';
|
|
@@ -2,10 +2,28 @@ import type { Component } from 'solid-js';
|
|
|
2
2
|
export type BuiltinWorkbenchWidgetType = 'terminal' | 'file-browser' | 'system-monitor' | 'log-viewer' | 'code-editor';
|
|
3
3
|
export type WorkbenchWidgetType = BuiltinWorkbenchWidgetType | (string & {});
|
|
4
4
|
export declare const WORKBENCH_WIDGET_TYPES: readonly WorkbenchWidgetType[];
|
|
5
|
+
export type WorkbenchWidgetRenderMode = 'canvas_scaled' | 'projected_surface';
|
|
6
|
+
export interface WorkbenchProjectedRect {
|
|
7
|
+
widgetId: string;
|
|
8
|
+
worldX: number;
|
|
9
|
+
worldY: number;
|
|
10
|
+
worldWidth: number;
|
|
11
|
+
worldHeight: number;
|
|
12
|
+
screenX: number;
|
|
13
|
+
screenY: number;
|
|
14
|
+
screenWidth: number;
|
|
15
|
+
screenHeight: number;
|
|
16
|
+
viewportScale: number;
|
|
17
|
+
}
|
|
18
|
+
export interface WorkbenchWidgetSurfaceMetrics {
|
|
19
|
+
ready: boolean;
|
|
20
|
+
rect: WorkbenchProjectedRect;
|
|
21
|
+
}
|
|
5
22
|
export interface WorkbenchWidgetBodyProps<TWidgetType extends string = WorkbenchWidgetType> {
|
|
6
23
|
widgetId: string;
|
|
7
24
|
title: string;
|
|
8
25
|
type: TWidgetType;
|
|
26
|
+
surfaceMetrics?: WorkbenchWidgetSurfaceMetrics;
|
|
9
27
|
}
|
|
10
28
|
export interface WorkbenchWidgetDefinition<TWidgetType extends string = WorkbenchWidgetType> {
|
|
11
29
|
type: TWidgetType;
|
|
@@ -21,6 +39,7 @@ export interface WorkbenchWidgetDefinition<TWidgetType extends string = Workbenc
|
|
|
21
39
|
};
|
|
22
40
|
group?: string;
|
|
23
41
|
singleton?: boolean;
|
|
42
|
+
renderMode?: WorkbenchWidgetRenderMode;
|
|
24
43
|
}
|
|
25
44
|
export interface WorkbenchWidgetItem<TWidgetType extends string = WorkbenchWidgetType> {
|
|
26
45
|
id: string;
|
|
@@ -10,6 +10,10 @@ export interface UseWorkbenchModelOptions {
|
|
|
10
10
|
export declare function useWorkbenchModel(options: UseWorkbenchModelOptions): {
|
|
11
11
|
widgets: import("solid-js").Accessor<WorkbenchWidgetItem<WorkbenchWidgetType>[]>;
|
|
12
12
|
viewport: import("solid-js").Accessor<WorkbenchViewport>;
|
|
13
|
+
canvasFrameSize: import("solid-js").Accessor<{
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
}>;
|
|
13
17
|
locked: import("solid-js").Accessor<boolean>;
|
|
14
18
|
filters: import("solid-js").Accessor<Record<WorkbenchWidgetType, boolean>>;
|
|
15
19
|
selectedWidgetId: import("solid-js").Accessor<string | null>;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { createSignal as _, createMemo as d, onCleanup as mt } from "solid-js";
|
|
2
2
|
import { ArrowUp as Wt, Copy as xt, Trash as St } from "../icons/index.js";
|
|
3
|
-
import { getTopZIndex as Ct, createContextMenuPosition as pt, createWorkbenchId as kt, findNearestWidget as Ft, clampScale as Xt, WORKBENCH_CANVAS_ZOOM_STEP as
|
|
4
|
-
import { resolveWorkbenchWidgetDefinitions as Yt, getWidgetEntry as
|
|
3
|
+
import { getTopZIndex as Ct, createContextMenuPosition as pt, createWorkbenchId as kt, findNearestWidget as Ft, clampScale as Xt, WORKBENCH_CANVAS_ZOOM_STEP as Z, WORKBENCH_CONTEXT_MENU_WIDTH_PX as bt, estimateContextMenuHeight as Mt } from "./workbenchHelpers.js";
|
|
4
|
+
import { resolveWorkbenchWidgetDefinitions as Yt, getWidgetEntry as $, createWorkbenchFilterState as yt } from "./widgets/widgetRegistry.js";
|
|
5
5
|
function Nt(s) {
|
|
6
|
-
const [m, W] = _(null), [
|
|
6
|
+
const [m, W] = _(null), [j, A] = _(null), [D, K] = _({ width: 0, height: 0 });
|
|
7
7
|
let r = null, x = null;
|
|
8
|
-
const a = s.state, h = d(() => a().widgets), u = d(() => a().viewport), L = d(() => a().locked),
|
|
8
|
+
const a = s.state, h = d(() => a().widgets), u = d(() => a().viewport), L = d(() => a().locked), T = d(() => a().filters), k = d(() => a().selectedWidgetId), F = d(() => Ct(h())), U = d(() => `${Math.round(u().scale * 100)}%`), G = () => typeof s.widgetDefinitions == "function" ? s.widgetDefinitions() : s.widgetDefinitions, f = d(
|
|
9
9
|
() => Yt(G())
|
|
10
10
|
), X = (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 }, c =
|
|
11
|
+
const n = Number.isFinite(t) && t > 0 ? t : 0, i = Number.isFinite(e) && e > 0 ? e : 0, o = { width: n, height: i }, c = D();
|
|
12
12
|
return c.width === n && c.height === i ? c : (K(o), o);
|
|
13
|
-
},
|
|
13
|
+
}, N = () => {
|
|
14
14
|
x?.disconnect(), x = null;
|
|
15
15
|
}, w = () => r ? X(r.clientWidth, r.clientHeight) : X(0, 0), J = (t) => {
|
|
16
16
|
if (r === (t ?? null)) {
|
|
17
17
|
w();
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
N(), r = t ?? null, w(), !(!r || typeof ResizeObserver > "u") && (x = new ResizeObserver((e) => {
|
|
21
21
|
const n = e[0];
|
|
22
22
|
X(
|
|
23
23
|
n?.contentRect.width ?? r?.clientWidth ?? 0,
|
|
@@ -26,7 +26,7 @@ function Nt(s) {
|
|
|
26
26
|
}), x.observe(r));
|
|
27
27
|
};
|
|
28
28
|
mt(() => {
|
|
29
|
-
|
|
29
|
+
N(), r = null;
|
|
30
30
|
});
|
|
31
31
|
const Q = (t) => {
|
|
32
32
|
W({
|
|
@@ -43,7 +43,7 @@ function Nt(s) {
|
|
|
43
43
|
worldY: e.y,
|
|
44
44
|
widgetId: e.id
|
|
45
45
|
});
|
|
46
|
-
}, g = () => W(null), et = (t) => a().widgets.find((e) => e.id === t) ?? null, b = (t) => a().widgets.find((e) => e.type === t) ?? null,
|
|
46
|
+
}, g = () => W(null), et = (t) => a().widgets.find((e) => e.id === t) ?? null, b = (t) => a().widgets.find((e) => e.type === t) ?? null, R = d(() => {
|
|
47
47
|
const t = m();
|
|
48
48
|
if (!t) return [];
|
|
49
49
|
if (t.widgetId) {
|
|
@@ -62,7 +62,7 @@ function Nt(s) {
|
|
|
62
62
|
label: "Duplicate",
|
|
63
63
|
icon: xt,
|
|
64
64
|
onSelect: () => {
|
|
65
|
-
|
|
65
|
+
V(e.type, e.x + 32, e.y + 32), g();
|
|
66
66
|
}
|
|
67
67
|
})), n.push({ id: "separator-delete", kind: "separator" }), n.push({
|
|
68
68
|
id: "delete",
|
|
@@ -87,7 +87,7 @@ function Nt(s) {
|
|
|
87
87
|
}), nt = d(() => {
|
|
88
88
|
const t = m();
|
|
89
89
|
if (!t) return;
|
|
90
|
-
const e =
|
|
90
|
+
const e = R(), n = e.filter((o) => o.kind === "action").length, i = e.filter((o) => o.kind === "separator").length;
|
|
91
91
|
return pt({
|
|
92
92
|
clientX: t.clientX,
|
|
93
93
|
clientY: t.clientY,
|
|
@@ -95,7 +95,7 @@ function Nt(s) {
|
|
|
95
95
|
menuHeight: Mt(n, i)
|
|
96
96
|
});
|
|
97
97
|
}), M = (t, e, n) => {
|
|
98
|
-
const i =
|
|
98
|
+
const i = $(t, f()), o = i.singleton ? b(t) : null;
|
|
99
99
|
if (o)
|
|
100
100
|
return C(o, { centerViewport: !0 });
|
|
101
101
|
const c = i.defaultSize, l = {
|
|
@@ -115,9 +115,9 @@ function Nt(s) {
|
|
|
115
115
|
selectedWidgetId: l.id
|
|
116
116
|
})), l;
|
|
117
117
|
}, Y = (t, e, n) => {
|
|
118
|
-
const i =
|
|
118
|
+
const i = $(t, f()).defaultSize;
|
|
119
119
|
return M(t, e - i.width / 2, n - i.height / 2);
|
|
120
|
-
},
|
|
120
|
+
}, V = (t, e, n) => M(t, e, n), y = (t) => {
|
|
121
121
|
s.setState((e) => ({
|
|
122
122
|
...e,
|
|
123
123
|
widgets: e.widgets.filter((n) => n.id !== t),
|
|
@@ -150,9 +150,9 @@ function Nt(s) {
|
|
|
150
150
|
}));
|
|
151
151
|
}, I = (t) => {
|
|
152
152
|
s.setState((e) => ({ ...e, viewport: t }));
|
|
153
|
-
},
|
|
153
|
+
}, H = (t) => {
|
|
154
154
|
const e = u(), n = w(), i = (n.width / 2 - e.x) / e.scale, o = (n.height / 2 - e.y) / e.scale, c = Xt(
|
|
155
|
-
t === "in" ? e.scale *
|
|
155
|
+
t === "in" ? e.scale * Z : e.scale / Z
|
|
156
156
|
), l = {
|
|
157
157
|
x: n.width / 2 - i * c,
|
|
158
158
|
y: n.height / 2 - o * c,
|
|
@@ -179,7 +179,7 @@ function Nt(s) {
|
|
|
179
179
|
...e,
|
|
180
180
|
filters: t
|
|
181
181
|
}));
|
|
182
|
-
},
|
|
182
|
+
}, E = (t) => {
|
|
183
183
|
s.setState((e) => ({ ...e, selectedWidgetId: t }));
|
|
184
184
|
}, at = () => {
|
|
185
185
|
const t = w(), e = u();
|
|
@@ -188,38 +188,39 @@ function Nt(s) {
|
|
|
188
188
|
worldY: t.height > 0 ? (t.height / 2 - e.y) / e.scale : 180
|
|
189
189
|
};
|
|
190
190
|
};
|
|
191
|
-
let
|
|
191
|
+
let q = 0;
|
|
192
192
|
const ut = (t, e, n) => {
|
|
193
|
-
const i = u(), o = i.x, c = i.y, l = i.scale, p = performance.now(), gt = 360, ht = ++
|
|
194
|
-
if (ht !==
|
|
195
|
-
const wt = v - p,
|
|
193
|
+
const i = u(), o = i.x, c = i.y, l = i.scale, p = performance.now(), gt = 360, ht = ++q, ft = (v) => 1 - Math.pow(1 - v, 3), B = (v) => {
|
|
194
|
+
if (ht !== q) return;
|
|
195
|
+
const wt = v - p, P = Math.min(Math.max(wt / gt, 0), 1), O = ft(P);
|
|
196
196
|
I({
|
|
197
197
|
x: o + (t - o) * O,
|
|
198
198
|
y: c + (e - c) * O,
|
|
199
199
|
scale: l + (n - l) * O
|
|
200
|
-
}),
|
|
200
|
+
}), P < 1 && requestAnimationFrame(B);
|
|
201
201
|
};
|
|
202
|
-
requestAnimationFrame(
|
|
202
|
+
requestAnimationFrame(B);
|
|
203
203
|
}, z = (t) => {
|
|
204
204
|
const e = w();
|
|
205
205
|
if (e.width === 0 || e.height === 0) return;
|
|
206
206
|
const n = u(), i = e.width / 2 - (t.x + t.width / 2) * n.scale, o = e.height / 2 - (t.y + t.height / 2) * n.scale;
|
|
207
207
|
ut(i, o, n.scale);
|
|
208
|
-
}, C = (t, e = {}) => (
|
|
208
|
+
}, C = (t, e = {}) => (E(t.id), S(t.id), e.centerViewport !== !1 && z(t), t);
|
|
209
209
|
return {
|
|
210
210
|
widgets: h,
|
|
211
211
|
viewport: u,
|
|
212
|
+
canvasFrameSize: D,
|
|
212
213
|
locked: L,
|
|
213
|
-
filters:
|
|
214
|
+
filters: T,
|
|
214
215
|
selectedWidgetId: k,
|
|
215
216
|
topZIndex: F,
|
|
216
217
|
scaleLabel: U,
|
|
217
|
-
optimisticFrontWidgetId:
|
|
218
|
+
optimisticFrontWidgetId: j,
|
|
218
219
|
widgetDefinitions: f,
|
|
219
220
|
setCanvasFrameRef: J,
|
|
220
221
|
contextMenu: {
|
|
221
222
|
state: m,
|
|
222
|
-
items:
|
|
223
|
+
items: R,
|
|
223
224
|
position: nt,
|
|
224
225
|
close: g,
|
|
225
226
|
retarget: (t) => {
|
|
@@ -234,7 +235,7 @@ function Nt(s) {
|
|
|
234
235
|
canvas: {
|
|
235
236
|
openCanvasContextMenu: Q,
|
|
236
237
|
openWidgetContextMenu: tt,
|
|
237
|
-
selectWidget:
|
|
238
|
+
selectWidget: E,
|
|
238
239
|
startOptimisticFront: it,
|
|
239
240
|
commitFront: S,
|
|
240
241
|
commitMove: ot,
|
|
@@ -242,8 +243,8 @@ function Nt(s) {
|
|
|
242
243
|
commitViewport: I
|
|
243
244
|
},
|
|
244
245
|
hud: {
|
|
245
|
-
zoomIn: () =>
|
|
246
|
-
zoomOut: () =>
|
|
246
|
+
zoomIn: () => H("in"),
|
|
247
|
+
zoomOut: () => H("out")
|
|
247
248
|
},
|
|
248
249
|
lock: {
|
|
249
250
|
toggle: ct
|
|
@@ -259,7 +260,7 @@ function Nt(s) {
|
|
|
259
260
|
h(),
|
|
260
261
|
k(),
|
|
261
262
|
t,
|
|
262
|
-
|
|
263
|
+
T()
|
|
263
264
|
);
|
|
264
265
|
e && C(e);
|
|
265
266
|
},
|
|
@@ -274,7 +275,7 @@ function Nt(s) {
|
|
|
274
275
|
deleteWidget: y,
|
|
275
276
|
addWidget: M,
|
|
276
277
|
addWidgetAtCursor: Y,
|
|
277
|
-
addWidgetCentered:
|
|
278
|
+
addWidgetCentered: V,
|
|
278
279
|
ensureWidget: (t, e) => {
|
|
279
280
|
const n = b(t);
|
|
280
281
|
if (n)
|
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
import { type WorkbenchState, type WorkbenchViewport, type WorkbenchWidgetDefinition, type WorkbenchWidgetItem, type WorkbenchWidgetType } from './types';
|
|
1
|
+
import { type WorkbenchProjectedRect, type WorkbenchState, type WorkbenchViewport, type WorkbenchWidgetDefinition, type WorkbenchWidgetItem, type WorkbenchWidgetRenderMode, type WorkbenchWidgetSurfaceMetrics, type WorkbenchWidgetType } from './types';
|
|
2
2
|
export declare function createWorkbenchId(): string;
|
|
3
|
+
export declare function resolveWorkbenchWidgetRenderMode(definition: WorkbenchWidgetDefinition): WorkbenchWidgetRenderMode;
|
|
4
|
+
export interface CreateWorkbenchProjectedRectInput {
|
|
5
|
+
widgetId: string;
|
|
6
|
+
worldX: number;
|
|
7
|
+
worldY: number;
|
|
8
|
+
worldWidth: number;
|
|
9
|
+
worldHeight: number;
|
|
10
|
+
viewport: WorkbenchViewport;
|
|
11
|
+
}
|
|
12
|
+
export declare function createWorkbenchProjectedRect(input: CreateWorkbenchProjectedRectInput): WorkbenchProjectedRect;
|
|
13
|
+
export declare function createWorkbenchWidgetSurfaceMetrics(input: CreateWorkbenchProjectedRectInput & {
|
|
14
|
+
ready: boolean;
|
|
15
|
+
}): WorkbenchWidgetSurfaceMetrics;
|
|
3
16
|
export declare function sanitizeViewport(viewport: Partial<WorkbenchViewport> | undefined): WorkbenchViewport;
|
|
4
17
|
export declare function sanitizeFilters(filters: Partial<Record<WorkbenchWidgetType, boolean>> | undefined, widgetDefinitions?: readonly WorkbenchWidgetDefinition[]): Record<WorkbenchWidgetType, boolean>;
|
|
5
18
|
export interface SanitizeWorkbenchStateOptions {
|