@floegence/floe-webapp-core 0.35.59 → 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.
- package/dist/components/deck/DeckCell.js +47 -50
- package/dist/components/deck/DeckContextMenu.d.ts +22 -0
- package/dist/components/deck/DeckContextMenu.js +73 -0
- package/dist/components/deck/DeckGrid.js +147 -104
- package/dist/components/deck/DeckTopBar.js +74 -96
- package/dist/components/deck/WidgetFrame.d.ts +7 -1
- package/dist/components/deck/WidgetFrame.js +60 -52
- package/dist/components/deck/index.d.ts +1 -0
- 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/InfiniteCanvas.d.ts +2 -0
- package/dist/components/ui/InfiniteCanvas.js +43 -37
- package/dist/components/workbench/WorkbenchCanvas.d.ts +29 -0
- package/dist/components/workbench/WorkbenchCanvas.js +83 -0
- package/dist/components/workbench/WorkbenchContextMenu.d.ts +24 -0
- package/dist/components/workbench/WorkbenchContextMenu.js +44 -0
- package/dist/components/workbench/WorkbenchFilterBar.d.ts +17 -0
- package/dist/components/workbench/WorkbenchFilterBar.js +267 -0
- package/dist/components/workbench/WorkbenchHud.d.ts +6 -0
- package/dist/components/workbench/WorkbenchHud.js +17 -0
- package/dist/components/workbench/WorkbenchLockButton.d.ts +6 -0
- package/dist/components/workbench/WorkbenchLockButton.js +49 -0
- package/dist/components/workbench/WorkbenchOverlay.d.ts +18 -0
- package/dist/components/workbench/WorkbenchOverlay.js +107 -0
- package/dist/components/workbench/WorkbenchSurface.d.ts +34 -0
- package/dist/components/workbench/WorkbenchSurface.js +200 -0
- package/dist/components/workbench/WorkbenchWidget.d.ts +26 -0
- package/dist/components/workbench/WorkbenchWidget.js +192 -0
- package/dist/components/workbench/index.d.ts +7 -0
- package/dist/components/workbench/types.d.ts +56 -0
- package/dist/components/workbench/types.js +11 -0
- package/dist/components/workbench/useWorkbenchModel.d.ts +83 -0
- package/dist/components/workbench/useWorkbenchModel.js +284 -0
- package/dist/components/workbench/widgets/CodeEditorWidget.d.ts +1 -0
- package/dist/components/workbench/widgets/CodeEditorWidget.js +144 -0
- package/dist/components/workbench/widgets/FileBrowserWidget.d.ts +1 -0
- package/dist/components/workbench/widgets/FileBrowserWidget.js +142 -0
- package/dist/components/workbench/widgets/LogViewerWidget.d.ts +1 -0
- package/dist/components/workbench/widgets/LogViewerWidget.js +86 -0
- package/dist/components/workbench/widgets/SystemMonitorWidget.d.ts +1 -0
- package/dist/components/workbench/widgets/SystemMonitorWidget.js +122 -0
- package/dist/components/workbench/widgets/TerminalWidget.d.ts +1 -0
- package/dist/components/workbench/widgets/TerminalWidget.js +70 -0
- package/dist/components/workbench/widgets/widgetRegistry.d.ts +14 -0
- package/dist/components/workbench/widgets/widgetRegistry.js +71 -0
- package/dist/components/workbench/workbenchHelpers.d.ts +26 -0
- package/dist/components/workbench/workbenchHelpers.js +139 -0
- package/dist/deck.js +14 -12
- package/dist/display-mode.css +70 -0
- package/dist/full.js +475 -468
- package/dist/hooks/useDeckDrag.js +15 -15
- package/dist/layout.js +32 -27
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +2 -0
- package/dist/ui.css +4 -0
- package/dist/workbench.css +1220 -0
- package/dist/workbench.d.ts +1 -0
- package/dist/workbench.js +23 -0
- package/package.json +5 -1
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { Component } from 'solid-js';
|
|
2
|
+
export type BuiltinWorkbenchWidgetType = 'terminal' | 'file-browser' | 'system-monitor' | 'log-viewer' | 'code-editor';
|
|
3
|
+
export type WorkbenchWidgetType = BuiltinWorkbenchWidgetType | (string & {});
|
|
4
|
+
export declare const WORKBENCH_WIDGET_TYPES: readonly WorkbenchWidgetType[];
|
|
5
|
+
export interface WorkbenchWidgetBodyProps<TWidgetType extends string = WorkbenchWidgetType> {
|
|
6
|
+
widgetId: string;
|
|
7
|
+
title: string;
|
|
8
|
+
type: TWidgetType;
|
|
9
|
+
}
|
|
10
|
+
export interface WorkbenchWidgetDefinition<TWidgetType extends string = WorkbenchWidgetType> {
|
|
11
|
+
type: TWidgetType;
|
|
12
|
+
label: string;
|
|
13
|
+
icon: Component<{
|
|
14
|
+
class?: string;
|
|
15
|
+
}>;
|
|
16
|
+
body: Component<WorkbenchWidgetBodyProps<TWidgetType>>;
|
|
17
|
+
defaultTitle: string;
|
|
18
|
+
defaultSize: {
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
};
|
|
22
|
+
group?: string;
|
|
23
|
+
singleton?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface WorkbenchWidgetItem<TWidgetType extends string = WorkbenchWidgetType> {
|
|
26
|
+
id: string;
|
|
27
|
+
type: TWidgetType;
|
|
28
|
+
title: string;
|
|
29
|
+
x: number;
|
|
30
|
+
y: number;
|
|
31
|
+
width: number;
|
|
32
|
+
height: number;
|
|
33
|
+
z_index: number;
|
|
34
|
+
created_at_unix_ms: number;
|
|
35
|
+
}
|
|
36
|
+
export interface WorkbenchViewport {
|
|
37
|
+
x: number;
|
|
38
|
+
y: number;
|
|
39
|
+
scale: number;
|
|
40
|
+
}
|
|
41
|
+
export interface WorkbenchState<TWidgetType extends string = WorkbenchWidgetType> {
|
|
42
|
+
version: 1;
|
|
43
|
+
widgets: WorkbenchWidgetItem<TWidgetType>[];
|
|
44
|
+
viewport: WorkbenchViewport;
|
|
45
|
+
locked: boolean;
|
|
46
|
+
filters: Record<TWidgetType, boolean>;
|
|
47
|
+
selectedWidgetId: string | null;
|
|
48
|
+
}
|
|
49
|
+
export interface WorkbenchContextMenuState {
|
|
50
|
+
clientX: number;
|
|
51
|
+
clientY: number;
|
|
52
|
+
worldX: number;
|
|
53
|
+
worldY: number;
|
|
54
|
+
widgetId?: string | null;
|
|
55
|
+
}
|
|
56
|
+
export declare const DEFAULT_WORKBENCH_VIEWPORT: WorkbenchViewport;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { InfiniteCanvasContextMenuEvent } from '../../ui';
|
|
2
|
+
import { type WorkbenchWidgetDefinition, type WorkbenchContextMenuState, type WorkbenchState, type WorkbenchViewport, type WorkbenchWidgetItem, type WorkbenchWidgetType } from './types';
|
|
3
|
+
import type { WorkbenchContextMenuItem } from './WorkbenchContextMenu';
|
|
4
|
+
export interface UseWorkbenchModelOptions {
|
|
5
|
+
state: () => WorkbenchState;
|
|
6
|
+
setState: (updater: (prev: WorkbenchState) => WorkbenchState) => void;
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
widgetDefinitions?: readonly WorkbenchWidgetDefinition[] | (() => readonly WorkbenchWidgetDefinition[] | undefined);
|
|
9
|
+
}
|
|
10
|
+
export declare function useWorkbenchModel(options: UseWorkbenchModelOptions): {
|
|
11
|
+
widgets: import("solid-js").Accessor<WorkbenchWidgetItem<WorkbenchWidgetType>[]>;
|
|
12
|
+
viewport: import("solid-js").Accessor<WorkbenchViewport>;
|
|
13
|
+
locked: import("solid-js").Accessor<boolean>;
|
|
14
|
+
filters: import("solid-js").Accessor<Record<WorkbenchWidgetType, boolean>>;
|
|
15
|
+
selectedWidgetId: import("solid-js").Accessor<string | null>;
|
|
16
|
+
topZIndex: import("solid-js").Accessor<number>;
|
|
17
|
+
scaleLabel: import("solid-js").Accessor<string>;
|
|
18
|
+
optimisticFrontWidgetId: import("solid-js").Accessor<string | null>;
|
|
19
|
+
widgetDefinitions: import("solid-js").Accessor<readonly WorkbenchWidgetDefinition<WorkbenchWidgetType>[]>;
|
|
20
|
+
setCanvasFrameRef: (el: HTMLDivElement | undefined) => void;
|
|
21
|
+
contextMenu: {
|
|
22
|
+
state: import("solid-js").Accessor<WorkbenchContextMenuState | null>;
|
|
23
|
+
items: import("solid-js").Accessor<WorkbenchContextMenuItem[]>;
|
|
24
|
+
position: import("solid-js").Accessor<{
|
|
25
|
+
left: number;
|
|
26
|
+
top: number;
|
|
27
|
+
} | undefined>;
|
|
28
|
+
close: () => null;
|
|
29
|
+
retarget: (event: MouseEvent) => void;
|
|
30
|
+
};
|
|
31
|
+
canvas: {
|
|
32
|
+
openCanvasContextMenu: (event: InfiniteCanvasContextMenuEvent) => void;
|
|
33
|
+
openWidgetContextMenu: (event: MouseEvent, item: WorkbenchWidgetItem) => void;
|
|
34
|
+
selectWidget: (widgetId: string) => void;
|
|
35
|
+
startOptimisticFront: (widgetId: string) => void;
|
|
36
|
+
commitFront: (widgetId: string) => void;
|
|
37
|
+
commitMove: (widgetId: string, position: {
|
|
38
|
+
x: number;
|
|
39
|
+
y: number;
|
|
40
|
+
}) => void;
|
|
41
|
+
commitResize: (widgetId: string, size: {
|
|
42
|
+
width: number;
|
|
43
|
+
height: number;
|
|
44
|
+
}) => void;
|
|
45
|
+
commitViewport: (next: WorkbenchViewport) => void;
|
|
46
|
+
};
|
|
47
|
+
hud: {
|
|
48
|
+
zoomIn: () => void;
|
|
49
|
+
zoomOut: () => void;
|
|
50
|
+
};
|
|
51
|
+
lock: {
|
|
52
|
+
toggle: () => void;
|
|
53
|
+
};
|
|
54
|
+
filter: {
|
|
55
|
+
toggle: (type: WorkbenchWidgetType) => void;
|
|
56
|
+
solo: (type: WorkbenchWidgetType) => void;
|
|
57
|
+
showAll: () => void;
|
|
58
|
+
};
|
|
59
|
+
navigation: {
|
|
60
|
+
handleArrowNavigation: (direction: "up" | "down" | "left" | "right") => void;
|
|
61
|
+
centerOnWidget: (widget: WorkbenchWidgetItem) => void;
|
|
62
|
+
focusWidget: (widget: WorkbenchWidgetItem, options?: {
|
|
63
|
+
centerViewport?: boolean;
|
|
64
|
+
}) => WorkbenchWidgetItem<WorkbenchWidgetType>;
|
|
65
|
+
};
|
|
66
|
+
widgetActions: {
|
|
67
|
+
deleteSelected: () => void;
|
|
68
|
+
deleteWidget: (widgetId: string) => void;
|
|
69
|
+
addWidget: (type: WorkbenchWidgetType, worldX: number, worldY: number) => WorkbenchWidgetItem<WorkbenchWidgetType>;
|
|
70
|
+
addWidgetAtCursor: (type: WorkbenchWidgetType, worldX: number, worldY: number) => WorkbenchWidgetItem<WorkbenchWidgetType>;
|
|
71
|
+
addWidgetCentered: (type: WorkbenchWidgetType, worldX: number, worldY: number) => WorkbenchWidgetItem<WorkbenchWidgetType>;
|
|
72
|
+
ensureWidget: (type: WorkbenchWidgetType, ensureOptions?: {
|
|
73
|
+
centerViewport?: boolean;
|
|
74
|
+
worldX?: number;
|
|
75
|
+
worldY?: number;
|
|
76
|
+
}) => WorkbenchWidgetItem<WorkbenchWidgetType>;
|
|
77
|
+
};
|
|
78
|
+
queries: {
|
|
79
|
+
findWidgetByType: (type: WorkbenchWidgetType) => WorkbenchWidgetItem<WorkbenchWidgetType> | null;
|
|
80
|
+
findWidgetById: (widgetId: string) => WorkbenchWidgetItem<WorkbenchWidgetType> | null;
|
|
81
|
+
};
|
|
82
|
+
handleCloseRequest: () => void;
|
|
83
|
+
};
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { createSignal as _, createMemo as s } from "solid-js";
|
|
2
|
+
import { ArrowUp as gt, Copy as ut, Trash as ht } from "../icons/index.js";
|
|
3
|
+
import { getTopZIndex as ft, createContextMenuPosition as wt, createWorkbenchId as mt, findNearestWidget as Wt, clampScale as xt, WORKBENCH_CANVAS_ZOOM_STEP as R, WORKBENCH_CONTEXT_MENU_WIDTH_PX as St, estimateContextMenuHeight as pt } from "./workbenchHelpers.js";
|
|
4
|
+
import { resolveWorkbenchWidgetDefinitions as Ct, getWidgetEntry as q, createWorkbenchFilterState as kt } from "./widgets/widgetRegistry.js";
|
|
5
|
+
function At(c) {
|
|
6
|
+
const [f, w] = _(null), [B, A] = _(null), [S, P] = _({ width: 0, height: 0 }), l = c.state, u = s(() => l().widgets), a = s(() => l().viewport), v = s(() => l().locked), D = s(() => l().filters), p = s(() => l().selectedWidgetId), C = s(() => ft(u())), Z = s(() => `${Math.round(a().scale * 100)}%`), $ = () => typeof c.widgetDefinitions == "function" ? c.widgetDefinitions() : c.widgetDefinitions, h = s(
|
|
7
|
+
() => Ct($())
|
|
8
|
+
), j = (t) => {
|
|
9
|
+
t && P({ width: t.clientWidth, height: t.clientHeight });
|
|
10
|
+
}, K = (t) => {
|
|
11
|
+
w({
|
|
12
|
+
clientX: t.clientX,
|
|
13
|
+
clientY: t.clientY,
|
|
14
|
+
worldX: t.worldX,
|
|
15
|
+
worldY: t.worldY
|
|
16
|
+
});
|
|
17
|
+
}, L = (t, e) => {
|
|
18
|
+
m(e.id), w({
|
|
19
|
+
clientX: t.clientX,
|
|
20
|
+
clientY: t.clientY,
|
|
21
|
+
worldX: e.x,
|
|
22
|
+
worldY: e.y,
|
|
23
|
+
widgetId: e.id
|
|
24
|
+
});
|
|
25
|
+
}, g = () => w(null), U = (t) => l().widgets.find((e) => e.id === t) ?? null, k = (t) => l().widgets.find((e) => e.type === t) ?? null, T = s(() => {
|
|
26
|
+
const t = f();
|
|
27
|
+
if (!t) return [];
|
|
28
|
+
if (t.widgetId) {
|
|
29
|
+
const e = u().find((i) => i.id === t.widgetId), n = [];
|
|
30
|
+
return e && (n.push({
|
|
31
|
+
id: "bring-to-front",
|
|
32
|
+
kind: "action",
|
|
33
|
+
label: "Bring to Front",
|
|
34
|
+
icon: gt,
|
|
35
|
+
onSelect: () => {
|
|
36
|
+
m(e.id), g();
|
|
37
|
+
}
|
|
38
|
+
}), n.push({
|
|
39
|
+
id: "duplicate",
|
|
40
|
+
kind: "action",
|
|
41
|
+
label: "Duplicate",
|
|
42
|
+
icon: ut,
|
|
43
|
+
onSelect: () => {
|
|
44
|
+
z(e.type, e.x + 32, e.y + 32), g();
|
|
45
|
+
}
|
|
46
|
+
})), n.push({ id: "separator-delete", kind: "separator" }), n.push({
|
|
47
|
+
id: "delete",
|
|
48
|
+
kind: "action",
|
|
49
|
+
label: "Delete",
|
|
50
|
+
icon: ht,
|
|
51
|
+
destructive: !0,
|
|
52
|
+
onSelect: () => {
|
|
53
|
+
t.widgetId && Y(t.widgetId), g();
|
|
54
|
+
}
|
|
55
|
+
}), n;
|
|
56
|
+
}
|
|
57
|
+
return h().map((e) => ({
|
|
58
|
+
id: `add-${e.type}`,
|
|
59
|
+
kind: "action",
|
|
60
|
+
label: `Add ${e.label}`,
|
|
61
|
+
icon: e.icon,
|
|
62
|
+
onSelect: () => {
|
|
63
|
+
M(e.type, t.worldX, t.worldY), g();
|
|
64
|
+
}
|
|
65
|
+
}));
|
|
66
|
+
}), G = s(() => {
|
|
67
|
+
const t = f();
|
|
68
|
+
if (!t) return;
|
|
69
|
+
const e = T(), n = e.filter((o) => o.kind === "action").length, i = e.filter((o) => o.kind === "separator").length;
|
|
70
|
+
return wt({
|
|
71
|
+
clientX: t.clientX,
|
|
72
|
+
clientY: t.clientY,
|
|
73
|
+
menuWidth: St,
|
|
74
|
+
menuHeight: pt(n, i)
|
|
75
|
+
});
|
|
76
|
+
}), X = (t, e, n) => {
|
|
77
|
+
const i = q(t, h()), o = i.singleton ? k(t) : null;
|
|
78
|
+
if (o)
|
|
79
|
+
return W(o, { centerViewport: !0 });
|
|
80
|
+
const d = i.defaultSize, r = {
|
|
81
|
+
id: mt(),
|
|
82
|
+
type: t,
|
|
83
|
+
title: i.defaultTitle,
|
|
84
|
+
x: e,
|
|
85
|
+
y: n,
|
|
86
|
+
width: d.width,
|
|
87
|
+
height: d.height,
|
|
88
|
+
z_index: C() + 1,
|
|
89
|
+
created_at_unix_ms: Date.now()
|
|
90
|
+
};
|
|
91
|
+
return c.setState((x) => ({
|
|
92
|
+
...x,
|
|
93
|
+
widgets: [...x.widgets, r],
|
|
94
|
+
selectedWidgetId: r.id
|
|
95
|
+
})), r;
|
|
96
|
+
}, M = (t, e, n) => {
|
|
97
|
+
const i = q(t, h()).defaultSize;
|
|
98
|
+
return X(t, e - i.width / 2, n - i.height / 2);
|
|
99
|
+
}, z = (t, e, n) => X(t, e, n), Y = (t) => {
|
|
100
|
+
c.setState((e) => ({
|
|
101
|
+
...e,
|
|
102
|
+
widgets: e.widgets.filter((n) => n.id !== t),
|
|
103
|
+
selectedWidgetId: e.selectedWidgetId === t ? null : e.selectedWidgetId
|
|
104
|
+
}));
|
|
105
|
+
}, J = (t) => {
|
|
106
|
+
A(t);
|
|
107
|
+
}, m = (t) => {
|
|
108
|
+
A(t);
|
|
109
|
+
const e = C(), n = u().find((i) => i.id === t);
|
|
110
|
+
n && n.z_index < e && c.setState((i) => ({
|
|
111
|
+
...i,
|
|
112
|
+
widgets: i.widgets.map(
|
|
113
|
+
(o) => o.id === t ? { ...o, z_index: e + 1 } : o
|
|
114
|
+
)
|
|
115
|
+
}));
|
|
116
|
+
}, Q = (t, e) => {
|
|
117
|
+
c.setState((n) => ({
|
|
118
|
+
...n,
|
|
119
|
+
widgets: n.widgets.map(
|
|
120
|
+
(i) => i.id === t ? { ...i, x: e.x, y: e.y } : i
|
|
121
|
+
)
|
|
122
|
+
}));
|
|
123
|
+
}, tt = (t, e) => {
|
|
124
|
+
c.setState((n) => ({
|
|
125
|
+
...n,
|
|
126
|
+
widgets: n.widgets.map(
|
|
127
|
+
(i) => i.id === t ? { ...i, width: e.width, height: e.height } : i
|
|
128
|
+
)
|
|
129
|
+
}));
|
|
130
|
+
}, I = (t) => {
|
|
131
|
+
c.setState((e) => ({ ...e, viewport: t }));
|
|
132
|
+
}, O = (t) => {
|
|
133
|
+
const e = a(), n = S(), i = (n.width / 2 - e.x) / e.scale, o = (n.height / 2 - e.y) / e.scale, d = xt(
|
|
134
|
+
t === "in" ? e.scale * R : e.scale / R
|
|
135
|
+
), r = {
|
|
136
|
+
x: n.width / 2 - i * d,
|
|
137
|
+
y: n.height / 2 - o * d,
|
|
138
|
+
scale: d
|
|
139
|
+
};
|
|
140
|
+
I(r);
|
|
141
|
+
}, et = () => {
|
|
142
|
+
c.setState((t) => ({ ...t, locked: !t.locked }));
|
|
143
|
+
}, nt = (t) => {
|
|
144
|
+
c.setState((e) => ({
|
|
145
|
+
...e,
|
|
146
|
+
filters: { ...e.filters, [t]: !e.filters[t] }
|
|
147
|
+
}));
|
|
148
|
+
}, it = (t) => {
|
|
149
|
+
c.setState((e) => {
|
|
150
|
+
const n = { ...e.filters };
|
|
151
|
+
for (const i of Object.keys(n))
|
|
152
|
+
n[i] = i === t;
|
|
153
|
+
return { ...e, filters: n };
|
|
154
|
+
});
|
|
155
|
+
}, ot = () => {
|
|
156
|
+
const t = kt(h());
|
|
157
|
+
c.setState((e) => ({
|
|
158
|
+
...e,
|
|
159
|
+
filters: t
|
|
160
|
+
}));
|
|
161
|
+
}, V = (t) => {
|
|
162
|
+
c.setState((e) => ({ ...e, selectedWidgetId: t }));
|
|
163
|
+
}, ct = () => {
|
|
164
|
+
const t = S(), e = a();
|
|
165
|
+
return {
|
|
166
|
+
worldX: t.width > 0 ? (t.width / 2 - e.x) / e.scale : 240,
|
|
167
|
+
worldY: t.height > 0 ? (t.height / 2 - e.y) / e.scale : 180
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
let N = 0;
|
|
171
|
+
const st = (t, e, n) => {
|
|
172
|
+
const i = a(), o = i.x, d = i.y, r = i.scale, x = performance.now(), dt = 360, rt = ++N, lt = (F) => 1 - Math.pow(1 - F, 3), E = (F) => {
|
|
173
|
+
if (rt !== N) return;
|
|
174
|
+
const at = F - x, H = Math.min(Math.max(at / dt, 0), 1), b = lt(H);
|
|
175
|
+
I({
|
|
176
|
+
x: o + (t - o) * b,
|
|
177
|
+
y: d + (e - d) * b,
|
|
178
|
+
scale: r + (n - r) * b
|
|
179
|
+
}), H < 1 && requestAnimationFrame(E);
|
|
180
|
+
};
|
|
181
|
+
requestAnimationFrame(E);
|
|
182
|
+
}, y = (t) => {
|
|
183
|
+
const e = S();
|
|
184
|
+
if (e.width === 0 || e.height === 0) return;
|
|
185
|
+
const n = a(), i = e.width / 2 - (t.x + t.width / 2) * n.scale, o = e.height / 2 - (t.y + t.height / 2) * n.scale;
|
|
186
|
+
st(i, o, n.scale);
|
|
187
|
+
}, W = (t, e = {}) => (V(t.id), m(t.id), e.centerViewport !== !1 && y(t), t);
|
|
188
|
+
return {
|
|
189
|
+
widgets: u,
|
|
190
|
+
viewport: a,
|
|
191
|
+
locked: v,
|
|
192
|
+
filters: D,
|
|
193
|
+
selectedWidgetId: p,
|
|
194
|
+
topZIndex: C,
|
|
195
|
+
scaleLabel: Z,
|
|
196
|
+
optimisticFrontWidgetId: B,
|
|
197
|
+
widgetDefinitions: h,
|
|
198
|
+
setCanvasFrameRef: j,
|
|
199
|
+
contextMenu: {
|
|
200
|
+
state: f,
|
|
201
|
+
items: T,
|
|
202
|
+
position: G,
|
|
203
|
+
close: g,
|
|
204
|
+
retarget: (t) => {
|
|
205
|
+
t.preventDefault(), t.stopPropagation(), w({
|
|
206
|
+
clientX: t.clientX,
|
|
207
|
+
clientY: t.clientY,
|
|
208
|
+
worldX: 0,
|
|
209
|
+
worldY: 0
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
canvas: {
|
|
214
|
+
openCanvasContextMenu: K,
|
|
215
|
+
openWidgetContextMenu: L,
|
|
216
|
+
selectWidget: V,
|
|
217
|
+
startOptimisticFront: J,
|
|
218
|
+
commitFront: m,
|
|
219
|
+
commitMove: Q,
|
|
220
|
+
commitResize: tt,
|
|
221
|
+
commitViewport: I
|
|
222
|
+
},
|
|
223
|
+
hud: {
|
|
224
|
+
zoomIn: () => O("in"),
|
|
225
|
+
zoomOut: () => O("out")
|
|
226
|
+
},
|
|
227
|
+
lock: {
|
|
228
|
+
toggle: et
|
|
229
|
+
},
|
|
230
|
+
filter: {
|
|
231
|
+
toggle: nt,
|
|
232
|
+
solo: it,
|
|
233
|
+
showAll: ot
|
|
234
|
+
},
|
|
235
|
+
navigation: {
|
|
236
|
+
handleArrowNavigation: (t) => {
|
|
237
|
+
const e = Wt(
|
|
238
|
+
u(),
|
|
239
|
+
p(),
|
|
240
|
+
t,
|
|
241
|
+
D()
|
|
242
|
+
);
|
|
243
|
+
e && W(e);
|
|
244
|
+
},
|
|
245
|
+
centerOnWidget: y,
|
|
246
|
+
focusWidget: W
|
|
247
|
+
},
|
|
248
|
+
widgetActions: {
|
|
249
|
+
deleteSelected: () => {
|
|
250
|
+
const t = p();
|
|
251
|
+
t && Y(t);
|
|
252
|
+
},
|
|
253
|
+
deleteWidget: Y,
|
|
254
|
+
addWidget: X,
|
|
255
|
+
addWidgetAtCursor: M,
|
|
256
|
+
addWidgetCentered: z,
|
|
257
|
+
ensureWidget: (t, e) => {
|
|
258
|
+
const n = k(t);
|
|
259
|
+
if (n)
|
|
260
|
+
return W(n, { centerViewport: e?.centerViewport ?? !0 });
|
|
261
|
+
const i = ct(), o = M(
|
|
262
|
+
t,
|
|
263
|
+
e?.worldX ?? i.worldX,
|
|
264
|
+
e?.worldY ?? i.worldY
|
|
265
|
+
);
|
|
266
|
+
return (e?.centerViewport ?? !0) && o && y(o), o;
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
queries: {
|
|
270
|
+
findWidgetByType: k,
|
|
271
|
+
findWidgetById: U
|
|
272
|
+
},
|
|
273
|
+
handleCloseRequest: () => {
|
|
274
|
+
if (f()) {
|
|
275
|
+
g();
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
c.onClose();
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
export {
|
|
283
|
+
At as useWorkbenchModel
|
|
284
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function CodeEditorWidget(): import("solid-js").JSX.Element;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { insert as e, createComponent as d, effect as k, className as m, memo as w, template as o } from "solid-js/web";
|
|
2
|
+
import { For as l } from "solid-js";
|
|
3
|
+
var g = /* @__PURE__ */ o("<div class=workbench-widget-codeeditor><div class=workbench-widget-codeeditor__gutter></div><div class=workbench-widget-codeeditor__code>"), p = /* @__PURE__ */ o("<span>"), h = /* @__PURE__ */ o("<div class=workbench-widget-codeeditor__line>"), v = /* @__PURE__ */ o("<span class=workbench-widget-codeeditor__caret aria-hidden=true>");
|
|
4
|
+
const u = [{
|
|
5
|
+
tokens: [{
|
|
6
|
+
kind: "comment",
|
|
7
|
+
text: "// workbench counter demo"
|
|
8
|
+
}]
|
|
9
|
+
}, {
|
|
10
|
+
tokens: [{
|
|
11
|
+
kind: "keyword",
|
|
12
|
+
text: "import"
|
|
13
|
+
}, {
|
|
14
|
+
kind: "plain",
|
|
15
|
+
text: " { createSignal } "
|
|
16
|
+
}, {
|
|
17
|
+
kind: "keyword",
|
|
18
|
+
text: "from"
|
|
19
|
+
}, {
|
|
20
|
+
kind: "string",
|
|
21
|
+
text: " 'solid-js'"
|
|
22
|
+
}, {
|
|
23
|
+
kind: "plain",
|
|
24
|
+
text: ";"
|
|
25
|
+
}]
|
|
26
|
+
}, {
|
|
27
|
+
tokens: []
|
|
28
|
+
}, {
|
|
29
|
+
tokens: [{
|
|
30
|
+
kind: "keyword",
|
|
31
|
+
text: "export function "
|
|
32
|
+
}, {
|
|
33
|
+
kind: "fn",
|
|
34
|
+
text: "Counter"
|
|
35
|
+
}, {
|
|
36
|
+
kind: "plain",
|
|
37
|
+
text: "() {"
|
|
38
|
+
}]
|
|
39
|
+
}, {
|
|
40
|
+
tokens: [{
|
|
41
|
+
kind: "plain",
|
|
42
|
+
text: " "
|
|
43
|
+
}, {
|
|
44
|
+
kind: "keyword",
|
|
45
|
+
text: "const"
|
|
46
|
+
}, {
|
|
47
|
+
kind: "plain",
|
|
48
|
+
text: " [count, setCount] = "
|
|
49
|
+
}, {
|
|
50
|
+
kind: "fn",
|
|
51
|
+
text: "createSignal"
|
|
52
|
+
}, {
|
|
53
|
+
kind: "plain",
|
|
54
|
+
text: "("
|
|
55
|
+
}, {
|
|
56
|
+
kind: "number",
|
|
57
|
+
text: "0"
|
|
58
|
+
}, {
|
|
59
|
+
kind: "plain",
|
|
60
|
+
text: ");"
|
|
61
|
+
}]
|
|
62
|
+
}, {
|
|
63
|
+
tokens: []
|
|
64
|
+
}, {
|
|
65
|
+
tokens: [{
|
|
66
|
+
kind: "plain",
|
|
67
|
+
text: " "
|
|
68
|
+
}, {
|
|
69
|
+
kind: "keyword",
|
|
70
|
+
text: "return"
|
|
71
|
+
}, {
|
|
72
|
+
kind: "plain",
|
|
73
|
+
text: " ("
|
|
74
|
+
}]
|
|
75
|
+
}, {
|
|
76
|
+
tokens: [{
|
|
77
|
+
kind: "plain",
|
|
78
|
+
text: " <button "
|
|
79
|
+
}, {
|
|
80
|
+
kind: "attr",
|
|
81
|
+
text: "onClick"
|
|
82
|
+
}, {
|
|
83
|
+
kind: "plain",
|
|
84
|
+
text: "={() => setCount(c => c + "
|
|
85
|
+
}, {
|
|
86
|
+
kind: "number",
|
|
87
|
+
text: "1"
|
|
88
|
+
}, {
|
|
89
|
+
kind: "plain",
|
|
90
|
+
text: ")}>"
|
|
91
|
+
}]
|
|
92
|
+
}, {
|
|
93
|
+
tokens: [{
|
|
94
|
+
kind: "plain",
|
|
95
|
+
text: " Count: {count()}"
|
|
96
|
+
}]
|
|
97
|
+
}, {
|
|
98
|
+
tokens: [{
|
|
99
|
+
kind: "plain",
|
|
100
|
+
text: " </button>"
|
|
101
|
+
}]
|
|
102
|
+
}, {
|
|
103
|
+
tokens: [{
|
|
104
|
+
kind: "plain",
|
|
105
|
+
text: " );"
|
|
106
|
+
}]
|
|
107
|
+
}, {
|
|
108
|
+
tokens: [{
|
|
109
|
+
kind: "plain",
|
|
110
|
+
text: "}"
|
|
111
|
+
}]
|
|
112
|
+
}], a = 4;
|
|
113
|
+
function f() {
|
|
114
|
+
return (() => {
|
|
115
|
+
var c = g(), s = c.firstChild, _ = s.nextSibling;
|
|
116
|
+
return e(s, d(l, {
|
|
117
|
+
each: u,
|
|
118
|
+
children: (x, n) => (() => {
|
|
119
|
+
var t = p();
|
|
120
|
+
return e(t, () => n() + 1), k(() => t.classList.toggle("is-active", n() === a)), t;
|
|
121
|
+
})()
|
|
122
|
+
})), e(_, d(l, {
|
|
123
|
+
each: u,
|
|
124
|
+
children: (x, n) => (() => {
|
|
125
|
+
var t = h();
|
|
126
|
+
return e(t, d(l, {
|
|
127
|
+
get each() {
|
|
128
|
+
return x.tokens;
|
|
129
|
+
},
|
|
130
|
+
children: (i) => (() => {
|
|
131
|
+
var r = p();
|
|
132
|
+
return e(r, () => i.text), k(() => m(r, `workbench-widget-codeeditor__${i.kind}`)), r;
|
|
133
|
+
})()
|
|
134
|
+
}), null), e(t, (() => {
|
|
135
|
+
var i = w(() => n() === a);
|
|
136
|
+
return () => i() ? v() : null;
|
|
137
|
+
})(), null), k(() => t.classList.toggle("is-active", n() === a)), t;
|
|
138
|
+
})()
|
|
139
|
+
})), c;
|
|
140
|
+
})();
|
|
141
|
+
}
|
|
142
|
+
export {
|
|
143
|
+
f as CodeEditorWidget
|
|
144
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function FileBrowserWidget(): import("solid-js").JSX.Element;
|