@floegence/floe-webapp-core 0.36.7 → 0.36.8
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/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/editor.js +5 -2
- package/dist/full.js +519 -516
- package/dist/styles.css +1 -1
- package/dist/ui.js +97 -94
- package/dist/workbench.css +16 -0
- package/dist/workbench.js +17 -14
- package/package.json +1 -1
|
@@ -2,10 +2,28 @@ import type { Component } from 'solid-js';
|
|
|
2
2
|
export type BuiltinWorkbenchWidgetType = 'terminal' | 'file-browser' | 'system-monitor' | 'log-viewer' | 'code-editor';
|
|
3
3
|
export type WorkbenchWidgetType = BuiltinWorkbenchWidgetType | (string & {});
|
|
4
4
|
export declare const WORKBENCH_WIDGET_TYPES: readonly WorkbenchWidgetType[];
|
|
5
|
+
export type WorkbenchWidgetRenderMode = 'canvas_scaled' | 'projected_surface';
|
|
6
|
+
export interface WorkbenchProjectedRect {
|
|
7
|
+
widgetId: string;
|
|
8
|
+
worldX: number;
|
|
9
|
+
worldY: number;
|
|
10
|
+
worldWidth: number;
|
|
11
|
+
worldHeight: number;
|
|
12
|
+
screenX: number;
|
|
13
|
+
screenY: number;
|
|
14
|
+
screenWidth: number;
|
|
15
|
+
screenHeight: number;
|
|
16
|
+
viewportScale: number;
|
|
17
|
+
}
|
|
18
|
+
export interface WorkbenchWidgetSurfaceMetrics {
|
|
19
|
+
ready: boolean;
|
|
20
|
+
rect: WorkbenchProjectedRect;
|
|
21
|
+
}
|
|
5
22
|
export interface WorkbenchWidgetBodyProps<TWidgetType extends string = WorkbenchWidgetType> {
|
|
6
23
|
widgetId: string;
|
|
7
24
|
title: string;
|
|
8
25
|
type: TWidgetType;
|
|
26
|
+
surfaceMetrics?: WorkbenchWidgetSurfaceMetrics;
|
|
9
27
|
}
|
|
10
28
|
export interface WorkbenchWidgetDefinition<TWidgetType extends string = WorkbenchWidgetType> {
|
|
11
29
|
type: TWidgetType;
|
|
@@ -21,6 +39,7 @@ export interface WorkbenchWidgetDefinition<TWidgetType extends string = Workbenc
|
|
|
21
39
|
};
|
|
22
40
|
group?: string;
|
|
23
41
|
singleton?: boolean;
|
|
42
|
+
renderMode?: WorkbenchWidgetRenderMode;
|
|
24
43
|
}
|
|
25
44
|
export interface WorkbenchWidgetItem<TWidgetType extends string = WorkbenchWidgetType> {
|
|
26
45
|
id: string;
|
|
@@ -10,6 +10,10 @@ export interface UseWorkbenchModelOptions {
|
|
|
10
10
|
export declare function useWorkbenchModel(options: UseWorkbenchModelOptions): {
|
|
11
11
|
widgets: import("solid-js").Accessor<WorkbenchWidgetItem<WorkbenchWidgetType>[]>;
|
|
12
12
|
viewport: import("solid-js").Accessor<WorkbenchViewport>;
|
|
13
|
+
canvasFrameSize: import("solid-js").Accessor<{
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
}>;
|
|
13
17
|
locked: import("solid-js").Accessor<boolean>;
|
|
14
18
|
filters: import("solid-js").Accessor<Record<WorkbenchWidgetType, boolean>>;
|
|
15
19
|
selectedWidgetId: import("solid-js").Accessor<string | null>;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { createSignal as _, createMemo as d, onCleanup as mt } from "solid-js";
|
|
2
2
|
import { ArrowUp as Wt, Copy as xt, Trash as St } from "../icons/index.js";
|
|
3
|
-
import { getTopZIndex as Ct, createContextMenuPosition as pt, createWorkbenchId as kt, findNearestWidget as Ft, clampScale as Xt, WORKBENCH_CANVAS_ZOOM_STEP as
|
|
4
|
-
import { resolveWorkbenchWidgetDefinitions as Yt, getWidgetEntry as
|
|
3
|
+
import { getTopZIndex as Ct, createContextMenuPosition as pt, createWorkbenchId as kt, findNearestWidget as Ft, clampScale as Xt, WORKBENCH_CANVAS_ZOOM_STEP as Z, WORKBENCH_CONTEXT_MENU_WIDTH_PX as bt, estimateContextMenuHeight as Mt } from "./workbenchHelpers.js";
|
|
4
|
+
import { resolveWorkbenchWidgetDefinitions as Yt, getWidgetEntry as $, createWorkbenchFilterState as yt } from "./widgets/widgetRegistry.js";
|
|
5
5
|
function Nt(s) {
|
|
6
|
-
const [m, W] = _(null), [
|
|
6
|
+
const [m, W] = _(null), [j, A] = _(null), [D, K] = _({ width: 0, height: 0 });
|
|
7
7
|
let r = null, x = null;
|
|
8
|
-
const a = s.state, h = d(() => a().widgets), u = d(() => a().viewport), L = d(() => a().locked),
|
|
8
|
+
const a = s.state, h = d(() => a().widgets), u = d(() => a().viewport), L = d(() => a().locked), T = d(() => a().filters), k = d(() => a().selectedWidgetId), F = d(() => Ct(h())), U = d(() => `${Math.round(u().scale * 100)}%`), G = () => typeof s.widgetDefinitions == "function" ? s.widgetDefinitions() : s.widgetDefinitions, f = d(
|
|
9
9
|
() => Yt(G())
|
|
10
10
|
), X = (t, e) => {
|
|
11
|
-
const n = Number.isFinite(t) && t > 0 ? t : 0, i = Number.isFinite(e) && e > 0 ? e : 0, o = { width: n, height: i }, c =
|
|
11
|
+
const n = Number.isFinite(t) && t > 0 ? t : 0, i = Number.isFinite(e) && e > 0 ? e : 0, o = { width: n, height: i }, c = D();
|
|
12
12
|
return c.width === n && c.height === i ? c : (K(o), o);
|
|
13
|
-
},
|
|
13
|
+
}, N = () => {
|
|
14
14
|
x?.disconnect(), x = null;
|
|
15
15
|
}, w = () => r ? X(r.clientWidth, r.clientHeight) : X(0, 0), J = (t) => {
|
|
16
16
|
if (r === (t ?? null)) {
|
|
17
17
|
w();
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
N(), r = t ?? null, w(), !(!r || typeof ResizeObserver > "u") && (x = new ResizeObserver((e) => {
|
|
21
21
|
const n = e[0];
|
|
22
22
|
X(
|
|
23
23
|
n?.contentRect.width ?? r?.clientWidth ?? 0,
|
|
@@ -26,7 +26,7 @@ function Nt(s) {
|
|
|
26
26
|
}), x.observe(r));
|
|
27
27
|
};
|
|
28
28
|
mt(() => {
|
|
29
|
-
|
|
29
|
+
N(), r = null;
|
|
30
30
|
});
|
|
31
31
|
const Q = (t) => {
|
|
32
32
|
W({
|
|
@@ -43,7 +43,7 @@ function Nt(s) {
|
|
|
43
43
|
worldY: e.y,
|
|
44
44
|
widgetId: e.id
|
|
45
45
|
});
|
|
46
|
-
}, g = () => W(null), et = (t) => a().widgets.find((e) => e.id === t) ?? null, b = (t) => a().widgets.find((e) => e.type === t) ?? null,
|
|
46
|
+
}, g = () => W(null), et = (t) => a().widgets.find((e) => e.id === t) ?? null, b = (t) => a().widgets.find((e) => e.type === t) ?? null, R = d(() => {
|
|
47
47
|
const t = m();
|
|
48
48
|
if (!t) return [];
|
|
49
49
|
if (t.widgetId) {
|
|
@@ -62,7 +62,7 @@ function Nt(s) {
|
|
|
62
62
|
label: "Duplicate",
|
|
63
63
|
icon: xt,
|
|
64
64
|
onSelect: () => {
|
|
65
|
-
|
|
65
|
+
V(e.type, e.x + 32, e.y + 32), g();
|
|
66
66
|
}
|
|
67
67
|
})), n.push({ id: "separator-delete", kind: "separator" }), n.push({
|
|
68
68
|
id: "delete",
|
|
@@ -87,7 +87,7 @@ function Nt(s) {
|
|
|
87
87
|
}), nt = d(() => {
|
|
88
88
|
const t = m();
|
|
89
89
|
if (!t) return;
|
|
90
|
-
const e =
|
|
90
|
+
const e = R(), n = e.filter((o) => o.kind === "action").length, i = e.filter((o) => o.kind === "separator").length;
|
|
91
91
|
return pt({
|
|
92
92
|
clientX: t.clientX,
|
|
93
93
|
clientY: t.clientY,
|
|
@@ -95,7 +95,7 @@ function Nt(s) {
|
|
|
95
95
|
menuHeight: Mt(n, i)
|
|
96
96
|
});
|
|
97
97
|
}), M = (t, e, n) => {
|
|
98
|
-
const i =
|
|
98
|
+
const i = $(t, f()), o = i.singleton ? b(t) : null;
|
|
99
99
|
if (o)
|
|
100
100
|
return C(o, { centerViewport: !0 });
|
|
101
101
|
const c = i.defaultSize, l = {
|
|
@@ -115,9 +115,9 @@ function Nt(s) {
|
|
|
115
115
|
selectedWidgetId: l.id
|
|
116
116
|
})), l;
|
|
117
117
|
}, Y = (t, e, n) => {
|
|
118
|
-
const i =
|
|
118
|
+
const i = $(t, f()).defaultSize;
|
|
119
119
|
return M(t, e - i.width / 2, n - i.height / 2);
|
|
120
|
-
},
|
|
120
|
+
}, V = (t, e, n) => M(t, e, n), y = (t) => {
|
|
121
121
|
s.setState((e) => ({
|
|
122
122
|
...e,
|
|
123
123
|
widgets: e.widgets.filter((n) => n.id !== t),
|
|
@@ -150,9 +150,9 @@ function Nt(s) {
|
|
|
150
150
|
}));
|
|
151
151
|
}, I = (t) => {
|
|
152
152
|
s.setState((e) => ({ ...e, viewport: t }));
|
|
153
|
-
},
|
|
153
|
+
}, H = (t) => {
|
|
154
154
|
const e = u(), n = w(), i = (n.width / 2 - e.x) / e.scale, o = (n.height / 2 - e.y) / e.scale, c = Xt(
|
|
155
|
-
t === "in" ? e.scale *
|
|
155
|
+
t === "in" ? e.scale * Z : e.scale / Z
|
|
156
156
|
), l = {
|
|
157
157
|
x: n.width / 2 - i * c,
|
|
158
158
|
y: n.height / 2 - o * c,
|
|
@@ -179,7 +179,7 @@ function Nt(s) {
|
|
|
179
179
|
...e,
|
|
180
180
|
filters: t
|
|
181
181
|
}));
|
|
182
|
-
},
|
|
182
|
+
}, E = (t) => {
|
|
183
183
|
s.setState((e) => ({ ...e, selectedWidgetId: t }));
|
|
184
184
|
}, at = () => {
|
|
185
185
|
const t = w(), e = u();
|
|
@@ -188,38 +188,39 @@ function Nt(s) {
|
|
|
188
188
|
worldY: t.height > 0 ? (t.height / 2 - e.y) / e.scale : 180
|
|
189
189
|
};
|
|
190
190
|
};
|
|
191
|
-
let
|
|
191
|
+
let q = 0;
|
|
192
192
|
const ut = (t, e, n) => {
|
|
193
|
-
const i = u(), o = i.x, c = i.y, l = i.scale, p = performance.now(), gt = 360, ht = ++
|
|
194
|
-
if (ht !==
|
|
195
|
-
const wt = v - p,
|
|
193
|
+
const i = u(), o = i.x, c = i.y, l = i.scale, p = performance.now(), gt = 360, ht = ++q, ft = (v) => 1 - Math.pow(1 - v, 3), B = (v) => {
|
|
194
|
+
if (ht !== q) return;
|
|
195
|
+
const wt = v - p, P = Math.min(Math.max(wt / gt, 0), 1), O = ft(P);
|
|
196
196
|
I({
|
|
197
197
|
x: o + (t - o) * O,
|
|
198
198
|
y: c + (e - c) * O,
|
|
199
199
|
scale: l + (n - l) * O
|
|
200
|
-
}),
|
|
200
|
+
}), P < 1 && requestAnimationFrame(B);
|
|
201
201
|
};
|
|
202
|
-
requestAnimationFrame(
|
|
202
|
+
requestAnimationFrame(B);
|
|
203
203
|
}, z = (t) => {
|
|
204
204
|
const e = w();
|
|
205
205
|
if (e.width === 0 || e.height === 0) return;
|
|
206
206
|
const n = u(), i = e.width / 2 - (t.x + t.width / 2) * n.scale, o = e.height / 2 - (t.y + t.height / 2) * n.scale;
|
|
207
207
|
ut(i, o, n.scale);
|
|
208
|
-
}, C = (t, e = {}) => (
|
|
208
|
+
}, C = (t, e = {}) => (E(t.id), S(t.id), e.centerViewport !== !1 && z(t), t);
|
|
209
209
|
return {
|
|
210
210
|
widgets: h,
|
|
211
211
|
viewport: u,
|
|
212
|
+
canvasFrameSize: D,
|
|
212
213
|
locked: L,
|
|
213
|
-
filters:
|
|
214
|
+
filters: T,
|
|
214
215
|
selectedWidgetId: k,
|
|
215
216
|
topZIndex: F,
|
|
216
217
|
scaleLabel: U,
|
|
217
|
-
optimisticFrontWidgetId:
|
|
218
|
+
optimisticFrontWidgetId: j,
|
|
218
219
|
widgetDefinitions: f,
|
|
219
220
|
setCanvasFrameRef: J,
|
|
220
221
|
contextMenu: {
|
|
221
222
|
state: m,
|
|
222
|
-
items:
|
|
223
|
+
items: R,
|
|
223
224
|
position: nt,
|
|
224
225
|
close: g,
|
|
225
226
|
retarget: (t) => {
|
|
@@ -234,7 +235,7 @@ function Nt(s) {
|
|
|
234
235
|
canvas: {
|
|
235
236
|
openCanvasContextMenu: Q,
|
|
236
237
|
openWidgetContextMenu: tt,
|
|
237
|
-
selectWidget:
|
|
238
|
+
selectWidget: E,
|
|
238
239
|
startOptimisticFront: it,
|
|
239
240
|
commitFront: S,
|
|
240
241
|
commitMove: ot,
|
|
@@ -242,8 +243,8 @@ function Nt(s) {
|
|
|
242
243
|
commitViewport: I
|
|
243
244
|
},
|
|
244
245
|
hud: {
|
|
245
|
-
zoomIn: () =>
|
|
246
|
-
zoomOut: () =>
|
|
246
|
+
zoomIn: () => H("in"),
|
|
247
|
+
zoomOut: () => H("out")
|
|
247
248
|
},
|
|
248
249
|
lock: {
|
|
249
250
|
toggle: ct
|
|
@@ -259,7 +260,7 @@ function Nt(s) {
|
|
|
259
260
|
h(),
|
|
260
261
|
k(),
|
|
261
262
|
t,
|
|
262
|
-
|
|
263
|
+
T()
|
|
263
264
|
);
|
|
264
265
|
e && C(e);
|
|
265
266
|
},
|
|
@@ -274,7 +275,7 @@ function Nt(s) {
|
|
|
274
275
|
deleteWidget: y,
|
|
275
276
|
addWidget: M,
|
|
276
277
|
addWidgetAtCursor: Y,
|
|
277
|
-
addWidgetCentered:
|
|
278
|
+
addWidgetCentered: V,
|
|
278
279
|
ensureWidget: (t, e) => {
|
|
279
280
|
const n = b(t);
|
|
280
281
|
if (n)
|
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
import { type WorkbenchState, type WorkbenchViewport, type WorkbenchWidgetDefinition, type WorkbenchWidgetItem, type WorkbenchWidgetType } from './types';
|
|
1
|
+
import { 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
|
+
export declare function resolveWorkbenchWidgetRenderMode(definition: WorkbenchWidgetDefinition): WorkbenchWidgetRenderMode;
|
|
4
|
+
export interface CreateWorkbenchProjectedRectInput {
|
|
5
|
+
widgetId: string;
|
|
6
|
+
worldX: number;
|
|
7
|
+
worldY: number;
|
|
8
|
+
worldWidth: number;
|
|
9
|
+
worldHeight: number;
|
|
10
|
+
viewport: WorkbenchViewport;
|
|
11
|
+
}
|
|
12
|
+
export declare function createWorkbenchProjectedRect(input: CreateWorkbenchProjectedRectInput): WorkbenchProjectedRect;
|
|
13
|
+
export declare function createWorkbenchWidgetSurfaceMetrics(input: CreateWorkbenchProjectedRectInput & {
|
|
14
|
+
ready: boolean;
|
|
15
|
+
}): WorkbenchWidgetSurfaceMetrics;
|
|
3
16
|
export declare function sanitizeViewport(viewport: Partial<WorkbenchViewport> | undefined): WorkbenchViewport;
|
|
4
17
|
export declare function sanitizeFilters(filters: Partial<Record<WorkbenchWidgetType, boolean>> | undefined, widgetDefinitions?: readonly WorkbenchWidgetDefinition[]): Record<WorkbenchWidgetType, boolean>;
|
|
5
18
|
export interface SanitizeWorkbenchStateOptions {
|
|
@@ -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
|
package/dist/editor.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { CodeEditor as r } from "./components/editor/CodeEditor.js";
|
|
2
|
-
import {
|
|
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";
|
|
3
4
|
export {
|
|
4
5
|
r as CodeEditor,
|
|
5
|
-
|
|
6
|
+
a as DEFAULT_MONACO_STANDALONE_FEATURES,
|
|
7
|
+
i as isCodeEditorLanguageSupported,
|
|
8
|
+
d as normalizeMonacoRuntimeFeatureSet,
|
|
6
9
|
p as resolveCodeEditorLanguageSpec
|
|
7
10
|
};
|