@floegence/floe-webapp-core 0.36.3 → 0.36.4
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/index.d.ts +1 -1
- package/dist/components/ui/localInteractionSurface.d.ts +8 -0
- package/dist/components/ui/localInteractionSurface.js +28 -15
- package/dist/components/workbench/WorkbenchCanvas.d.ts +0 -1
- package/dist/components/workbench/WorkbenchCanvas.js +6 -9
- package/dist/components/workbench/WorkbenchCanvasField.d.ts +0 -1
- package/dist/components/workbench/WorkbenchCanvasField.js +60 -61
- package/dist/components/workbench/WorkbenchSurface.js +6 -9
- package/dist/components/workbench/WorkbenchWidget.d.ts +2 -2
- package/dist/components/workbench/WorkbenchWidget.js +144 -130
- package/dist/components/workbench/index.d.ts +1 -1
- package/dist/components/workbench/workbenchHelpers.d.ts +5 -0
- package/dist/components/workbench/workbenchHelpers.js +85 -72
- package/dist/full.js +467 -464
- package/dist/styles.css +1 -1
- package/dist/ui.js +91 -88
- package/dist/workbench.css +1 -0
- package/dist/workbench.js +12 -11
- package/package.json +1 -1
|
@@ -1,178 +1,192 @@
|
|
|
1
|
-
import { insert as u, createComponent as
|
|
2
|
-
import { createSignal as
|
|
3
|
-
import { startHotInteraction as
|
|
4
|
-
import { GripVertical as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { spread as G, insert as u, createComponent as I, memo as K, effect as V, setAttribute as q, setStyleProperty as m, template as P, use as U, delegateEvents as j } from "solid-js/web";
|
|
2
|
+
import { createSignal as H, onCleanup as J, untrack as _, createMemo as A } from "solid-js";
|
|
3
|
+
import { startHotInteraction as O } from "../../utils/hotInteraction.js";
|
|
4
|
+
import { GripVertical as Q, X as Z } from "../icons/index.js";
|
|
5
|
+
import { WORKBENCH_WIDGET_SHELL_ATTR as p, resolveWorkbenchWidgetEventOwnership as tt } from "../ui/localInteractionSurface.js";
|
|
6
|
+
var et = /* @__PURE__ */ P('<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>'), it = /* @__PURE__ */ P('<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">');
|
|
7
|
+
const nt = 220, ot = 160, at = '[data-floe-canvas-interactive="true"]', rt = '[data-floe-canvas-pan-surface="true"]';
|
|
8
|
+
function ht(i) {
|
|
9
|
+
const [f, C] = H(null), [v, x] = H(null);
|
|
10
|
+
let h, w, b;
|
|
11
|
+
J(() => {
|
|
12
|
+
h?.abort(), h = void 0, w?.abort(), w = void 0, _(f)?.stopInteraction(), _(v)?.stopInteraction();
|
|
12
13
|
});
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
const S = () => f() !== null, y = () => v() !== null, E = (e) => tt({
|
|
15
|
+
target: e,
|
|
16
|
+
widgetRoot: b ?? null,
|
|
17
|
+
interactiveSelector: at,
|
|
18
|
+
panSurfaceSelector: rt
|
|
19
|
+
}), N = (e) => {
|
|
20
|
+
e.button === 0 && (i.onSelect(i.widgetId), i.onCommitFront(i.widgetId), E(e.target) === "widget_shell" && b?.focus({
|
|
21
|
+
preventScroll: !0
|
|
22
|
+
}));
|
|
23
|
+
}, W = A(() => {
|
|
24
|
+
const e = f();
|
|
25
|
+
return e ? {
|
|
26
|
+
x: e.worldX,
|
|
27
|
+
y: e.worldY
|
|
18
28
|
} : {
|
|
19
|
-
x:
|
|
20
|
-
y:
|
|
29
|
+
x: i.x,
|
|
30
|
+
y: i.y
|
|
21
31
|
};
|
|
22
|
-
}),
|
|
23
|
-
const
|
|
24
|
-
return
|
|
25
|
-
width: i.width,
|
|
26
|
-
height: i.height
|
|
27
|
-
} : {
|
|
32
|
+
}), M = A(() => {
|
|
33
|
+
const e = v();
|
|
34
|
+
return e ? {
|
|
28
35
|
width: e.width,
|
|
29
36
|
height: e.height
|
|
37
|
+
} : {
|
|
38
|
+
width: i.width,
|
|
39
|
+
height: i.height
|
|
30
40
|
};
|
|
31
|
-
}), $ = (
|
|
32
|
-
const
|
|
33
|
-
if (!
|
|
41
|
+
}), $ = (e) => {
|
|
42
|
+
const n = _(f);
|
|
43
|
+
if (!n) return;
|
|
34
44
|
const a = {
|
|
35
|
-
x:
|
|
36
|
-
y:
|
|
45
|
+
x: n.worldX,
|
|
46
|
+
y: n.worldY
|
|
37
47
|
}, r = {
|
|
38
|
-
x:
|
|
39
|
-
y:
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
}, F = (
|
|
43
|
-
if (
|
|
44
|
-
|
|
45
|
-
const
|
|
48
|
+
x: n.startWorldX,
|
|
49
|
+
y: n.startWorldY
|
|
50
|
+
}, s = e && (Math.abs(a.x - r.x) > 1 || Math.abs(a.y - r.y) > 1);
|
|
51
|
+
i.onCommitFront(i.widgetId), s && i.onCommitMove(i.widgetId, a), n.stopInteraction(), C(null), h?.abort(), h = void 0;
|
|
52
|
+
}, F = (e) => {
|
|
53
|
+
if (e.button !== 0 || i.locked) return;
|
|
54
|
+
e.preventDefault(), e.stopPropagation(), h?.abort(), i.onStartOptimisticFront(i.widgetId);
|
|
55
|
+
const n = O({
|
|
46
56
|
kind: "drag",
|
|
47
57
|
cursor: "grabbing"
|
|
48
|
-
}), a = Math.max(
|
|
49
|
-
|
|
50
|
-
pointerId:
|
|
51
|
-
startClientX:
|
|
52
|
-
startClientY:
|
|
53
|
-
startWorldX:
|
|
54
|
-
startWorldY:
|
|
55
|
-
worldX:
|
|
56
|
-
worldY:
|
|
58
|
+
}), a = Math.max(i.viewportScale, 1e-3);
|
|
59
|
+
C({
|
|
60
|
+
pointerId: e.pointerId,
|
|
61
|
+
startClientX: e.clientX,
|
|
62
|
+
startClientY: e.clientY,
|
|
63
|
+
startWorldX: i.x,
|
|
64
|
+
startWorldY: i.y,
|
|
65
|
+
worldX: i.x,
|
|
66
|
+
worldY: i.y,
|
|
57
67
|
moved: !1,
|
|
58
68
|
scale: a,
|
|
59
|
-
stopInteraction:
|
|
69
|
+
stopInteraction: n
|
|
60
70
|
});
|
|
61
|
-
const r = (
|
|
62
|
-
|
|
63
|
-
if (!
|
|
64
|
-
const
|
|
71
|
+
const r = (o) => {
|
|
72
|
+
C((t) => {
|
|
73
|
+
if (!t || t.pointerId !== o.pointerId) return t;
|
|
74
|
+
const d = t.startWorldX + (o.clientX - t.startClientX) / t.scale, g = t.startWorldY + (o.clientY - t.startClientY) / t.scale;
|
|
65
75
|
return {
|
|
66
|
-
...
|
|
67
|
-
worldX:
|
|
76
|
+
...t,
|
|
77
|
+
worldX: d,
|
|
68
78
|
worldY: g,
|
|
69
|
-
moved:
|
|
79
|
+
moved: t.moved || Math.abs(d - t.startWorldX) > 2 || Math.abs(g - t.startWorldY) > 2
|
|
70
80
|
};
|
|
71
81
|
});
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
},
|
|
77
|
-
h =
|
|
78
|
-
signal:
|
|
79
|
-
}), window.addEventListener("pointerup",
|
|
82
|
+
}, s = (o) => {
|
|
83
|
+
o.pointerId === e.pointerId && $(!0);
|
|
84
|
+
}, c = (o) => {
|
|
85
|
+
o.pointerId === e.pointerId && $(!1);
|
|
86
|
+
}, l = new AbortController();
|
|
87
|
+
h = l, window.addEventListener("pointermove", r, {
|
|
88
|
+
signal: l.signal
|
|
89
|
+
}), window.addEventListener("pointerup", s, {
|
|
80
90
|
once: !0,
|
|
81
|
-
signal:
|
|
82
|
-
}), window.addEventListener("pointercancel",
|
|
91
|
+
signal: l.signal
|
|
92
|
+
}), window.addEventListener("pointercancel", c, {
|
|
83
93
|
once: !0,
|
|
84
|
-
signal:
|
|
94
|
+
signal: l.signal
|
|
85
95
|
});
|
|
86
|
-
},
|
|
87
|
-
const
|
|
88
|
-
if (!
|
|
96
|
+
}, k = (e) => {
|
|
97
|
+
const n = _(v);
|
|
98
|
+
if (!n) return;
|
|
89
99
|
const a = {
|
|
90
|
-
width:
|
|
91
|
-
height:
|
|
92
|
-
}, r = Math.abs(
|
|
93
|
-
|
|
94
|
-
},
|
|
95
|
-
if (
|
|
96
|
-
|
|
97
|
-
const
|
|
100
|
+
width: n.width,
|
|
101
|
+
height: n.height
|
|
102
|
+
}, r = Math.abs(n.width - n.startWidth) > 1 || Math.abs(n.height - n.startHeight) > 1;
|
|
103
|
+
e && r && i.onCommitResize(i.widgetId, a), n.stopInteraction(), x(null), w?.abort(), w = void 0;
|
|
104
|
+
}, B = (e) => {
|
|
105
|
+
if (e.button !== 0 || i.locked) return;
|
|
106
|
+
e.preventDefault(), e.stopPropagation(), w?.abort(), i.onStartOptimisticFront(i.widgetId);
|
|
107
|
+
const n = O({
|
|
98
108
|
kind: "drag",
|
|
99
109
|
cursor: "nwse-resize"
|
|
100
|
-
}), a = Math.max(
|
|
101
|
-
|
|
102
|
-
pointerId:
|
|
103
|
-
startClientX:
|
|
104
|
-
startClientY:
|
|
105
|
-
startWidth:
|
|
106
|
-
startHeight:
|
|
107
|
-
width:
|
|
108
|
-
height:
|
|
110
|
+
}), a = Math.max(i.viewportScale, 1e-3);
|
|
111
|
+
x({
|
|
112
|
+
pointerId: e.pointerId,
|
|
113
|
+
startClientX: e.clientX,
|
|
114
|
+
startClientY: e.clientY,
|
|
115
|
+
startWidth: i.width,
|
|
116
|
+
startHeight: i.height,
|
|
117
|
+
width: i.width,
|
|
118
|
+
height: i.height,
|
|
109
119
|
scale: a,
|
|
110
|
-
stopInteraction:
|
|
120
|
+
stopInteraction: n
|
|
111
121
|
});
|
|
112
|
-
const r = (
|
|
113
|
-
|
|
114
|
-
if (!
|
|
115
|
-
const
|
|
122
|
+
const r = (o) => {
|
|
123
|
+
x((t) => {
|
|
124
|
+
if (!t || t.pointerId !== o.pointerId) return t;
|
|
125
|
+
const d = Math.max(nt, t.startWidth + (o.clientX - t.startClientX) / t.scale), g = Math.max(ot, t.startHeight + (o.clientY - t.startClientY) / t.scale);
|
|
116
126
|
return {
|
|
117
|
-
...
|
|
118
|
-
width:
|
|
127
|
+
...t,
|
|
128
|
+
width: d,
|
|
119
129
|
height: g
|
|
120
130
|
};
|
|
121
131
|
});
|
|
122
|
-
},
|
|
123
|
-
|
|
124
|
-
},
|
|
125
|
-
|
|
126
|
-
},
|
|
127
|
-
w =
|
|
128
|
-
signal:
|
|
129
|
-
}), window.addEventListener("pointerup",
|
|
132
|
+
}, s = (o) => {
|
|
133
|
+
o.pointerId === e.pointerId && k(!0);
|
|
134
|
+
}, c = (o) => {
|
|
135
|
+
o.pointerId === e.pointerId && k(!1);
|
|
136
|
+
}, l = new AbortController();
|
|
137
|
+
w = l, window.addEventListener("pointermove", r, {
|
|
138
|
+
signal: l.signal
|
|
139
|
+
}), window.addEventListener("pointerup", s, {
|
|
130
140
|
once: !0,
|
|
131
|
-
signal:
|
|
132
|
-
}), window.addEventListener("pointercancel",
|
|
141
|
+
signal: l.signal
|
|
142
|
+
}), window.addEventListener("pointercancel", c, {
|
|
133
143
|
once: !0,
|
|
134
|
-
signal:
|
|
144
|
+
signal: l.signal
|
|
135
145
|
});
|
|
136
146
|
};
|
|
137
147
|
return (() => {
|
|
138
|
-
var
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
},
|
|
142
|
-
|
|
143
|
-
},
|
|
148
|
+
var e = et(), n = e.firstChild, a = n.firstChild, r = a.nextSibling, s = r.firstChild, c = r.nextSibling, l = n.nextSibling;
|
|
149
|
+
e.$$contextmenu = (t) => {
|
|
150
|
+
E(t.target) === "widget_shell" && (t.preventDefault(), t.stopPropagation(), i.onContextMenu(t, i.itemSnapshot()));
|
|
151
|
+
}, e.addEventListener("focus", () => {
|
|
152
|
+
i.onSelect(i.widgetId);
|
|
153
|
+
}), e.$$pointerdown = N;
|
|
154
|
+
var o = b;
|
|
155
|
+
return typeof o == "function" ? U(o, e) : b = e, G(n, {
|
|
156
|
+
[p]: "true"
|
|
157
|
+
}, !1, !0), a.$$pointerdown = F, u(a, I(Q, {
|
|
144
158
|
class: "w-3.5 h-3.5"
|
|
145
159
|
})), u(r, () => {
|
|
146
|
-
const t =
|
|
147
|
-
return
|
|
160
|
+
const t = i.definition.icon;
|
|
161
|
+
return I(t, {
|
|
148
162
|
class: "w-3.5 h-3.5"
|
|
149
163
|
});
|
|
150
|
-
},
|
|
151
|
-
t.stopPropagation(), t.preventDefault(),
|
|
152
|
-
},
|
|
164
|
+
}, s), u(s, () => i.widgetTitle), c.$$click = (t) => {
|
|
165
|
+
t.stopPropagation(), t.preventDefault(), i.onRequestDelete(i.widgetId);
|
|
166
|
+
}, c.$$pointerdown = (t) => t.stopPropagation(), u(c, I(Z, {
|
|
153
167
|
class: "w-3 h-3"
|
|
154
|
-
})), u(
|
|
155
|
-
const t =
|
|
156
|
-
return
|
|
168
|
+
})), u(l, () => {
|
|
169
|
+
const t = i.definition.body;
|
|
170
|
+
return I(t, {
|
|
157
171
|
get widgetId() {
|
|
158
|
-
return
|
|
172
|
+
return i.widgetId;
|
|
159
173
|
},
|
|
160
174
|
get title() {
|
|
161
|
-
return
|
|
175
|
+
return i.widgetTitle;
|
|
162
176
|
},
|
|
163
177
|
get type() {
|
|
164
|
-
return
|
|
178
|
+
return i.widgetType;
|
|
165
179
|
}
|
|
166
180
|
});
|
|
167
|
-
}), u(
|
|
168
|
-
var t =
|
|
181
|
+
}), u(e, (() => {
|
|
182
|
+
var t = K(() => !!i.locked);
|
|
169
183
|
return () => t() ? null : (() => {
|
|
170
|
-
var
|
|
171
|
-
return
|
|
184
|
+
var d = it();
|
|
185
|
+
return d.$$pointerdown = B, d;
|
|
172
186
|
})();
|
|
173
|
-
})(), null),
|
|
174
|
-
var
|
|
175
|
-
return
|
|
187
|
+
})(), null), V((t) => {
|
|
188
|
+
var d = !!i.selected, g = !!S(), L = !!y(), R = !!i.filtered, X = i.widgetId, Y = `translate(${W().x}px, ${W().y}px)`, z = `${M().width}px`, D = `${M().height}px`, T = S() || y() || i.optimisticFront ? `${i.topRenderLayer + 1}` : `${i.renderLayer}`;
|
|
189
|
+
return d !== t.e && e.classList.toggle("is-selected", t.e = d), g !== t.t && e.classList.toggle("is-dragging", t.t = g), L !== t.a && e.classList.toggle("is-resizing", t.a = L), R !== t.o && e.classList.toggle("is-filtered-out", t.o = R), X !== t.i && q(e, "data-floe-workbench-widget-id", t.i = X), Y !== t.n && m(e, "transform", t.n = Y), z !== t.s && m(e, "width", t.s = z), D !== t.h && m(e, "height", t.h = D), T !== t.r && m(e, "z-index", t.r = T), t;
|
|
176
190
|
}, {
|
|
177
191
|
e: void 0,
|
|
178
192
|
t: void 0,
|
|
@@ -183,10 +197,10 @@ function et(e) {
|
|
|
183
197
|
s: void 0,
|
|
184
198
|
h: void 0,
|
|
185
199
|
r: void 0
|
|
186
|
-
}),
|
|
200
|
+
}), e;
|
|
187
201
|
})();
|
|
188
202
|
}
|
|
189
|
-
|
|
203
|
+
j(["pointerdown", "contextmenu", "click"]);
|
|
190
204
|
export {
|
|
191
|
-
|
|
205
|
+
ht as WorkbenchWidget
|
|
192
206
|
};
|
|
@@ -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, } from './workbenchHelpers';
|
|
7
|
+
export { sanitizeWorkbenchState, createDefaultWorkbenchState, createWorkbenchId, createWorkbenchRenderLayerMap, type WorkbenchRenderLayerMap, } from './workbenchHelpers';
|
|
@@ -10,6 +10,11 @@ export declare function sanitizeWorkbenchState(input: unknown, options?: Sanitiz
|
|
|
10
10
|
export declare function createDefaultWorkbenchState(widgetDefinitions?: readonly WorkbenchWidgetDefinition[]): WorkbenchState;
|
|
11
11
|
export declare const WORKBENCH_CANVAS_ZOOM_STEP = 1.18;
|
|
12
12
|
export declare const WORKBENCH_CONTEXT_MENU_WIDTH_PX = 200;
|
|
13
|
+
export interface WorkbenchRenderLayerMap {
|
|
14
|
+
byWidgetId: ReadonlyMap<string, number>;
|
|
15
|
+
topRenderLayer: number;
|
|
16
|
+
}
|
|
17
|
+
export declare function createWorkbenchRenderLayerMap(widgets: readonly WorkbenchWidgetItem[]): WorkbenchRenderLayerMap;
|
|
13
18
|
export declare function createContextMenuPosition(options: {
|
|
14
19
|
clientX: number;
|
|
15
20
|
clientY: number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DEFAULT_WORKBENCH_VIEWPORT as
|
|
2
|
-
import { resolveWorkbenchWidgetDefinitions as
|
|
1
|
+
import { DEFAULT_WORKBENCH_VIEWPORT as m } from "./types.js";
|
|
2
|
+
import { resolveWorkbenchWidgetDefinitions as x, getWidgetEntry as g, createWorkbenchFilterState as _, isValidWorkbenchWidgetType as W } from "./widgets/widgetRegistry.js";
|
|
3
3
|
function F() {
|
|
4
4
|
const e = globalThis.crypto;
|
|
5
5
|
return e && typeof e.randomUUID == "function" ? `wb-${e.randomUUID()}` : `wb-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
|
@@ -9,19 +9,19 @@ function M(e) {
|
|
|
9
9
|
x: Number.isFinite(e.x) ? e.x : 0,
|
|
10
10
|
y: Number.isFinite(e.y) ? e.y : 0,
|
|
11
11
|
scale: Number.isFinite(e.scale) && e.scale > 0 ? e.scale : 1
|
|
12
|
-
} : { ...
|
|
12
|
+
} : { ...m };
|
|
13
13
|
}
|
|
14
|
-
function k(e,
|
|
15
|
-
return
|
|
14
|
+
function k(e, i) {
|
|
15
|
+
return _(i, e);
|
|
16
16
|
}
|
|
17
|
-
function
|
|
18
|
-
const r =
|
|
19
|
-
if (!
|
|
20
|
-
return
|
|
21
|
-
const
|
|
17
|
+
function D(e, i = {}) {
|
|
18
|
+
const r = x(i.widgetDefinitions), s = i.createFallbackState ?? (() => z(r)), n = e;
|
|
19
|
+
if (!n || n.version !== 1 || !Array.isArray(n.widgets))
|
|
20
|
+
return s();
|
|
21
|
+
const a = n.widgets.filter(
|
|
22
22
|
(t) => !!t && typeof t.id == "string" && W(t.type, r) && typeof t.title == "string"
|
|
23
23
|
).map((t) => {
|
|
24
|
-
const u =
|
|
24
|
+
const u = g(t.type, r);
|
|
25
25
|
return {
|
|
26
26
|
id: t.id,
|
|
27
27
|
type: t.type,
|
|
@@ -33,107 +33,120 @@ function z(e, n = {}) {
|
|
|
33
33
|
z_index: Number.isFinite(t.z_index) && t.z_index >= 0 ? t.z_index : 1,
|
|
34
34
|
created_at_unix_ms: Number.isFinite(t.created_at_unix_ms) ? t.created_at_unix_ms : Date.now()
|
|
35
35
|
};
|
|
36
|
-
}),
|
|
36
|
+
}), d = typeof n.selectedWidgetId == "string" && a.some((t) => t.id === n.selectedWidgetId) ? n.selectedWidgetId : null;
|
|
37
37
|
return {
|
|
38
38
|
version: 1,
|
|
39
|
-
widgets:
|
|
40
|
-
viewport: M(
|
|
41
|
-
locked: typeof
|
|
42
|
-
filters: k(
|
|
43
|
-
selectedWidgetId:
|
|
39
|
+
widgets: a,
|
|
40
|
+
viewport: M(n.viewport),
|
|
41
|
+
locked: typeof n.locked == "boolean" ? n.locked : !1,
|
|
42
|
+
filters: k(n.filters, r),
|
|
43
|
+
selectedWidgetId: d
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
|
-
function
|
|
47
|
-
const
|
|
46
|
+
function z(e) {
|
|
47
|
+
const i = x(e), r = Date.now(), s = [
|
|
48
48
|
{ type: "terminal", title: "dev · terminal", x: 80, y: 80 },
|
|
49
49
|
{ type: "file-browser", title: "project · files", x: 600, y: 80 },
|
|
50
50
|
{ type: "system-monitor", title: "host · system monitor", x: 80, y: 420 },
|
|
51
51
|
{ type: "log-viewer", title: "services · logs", x: 540, y: 500 },
|
|
52
52
|
{ type: "code-editor", title: "Counter.tsx", x: 1e3, y: 180 }
|
|
53
|
-
],
|
|
54
|
-
const t =
|
|
53
|
+
], n = s.filter((a) => i.some((d) => d.type === a.type)).map((a, d) => {
|
|
54
|
+
const t = g(a.type, i);
|
|
55
55
|
return {
|
|
56
|
-
id: `wb-seed-${
|
|
57
|
-
type:
|
|
58
|
-
title:
|
|
59
|
-
x:
|
|
60
|
-
y:
|
|
56
|
+
id: `wb-seed-${d + 1}`,
|
|
57
|
+
type: a.type,
|
|
58
|
+
title: a.title,
|
|
59
|
+
x: a.x,
|
|
60
|
+
y: a.y,
|
|
61
61
|
width: t.defaultSize.width,
|
|
62
62
|
height: t.defaultSize.height,
|
|
63
|
-
z_index:
|
|
64
|
-
created_at_unix_ms: r - (
|
|
63
|
+
z_index: d + 1,
|
|
64
|
+
created_at_unix_ms: r - (s.length - d) * 6e5
|
|
65
65
|
};
|
|
66
66
|
});
|
|
67
67
|
return {
|
|
68
68
|
version: 1,
|
|
69
|
-
widgets:
|
|
70
|
-
viewport: { ...
|
|
69
|
+
widgets: n,
|
|
70
|
+
viewport: { ...m },
|
|
71
71
|
locked: !1,
|
|
72
|
-
filters:
|
|
73
|
-
selectedWidgetId:
|
|
72
|
+
filters: _(i),
|
|
73
|
+
selectedWidgetId: n[0]?.id ?? null
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
|
-
const
|
|
76
|
+
const I = 1.18, C = 200;
|
|
77
|
+
function w(e, i) {
|
|
78
|
+
return e.z_index !== i.z_index ? e.z_index - i.z_index : e.created_at_unix_ms !== i.created_at_unix_ms ? e.created_at_unix_ms - i.created_at_unix_ms : e.id.localeCompare(i.id);
|
|
79
|
+
}
|
|
77
80
|
function E(e) {
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
const i = [...e].sort(w), r = /* @__PURE__ */ new Map();
|
|
82
|
+
for (const [s, n] of i.entries())
|
|
83
|
+
r.set(n.id, s + 1);
|
|
84
|
+
return {
|
|
85
|
+
byWidgetId: r,
|
|
86
|
+
topRenderLayer: Math.max(i.length, 1)
|
|
87
|
+
};
|
|
81
88
|
}
|
|
82
89
|
function H(e) {
|
|
83
|
-
|
|
90
|
+
const i = typeof window < "u" ? window.innerWidth : 1280, r = typeof window < "u" ? window.innerHeight : 800;
|
|
91
|
+
let s = e.clientX, n = e.clientY;
|
|
92
|
+
return s + e.menuWidth > i && (s = Math.max(0, i - e.menuWidth - 8)), n + e.menuHeight > r && (n = Math.max(0, r - e.menuHeight - 8)), { left: s, top: n };
|
|
93
|
+
}
|
|
94
|
+
function T(e) {
|
|
95
|
+
return e.reduce((i, r) => Math.max(i, r.z_index), 1);
|
|
84
96
|
}
|
|
85
|
-
function
|
|
86
|
-
const
|
|
87
|
-
if (
|
|
88
|
-
if (!
|
|
89
|
-
const
|
|
90
|
-
if (!
|
|
91
|
-
const
|
|
92
|
-
let u = null,
|
|
93
|
-
for (const o of
|
|
94
|
-
if (o.id ===
|
|
95
|
-
const
|
|
96
|
-
let
|
|
97
|
+
function O(e, i, r, s) {
|
|
98
|
+
const n = e.filter((o) => s[o.type]);
|
|
99
|
+
if (n.length === 0) return null;
|
|
100
|
+
if (!i) return n[0] ?? null;
|
|
101
|
+
const a = n.find((o) => o.id === i);
|
|
102
|
+
if (!a) return n[0] ?? null;
|
|
103
|
+
const d = a.x + a.width / 2, t = a.y + a.height / 2;
|
|
104
|
+
let u = null, h = 1 / 0;
|
|
105
|
+
for (const o of n) {
|
|
106
|
+
if (o.id === i) continue;
|
|
107
|
+
const c = o.x + o.width / 2 - d, l = o.y + o.height / 2 - t;
|
|
108
|
+
let f = !1;
|
|
97
109
|
switch (r) {
|
|
98
110
|
case "up":
|
|
99
|
-
|
|
111
|
+
f = l < -10;
|
|
100
112
|
break;
|
|
101
113
|
case "down":
|
|
102
|
-
|
|
114
|
+
f = l > 10;
|
|
103
115
|
break;
|
|
104
116
|
case "left":
|
|
105
|
-
|
|
117
|
+
f = c < -10;
|
|
106
118
|
break;
|
|
107
119
|
case "right":
|
|
108
|
-
|
|
120
|
+
f = c > 10;
|
|
109
121
|
break;
|
|
110
122
|
}
|
|
111
|
-
if (!
|
|
112
|
-
const
|
|
113
|
-
Math.abs(r === "up" || r === "down" ?
|
|
114
|
-
Math.abs(r === "up" || r === "down" ? l :
|
|
115
|
-
), y =
|
|
116
|
-
y <
|
|
123
|
+
if (!f) continue;
|
|
124
|
+
const b = Math.sqrt(c * c + l * l), p = Math.atan2(
|
|
125
|
+
Math.abs(r === "up" || r === "down" ? c : l),
|
|
126
|
+
Math.abs(r === "up" || r === "down" ? l : c)
|
|
127
|
+
), y = b * (1 + p * 1.5);
|
|
128
|
+
y < h && (h = y, u = o);
|
|
117
129
|
}
|
|
118
130
|
return u;
|
|
119
131
|
}
|
|
120
|
-
function
|
|
121
|
-
return Math.max(
|
|
132
|
+
function R(e, i = 0.45, r = 2.2) {
|
|
133
|
+
return Math.max(i, Math.min(r, e));
|
|
122
134
|
}
|
|
123
|
-
function
|
|
124
|
-
return 16 + Math.max(1, e) * 32 + Math.max(0,
|
|
135
|
+
function v(e, i = 0) {
|
|
136
|
+
return 16 + Math.max(1, e) * 32 + Math.max(0, i) * 9;
|
|
125
137
|
}
|
|
126
138
|
export {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
139
|
+
I as WORKBENCH_CANVAS_ZOOM_STEP,
|
|
140
|
+
C as WORKBENCH_CONTEXT_MENU_WIDTH_PX,
|
|
141
|
+
R as clampScale,
|
|
142
|
+
H as createContextMenuPosition,
|
|
143
|
+
z as createDefaultWorkbenchState,
|
|
132
144
|
F as createWorkbenchId,
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
145
|
+
E as createWorkbenchRenderLayerMap,
|
|
146
|
+
v as estimateContextMenuHeight,
|
|
147
|
+
O as findNearestWidget,
|
|
148
|
+
T as getTopZIndex,
|
|
136
149
|
k as sanitizeFilters,
|
|
137
150
|
M as sanitizeViewport,
|
|
138
|
-
|
|
151
|
+
D as sanitizeWorkbenchState
|
|
139
152
|
};
|