@floegence/floe-webapp-core 0.36.27 → 0.36.30
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/workbench/WorkbenchContextMenu.js +25 -25
- package/dist/components/workbench/WorkbenchWidget.js +234 -182
- package/dist/components/workbench/index.d.ts +1 -1
- package/dist/components/workbench/types.d.ts +2 -0
- package/dist/components/workbench/useWorkbenchModel.js +131 -115
- package/dist/components/workbench/workbenchHelpers.d.ts +2 -1
- package/dist/components/workbench/workbenchHelpers.js +87 -83
- package/dist/styles.css +1 -1
- package/dist/workbench.css +30 -0
- package/dist/workbench.js +13 -12
- package/package.json +1 -1
|
@@ -1,32 +1,35 @@
|
|
|
1
1
|
import { DEFAULT_WORKBENCH_VIEWPORT as y } from "./types.js";
|
|
2
|
-
import { resolveWorkbenchWidgetDefinitions as
|
|
3
|
-
import { DEFAULT_WORKBENCH_THEME as b, isWorkbenchThemeId as
|
|
4
|
-
function
|
|
2
|
+
import { resolveWorkbenchWidgetDefinitions as w, getWidgetEntry as _, createWorkbenchFilterState as W, isValidWorkbenchWidgetType as N } from "./widgets/widgetRegistry.js";
|
|
3
|
+
import { DEFAULT_WORKBENCH_THEME as b, isWorkbenchThemeId as v } from "./workbenchThemes.js";
|
|
4
|
+
function O() {
|
|
5
5
|
const e = globalThis.crypto;
|
|
6
6
|
return e && typeof e.randomUUID == "function" ? `wb-${e.randomUUID()}` : `wb-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
|
7
7
|
}
|
|
8
|
-
function
|
|
8
|
+
function T(e) {
|
|
9
9
|
return e.renderMode ?? "canvas_scaled";
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
|
|
11
|
+
function A(e) {
|
|
12
|
+
return e.projectedSurfaceScaleBehavior ?? "stable_transform";
|
|
13
|
+
}
|
|
14
|
+
function H(e) {
|
|
15
|
+
const t = Number.isFinite(e.viewport.scale) && e.viewport.scale > 0 ? e.viewport.scale : 1, r = typeof window < "u" && Number.isFinite(window.devicePixelRatio) && window.devicePixelRatio > 0 ? window.devicePixelRatio : 1, d = Math.round((e.viewport.x + e.worldX * t) * r) / r, i = Math.round((e.viewport.y + e.worldY * t) * r) / r;
|
|
13
16
|
return {
|
|
14
17
|
widgetId: e.widgetId,
|
|
15
18
|
worldX: e.worldX,
|
|
16
19
|
worldY: e.worldY,
|
|
17
20
|
worldWidth: e.worldWidth,
|
|
18
21
|
worldHeight: e.worldHeight,
|
|
19
|
-
screenX:
|
|
20
|
-
screenY:
|
|
22
|
+
screenX: d,
|
|
23
|
+
screenY: i,
|
|
21
24
|
screenWidth: e.worldWidth * t,
|
|
22
25
|
screenHeight: e.worldHeight * t,
|
|
23
26
|
viewportScale: t
|
|
24
27
|
};
|
|
25
28
|
}
|
|
26
|
-
function
|
|
29
|
+
function B(e) {
|
|
27
30
|
return {
|
|
28
31
|
ready: e.ready,
|
|
29
|
-
rect:
|
|
32
|
+
rect: H(e)
|
|
30
33
|
};
|
|
31
34
|
}
|
|
32
35
|
function F(e) {
|
|
@@ -36,126 +39,126 @@ function F(e) {
|
|
|
36
39
|
scale: Number.isFinite(e.scale) && e.scale > 0 ? e.scale : 1
|
|
37
40
|
} : { ...y };
|
|
38
41
|
}
|
|
39
|
-
function
|
|
40
|
-
return
|
|
42
|
+
function E(e, t) {
|
|
43
|
+
return W(t, e);
|
|
41
44
|
}
|
|
42
45
|
function X(e, t = {}) {
|
|
43
|
-
const r =
|
|
44
|
-
if (!
|
|
46
|
+
const r = w(t.widgetDefinitions), d = t.createFallbackState ?? (() => I(r)), i = e;
|
|
47
|
+
if (!i || i.version !== 1 || !Array.isArray(i.widgets))
|
|
45
48
|
return d();
|
|
46
|
-
const a =
|
|
47
|
-
(
|
|
48
|
-
).map((
|
|
49
|
-
const h =
|
|
49
|
+
const a = i.widgets.filter(
|
|
50
|
+
(n) => !!n && typeof n.id == "string" && N(n.type, r) && typeof n.title == "string"
|
|
51
|
+
).map((n) => {
|
|
52
|
+
const h = _(n.type, r);
|
|
50
53
|
return {
|
|
51
|
-
id:
|
|
52
|
-
type:
|
|
53
|
-
title:
|
|
54
|
-
x: Number.isFinite(
|
|
55
|
-
y: Number.isFinite(
|
|
56
|
-
width: Number.isFinite(
|
|
57
|
-
height: Number.isFinite(
|
|
58
|
-
z_index: Number.isFinite(
|
|
59
|
-
created_at_unix_ms: Number.isFinite(
|
|
54
|
+
id: n.id,
|
|
55
|
+
type: n.type,
|
|
56
|
+
title: n.title,
|
|
57
|
+
x: Number.isFinite(n.x) ? n.x : 0,
|
|
58
|
+
y: Number.isFinite(n.y) ? n.y : 0,
|
|
59
|
+
width: Number.isFinite(n.width) && n.width > 0 ? n.width : h.defaultSize.width,
|
|
60
|
+
height: Number.isFinite(n.height) && n.height > 0 ? n.height : h.defaultSize.height,
|
|
61
|
+
z_index: Number.isFinite(n.z_index) && n.z_index >= 0 ? n.z_index : 1,
|
|
62
|
+
created_at_unix_ms: Number.isFinite(n.created_at_unix_ms) ? n.created_at_unix_ms : Date.now()
|
|
60
63
|
};
|
|
61
|
-
}), c = typeof
|
|
64
|
+
}), c = typeof i.selectedWidgetId == "string" && a.some((n) => n.id === i.selectedWidgetId) ? i.selectedWidgetId : null;
|
|
62
65
|
return {
|
|
63
66
|
version: 1,
|
|
64
67
|
widgets: a,
|
|
65
|
-
viewport: F(
|
|
66
|
-
locked: typeof
|
|
67
|
-
filters:
|
|
68
|
+
viewport: F(i.viewport),
|
|
69
|
+
locked: typeof i.locked == "boolean" ? i.locked : !1,
|
|
70
|
+
filters: E(i.filters, r),
|
|
68
71
|
selectedWidgetId: c,
|
|
69
|
-
theme:
|
|
72
|
+
theme: v(i.theme) ? i.theme : b
|
|
70
73
|
};
|
|
71
74
|
}
|
|
72
|
-
function
|
|
73
|
-
const t =
|
|
75
|
+
function I(e) {
|
|
76
|
+
const t = w(e), r = Date.now(), d = [
|
|
74
77
|
{ type: "terminal", title: "dev · terminal", x: 80, y: 80 },
|
|
75
78
|
{ type: "file-browser", title: "project · files", x: 600, y: 80 },
|
|
76
79
|
{ type: "system-monitor", title: "host · system monitor", x: 80, y: 420 },
|
|
77
80
|
{ type: "log-viewer", title: "services · logs", x: 540, y: 500 },
|
|
78
81
|
{ type: "code-editor", title: "Counter.tsx", x: 1e3, y: 180 }
|
|
79
|
-
],
|
|
80
|
-
const
|
|
82
|
+
], i = d.filter((a) => t.some((c) => c.type === a.type)).map((a, c) => {
|
|
83
|
+
const n = _(a.type, t);
|
|
81
84
|
return {
|
|
82
85
|
id: `wb-seed-${c + 1}`,
|
|
83
86
|
type: a.type,
|
|
84
87
|
title: a.title,
|
|
85
88
|
x: a.x,
|
|
86
89
|
y: a.y,
|
|
87
|
-
width:
|
|
88
|
-
height:
|
|
90
|
+
width: n.defaultSize.width,
|
|
91
|
+
height: n.defaultSize.height,
|
|
89
92
|
z_index: c + 1,
|
|
90
93
|
created_at_unix_ms: r - (d.length - c) * 6e5
|
|
91
94
|
};
|
|
92
95
|
});
|
|
93
96
|
return {
|
|
94
97
|
version: 1,
|
|
95
|
-
widgets:
|
|
98
|
+
widgets: i,
|
|
96
99
|
viewport: { ...y },
|
|
97
100
|
locked: !1,
|
|
98
|
-
filters:
|
|
99
|
-
selectedWidgetId:
|
|
101
|
+
filters: W(t),
|
|
102
|
+
selectedWidgetId: i[0]?.id ?? null,
|
|
100
103
|
theme: b
|
|
101
104
|
};
|
|
102
105
|
}
|
|
103
|
-
const
|
|
104
|
-
function
|
|
105
|
-
const t = M(e.scale,
|
|
106
|
+
const K = 1.18, U = 200, u = 0.45, m = 2.2, p = 48;
|
|
107
|
+
function R(e) {
|
|
108
|
+
const t = M(e.scale, u, m);
|
|
106
109
|
return {
|
|
107
110
|
x: e.frameWidth / 2 - (e.widget.x + e.widget.width / 2) * t,
|
|
108
111
|
y: e.frameHeight / 2 - (e.widget.y + e.widget.height / 2) * t,
|
|
109
112
|
scale: t
|
|
110
113
|
};
|
|
111
114
|
}
|
|
112
|
-
function
|
|
113
|
-
const t = e.minScale ??
|
|
115
|
+
function V(e) {
|
|
116
|
+
const t = e.minScale ?? u, r = e.maxScale ?? m, d = e.paddingPx ?? p, i = Math.max(e.frameWidth - d * 2, 1), a = Math.max(e.frameHeight - d * 2, 1), c = M(
|
|
114
117
|
Math.min(
|
|
115
|
-
|
|
118
|
+
i / Math.max(e.widget.width, 1),
|
|
116
119
|
a / Math.max(e.widget.height, 1)
|
|
117
120
|
),
|
|
118
121
|
t,
|
|
119
122
|
r
|
|
120
123
|
);
|
|
121
|
-
return
|
|
124
|
+
return R({
|
|
122
125
|
widget: e.widget,
|
|
123
126
|
scale: c,
|
|
124
127
|
frameWidth: e.frameWidth,
|
|
125
128
|
frameHeight: e.frameHeight
|
|
126
129
|
});
|
|
127
130
|
}
|
|
128
|
-
function
|
|
131
|
+
function z(e, t) {
|
|
129
132
|
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);
|
|
130
133
|
}
|
|
131
|
-
function
|
|
132
|
-
const t = [...e].sort(
|
|
133
|
-
for (const [d,
|
|
134
|
-
r.set(
|
|
134
|
+
function L(e) {
|
|
135
|
+
const t = [...e].sort(z), r = /* @__PURE__ */ new Map();
|
|
136
|
+
for (const [d, i] of t.entries())
|
|
137
|
+
r.set(i.id, d + 1);
|
|
135
138
|
return {
|
|
136
139
|
byWidgetId: r,
|
|
137
140
|
topRenderLayer: Math.max(t.length, 1)
|
|
138
141
|
};
|
|
139
142
|
}
|
|
140
|
-
function
|
|
143
|
+
function Y(e) {
|
|
141
144
|
const t = typeof window < "u" ? window.innerWidth : 1280, r = typeof window < "u" ? window.innerHeight : 800;
|
|
142
|
-
let d = e.clientX,
|
|
143
|
-
return d + e.menuWidth > t && (d = Math.max(0, t - e.menuWidth - 8)),
|
|
145
|
+
let d = e.clientX, i = e.clientY;
|
|
146
|
+
return d + e.menuWidth > t && (d = Math.max(0, t - e.menuWidth - 8)), i + e.menuHeight > r && (i = Math.max(0, r - e.menuHeight - 8)), { left: d, top: i };
|
|
144
147
|
}
|
|
145
|
-
function
|
|
148
|
+
function j(e) {
|
|
146
149
|
return e.reduce((t, r) => Math.max(t, r.z_index), 1);
|
|
147
150
|
}
|
|
148
151
|
function $(e, t, r, d) {
|
|
149
|
-
const
|
|
150
|
-
if (
|
|
151
|
-
if (!t) return
|
|
152
|
-
const a =
|
|
153
|
-
if (!a) return
|
|
154
|
-
const c = a.x + a.width / 2,
|
|
152
|
+
const i = e.filter((o) => d[o.type]);
|
|
153
|
+
if (i.length === 0) return null;
|
|
154
|
+
if (!t) return i[0] ?? null;
|
|
155
|
+
const a = i.find((o) => o.id === t);
|
|
156
|
+
if (!a) return i[0] ?? null;
|
|
157
|
+
const c = a.x + a.width / 2, n = a.y + a.height / 2;
|
|
155
158
|
let h = null, g = 1 / 0;
|
|
156
|
-
for (const o of
|
|
159
|
+
for (const o of i) {
|
|
157
160
|
if (o.id === t) continue;
|
|
158
|
-
const s = o.x + o.width / 2 - c, l = o.y + o.height / 2 -
|
|
161
|
+
const s = o.x + o.width / 2 - c, l = o.y + o.height / 2 - n;
|
|
159
162
|
let f = !1;
|
|
160
163
|
switch (r) {
|
|
161
164
|
case "up":
|
|
@@ -180,32 +183,33 @@ function $(e, t, r, d) {
|
|
|
180
183
|
}
|
|
181
184
|
return h;
|
|
182
185
|
}
|
|
183
|
-
function M(e, t =
|
|
186
|
+
function M(e, t = u, r = m) {
|
|
184
187
|
return Math.max(t, Math.min(r, e));
|
|
185
188
|
}
|
|
186
|
-
function
|
|
189
|
+
function Z(e, t = 0) {
|
|
187
190
|
return 16 + Math.max(1, e) * 32 + Math.max(0, t) * 9;
|
|
188
191
|
}
|
|
189
192
|
export {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
193
|
+
K as WORKBENCH_CANVAS_ZOOM_STEP,
|
|
194
|
+
U as WORKBENCH_CONTEXT_MENU_WIDTH_PX,
|
|
195
|
+
m as WORKBENCH_MAX_SCALE,
|
|
196
|
+
u as WORKBENCH_MIN_SCALE,
|
|
194
197
|
p as WORKBENCH_VIEWPORT_FIT_PADDING_PX,
|
|
195
198
|
M as clampScale,
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
199
|
+
Y as createContextMenuPosition,
|
|
200
|
+
I as createDefaultWorkbenchState,
|
|
201
|
+
O as createWorkbenchId,
|
|
202
|
+
H as createWorkbenchProjectedRect,
|
|
203
|
+
L as createWorkbenchRenderLayerMap,
|
|
204
|
+
R as createWorkbenchViewportCenteredOnWidget,
|
|
205
|
+
V as createWorkbenchViewportFitForWidget,
|
|
206
|
+
B as createWorkbenchWidgetSurfaceMetrics,
|
|
207
|
+
Z as estimateContextMenuHeight,
|
|
205
208
|
$ as findNearestWidget,
|
|
206
|
-
|
|
207
|
-
A as
|
|
208
|
-
|
|
209
|
+
j as getTopZIndex,
|
|
210
|
+
A as resolveWorkbenchProjectedSurfaceScaleBehavior,
|
|
211
|
+
T as resolveWorkbenchWidgetRenderMode,
|
|
212
|
+
E as sanitizeFilters,
|
|
209
213
|
F as sanitizeViewport,
|
|
210
214
|
X as sanitizeWorkbenchState
|
|
211
215
|
};
|