@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.
@@ -1,13 +1,13 @@
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() {
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 I(e) {
7
+ function O(e) {
8
8
  return e.renderMode ?? "canvas_scaled";
9
9
  }
10
- function p(e) {
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 H(e) {
25
+ function R(e) {
26
26
  return {
27
27
  ready: e.ready,
28
- rect: p(e)
28
+ rect: N(e)
29
29
  };
30
30
  }
31
- function M(e) {
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
- } : { ...g };
36
+ } : { ...y };
37
37
  }
38
- function k(e, t) {
39
- return _(t, e);
38
+ function F(e, t) {
39
+ return w(t, e);
40
40
  }
41
- function D(e, t = {}) {
42
- const r = m(t.widgetDefinitions), d = t.createFallbackState ?? (() => S(r)), n = e;
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 o = n.widgets.filter(
46
- (i) => !!i && typeof i.id == "string" && w(i.type, r) && typeof i.title == "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 = x(i.type, r);
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
- }), a = typeof n.selectedWidgetId == "string" && o.some((i) => i.id === n.selectedWidgetId) ? n.selectedWidgetId : null;
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: o,
64
- viewport: M(n.viewport),
63
+ widgets: a,
64
+ viewport: H(n.viewport),
65
65
  locked: typeof n.locked == "boolean" ? n.locked : !1,
66
- filters: k(n.filters, r),
67
- selectedWidgetId: a
66
+ filters: F(n.filters, r),
67
+ selectedWidgetId: c
68
68
  };
69
69
  }
70
- function S(e) {
71
- const t = m(e), r = Date.now(), d = [
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((o) => t.some((a) => a.type === o.type)).map((o, a) => {
78
- const i = x(o.type, t);
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-${a + 1}`,
81
- type: o.type,
82
- title: o.title,
83
- x: o.x,
84
- y: o.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: a + 1,
88
- created_at_unix_ms: r - (d.length - a) * 6e5
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: { ...g },
94
+ viewport: { ...y },
95
95
  locked: !1,
96
- filters: _(t),
96
+ filters: w(t),
97
97
  selectedWidgetId: n[0]?.id ?? null
98
98
  };
99
99
  }
100
- const C = 1.18, E = 200;
101
- function z(e, t) {
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 R(e) {
105
- const t = [...e].sort(z), r = /* @__PURE__ */ new Map();
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 T(e) {
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 O(e) {
142
+ function K(e) {
119
143
  return e.reduce((t, r) => Math.max(t, r.z_index), 1);
120
144
  }
121
- function X(e, t, r, d) {
122
- const n = e.filter((c) => d[c.type]);
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 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;
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
- u = l < -10;
159
+ f = l < -10;
136
160
  break;
137
161
  case "down":
138
- u = l > 10;
162
+ f = l > 10;
139
163
  break;
140
164
  case "left":
141
- u = s < -10;
165
+ f = s < -10;
142
166
  break;
143
167
  case "right":
144
- u = s > 10;
168
+ f = s > 10;
145
169
  break;
146
170
  }
147
- if (!u) continue;
148
- const b = Math.sqrt(s * s + l * l), W = Math.atan2(
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
- ), y = b * (1 + W * 1.5);
152
- y < f && (f = y, h = c);
175
+ ), x = M * (1 + S * 1.5);
176
+ x < m && (m = x, h = o);
153
177
  }
154
178
  return h;
155
179
  }
156
- function U(e, t = 0.45, r = 2.2) {
180
+ function b(e, t = u, r = g) {
157
181
  return Math.max(t, Math.min(r, e));
158
182
  }
159
- function A(e, t = 0) {
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
- 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,
176
- k as sanitizeFilters,
177
- M as sanitizeViewport,
178
- D as sanitizeWorkbenchState
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 k } from "../utils/gridLayout.js";
4
- import { startDeckPointerSession as y } from "../components/deck/deckPointerSession.js";
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 = y({
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.cellWidth), D = Math.round(t.deltaY / t.cellHeight), w = k(r, f, D, t.cols);
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 o, WORKBENCH_WIDGET_TYPES as t } from "./components/workbench/types.js";
2
- import { WIDGET_REGISTRY as W, createWorkbenchFilterState as n, getWidgetEntry as a, isValidWorkbenchWidgetType as b, resolveWorkbenchWidgetDefinitions as h } from "./components/workbench/widgets/widgetRegistry.js";
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 R, createWorkbenchId as l, createWorkbenchProjectedRect as m, createWorkbenchRenderLayerMap as s, createWorkbenchWidgetSurfaceMetrics as S, resolveWorkbenchWidgetRenderMode as T, sanitizeWorkbenchState as g } from "./components/workbench/workbenchHelpers.js";
7
- import { useWorkbenchModel as D } from "./components/workbench/useWorkbenchModel.js";
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
- o as DEFAULT_WORKBENCH_VIEWPORT,
9
+ t as DEFAULT_WORKBENCH_VIEWPORT,
10
10
  W as WIDGET_REGISTRY,
11
- t as WORKBENCH_WIDGET_TYPES,
11
+ o as WORKBENCH_WIDGET_TYPES,
12
12
  k as WorkbenchContextMenu,
13
13
  f as WorkbenchOverlay,
14
14
  E as WorkbenchSurface,
15
- R as createDefaultWorkbenchState,
15
+ x as createDefaultWorkbenchState,
16
16
  n as createWorkbenchFilterState,
17
- l as createWorkbenchId,
18
- m as createWorkbenchProjectedRect,
19
- s as createWorkbenchRenderLayerMap,
20
- S as createWorkbenchWidgetSurfaceMetrics,
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
- b as isValidWorkbenchWidgetType,
23
- h as resolveWorkbenchWidgetDefinitions,
24
- T as resolveWorkbenchWidgetRenderMode,
25
- g as sanitizeWorkbenchState,
26
- D as useWorkbenchModel
24
+ i as isValidWorkbenchWidgetType,
25
+ b as resolveWorkbenchWidgetDefinitions,
26
+ u as resolveWorkbenchWidgetRenderMode,
27
+ D as sanitizeWorkbenchState,
28
+ M as useWorkbenchModel
27
29
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-core",
3
- "version": "0.36.10",
3
+ "version": "0.36.12",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",