@floegence/floe-webapp-core 0.36.28 → 0.36.31

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.
@@ -5,6 +5,7 @@ export type BuiltinWorkbenchWidgetType = 'terminal' | 'file-browser' | 'system-m
5
5
  export type WorkbenchWidgetType = BuiltinWorkbenchWidgetType | (string & {});
6
6
  export declare const WORKBENCH_WIDGET_TYPES: readonly WorkbenchWidgetType[];
7
7
  export type WorkbenchWidgetRenderMode = 'canvas_scaled' | 'projected_surface';
8
+ export type WorkbenchProjectedSurfaceScaleBehavior = 'stable_transform' | 'settle_sharp_zoom';
8
9
  export type WorkbenchCanvasOwnerReason = 'initial' | 'background_pointer' | 'background_focus' | 'selection_cleared' | (string & {});
9
10
  export type WorkbenchWidgetOwnerReason = 'pointer' | 'focus' | 'activation' | (string & {});
10
11
  export type WorkbenchInputOwner = {
@@ -112,6 +113,7 @@ export interface WorkbenchWidgetDefinition<TWidgetType extends string = Workbenc
112
113
  group?: string;
113
114
  singleton?: boolean;
114
115
  renderMode?: WorkbenchWidgetRenderMode;
116
+ projectedSurfaceScaleBehavior?: WorkbenchProjectedSurfaceScaleBehavior;
115
117
  }
116
118
  export interface WorkbenchWidgetItem<TWidgetType extends string = WorkbenchWidgetType> {
117
119
  id: string;
@@ -1,6 +1,7 @@
1
- import { type WorkbenchProjectedRect, type WorkbenchState, type WorkbenchViewport, type WorkbenchWidgetDefinition, type WorkbenchWidgetItem, type WorkbenchWidgetRenderMode, type WorkbenchWidgetSurfaceMetrics, type WorkbenchWidgetType } from './types';
1
+ import { type WorkbenchProjectedSurfaceScaleBehavior, type WorkbenchProjectedRect, type WorkbenchState, type WorkbenchViewport, type WorkbenchWidgetDefinition, type WorkbenchWidgetItem, type WorkbenchWidgetRenderMode, type WorkbenchWidgetSurfaceMetrics, type WorkbenchWidgetType } from './types';
2
2
  export declare function createWorkbenchId(): string;
3
3
  export declare function resolveWorkbenchWidgetRenderMode(definition: WorkbenchWidgetDefinition): WorkbenchWidgetRenderMode;
4
+ export declare function resolveWorkbenchProjectedSurfaceScaleBehavior(definition: WorkbenchWidgetDefinition): WorkbenchProjectedSurfaceScaleBehavior;
4
5
  export interface CreateWorkbenchProjectedRectInput {
5
6
  widgetId: string;
6
7
  worldX: number;
@@ -1,32 +1,35 @@
1
1
  import { DEFAULT_WORKBENCH_VIEWPORT as y } from "./types.js";
2
- import { resolveWorkbenchWidgetDefinitions as _, getWidgetEntry as W, createWorkbenchFilterState as w, isValidWorkbenchWidgetType as H } from "./widgets/widgetRegistry.js";
3
- import { DEFAULT_WORKBENCH_THEME as b, isWorkbenchThemeId as N } from "./workbenchThemes.js";
4
- function T() {
2
+ import { resolveWorkbenchWidgetDefinitions as w, getWidgetEntry as _, createWorkbenchFilterState as W, isValidWorkbenchWidgetType as N } from "./widgets/widgetRegistry.js";
3
+ import { DEFAULT_WORKBENCH_THEME as b, isWorkbenchThemeId as v } from "./workbenchThemes.js";
4
+ function O() {
5
5
  const e = globalThis.crypto;
6
6
  return e && typeof e.randomUUID == "function" ? `wb-${e.randomUUID()}` : `wb-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
7
7
  }
8
- function A(e) {
8
+ function T(e) {
9
9
  return e.renderMode ?? "canvas_scaled";
10
10
  }
11
- function E(e) {
12
- const t = Number.isFinite(e.viewport.scale) && e.viewport.scale > 0 ? e.viewport.scale : 1;
11
+ function A(e) {
12
+ return e.projectedSurfaceScaleBehavior ?? "stable_transform";
13
+ }
14
+ function H(e) {
15
+ const t = Number.isFinite(e.viewport.scale) && e.viewport.scale > 0 ? e.viewport.scale : 1, r = typeof window < "u" && Number.isFinite(window.devicePixelRatio) && window.devicePixelRatio > 0 ? window.devicePixelRatio : 1, d = Math.round((e.viewport.x + e.worldX * t) * r) / r, i = Math.round((e.viewport.y + e.worldY * t) * r) / r;
13
16
  return {
14
17
  widgetId: e.widgetId,
15
18
  worldX: e.worldX,
16
19
  worldY: e.worldY,
17
20
  worldWidth: e.worldWidth,
18
21
  worldHeight: e.worldHeight,
19
- screenX: e.viewport.x + e.worldX * t,
20
- screenY: e.viewport.y + e.worldY * t,
22
+ screenX: d,
23
+ screenY: i,
21
24
  screenWidth: e.worldWidth * t,
22
25
  screenHeight: e.worldHeight * t,
23
26
  viewportScale: t
24
27
  };
25
28
  }
26
- function P(e) {
29
+ function B(e) {
27
30
  return {
28
31
  ready: e.ready,
29
- rect: E(e)
32
+ rect: H(e)
30
33
  };
31
34
  }
32
35
  function F(e) {
@@ -36,126 +39,126 @@ function F(e) {
36
39
  scale: Number.isFinite(e.scale) && e.scale > 0 ? e.scale : 1
37
40
  } : { ...y };
38
41
  }
39
- function I(e, t) {
40
- return w(t, e);
42
+ function E(e, t) {
43
+ return W(t, e);
41
44
  }
42
45
  function X(e, t = {}) {
43
- const r = _(t.widgetDefinitions), d = t.createFallbackState ?? (() => z(r)), n = e;
44
- if (!n || n.version !== 1 || !Array.isArray(n.widgets))
46
+ const r = w(t.widgetDefinitions), d = t.createFallbackState ?? (() => I(r)), i = e;
47
+ if (!i || i.version !== 1 || !Array.isArray(i.widgets))
45
48
  return d();
46
- const a = n.widgets.filter(
47
- (i) => !!i && typeof i.id == "string" && H(i.type, r) && typeof i.title == "string"
48
- ).map((i) => {
49
- const h = W(i.type, r);
49
+ const a = i.widgets.filter(
50
+ (n) => !!n && typeof n.id == "string" && N(n.type, r) && typeof n.title == "string"
51
+ ).map((n) => {
52
+ const h = _(n.type, r);
50
53
  return {
51
- id: i.id,
52
- type: i.type,
53
- title: i.title,
54
- x: Number.isFinite(i.x) ? i.x : 0,
55
- y: Number.isFinite(i.y) ? i.y : 0,
56
- width: Number.isFinite(i.width) && i.width > 0 ? i.width : h.defaultSize.width,
57
- height: Number.isFinite(i.height) && i.height > 0 ? i.height : h.defaultSize.height,
58
- z_index: Number.isFinite(i.z_index) && i.z_index >= 0 ? i.z_index : 1,
59
- created_at_unix_ms: Number.isFinite(i.created_at_unix_ms) ? i.created_at_unix_ms : Date.now()
54
+ id: n.id,
55
+ type: n.type,
56
+ title: n.title,
57
+ x: Number.isFinite(n.x) ? n.x : 0,
58
+ y: Number.isFinite(n.y) ? n.y : 0,
59
+ width: Number.isFinite(n.width) && n.width > 0 ? n.width : h.defaultSize.width,
60
+ height: Number.isFinite(n.height) && n.height > 0 ? n.height : h.defaultSize.height,
61
+ z_index: Number.isFinite(n.z_index) && n.z_index >= 0 ? n.z_index : 1,
62
+ created_at_unix_ms: Number.isFinite(n.created_at_unix_ms) ? n.created_at_unix_ms : Date.now()
60
63
  };
61
- }), c = typeof n.selectedWidgetId == "string" && a.some((i) => i.id === n.selectedWidgetId) ? n.selectedWidgetId : null;
64
+ }), c = typeof i.selectedWidgetId == "string" && a.some((n) => n.id === i.selectedWidgetId) ? i.selectedWidgetId : null;
62
65
  return {
63
66
  version: 1,
64
67
  widgets: a,
65
- viewport: F(n.viewport),
66
- locked: typeof n.locked == "boolean" ? n.locked : !1,
67
- filters: I(n.filters, r),
68
+ viewport: F(i.viewport),
69
+ locked: typeof i.locked == "boolean" ? i.locked : !1,
70
+ filters: E(i.filters, r),
68
71
  selectedWidgetId: c,
69
- theme: N(n.theme) ? n.theme : b
72
+ theme: v(i.theme) ? i.theme : b
70
73
  };
71
74
  }
72
- function z(e) {
73
- const t = _(e), r = Date.now(), d = [
75
+ function I(e) {
76
+ const t = w(e), r = Date.now(), d = [
74
77
  { type: "terminal", title: "dev · terminal", x: 80, y: 80 },
75
78
  { type: "file-browser", title: "project · files", x: 600, y: 80 },
76
79
  { type: "system-monitor", title: "host · system monitor", x: 80, y: 420 },
77
80
  { type: "log-viewer", title: "services · logs", x: 540, y: 500 },
78
81
  { type: "code-editor", title: "Counter.tsx", x: 1e3, y: 180 }
79
- ], n = d.filter((a) => t.some((c) => c.type === a.type)).map((a, c) => {
80
- const i = W(a.type, t);
82
+ ], i = d.filter((a) => t.some((c) => c.type === a.type)).map((a, c) => {
83
+ const n = _(a.type, t);
81
84
  return {
82
85
  id: `wb-seed-${c + 1}`,
83
86
  type: a.type,
84
87
  title: a.title,
85
88
  x: a.x,
86
89
  y: a.y,
87
- width: i.defaultSize.width,
88
- height: i.defaultSize.height,
90
+ width: n.defaultSize.width,
91
+ height: n.defaultSize.height,
89
92
  z_index: c + 1,
90
93
  created_at_unix_ms: r - (d.length - c) * 6e5
91
94
  };
92
95
  });
93
96
  return {
94
97
  version: 1,
95
- widgets: n,
98
+ widgets: i,
96
99
  viewport: { ...y },
97
100
  locked: !1,
98
- filters: w(t),
99
- selectedWidgetId: n[0]?.id ?? null,
101
+ filters: W(t),
102
+ selectedWidgetId: i[0]?.id ?? null,
100
103
  theme: b
101
104
  };
102
105
  }
103
- const B = 1.18, K = 200, m = 0.45, u = 2.2, p = 48;
104
- function v(e) {
105
- const t = M(e.scale, m, u);
106
+ const K = 1.18, U = 200, u = 0.45, m = 2.2, p = 48;
107
+ function R(e) {
108
+ const t = M(e.scale, u, m);
106
109
  return {
107
110
  x: e.frameWidth / 2 - (e.widget.x + e.widget.width / 2) * t,
108
111
  y: e.frameHeight / 2 - (e.widget.y + e.widget.height / 2) * t,
109
112
  scale: t
110
113
  };
111
114
  }
112
- function U(e) {
113
- const t = e.minScale ?? m, r = e.maxScale ?? u, d = e.paddingPx ?? p, n = Math.max(e.frameWidth - d * 2, 1), a = Math.max(e.frameHeight - d * 2, 1), c = M(
115
+ function V(e) {
116
+ const t = e.minScale ?? u, r = e.maxScale ?? m, d = e.paddingPx ?? p, i = Math.max(e.frameWidth - d * 2, 1), a = Math.max(e.frameHeight - d * 2, 1), c = M(
114
117
  Math.min(
115
- n / Math.max(e.widget.width, 1),
118
+ i / Math.max(e.widget.width, 1),
116
119
  a / Math.max(e.widget.height, 1)
117
120
  ),
118
121
  t,
119
122
  r
120
123
  );
121
- return v({
124
+ return R({
122
125
  widget: e.widget,
123
126
  scale: c,
124
127
  frameWidth: e.frameWidth,
125
128
  frameHeight: e.frameHeight
126
129
  });
127
130
  }
128
- function C(e, t) {
131
+ function z(e, t) {
129
132
  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);
130
133
  }
131
- function V(e) {
132
- const t = [...e].sort(C), r = /* @__PURE__ */ new Map();
133
- for (const [d, n] of t.entries())
134
- r.set(n.id, d + 1);
134
+ function L(e) {
135
+ const t = [...e].sort(z), r = /* @__PURE__ */ new Map();
136
+ for (const [d, i] of t.entries())
137
+ r.set(i.id, d + 1);
135
138
  return {
136
139
  byWidgetId: r,
137
140
  topRenderLayer: Math.max(t.length, 1)
138
141
  };
139
142
  }
140
- function L(e) {
143
+ function Y(e) {
141
144
  const t = typeof window < "u" ? window.innerWidth : 1280, r = typeof window < "u" ? window.innerHeight : 800;
142
- let d = e.clientX, n = e.clientY;
143
- 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 };
145
+ let d = e.clientX, i = e.clientY;
146
+ return d + e.menuWidth > t && (d = Math.max(0, t - e.menuWidth - 8)), i + e.menuHeight > r && (i = Math.max(0, r - e.menuHeight - 8)), { left: d, top: i };
144
147
  }
145
- function Y(e) {
148
+ function j(e) {
146
149
  return e.reduce((t, r) => Math.max(t, r.z_index), 1);
147
150
  }
148
151
  function $(e, t, r, d) {
149
- const n = e.filter((o) => d[o.type]);
150
- if (n.length === 0) return null;
151
- if (!t) return n[0] ?? null;
152
- const a = n.find((o) => o.id === t);
153
- if (!a) return n[0] ?? null;
154
- const c = a.x + a.width / 2, i = a.y + a.height / 2;
152
+ const i = e.filter((o) => d[o.type]);
153
+ if (i.length === 0) return null;
154
+ if (!t) return i[0] ?? null;
155
+ const a = i.find((o) => o.id === t);
156
+ if (!a) return i[0] ?? null;
157
+ const c = a.x + a.width / 2, n = a.y + a.height / 2;
155
158
  let h = null, g = 1 / 0;
156
- for (const o of n) {
159
+ for (const o of i) {
157
160
  if (o.id === t) continue;
158
- const s = o.x + o.width / 2 - c, l = o.y + o.height / 2 - i;
161
+ const s = o.x + o.width / 2 - c, l = o.y + o.height / 2 - n;
159
162
  let f = !1;
160
163
  switch (r) {
161
164
  case "up":
@@ -180,32 +183,33 @@ function $(e, t, r, d) {
180
183
  }
181
184
  return h;
182
185
  }
183
- function M(e, t = m, r = u) {
186
+ function M(e, t = u, r = m) {
184
187
  return Math.max(t, Math.min(r, e));
185
188
  }
186
- function j(e, t = 0) {
189
+ function Z(e, t = 0) {
187
190
  return 16 + Math.max(1, e) * 32 + Math.max(0, t) * 9;
188
191
  }
189
192
  export {
190
- B as WORKBENCH_CANVAS_ZOOM_STEP,
191
- K as WORKBENCH_CONTEXT_MENU_WIDTH_PX,
192
- u as WORKBENCH_MAX_SCALE,
193
- m as WORKBENCH_MIN_SCALE,
193
+ K as WORKBENCH_CANVAS_ZOOM_STEP,
194
+ U as WORKBENCH_CONTEXT_MENU_WIDTH_PX,
195
+ m as WORKBENCH_MAX_SCALE,
196
+ u as WORKBENCH_MIN_SCALE,
194
197
  p as WORKBENCH_VIEWPORT_FIT_PADDING_PX,
195
198
  M as clampScale,
196
- L as createContextMenuPosition,
197
- z as createDefaultWorkbenchState,
198
- T as createWorkbenchId,
199
- E as createWorkbenchProjectedRect,
200
- V as createWorkbenchRenderLayerMap,
201
- v as createWorkbenchViewportCenteredOnWidget,
202
- U as createWorkbenchViewportFitForWidget,
203
- P as createWorkbenchWidgetSurfaceMetrics,
204
- j as estimateContextMenuHeight,
199
+ Y as createContextMenuPosition,
200
+ I as createDefaultWorkbenchState,
201
+ O as createWorkbenchId,
202
+ H as createWorkbenchProjectedRect,
203
+ L as createWorkbenchRenderLayerMap,
204
+ R as createWorkbenchViewportCenteredOnWidget,
205
+ V as createWorkbenchViewportFitForWidget,
206
+ B as createWorkbenchWidgetSurfaceMetrics,
207
+ Z as estimateContextMenuHeight,
205
208
  $ as findNearestWidget,
206
- Y as getTopZIndex,
207
- A as resolveWorkbenchWidgetRenderMode,
208
- I as sanitizeFilters,
209
+ j as getTopZIndex,
210
+ A as resolveWorkbenchProjectedSurfaceScaleBehavior,
211
+ T as resolveWorkbenchWidgetRenderMode,
212
+ E as sanitizeFilters,
209
213
  F as sanitizeViewport,
210
214
  X as sanitizeWorkbenchState
211
215
  };
package/dist/editor.js CHANGED
@@ -1,10 +1,14 @@
1
1
  import { CodeEditor as r } from "./components/editor/CodeEditor.js";
2
- import { DEFAULT_MONACO_STANDALONE_FEATURES as a, normalizeMonacoRuntimeFeatureSet as d } from "./components/editor/monacoStandaloneRuntime.js";
3
- import { isCodeEditorLanguageSupported as i, resolveCodeEditorLanguageSpec as p } from "./components/editor/languages.js";
2
+ import { DEFAULT_MONACO_RUNTIME_PROFILE as E, DEFAULT_MONACO_STANDALONE_FEATURES as a, MONACO_RUNTIME_BLUEPRINTS as i, normalizeMonacoRuntimeFeatureSet as n, resolveMonacoRuntimeProfile as R, resolveMonacoRuntimeRequest as u } from "./components/editor/monacoStandaloneRuntime.js";
3
+ import { isCodeEditorLanguageSupported as M, resolveCodeEditorLanguageSpec as N } from "./components/editor/languages.js";
4
4
  export {
5
5
  r as CodeEditor,
6
+ E as DEFAULT_MONACO_RUNTIME_PROFILE,
6
7
  a as DEFAULT_MONACO_STANDALONE_FEATURES,
7
- i as isCodeEditorLanguageSupported,
8
- d as normalizeMonacoRuntimeFeatureSet,
9
- p as resolveCodeEditorLanguageSpec
8
+ i as MONACO_RUNTIME_BLUEPRINTS,
9
+ M as isCodeEditorLanguageSupported,
10
+ n as normalizeMonacoRuntimeFeatureSet,
11
+ N as resolveCodeEditorLanguageSpec,
12
+ R as resolveMonacoRuntimeProfile,
13
+ u as resolveMonacoRuntimeRequest
10
14
  };