@floegence/floe-webapp-core 0.36.0 → 0.36.1

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.
Files changed (29) hide show
  1. package/dist/components/layout/DisplayModePageShell.d.ts +8 -0
  2. package/dist/components/layout/DisplayModePageShell.js +22 -0
  3. package/dist/components/layout/DisplayModeSwitcher.d.ts +7 -0
  4. package/dist/components/layout/DisplayModeSwitcher.js +52 -0
  5. package/dist/components/layout/index.d.ts +2 -0
  6. package/dist/components/workbench/WorkbenchCanvas.d.ts +2 -1
  7. package/dist/components/workbench/WorkbenchCanvas.js +17 -13
  8. package/dist/components/workbench/WorkbenchFilterBar.d.ts +2 -1
  9. package/dist/components/workbench/WorkbenchFilterBar.js +71 -70
  10. package/dist/components/workbench/WorkbenchSurface.d.ts +14 -1
  11. package/dist/components/workbench/WorkbenchSurface.js +73 -56
  12. package/dist/components/workbench/WorkbenchWidget.d.ts +2 -1
  13. package/dist/components/workbench/WorkbenchWidget.js +90 -81
  14. package/dist/components/workbench/index.d.ts +2 -2
  15. package/dist/components/workbench/types.d.ts +28 -11
  16. package/dist/components/workbench/types.js +2 -16
  17. package/dist/components/workbench/useWorkbenchModel.d.ts +19 -6
  18. package/dist/components/workbench/useWorkbenchModel.js +152 -127
  19. package/dist/components/workbench/widgets/widgetRegistry.d.ts +6 -5
  20. package/dist/components/workbench/widgets/widgetRegistry.js +47 -26
  21. package/dist/components/workbench/workbenchHelpers.d.ts +8 -4
  22. package/dist/components/workbench/workbenchHelpers.js +97 -134
  23. package/dist/display-mode.css +70 -0
  24. package/dist/full.js +485 -480
  25. package/dist/layout.js +32 -27
  26. package/dist/styles.css +1 -1
  27. package/dist/tailwind.css +1 -0
  28. package/dist/workbench.js +21 -20
  29. package/package.json +1 -1
@@ -1,176 +1,139 @@
1
- import { DEFAULT_FILTERS as l, DEFAULT_WORKBENCH_VIEWPORT as _, WORKBENCH_WIDGET_TYPES as m } from "./types.js";
2
- function z() {
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 p(e) {
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 w(e) {
14
- if (!e) return { ...l };
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 W(e) {
21
- return typeof e == "string" && m.includes(e);
22
- }
23
- function E(e) {
24
- const i = e;
25
- return !i || i.version !== 1 || !Array.isArray(i.widgets) ? M() : {
26
- version: 1,
27
- widgets: i.widgets.filter(
28
- (t) => !!t && typeof t.id == "string" && W(t.type) && typeof t.title == "string"
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 : 300,
36
- height: Number.isFinite(t.height) && t.height > 0 ? t.height : 200,
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
- viewport: p(i.viewport),
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: w(i.filters),
43
- selectedWidgetId: typeof i.selectedWidgetId == "string" ? i.selectedWidgetId : null
42
+ filters: k(i.filters, r),
43
+ selectedWidgetId: c
44
44
  };
45
45
  }
46
- function M() {
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: { ...l },
110
- selectedWidgetId: null
72
+ filters: b(n),
73
+ selectedWidgetId: i[0]?.id ?? null
111
74
  };
112
75
  }
113
- const F = 1.18, T = 200;
114
- function I(e) {
115
- const i = typeof window < "u" ? window.innerWidth : 1280, n = typeof window < "u" ? window.innerHeight : 800;
116
- let t = e.clientX, s = e.clientY;
117
- return t + e.menuWidth > i && (t = Math.max(0, i - e.menuWidth - 8)), s + e.menuHeight > n && (s = Math.max(0, n - e.menuHeight - 8)), { left: t, top: s };
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 k(e) {
120
- return e.reduce((i, n) => Math.max(i, n.z_index), 1);
82
+ function H(e) {
83
+ return e.reduce((n, r) => Math.max(n, r.z_index), 1);
121
84
  }
122
- function D(e, i, n, t) {
123
- const s = e.filter((r) => t[r.type]);
124
- if (s.length === 0) return null;
125
- if (!i) return s[0] ?? null;
126
- const o = s.find((r) => r.id === i);
127
- if (!o) return s[0] ?? null;
128
- const x = o.x + o.width / 2, g = o.y + o.height / 2;
129
- let u = null, h = 1 / 0;
130
- for (const r of s) {
131
- if (r.id === i) continue;
132
- const d = r.x + r.width / 2 - x, a = r.y + r.height / 2 - g;
133
- let c = !1;
134
- switch (n) {
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
- c = a < -10;
99
+ h = l < -10;
137
100
  break;
138
101
  case "down":
139
- c = a > 10;
102
+ h = l > 10;
140
103
  break;
141
104
  case "left":
142
- c = d < -10;
105
+ h = d < -10;
143
106
  break;
144
107
  case "right":
145
- c = d > 10;
108
+ h = d > 10;
146
109
  break;
147
110
  }
148
- if (!c) continue;
149
- const y = Math.sqrt(d * d + a * a), b = Math.atan2(
150
- Math.abs(n === "up" || n === "down" ? d : a),
151
- Math.abs(n === "up" || n === "down" ? a : d)
152
- ), f = y * (1 + b * 1.5);
153
- f < h && (h = f, u = r);
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 H(e, i = 0.45, n = 2.2) {
158
- return Math.max(i, Math.min(n, e));
120
+ function C(e, n = 0.45, r = 2.2) {
121
+ return Math.max(n, Math.min(r, e));
159
122
  }
160
- function S(e, i = 0) {
161
- return 16 + Math.max(1, e) * 32 + Math.max(0, i) * 9;
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
- F as WORKBENCH_CANVAS_ZOOM_STEP,
165
- T as WORKBENCH_CONTEXT_MENU_WIDTH_PX,
166
- H as clampScale,
167
- I as createContextMenuPosition,
168
- M as createDefaultWorkbenchState,
169
- z as createWorkbenchId,
170
- S as estimateContextMenuHeight,
171
- D as findNearestWidget,
172
- k as getTopZIndex,
173
- w as sanitizeFilters,
174
- p as sanitizeViewport,
175
- E as sanitizeWorkbenchState
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
+ }