@floegence/floe-webapp-core 0.36.0 → 0.36.2
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 +4 -4
- package/dist/components/layout/DisplayModePageShell.d.ts +8 -0
- package/dist/components/layout/DisplayModePageShell.js +22 -0
- package/dist/components/layout/DisplayModeSwitcher.d.ts +7 -0
- package/dist/components/layout/DisplayModeSwitcher.js +52 -0
- package/dist/components/layout/index.d.ts +2 -0
- package/dist/components/ui/Dialog.js +115 -87
- package/dist/components/ui/FloatingWindow.js +158 -144
- package/dist/components/ui/dialogSurfaceScope.d.ts +14 -0
- package/dist/components/ui/dialogSurfaceScope.js +45 -0
- package/dist/components/workbench/WorkbenchCanvas.d.ts +2 -1
- package/dist/components/workbench/WorkbenchCanvas.js +54 -56
- package/dist/components/workbench/WorkbenchCanvasField.d.ts +25 -0
- package/dist/components/workbench/WorkbenchCanvasField.js +145 -0
- package/dist/components/workbench/WorkbenchFilterBar.d.ts +2 -1
- package/dist/components/workbench/WorkbenchFilterBar.js +71 -70
- package/dist/components/workbench/WorkbenchSurface.d.ts +14 -1
- package/dist/components/workbench/WorkbenchSurface.js +73 -56
- package/dist/components/workbench/WorkbenchWidget.d.ts +11 -2
- package/dist/components/workbench/WorkbenchWidget.js +112 -103
- package/dist/components/workbench/index.d.ts +2 -2
- package/dist/components/workbench/types.d.ts +28 -11
- package/dist/components/workbench/types.js +2 -16
- package/dist/components/workbench/useWorkbenchModel.d.ts +19 -6
- package/dist/components/workbench/useWorkbenchModel.js +152 -127
- package/dist/components/workbench/widgets/widgetRegistry.d.ts +6 -5
- package/dist/components/workbench/widgets/widgetRegistry.js +47 -26
- package/dist/components/workbench/workbenchHelpers.d.ts +8 -4
- package/dist/components/workbench/workbenchHelpers.js +97 -134
- package/dist/display-mode.css +70 -0
- package/dist/full.js +485 -480
- package/dist/hooks/useOverlayMask.d.ts +11 -9
- package/dist/hooks/useOverlayMask.js +54 -52
- package/dist/layout.js +32 -27
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +1 -0
- package/dist/workbench.js +21 -20
- package/package.json +1 -1
|
@@ -1,176 +1,139 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { DEFAULT_WORKBENCH_VIEWPORT as g } from "./types.js";
|
|
2
|
+
import { resolveWorkbenchWidgetDefinitions as m, getWidgetEntry as x, createWorkbenchFilterState as b, isValidWorkbenchWidgetType as W } from "./widgets/widgetRegistry.js";
|
|
3
|
+
function F() {
|
|
3
4
|
const e = globalThis.crypto;
|
|
4
5
|
return e && typeof e.randomUUID == "function" ? `wb-${e.randomUUID()}` : `wb-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
|
5
6
|
}
|
|
6
|
-
function
|
|
7
|
+
function M(e) {
|
|
7
8
|
return e ? {
|
|
8
9
|
x: Number.isFinite(e.x) ? e.x : 0,
|
|
9
10
|
y: Number.isFinite(e.y) ? e.y : 0,
|
|
10
11
|
scale: Number.isFinite(e.scale) && e.scale > 0 ? e.scale : 1
|
|
11
|
-
} : { ...
|
|
12
|
+
} : { ...g };
|
|
12
13
|
}
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
const i = { ...l };
|
|
16
|
-
for (const n of m)
|
|
17
|
-
typeof e[n] == "boolean" && (i[n] = e[n]);
|
|
18
|
-
return i;
|
|
14
|
+
function k(e, n) {
|
|
15
|
+
return b(n, e);
|
|
19
16
|
}
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
).map((t) => ({
|
|
17
|
+
function z(e, n = {}) {
|
|
18
|
+
const r = m(n.widgetDefinitions), a = n.createFallbackState ?? (() => N(r)), i = e;
|
|
19
|
+
if (!i || i.version !== 1 || !Array.isArray(i.widgets))
|
|
20
|
+
return a();
|
|
21
|
+
const s = i.widgets.filter(
|
|
22
|
+
(t) => !!t && typeof t.id == "string" && W(t.type, r) && typeof t.title == "string"
|
|
23
|
+
).map((t) => {
|
|
24
|
+
const u = x(t.type, r);
|
|
25
|
+
return {
|
|
30
26
|
id: t.id,
|
|
31
27
|
type: t.type,
|
|
32
28
|
title: t.title,
|
|
33
29
|
x: Number.isFinite(t.x) ? t.x : 0,
|
|
34
30
|
y: Number.isFinite(t.y) ? t.y : 0,
|
|
35
|
-
width: Number.isFinite(t.width) && t.width > 0 ? t.width :
|
|
36
|
-
height: Number.isFinite(t.height) && t.height > 0 ? t.height :
|
|
31
|
+
width: Number.isFinite(t.width) && t.width > 0 ? t.width : u.defaultSize.width,
|
|
32
|
+
height: Number.isFinite(t.height) && t.height > 0 ? t.height : u.defaultSize.height,
|
|
37
33
|
z_index: Number.isFinite(t.z_index) && t.z_index >= 0 ? t.z_index : 1,
|
|
38
34
|
created_at_unix_ms: Number.isFinite(t.created_at_unix_ms) ? t.created_at_unix_ms : Date.now()
|
|
39
|
-
}
|
|
40
|
-
|
|
35
|
+
};
|
|
36
|
+
}), c = typeof i.selectedWidgetId == "string" && s.some((t) => t.id === i.selectedWidgetId) ? i.selectedWidgetId : null;
|
|
37
|
+
return {
|
|
38
|
+
version: 1,
|
|
39
|
+
widgets: s,
|
|
40
|
+
viewport: M(i.viewport),
|
|
41
41
|
locked: typeof i.locked == "boolean" ? i.locked : !1,
|
|
42
|
-
filters:
|
|
43
|
-
selectedWidgetId:
|
|
42
|
+
filters: k(i.filters, r),
|
|
43
|
+
selectedWidgetId: c
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
|
-
function
|
|
47
|
-
const e = Date.now()
|
|
46
|
+
function N(e) {
|
|
47
|
+
const n = m(e), r = Date.now(), a = [
|
|
48
|
+
{ type: "terminal", title: "dev · terminal", x: 80, y: 80 },
|
|
49
|
+
{ type: "file-browser", title: "project · files", x: 600, y: 80 },
|
|
50
|
+
{ type: "system-monitor", title: "host · system monitor", x: 80, y: 420 },
|
|
51
|
+
{ type: "log-viewer", title: "services · logs", x: 540, y: 500 },
|
|
52
|
+
{ type: "code-editor", title: "Counter.tsx", x: 1e3, y: 180 }
|
|
53
|
+
], i = a.filter((s) => n.some((c) => c.type === s.type)).map((s, c) => {
|
|
54
|
+
const t = x(s.type, n);
|
|
55
|
+
return {
|
|
56
|
+
id: `wb-seed-${c + 1}`,
|
|
57
|
+
type: s.type,
|
|
58
|
+
title: s.title,
|
|
59
|
+
x: s.x,
|
|
60
|
+
y: s.y,
|
|
61
|
+
width: t.defaultSize.width,
|
|
62
|
+
height: t.defaultSize.height,
|
|
63
|
+
z_index: c + 1,
|
|
64
|
+
created_at_unix_ms: r - (a.length - c) * 6e5
|
|
65
|
+
};
|
|
66
|
+
});
|
|
48
67
|
return {
|
|
49
68
|
version: 1,
|
|
50
|
-
widgets:
|
|
51
|
-
|
|
52
|
-
id: "wb-seed-terminal",
|
|
53
|
-
type: "terminal",
|
|
54
|
-
title: "dev · terminal",
|
|
55
|
-
x: 80,
|
|
56
|
-
y: 80,
|
|
57
|
-
width: 480,
|
|
58
|
-
height: 300,
|
|
59
|
-
z_index: 1,
|
|
60
|
-
created_at_unix_ms: e - 36e5
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
id: "wb-seed-files",
|
|
64
|
-
type: "file-browser",
|
|
65
|
-
title: "project · files",
|
|
66
|
-
x: 600,
|
|
67
|
-
y: 80,
|
|
68
|
-
width: 360,
|
|
69
|
-
height: 380,
|
|
70
|
-
z_index: 2,
|
|
71
|
-
created_at_unix_ms: e - 3e6
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
id: "wb-seed-monitor",
|
|
75
|
-
type: "system-monitor",
|
|
76
|
-
title: "host · system monitor",
|
|
77
|
-
x: 80,
|
|
78
|
-
y: 420,
|
|
79
|
-
width: 420,
|
|
80
|
-
height: 260,
|
|
81
|
-
z_index: 3,
|
|
82
|
-
created_at_unix_ms: e - 24e5
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
id: "wb-seed-logs",
|
|
86
|
-
type: "log-viewer",
|
|
87
|
-
title: "services · logs",
|
|
88
|
-
x: 540,
|
|
89
|
-
y: 500,
|
|
90
|
-
width: 520,
|
|
91
|
-
height: 240,
|
|
92
|
-
z_index: 4,
|
|
93
|
-
created_at_unix_ms: e - 18e5
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
id: "wb-seed-code",
|
|
97
|
-
type: "code-editor",
|
|
98
|
-
title: "Counter.tsx",
|
|
99
|
-
x: 1e3,
|
|
100
|
-
y: 180,
|
|
101
|
-
width: 500,
|
|
102
|
-
height: 340,
|
|
103
|
-
z_index: 5,
|
|
104
|
-
created_at_unix_ms: e - 12e5
|
|
105
|
-
}
|
|
106
|
-
],
|
|
107
|
-
viewport: { ..._ },
|
|
69
|
+
widgets: i,
|
|
70
|
+
viewport: { ...g },
|
|
108
71
|
locked: !1,
|
|
109
|
-
filters:
|
|
110
|
-
selectedWidgetId: null
|
|
72
|
+
filters: b(n),
|
|
73
|
+
selectedWidgetId: i[0]?.id ?? null
|
|
111
74
|
};
|
|
112
75
|
}
|
|
113
|
-
const
|
|
114
|
-
function
|
|
115
|
-
const
|
|
116
|
-
let
|
|
117
|
-
return
|
|
76
|
+
const D = 1.18, I = 200;
|
|
77
|
+
function E(e) {
|
|
78
|
+
const n = typeof window < "u" ? window.innerWidth : 1280, r = typeof window < "u" ? window.innerHeight : 800;
|
|
79
|
+
let a = e.clientX, i = e.clientY;
|
|
80
|
+
return a + e.menuWidth > n && (a = Math.max(0, n - e.menuWidth - 8)), i + e.menuHeight > r && (i = Math.max(0, r - e.menuHeight - 8)), { left: a, top: i };
|
|
118
81
|
}
|
|
119
|
-
function
|
|
120
|
-
return e.reduce((
|
|
82
|
+
function H(e) {
|
|
83
|
+
return e.reduce((n, r) => Math.max(n, r.z_index), 1);
|
|
121
84
|
}
|
|
122
|
-
function
|
|
123
|
-
const
|
|
124
|
-
if (
|
|
125
|
-
if (!
|
|
126
|
-
const
|
|
127
|
-
if (!
|
|
128
|
-
const
|
|
129
|
-
let u = null,
|
|
130
|
-
for (const
|
|
131
|
-
if (
|
|
132
|
-
const d =
|
|
133
|
-
let
|
|
134
|
-
switch (
|
|
85
|
+
function T(e, n, r, a) {
|
|
86
|
+
const i = e.filter((o) => a[o.type]);
|
|
87
|
+
if (i.length === 0) return null;
|
|
88
|
+
if (!n) return i[0] ?? null;
|
|
89
|
+
const s = i.find((o) => o.id === n);
|
|
90
|
+
if (!s) return i[0] ?? null;
|
|
91
|
+
const c = s.x + s.width / 2, t = s.y + s.height / 2;
|
|
92
|
+
let u = null, f = 1 / 0;
|
|
93
|
+
for (const o of i) {
|
|
94
|
+
if (o.id === n) continue;
|
|
95
|
+
const d = o.x + o.width / 2 - c, l = o.y + o.height / 2 - t;
|
|
96
|
+
let h = !1;
|
|
97
|
+
switch (r) {
|
|
135
98
|
case "up":
|
|
136
|
-
|
|
99
|
+
h = l < -10;
|
|
137
100
|
break;
|
|
138
101
|
case "down":
|
|
139
|
-
|
|
102
|
+
h = l > 10;
|
|
140
103
|
break;
|
|
141
104
|
case "left":
|
|
142
|
-
|
|
105
|
+
h = d < -10;
|
|
143
106
|
break;
|
|
144
107
|
case "right":
|
|
145
|
-
|
|
108
|
+
h = d > 10;
|
|
146
109
|
break;
|
|
147
110
|
}
|
|
148
|
-
if (!
|
|
149
|
-
const
|
|
150
|
-
Math.abs(
|
|
151
|
-
Math.abs(
|
|
152
|
-
),
|
|
153
|
-
|
|
111
|
+
if (!h) continue;
|
|
112
|
+
const p = Math.sqrt(d * d + l * l), _ = Math.atan2(
|
|
113
|
+
Math.abs(r === "up" || r === "down" ? d : l),
|
|
114
|
+
Math.abs(r === "up" || r === "down" ? l : d)
|
|
115
|
+
), y = p * (1 + _ * 1.5);
|
|
116
|
+
y < f && (f = y, u = o);
|
|
154
117
|
}
|
|
155
118
|
return u;
|
|
156
119
|
}
|
|
157
|
-
function
|
|
158
|
-
return Math.max(
|
|
120
|
+
function C(e, n = 0.45, r = 2.2) {
|
|
121
|
+
return Math.max(n, Math.min(r, e));
|
|
159
122
|
}
|
|
160
|
-
function
|
|
161
|
-
return 16 + Math.max(1, e) * 32 + Math.max(0,
|
|
123
|
+
function O(e, n = 0) {
|
|
124
|
+
return 16 + Math.max(1, e) * 32 + Math.max(0, n) * 9;
|
|
162
125
|
}
|
|
163
126
|
export {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
127
|
+
D as WORKBENCH_CANVAS_ZOOM_STEP,
|
|
128
|
+
I as WORKBENCH_CONTEXT_MENU_WIDTH_PX,
|
|
129
|
+
C as clampScale,
|
|
130
|
+
E as createContextMenuPosition,
|
|
131
|
+
N as createDefaultWorkbenchState,
|
|
132
|
+
F as createWorkbenchId,
|
|
133
|
+
O as estimateContextMenuHeight,
|
|
134
|
+
T as findNearestWidget,
|
|
135
|
+
H as getTopZIndex,
|
|
136
|
+
k as sanitizeFilters,
|
|
137
|
+
M as sanitizeViewport,
|
|
138
|
+
z as sanitizeWorkbenchState
|
|
176
139
|
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
@layer components {
|
|
2
|
+
.display-mode-page-shell {
|
|
3
|
+
position: fixed;
|
|
4
|
+
inset: 0;
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
background: var(--background, #fff);
|
|
8
|
+
color: var(--foreground, #111);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.display-mode-page-shell__body {
|
|
12
|
+
position: relative;
|
|
13
|
+
flex: 1;
|
|
14
|
+
overflow: hidden;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.display-mode-switcher {
|
|
18
|
+
display: inline-flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
gap: 1px;
|
|
21
|
+
padding: 2px;
|
|
22
|
+
border: 1px solid color-mix(in srgb, var(--border, #e5e5e5) 60%, transparent);
|
|
23
|
+
border-radius: 8px;
|
|
24
|
+
background: color-mix(in srgb, var(--muted, #f1f1f1) 70%, transparent);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.display-mode-switcher__pill {
|
|
28
|
+
position: relative;
|
|
29
|
+
display: inline-flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
gap: 5px;
|
|
32
|
+
padding: 4px 9px;
|
|
33
|
+
border: none;
|
|
34
|
+
border-radius: 6px;
|
|
35
|
+
background: transparent;
|
|
36
|
+
color: var(--muted-foreground, #888);
|
|
37
|
+
font-size: 11px;
|
|
38
|
+
font-weight: 600;
|
|
39
|
+
letter-spacing: -0.005em;
|
|
40
|
+
cursor: pointer;
|
|
41
|
+
isolation: isolate;
|
|
42
|
+
transition: color 140ms ease;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.display-mode-switcher__pill:hover,
|
|
46
|
+
.display-mode-switcher__pill.is-active {
|
|
47
|
+
color: var(--foreground, #111);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.display-mode-switcher__pill-bg {
|
|
51
|
+
position: absolute;
|
|
52
|
+
inset: 0;
|
|
53
|
+
z-index: -1;
|
|
54
|
+
border: 1px solid color-mix(in srgb, var(--border, #e5e5e5) 70%, transparent);
|
|
55
|
+
border-radius: 6px;
|
|
56
|
+
background: var(--card, #fff);
|
|
57
|
+
box-shadow:
|
|
58
|
+
0 1px 2px color-mix(in srgb, var(--foreground, #000) 6%, transparent),
|
|
59
|
+
0 1px 0 color-mix(in srgb, white 60%, transparent) inset;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.display-mode-switcher__icon {
|
|
63
|
+
width: 12px;
|
|
64
|
+
height: 12px;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.display-mode-switcher__label {
|
|
68
|
+
line-height: 1;
|
|
69
|
+
}
|
|
70
|
+
}
|