@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,151 +1,178 @@
|
|
|
1
|
-
import { DEFAULT_WORKBENCH_VIEWPORT as
|
|
2
|
-
import { resolveWorkbenchWidgetDefinitions as
|
|
3
|
-
function
|
|
1
|
+
import { DEFAULT_WORKBENCH_VIEWPORT as g } from "./types.js";
|
|
2
|
+
import { resolveWorkbenchWidgetDefinitions as m, getWidgetEntry as x, createWorkbenchFilterState as _, isValidWorkbenchWidgetType as w } from "./widgets/widgetRegistry.js";
|
|
3
|
+
function v() {
|
|
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 I(e) {
|
|
8
|
+
return e.renderMode ?? "canvas_scaled";
|
|
9
|
+
}
|
|
10
|
+
function p(e) {
|
|
11
|
+
const t = Number.isFinite(e.viewport.scale) && e.viewport.scale > 0 ? e.viewport.scale : 1;
|
|
12
|
+
return {
|
|
13
|
+
widgetId: e.widgetId,
|
|
14
|
+
worldX: e.worldX,
|
|
15
|
+
worldY: e.worldY,
|
|
16
|
+
worldWidth: e.worldWidth,
|
|
17
|
+
worldHeight: e.worldHeight,
|
|
18
|
+
screenX: e.viewport.x + e.worldX * t,
|
|
19
|
+
screenY: e.viewport.y + e.worldY * t,
|
|
20
|
+
screenWidth: e.worldWidth * t,
|
|
21
|
+
screenHeight: e.worldHeight * t,
|
|
22
|
+
viewportScale: t
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function H(e) {
|
|
26
|
+
return {
|
|
27
|
+
ready: e.ready,
|
|
28
|
+
rect: p(e)
|
|
29
|
+
};
|
|
30
|
+
}
|
|
7
31
|
function M(e) {
|
|
8
32
|
return e ? {
|
|
9
33
|
x: Number.isFinite(e.x) ? e.x : 0,
|
|
10
34
|
y: Number.isFinite(e.y) ? e.y : 0,
|
|
11
35
|
scale: Number.isFinite(e.scale) && e.scale > 0 ? e.scale : 1
|
|
12
|
-
} : { ...
|
|
36
|
+
} : { ...g };
|
|
13
37
|
}
|
|
14
|
-
function k(e,
|
|
15
|
-
return _(
|
|
38
|
+
function k(e, t) {
|
|
39
|
+
return _(t, e);
|
|
16
40
|
}
|
|
17
|
-
function D(e,
|
|
18
|
-
const r =
|
|
41
|
+
function D(e, t = {}) {
|
|
42
|
+
const r = m(t.widgetDefinitions), d = t.createFallbackState ?? (() => S(r)), n = e;
|
|
19
43
|
if (!n || n.version !== 1 || !Array.isArray(n.widgets))
|
|
20
|
-
return
|
|
21
|
-
const
|
|
22
|
-
(
|
|
23
|
-
).map((
|
|
24
|
-
const
|
|
44
|
+
return d();
|
|
45
|
+
const o = n.widgets.filter(
|
|
46
|
+
(i) => !!i && typeof i.id == "string" && w(i.type, r) && typeof i.title == "string"
|
|
47
|
+
).map((i) => {
|
|
48
|
+
const h = x(i.type, r);
|
|
25
49
|
return {
|
|
26
|
-
id:
|
|
27
|
-
type:
|
|
28
|
-
title:
|
|
29
|
-
x: Number.isFinite(
|
|
30
|
-
y: Number.isFinite(
|
|
31
|
-
width: Number.isFinite(
|
|
32
|
-
height: Number.isFinite(
|
|
33
|
-
z_index: Number.isFinite(
|
|
34
|
-
created_at_unix_ms: Number.isFinite(
|
|
50
|
+
id: i.id,
|
|
51
|
+
type: i.type,
|
|
52
|
+
title: i.title,
|
|
53
|
+
x: Number.isFinite(i.x) ? i.x : 0,
|
|
54
|
+
y: Number.isFinite(i.y) ? i.y : 0,
|
|
55
|
+
width: Number.isFinite(i.width) && i.width > 0 ? i.width : h.defaultSize.width,
|
|
56
|
+
height: Number.isFinite(i.height) && i.height > 0 ? i.height : h.defaultSize.height,
|
|
57
|
+
z_index: Number.isFinite(i.z_index) && i.z_index >= 0 ? i.z_index : 1,
|
|
58
|
+
created_at_unix_ms: Number.isFinite(i.created_at_unix_ms) ? i.created_at_unix_ms : Date.now()
|
|
35
59
|
};
|
|
36
|
-
}),
|
|
60
|
+
}), a = typeof n.selectedWidgetId == "string" && o.some((i) => i.id === n.selectedWidgetId) ? n.selectedWidgetId : null;
|
|
37
61
|
return {
|
|
38
62
|
version: 1,
|
|
39
|
-
widgets:
|
|
63
|
+
widgets: o,
|
|
40
64
|
viewport: M(n.viewport),
|
|
41
65
|
locked: typeof n.locked == "boolean" ? n.locked : !1,
|
|
42
66
|
filters: k(n.filters, r),
|
|
43
|
-
selectedWidgetId:
|
|
67
|
+
selectedWidgetId: a
|
|
44
68
|
};
|
|
45
69
|
}
|
|
46
|
-
function
|
|
47
|
-
const
|
|
70
|
+
function S(e) {
|
|
71
|
+
const t = m(e), r = Date.now(), d = [
|
|
48
72
|
{ type: "terminal", title: "dev · terminal", x: 80, y: 80 },
|
|
49
73
|
{ type: "file-browser", title: "project · files", x: 600, y: 80 },
|
|
50
74
|
{ type: "system-monitor", title: "host · system monitor", x: 80, y: 420 },
|
|
51
75
|
{ type: "log-viewer", title: "services · logs", x: 540, y: 500 },
|
|
52
76
|
{ type: "code-editor", title: "Counter.tsx", x: 1e3, y: 180 }
|
|
53
|
-
], n =
|
|
54
|
-
const
|
|
77
|
+
], n = d.filter((o) => t.some((a) => a.type === o.type)).map((o, a) => {
|
|
78
|
+
const i = x(o.type, t);
|
|
55
79
|
return {
|
|
56
|
-
id: `wb-seed-${
|
|
57
|
-
type:
|
|
58
|
-
title:
|
|
59
|
-
x:
|
|
60
|
-
y:
|
|
61
|
-
width:
|
|
62
|
-
height:
|
|
63
|
-
z_index:
|
|
64
|
-
created_at_unix_ms: r - (
|
|
80
|
+
id: `wb-seed-${a + 1}`,
|
|
81
|
+
type: o.type,
|
|
82
|
+
title: o.title,
|
|
83
|
+
x: o.x,
|
|
84
|
+
y: o.y,
|
|
85
|
+
width: i.defaultSize.width,
|
|
86
|
+
height: i.defaultSize.height,
|
|
87
|
+
z_index: a + 1,
|
|
88
|
+
created_at_unix_ms: r - (d.length - a) * 6e5
|
|
65
89
|
};
|
|
66
90
|
});
|
|
67
91
|
return {
|
|
68
92
|
version: 1,
|
|
69
93
|
widgets: n,
|
|
70
|
-
viewport: { ...
|
|
94
|
+
viewport: { ...g },
|
|
71
95
|
locked: !1,
|
|
72
|
-
filters: _(
|
|
96
|
+
filters: _(t),
|
|
73
97
|
selectedWidgetId: n[0]?.id ?? null
|
|
74
98
|
};
|
|
75
99
|
}
|
|
76
|
-
const
|
|
77
|
-
function
|
|
78
|
-
return e.z_index !==
|
|
100
|
+
const C = 1.18, E = 200;
|
|
101
|
+
function z(e, t) {
|
|
102
|
+
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);
|
|
79
103
|
}
|
|
80
|
-
function
|
|
81
|
-
const
|
|
82
|
-
for (const [
|
|
83
|
-
r.set(n.id,
|
|
104
|
+
function R(e) {
|
|
105
|
+
const t = [...e].sort(z), r = /* @__PURE__ */ new Map();
|
|
106
|
+
for (const [d, n] of t.entries())
|
|
107
|
+
r.set(n.id, d + 1);
|
|
84
108
|
return {
|
|
85
109
|
byWidgetId: r,
|
|
86
|
-
topRenderLayer: Math.max(
|
|
110
|
+
topRenderLayer: Math.max(t.length, 1)
|
|
87
111
|
};
|
|
88
112
|
}
|
|
89
|
-
function H(e) {
|
|
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
113
|
function T(e) {
|
|
95
|
-
|
|
114
|
+
const t = typeof window < "u" ? window.innerWidth : 1280, r = typeof window < "u" ? window.innerHeight : 800;
|
|
115
|
+
let d = e.clientX, n = e.clientY;
|
|
116
|
+
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
|
+
}
|
|
118
|
+
function O(e) {
|
|
119
|
+
return e.reduce((t, r) => Math.max(t, r.z_index), 1);
|
|
96
120
|
}
|
|
97
|
-
function
|
|
98
|
-
const n = e.filter((
|
|
121
|
+
function X(e, t, r, d) {
|
|
122
|
+
const n = e.filter((c) => d[c.type]);
|
|
99
123
|
if (n.length === 0) return null;
|
|
100
|
-
if (!
|
|
101
|
-
const
|
|
102
|
-
if (!
|
|
103
|
-
const
|
|
104
|
-
let
|
|
105
|
-
for (const
|
|
106
|
-
if (
|
|
107
|
-
const
|
|
108
|
-
let
|
|
124
|
+
if (!t) return n[0] ?? null;
|
|
125
|
+
const o = n.find((c) => c.id === t);
|
|
126
|
+
if (!o) return n[0] ?? null;
|
|
127
|
+
const a = o.x + o.width / 2, i = o.y + o.height / 2;
|
|
128
|
+
let h = null, f = 1 / 0;
|
|
129
|
+
for (const c of n) {
|
|
130
|
+
if (c.id === t) continue;
|
|
131
|
+
const s = c.x + c.width / 2 - a, l = c.y + c.height / 2 - i;
|
|
132
|
+
let u = !1;
|
|
109
133
|
switch (r) {
|
|
110
134
|
case "up":
|
|
111
|
-
|
|
135
|
+
u = l < -10;
|
|
112
136
|
break;
|
|
113
137
|
case "down":
|
|
114
|
-
|
|
138
|
+
u = l > 10;
|
|
115
139
|
break;
|
|
116
140
|
case "left":
|
|
117
|
-
|
|
141
|
+
u = s < -10;
|
|
118
142
|
break;
|
|
119
143
|
case "right":
|
|
120
|
-
|
|
144
|
+
u = s > 10;
|
|
121
145
|
break;
|
|
122
146
|
}
|
|
123
|
-
if (!
|
|
124
|
-
const b = Math.sqrt(
|
|
125
|
-
Math.abs(r === "up" || r === "down" ?
|
|
126
|
-
Math.abs(r === "up" || r === "down" ? l :
|
|
127
|
-
), y = b * (1 +
|
|
128
|
-
y <
|
|
147
|
+
if (!u) continue;
|
|
148
|
+
const b = Math.sqrt(s * s + l * l), W = Math.atan2(
|
|
149
|
+
Math.abs(r === "up" || r === "down" ? s : l),
|
|
150
|
+
Math.abs(r === "up" || r === "down" ? l : s)
|
|
151
|
+
), y = b * (1 + W * 1.5);
|
|
152
|
+
y < f && (f = y, h = c);
|
|
129
153
|
}
|
|
130
|
-
return
|
|
154
|
+
return h;
|
|
131
155
|
}
|
|
132
|
-
function
|
|
133
|
-
return Math.max(
|
|
156
|
+
function U(e, t = 0.45, r = 2.2) {
|
|
157
|
+
return Math.max(t, Math.min(r, e));
|
|
134
158
|
}
|
|
135
|
-
function
|
|
136
|
-
return 16 + Math.max(1, e) * 32 + Math.max(0,
|
|
159
|
+
function A(e, t = 0) {
|
|
160
|
+
return 16 + Math.max(1, e) * 32 + Math.max(0, t) * 9;
|
|
137
161
|
}
|
|
138
162
|
export {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
163
|
+
C as WORKBENCH_CANVAS_ZOOM_STEP,
|
|
164
|
+
E as WORKBENCH_CONTEXT_MENU_WIDTH_PX,
|
|
165
|
+
U as clampScale,
|
|
166
|
+
T as createContextMenuPosition,
|
|
167
|
+
S as createDefaultWorkbenchState,
|
|
168
|
+
v as createWorkbenchId,
|
|
169
|
+
p as createWorkbenchProjectedRect,
|
|
170
|
+
R as createWorkbenchRenderLayerMap,
|
|
171
|
+
H as createWorkbenchWidgetSurfaceMetrics,
|
|
172
|
+
A as estimateContextMenuHeight,
|
|
173
|
+
X as findNearestWidget,
|
|
174
|
+
O as getTopZIndex,
|
|
175
|
+
I as resolveWorkbenchWidgetRenderMode,
|
|
149
176
|
k as sanitizeFilters,
|
|
150
177
|
M as sanitizeViewport,
|
|
151
178
|
D as sanitizeWorkbenchState
|
|
@@ -30,11 +30,6 @@ export interface DragState {
|
|
|
30
30
|
widgetId: string;
|
|
31
31
|
originalPosition: GridPosition;
|
|
32
32
|
currentPosition: GridPosition;
|
|
33
|
-
/** Pixel offset for smooth visual following */
|
|
34
|
-
pixelOffset: {
|
|
35
|
-
x: number;
|
|
36
|
-
y: number;
|
|
37
|
-
};
|
|
38
33
|
startX: number;
|
|
39
34
|
startY: number;
|
|
40
35
|
}
|
|
@@ -74,10 +69,7 @@ export interface DeckContextValue {
|
|
|
74
69
|
getWidgetState: (widgetId: string) => Record<string, unknown>;
|
|
75
70
|
dragState: Accessor<DragState | null>;
|
|
76
71
|
startDrag: (widgetId: string, startX: number, startY: number) => void;
|
|
77
|
-
updateDrag: (currentPosition: GridPosition
|
|
78
|
-
x: number;
|
|
79
|
-
y: number;
|
|
80
|
-
}) => void;
|
|
72
|
+
updateDrag: (currentPosition: GridPosition) => void;
|
|
81
73
|
endDrag: (commit: boolean) => void;
|
|
82
74
|
resizeState: Accessor<ResizeState | null>;
|
|
83
75
|
startResize: (widgetId: string, edge: ResizeState['edge'], startX: number, startY: number) => void;
|