@floegence/floe-webapp-core 0.36.10 → 0.36.12
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.js +7 -17
- package/dist/components/deck/DeckGrid.js +64 -64
- package/dist/components/deck/WidgetResizeHandle.js +21 -21
- package/dist/components/deck/deckGridMetrics.d.ts +7 -0
- package/dist/components/deck/deckGridMetrics.js +41 -26
- package/dist/components/deck/deckPointerSession.d.ts +2 -0
- package/dist/components/deck/deckPointerSession.js +38 -31
- package/dist/components/workbench/WorkbenchContextMenu.js +32 -27
- package/dist/components/workbench/WorkbenchSurface.d.ts +3 -0
- package/dist/components/workbench/WorkbenchSurface.js +46 -35
- package/dist/components/workbench/index.d.ts +1 -1
- package/dist/components/workbench/useWorkbenchModel.d.ts +6 -0
- package/dist/components/workbench/useWorkbenchModel.js +187 -159
- package/dist/components/workbench/workbenchContextMenuDismiss.d.ts +5 -0
- package/dist/components/workbench/workbenchContextMenuDismiss.js +29 -0
- package/dist/components/workbench/workbenchHelpers.d.ts +17 -0
- package/dist/components/workbench/workbenchHelpers.js +105 -76
- package/dist/hooks/useDeckDrag.js +4 -4
- package/dist/workbench.js +18 -16
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { DEFAULT_WORKBENCH_VIEWPORT as
|
|
2
|
-
import { resolveWorkbenchWidgetDefinitions as
|
|
3
|
-
function
|
|
1
|
+
import { DEFAULT_WORKBENCH_VIEWPORT as y } from "./types.js";
|
|
2
|
+
import { resolveWorkbenchWidgetDefinitions as _, getWidgetEntry as W, createWorkbenchFilterState as w, isValidWorkbenchWidgetType as k } from "./widgets/widgetRegistry.js";
|
|
3
|
+
function D() {
|
|
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)}`;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function O(e) {
|
|
8
8
|
return e.renderMode ?? "canvas_scaled";
|
|
9
9
|
}
|
|
10
|
-
function
|
|
10
|
+
function N(e) {
|
|
11
11
|
const t = Number.isFinite(e.viewport.scale) && e.viewport.scale > 0 ? e.viewport.scale : 1;
|
|
12
12
|
return {
|
|
13
13
|
widgetId: e.widgetId,
|
|
@@ -22,30 +22,30 @@ function p(e) {
|
|
|
22
22
|
viewportScale: t
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function R(e) {
|
|
26
26
|
return {
|
|
27
27
|
ready: e.ready,
|
|
28
|
-
rect:
|
|
28
|
+
rect: N(e)
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
-
function
|
|
31
|
+
function H(e) {
|
|
32
32
|
return e ? {
|
|
33
33
|
x: Number.isFinite(e.x) ? e.x : 0,
|
|
34
34
|
y: Number.isFinite(e.y) ? e.y : 0,
|
|
35
35
|
scale: Number.isFinite(e.scale) && e.scale > 0 ? e.scale : 1
|
|
36
|
-
} : { ...
|
|
36
|
+
} : { ...y };
|
|
37
37
|
}
|
|
38
|
-
function
|
|
39
|
-
return
|
|
38
|
+
function F(e, t) {
|
|
39
|
+
return w(t, e);
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
const r =
|
|
41
|
+
function T(e, t = {}) {
|
|
42
|
+
const r = _(t.widgetDefinitions), d = t.createFallbackState ?? (() => I(r)), n = e;
|
|
43
43
|
if (!n || n.version !== 1 || !Array.isArray(n.widgets))
|
|
44
44
|
return d();
|
|
45
|
-
const
|
|
46
|
-
(i) => !!i && typeof i.id == "string" &&
|
|
45
|
+
const a = n.widgets.filter(
|
|
46
|
+
(i) => !!i && typeof i.id == "string" && k(i.type, r) && typeof i.title == "string"
|
|
47
47
|
).map((i) => {
|
|
48
|
-
const h =
|
|
48
|
+
const h = W(i.type, r);
|
|
49
49
|
return {
|
|
50
50
|
id: i.id,
|
|
51
51
|
type: i.type,
|
|
@@ -57,52 +57,76 @@ function D(e, t = {}) {
|
|
|
57
57
|
z_index: Number.isFinite(i.z_index) && i.z_index >= 0 ? i.z_index : 1,
|
|
58
58
|
created_at_unix_ms: Number.isFinite(i.created_at_unix_ms) ? i.created_at_unix_ms : Date.now()
|
|
59
59
|
};
|
|
60
|
-
}),
|
|
60
|
+
}), c = typeof n.selectedWidgetId == "string" && a.some((i) => i.id === n.selectedWidgetId) ? n.selectedWidgetId : null;
|
|
61
61
|
return {
|
|
62
62
|
version: 1,
|
|
63
|
-
widgets:
|
|
64
|
-
viewport:
|
|
63
|
+
widgets: a,
|
|
64
|
+
viewport: H(n.viewport),
|
|
65
65
|
locked: typeof n.locked == "boolean" ? n.locked : !1,
|
|
66
|
-
filters:
|
|
67
|
-
selectedWidgetId:
|
|
66
|
+
filters: F(n.filters, r),
|
|
67
|
+
selectedWidgetId: c
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
|
-
function
|
|
71
|
-
const t =
|
|
70
|
+
function I(e) {
|
|
71
|
+
const t = _(e), r = Date.now(), d = [
|
|
72
72
|
{ type: "terminal", title: "dev · terminal", x: 80, y: 80 },
|
|
73
73
|
{ type: "file-browser", title: "project · files", x: 600, y: 80 },
|
|
74
74
|
{ type: "system-monitor", title: "host · system monitor", x: 80, y: 420 },
|
|
75
75
|
{ type: "log-viewer", title: "services · logs", x: 540, y: 500 },
|
|
76
76
|
{ type: "code-editor", title: "Counter.tsx", x: 1e3, y: 180 }
|
|
77
|
-
], n = d.filter((
|
|
78
|
-
const i =
|
|
77
|
+
], n = d.filter((a) => t.some((c) => c.type === a.type)).map((a, c) => {
|
|
78
|
+
const i = W(a.type, t);
|
|
79
79
|
return {
|
|
80
|
-
id: `wb-seed-${
|
|
81
|
-
type:
|
|
82
|
-
title:
|
|
83
|
-
x:
|
|
84
|
-
y:
|
|
80
|
+
id: `wb-seed-${c + 1}`,
|
|
81
|
+
type: a.type,
|
|
82
|
+
title: a.title,
|
|
83
|
+
x: a.x,
|
|
84
|
+
y: a.y,
|
|
85
85
|
width: i.defaultSize.width,
|
|
86
86
|
height: i.defaultSize.height,
|
|
87
|
-
z_index:
|
|
88
|
-
created_at_unix_ms: r - (d.length -
|
|
87
|
+
z_index: c + 1,
|
|
88
|
+
created_at_unix_ms: r - (d.length - c) * 6e5
|
|
89
89
|
};
|
|
90
90
|
});
|
|
91
91
|
return {
|
|
92
92
|
version: 1,
|
|
93
93
|
widgets: n,
|
|
94
|
-
viewport: { ...
|
|
94
|
+
viewport: { ...y },
|
|
95
95
|
locked: !1,
|
|
96
|
-
filters:
|
|
96
|
+
filters: w(t),
|
|
97
97
|
selectedWidgetId: n[0]?.id ?? null
|
|
98
98
|
};
|
|
99
99
|
}
|
|
100
|
-
const
|
|
101
|
-
function
|
|
100
|
+
const P = 1.18, A = 200, u = 0.45, g = 2.2, z = 48;
|
|
101
|
+
function v(e) {
|
|
102
|
+
const t = b(e.scale, u, g);
|
|
103
|
+
return {
|
|
104
|
+
x: e.frameWidth / 2 - (e.widget.x + e.widget.width / 2) * t,
|
|
105
|
+
y: e.frameHeight / 2 - (e.widget.y + e.widget.height / 2) * t,
|
|
106
|
+
scale: t
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function X(e) {
|
|
110
|
+
const t = e.minScale ?? u, r = e.maxScale ?? g, d = e.paddingPx ?? z, n = Math.max(e.frameWidth - d * 2, 1), a = Math.max(e.frameHeight - d * 2, 1), c = b(
|
|
111
|
+
Math.min(
|
|
112
|
+
n / Math.max(e.widget.width, 1),
|
|
113
|
+
a / Math.max(e.widget.height, 1)
|
|
114
|
+
),
|
|
115
|
+
t,
|
|
116
|
+
r
|
|
117
|
+
);
|
|
118
|
+
return v({
|
|
119
|
+
widget: e.widget,
|
|
120
|
+
scale: c,
|
|
121
|
+
frameWidth: e.frameWidth,
|
|
122
|
+
frameHeight: e.frameHeight
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
function p(e, t) {
|
|
102
126
|
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);
|
|
103
127
|
}
|
|
104
|
-
function
|
|
105
|
-
const t = [...e].sort(
|
|
128
|
+
function V(e) {
|
|
129
|
+
const t = [...e].sort(p), r = /* @__PURE__ */ new Map();
|
|
106
130
|
for (const [d, n] of t.entries())
|
|
107
131
|
r.set(n.id, d + 1);
|
|
108
132
|
return {
|
|
@@ -110,70 +134,75 @@ function R(e) {
|
|
|
110
134
|
topRenderLayer: Math.max(t.length, 1)
|
|
111
135
|
};
|
|
112
136
|
}
|
|
113
|
-
function
|
|
137
|
+
function B(e) {
|
|
114
138
|
const t = typeof window < "u" ? window.innerWidth : 1280, r = typeof window < "u" ? window.innerHeight : 800;
|
|
115
139
|
let d = e.clientX, n = e.clientY;
|
|
116
140
|
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 };
|
|
117
141
|
}
|
|
118
|
-
function
|
|
142
|
+
function K(e) {
|
|
119
143
|
return e.reduce((t, r) => Math.max(t, r.z_index), 1);
|
|
120
144
|
}
|
|
121
|
-
function
|
|
122
|
-
const n = e.filter((
|
|
145
|
+
function U(e, t, r, d) {
|
|
146
|
+
const n = e.filter((o) => d[o.type]);
|
|
123
147
|
if (n.length === 0) return null;
|
|
124
148
|
if (!t) return n[0] ?? null;
|
|
125
|
-
const
|
|
126
|
-
if (!
|
|
127
|
-
const
|
|
128
|
-
let h = null,
|
|
129
|
-
for (const
|
|
130
|
-
if (
|
|
131
|
-
const s =
|
|
132
|
-
let
|
|
149
|
+
const a = n.find((o) => o.id === t);
|
|
150
|
+
if (!a) return n[0] ?? null;
|
|
151
|
+
const c = a.x + a.width / 2, i = a.y + a.height / 2;
|
|
152
|
+
let h = null, m = 1 / 0;
|
|
153
|
+
for (const o of n) {
|
|
154
|
+
if (o.id === t) continue;
|
|
155
|
+
const s = o.x + o.width / 2 - c, l = o.y + o.height / 2 - i;
|
|
156
|
+
let f = !1;
|
|
133
157
|
switch (r) {
|
|
134
158
|
case "up":
|
|
135
|
-
|
|
159
|
+
f = l < -10;
|
|
136
160
|
break;
|
|
137
161
|
case "down":
|
|
138
|
-
|
|
162
|
+
f = l > 10;
|
|
139
163
|
break;
|
|
140
164
|
case "left":
|
|
141
|
-
|
|
165
|
+
f = s < -10;
|
|
142
166
|
break;
|
|
143
167
|
case "right":
|
|
144
|
-
|
|
168
|
+
f = s > 10;
|
|
145
169
|
break;
|
|
146
170
|
}
|
|
147
|
-
if (!
|
|
148
|
-
const
|
|
171
|
+
if (!f) continue;
|
|
172
|
+
const M = Math.sqrt(s * s + l * l), S = Math.atan2(
|
|
149
173
|
Math.abs(r === "up" || r === "down" ? s : l),
|
|
150
174
|
Math.abs(r === "up" || r === "down" ? l : s)
|
|
151
|
-
),
|
|
152
|
-
|
|
175
|
+
), x = M * (1 + S * 1.5);
|
|
176
|
+
x < m && (m = x, h = o);
|
|
153
177
|
}
|
|
154
178
|
return h;
|
|
155
179
|
}
|
|
156
|
-
function
|
|
180
|
+
function b(e, t = u, r = g) {
|
|
157
181
|
return Math.max(t, Math.min(r, e));
|
|
158
182
|
}
|
|
159
|
-
function
|
|
183
|
+
function L(e, t = 0) {
|
|
160
184
|
return 16 + Math.max(1, e) * 32 + Math.max(0, t) * 9;
|
|
161
185
|
}
|
|
162
186
|
export {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
187
|
+
P as WORKBENCH_CANVAS_ZOOM_STEP,
|
|
188
|
+
A as WORKBENCH_CONTEXT_MENU_WIDTH_PX,
|
|
189
|
+
g as WORKBENCH_MAX_SCALE,
|
|
190
|
+
u as WORKBENCH_MIN_SCALE,
|
|
191
|
+
z as WORKBENCH_VIEWPORT_FIT_PADDING_PX,
|
|
192
|
+
b as clampScale,
|
|
193
|
+
B as createContextMenuPosition,
|
|
194
|
+
I as createDefaultWorkbenchState,
|
|
195
|
+
D as createWorkbenchId,
|
|
196
|
+
N as createWorkbenchProjectedRect,
|
|
197
|
+
V as createWorkbenchRenderLayerMap,
|
|
198
|
+
v as createWorkbenchViewportCenteredOnWidget,
|
|
199
|
+
X as createWorkbenchViewportFitForWidget,
|
|
200
|
+
R as createWorkbenchWidgetSurfaceMetrics,
|
|
201
|
+
L as estimateContextMenuHeight,
|
|
202
|
+
U as findNearestWidget,
|
|
203
|
+
K as getTopZIndex,
|
|
204
|
+
O as resolveWorkbenchWidgetRenderMode,
|
|
205
|
+
F as sanitizeFilters,
|
|
206
|
+
H as sanitizeViewport,
|
|
207
|
+
T as sanitizeWorkbenchState
|
|
179
208
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createEffect as m, onCleanup as E } from "solid-js";
|
|
2
2
|
import { useDeck as h } from "../context/DeckContext.js";
|
|
3
|
-
import { applyDragDelta as
|
|
4
|
-
import { startDeckPointerSession as
|
|
3
|
+
import { applyDragDelta as P } from "../utils/gridLayout.js";
|
|
4
|
+
import { startDeckPointerSession as k } from "../components/deck/deckPointerSession.js";
|
|
5
5
|
function L() {
|
|
6
6
|
const o = h();
|
|
7
7
|
let i = null, l = null, r = null;
|
|
@@ -20,7 +20,7 @@ function L() {
|
|
|
20
20
|
if (!g) return;
|
|
21
21
|
e.preventDefault(), e.stopPropagation(), s(!1), o.startDrag(n, e.clientX, e.clientY);
|
|
22
22
|
const p = o.dragState();
|
|
23
|
-
!p || p.widgetId !== n || (l = n, r = { ...g.position }, i =
|
|
23
|
+
!p || p.widgetId !== n || (l = n, r = { ...g.position }, i = k({
|
|
24
24
|
kind: "drag",
|
|
25
25
|
widgetId: n,
|
|
26
26
|
gridEl: c,
|
|
@@ -29,7 +29,7 @@ function L() {
|
|
|
29
29
|
cursor: "grabbing",
|
|
30
30
|
onMove: (t) => {
|
|
31
31
|
if (!l || !r) return;
|
|
32
|
-
const f = Math.round(t.deltaX / t.
|
|
32
|
+
const f = Math.round(t.deltaX / t.colPitch), D = Math.round(t.deltaY / t.rowPitch), w = P(r, f, D, t.cols);
|
|
33
33
|
o.updateDrag(w, {
|
|
34
34
|
deltaX: t.deltaX,
|
|
35
35
|
deltaY: t.deltaY
|
package/dist/workbench.js
CHANGED
|
@@ -1,27 +1,29 @@
|
|
|
1
|
-
import { DEFAULT_WORKBENCH_VIEWPORT as
|
|
2
|
-
import { WIDGET_REGISTRY as W, createWorkbenchFilterState as n, getWidgetEntry as a, isValidWorkbenchWidgetType as
|
|
1
|
+
import { DEFAULT_WORKBENCH_VIEWPORT as t, WORKBENCH_WIDGET_TYPES as o } from "./components/workbench/types.js";
|
|
2
|
+
import { WIDGET_REGISTRY as W, createWorkbenchFilterState as n, getWidgetEntry as a, isValidWorkbenchWidgetType as i, resolveWorkbenchWidgetDefinitions as b } from "./components/workbench/widgets/widgetRegistry.js";
|
|
3
3
|
import { WorkbenchContextMenu as k } from "./components/workbench/WorkbenchContextMenu.js";
|
|
4
4
|
import { WorkbenchOverlay as f } from "./components/workbench/WorkbenchOverlay.js";
|
|
5
5
|
import { WorkbenchSurface as E } from "./components/workbench/WorkbenchSurface.js";
|
|
6
|
-
import { createDefaultWorkbenchState as
|
|
7
|
-
import { useWorkbenchModel as
|
|
6
|
+
import { createDefaultWorkbenchState as x, createWorkbenchId as R, createWorkbenchProjectedRect as l, createWorkbenchRenderLayerMap as m, createWorkbenchViewportCenteredOnWidget as s, createWorkbenchViewportFitForWidget as S, createWorkbenchWidgetSurfaceMetrics as T, resolveWorkbenchWidgetRenderMode as u, sanitizeWorkbenchState as D } from "./components/workbench/workbenchHelpers.js";
|
|
7
|
+
import { useWorkbenchModel as M } from "./components/workbench/useWorkbenchModel.js";
|
|
8
8
|
export {
|
|
9
|
-
|
|
9
|
+
t as DEFAULT_WORKBENCH_VIEWPORT,
|
|
10
10
|
W as WIDGET_REGISTRY,
|
|
11
|
-
|
|
11
|
+
o as WORKBENCH_WIDGET_TYPES,
|
|
12
12
|
k as WorkbenchContextMenu,
|
|
13
13
|
f as WorkbenchOverlay,
|
|
14
14
|
E as WorkbenchSurface,
|
|
15
|
-
|
|
15
|
+
x as createDefaultWorkbenchState,
|
|
16
16
|
n as createWorkbenchFilterState,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
R as createWorkbenchId,
|
|
18
|
+
l as createWorkbenchProjectedRect,
|
|
19
|
+
m as createWorkbenchRenderLayerMap,
|
|
20
|
+
s as createWorkbenchViewportCenteredOnWidget,
|
|
21
|
+
S as createWorkbenchViewportFitForWidget,
|
|
22
|
+
T as createWorkbenchWidgetSurfaceMetrics,
|
|
21
23
|
a as getWidgetEntry,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
i as isValidWorkbenchWidgetType,
|
|
25
|
+
b as resolveWorkbenchWidgetDefinitions,
|
|
26
|
+
u as resolveWorkbenchWidgetRenderMode,
|
|
27
|
+
D as sanitizeWorkbenchState,
|
|
28
|
+
M as useWorkbenchModel
|
|
27
29
|
};
|