@floegence/floe-webapp-core 0.36.32 → 0.36.34

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,25 +1,30 @@
1
1
  import { type JSX } from 'solid-js';
2
- import * as monaco from 'monaco-editor/esm/vs/editor/editor.api.js';
2
+ import type * as Monaco from 'monaco-editor/esm/vs/editor/editor.api.js';
3
3
  import 'monaco-editor/min/vs/editor/editor.main.css';
4
4
  import { type CodeEditorRuntimeOptions } from './monacoStandaloneRuntime';
5
+ type MonacoEditorOptions = Monaco.editor.IStandaloneEditorConstructionOptions;
6
+ type MonacoStandaloneCodeEditor = Monaco.editor.IStandaloneCodeEditor;
7
+ type MonacoTextModel = Monaco.editor.ITextModel;
8
+ type MonacoModelContentChangedEvent = Monaco.editor.IModelContentChangedEvent;
5
9
  export interface CodeEditorProps {
6
10
  path: string;
7
11
  language?: string;
8
12
  value: string;
9
- options?: monaco.editor.IStandaloneEditorConstructionOptions;
13
+ options?: MonacoEditorOptions;
10
14
  runtimeOptions?: CodeEditorRuntimeOptions;
11
15
  class?: string;
12
16
  style?: JSX.CSSProperties;
13
17
  onReady?: (api: CodeEditorApi) => void;
14
- onContentChange?: (e: monaco.editor.IModelContentChangedEvent, api: CodeEditorApi) => void;
18
+ onContentChange?: (e: MonacoModelContentChangedEvent, api: CodeEditorApi) => void;
15
19
  onSelectionChange?: (selectionText: string, api: CodeEditorApi) => void;
16
20
  onChange?: (value: string) => void;
17
21
  }
18
22
  export interface CodeEditorApi {
19
- editor: monaco.editor.IStandaloneCodeEditor;
20
- model: monaco.editor.ITextModel;
23
+ editor: MonacoStandaloneCodeEditor;
24
+ model: MonacoTextModel;
21
25
  getValue: () => string;
22
26
  getSelectedText: () => string;
23
27
  focus: () => void;
24
28
  }
25
29
  export declare function CodeEditor(props: CodeEditorProps): JSX.Element;
30
+ export {};
@@ -1,14 +1,13 @@
1
- import { use as L, effect as O, className as D, style as F, template as V } from "solid-js/web";
2
- import { onMount as b, onCleanup as q, createEffect as g } from "solid-js";
3
- import { useTheme as w } from "../../context/ThemeContext.js";
4
- import { useResizeObserver as A } from "../../hooks/useResizeObserver.js";
5
- import * as f from "monaco-editor/esm/vs/editor/editor.api.js";
1
+ import { use as L, effect as O, className as A, style as D, template as F } from "solid-js/web";
2
+ import { onMount as V, onCleanup as b, createEffect as g } from "solid-js";
3
+ import { useTheme as q } from "../../context/ThemeContext.js";
4
+ import { useResizeObserver as w } from "../../hooks/useResizeObserver.js";
6
5
  import "monaco-editor/min/vs/editor/editor.main.css";
7
6
  import { resolveCodeEditorLanguageSpec as U } from "./languages.js";
8
7
  import { ensureMonacoEnvironment as p } from "./monacoEnvironment.js";
9
- import { ensureMonacoStandaloneRuntime as N } from "./monacoStandaloneRuntime.js";
10
- var _ = /* @__PURE__ */ V("<div>");
11
- const E = {
8
+ import { loadMonacoEditorApi as N } from "./monacoStandaloneRuntime.js";
9
+ var _ = /* @__PURE__ */ F("<div>");
10
+ const T = {
12
11
  readOnly: !0,
13
12
  automaticLayout: !1,
14
13
  minimap: {
@@ -21,21 +20,21 @@ const E = {
21
20
  fontFamily: "var(--font-mono)"
22
21
  };
23
22
  let $ = 0;
24
- function k(t, c) {
25
- return f.Uri.parse(`inmemory://model/${t}/${encodeURIComponent(c)}`);
23
+ function k(t, d, a) {
24
+ return t.Uri.parse(`inmemory://model/${d}/${encodeURIComponent(a)}`);
26
25
  }
27
- function B(t, c) {
28
- if (!t || !c) return "";
29
- const r = t.getSelection();
30
- return !r || r.isEmpty() ? "" : c.getValueInRange(r);
26
+ function B(t, d) {
27
+ if (!t || !d) return "";
28
+ const a = t.getSelection();
29
+ return !a || a.isEmpty() ? "" : d.getValueInRange(a);
31
30
  }
32
31
  function X(t) {
33
- const c = w();
34
- let r;
35
- const R = ++$;
36
- let n, o, d, S = null, v = 0;
37
- const x = A(() => r), y = () => {
38
- f.editor.setTheme(c.resolvedTheme() === "dark" ? "vs-dark" : "vs");
32
+ const d = q();
33
+ let a;
34
+ const x = ++$;
35
+ let l, n, o, s, y = null, v = 0;
36
+ const R = w(() => a), S = () => {
37
+ l && l.editor.setTheme(d.resolvedTheme() === "dark" ? "vs-dark" : "vs");
39
38
  }, m = () => !n || !o ? null : {
40
39
  editor: n,
41
40
  model: o,
@@ -45,73 +44,73 @@ function X(t) {
45
44
  }, C = () => {
46
45
  const e = m();
47
46
  if (!e) return;
48
- const a = e.model.uri.toString();
49
- a !== S && (S = a, t.onReady?.(e));
47
+ const r = e.model.uri.toString();
48
+ r !== y && (y = r, t.onReady?.(e));
50
49
  }, M = () => {
51
50
  const e = m();
52
51
  e && t.onSelectionChange?.(e.getSelectedText(), e);
53
- }, I = async () => {
54
- if (!n) return;
55
- const e = ++v, a = U(t.language);
56
- let i = a.id;
52
+ }, E = async () => {
53
+ if (!n || !l) return;
54
+ const e = ++v, r = U(t.language);
55
+ let i = r.id;
57
56
  try {
58
- await a.load?.();
57
+ await r.load?.();
59
58
  } catch {
60
59
  if (e !== v) return;
61
60
  i = "plaintext";
62
61
  }
63
62
  if (!n || e !== v) return;
64
- const u = k(R, t.path);
63
+ const u = k(l, x, t.path);
65
64
  if (o && o.uri.toString() === u.toString()) {
66
- o.getLanguageId() !== i && f.editor.setModelLanguage(o, i), o.getValue() !== t.value && o.setValue(t.value), C(), M();
65
+ o.getLanguageId() !== i && l.editor.setModelLanguage(o, i), o.getValue() !== t.value && o.setValue(t.value), C(), M();
67
66
  return;
68
67
  }
69
- const l = f.editor.createModel(t.value, i, u);
70
- o?.dispose(), o = l, n.setModel(o), C(), M();
68
+ const c = l.editor.createModel(t.value, i, u);
69
+ o?.dispose(), o = c, n.setModel(o), C(), M();
71
70
  };
72
- return b(() => {
73
- let e = !1, a, i;
71
+ return V(() => {
72
+ let e = !1, r, i;
74
73
  (async () => {
75
- if (!r || (p(), await N(t.runtimeOptions), e || !r) || (n = f.editor.create(r, {
74
+ if (!a || (p(), l = await N(t.runtimeOptions), e || !a) || (n = l.editor.create(a, {
76
75
  model: null,
77
- ...E,
76
+ ...T,
78
77
  ...t.options ?? {}
79
- }), y(), await I(), e || !n)) return;
80
- const l = t.onContentChange, T = t.onChange, z = t.onSelectionChange;
81
- a = n.onDidChangeModelContent((s) => {
78
+ }), S(), await E(), e || !n)) return;
79
+ const c = t.onContentChange, I = t.onChange, z = t.onSelectionChange;
80
+ r = n.onDidChangeModelContent((f) => {
82
81
  const h = m();
83
- h && (l?.(s, h), T && T(h.getValue()));
82
+ h && (c?.(f, h), I && I(h.getValue()));
84
83
  }), i = n.onDidChangeCursorSelection(() => {
85
- const s = m();
86
- s && z?.(s.getSelectedText(), s);
84
+ const f = m();
85
+ f && z?.(f.getSelectedText(), f);
87
86
  });
88
- })().catch((l) => {
89
- console.error("Failed to initialize Monaco editor runtime", l);
90
- }), q(() => {
91
- e = !0, a?.dispose(), i?.dispose(), d && cancelAnimationFrame(d), n?.dispose(), o?.dispose(), n = void 0, o = void 0;
87
+ })().catch((c) => {
88
+ console.error("Failed to initialize Monaco editor runtime", c);
89
+ }), b(() => {
90
+ e = !0, r?.dispose(), i?.dispose(), s && cancelAnimationFrame(s), n?.dispose(), o?.dispose(), l = void 0, n = void 0, o = void 0;
92
91
  });
93
92
  }), g(() => {
94
- y();
93
+ S();
95
94
  }), g(() => {
96
95
  n && n.updateOptions({
97
- ...E,
96
+ ...T,
98
97
  ...t.options ?? {}
99
98
  });
100
99
  }), g(() => {
101
- t.path, t.language, t.value, I();
100
+ t.path, t.language, t.value, E();
102
101
  }), g(() => {
103
- const e = x();
104
- !e || !n || (d && cancelAnimationFrame(d), d = requestAnimationFrame(() => {
102
+ const e = R();
103
+ !e || !n || (s && cancelAnimationFrame(s), s = requestAnimationFrame(() => {
105
104
  n?.layout({
106
105
  width: e.width,
107
106
  height: e.height
108
107
  });
109
108
  }));
110
109
  }), (() => {
111
- var e = _(), a = r;
112
- return typeof a == "function" ? L(a, e) : r = e, O((i) => {
113
- var u = t.class, l = t.style;
114
- return u !== i.e && D(e, i.e = u), i.t = F(e, l, i.t), i;
110
+ var e = _(), r = a;
111
+ return typeof r == "function" ? L(r, e) : a = e, O((i) => {
112
+ var u = t.class, c = t.style;
113
+ return u !== i.e && A(e, i.e = u), i.t = D(e, c, i.t), i;
115
114
  }, {
116
115
  e: void 0,
117
116
  t: void 0
@@ -1,3 +1,4 @@
1
+ type MonacoEditorApi = typeof import('monaco-editor/esm/vs/editor/editor.api.js');
1
2
  export interface MonacoRuntimeFeatureSet {
2
3
  suggestMemory: boolean;
3
4
  codeLensCache: boolean;
@@ -25,11 +26,12 @@ export interface ResolvedMonacoRuntimeRequest {
25
26
  cacheKey: string;
26
27
  blueprint: MonacoStandaloneRuntimeBlueprint;
27
28
  }
28
- type MonacoStandaloneRuntimeLoader = (request: ResolvedMonacoRuntimeRequest) => Promise<unknown>;
29
+ type MonacoStandaloneRuntimeLoader = (request: ResolvedMonacoRuntimeRequest) => Promise<void>;
29
30
  export declare function normalizeMonacoRuntimeFeatureSet(standaloneFeatures?: Partial<MonacoRuntimeFeatureSet>): MonacoRuntimeFeatureSet;
30
31
  export declare const MONACO_RUNTIME_BLUEPRINTS: Record<MonacoRuntimeProfileName, MonacoStandaloneRuntimeBlueprint>;
31
32
  export declare function resolveMonacoRuntimeProfile(options?: CodeEditorRuntimeOptions): MonacoRuntimeProfileName;
32
33
  export declare function resolveMonacoRuntimeRequest(options?: CodeEditorRuntimeOptions): ResolvedMonacoRuntimeRequest;
33
34
  export declare function createMonacoStandaloneRuntime(loader: MonacoStandaloneRuntimeLoader): (options?: CodeEditorRuntimeOptions) => Promise<void>;
34
35
  export declare const ensureMonacoStandaloneRuntime: (options?: CodeEditorRuntimeOptions) => Promise<void>;
36
+ export declare function loadMonacoEditorApi(options?: CodeEditorRuntimeOptions): Promise<MonacoEditorApi>;
35
37
  export {};
@@ -1,32 +1,52 @@
1
- const l = {
1
+ const s = {
2
2
  suggestMemory: !0,
3
3
  codeLensCache: !0,
4
4
  inlayHintsCache: !0,
5
5
  treeViewsDnd: !0,
6
6
  actionWidget: !0
7
7
  }, a = "editor_full";
8
- function u(e) {
8
+ function d(e) {
9
9
  return {
10
- ...l,
10
+ ...s,
11
11
  ...e ?? {}
12
12
  };
13
13
  }
14
- const s = [
14
+ const c = [
15
15
  {
16
- id: "editor.main",
17
- load: () => import("monaco-editor/esm/vs/editor/editor.main.js")
16
+ id: "edcore.main",
17
+ load: () => import("monaco-editor/esm/vs/editor/edcore.main.js")
18
+ },
19
+ {
20
+ id: "suggestMemory",
21
+ load: () => import("monaco-editor/esm/vs/editor/contrib/suggest/browser/suggestMemory.js")
22
+ },
23
+ {
24
+ id: "codeLensCache",
25
+ load: () => import("monaco-editor/esm/vs/editor/contrib/codelens/browser/codeLensCache.js")
26
+ },
27
+ {
28
+ id: "inlayHintsContribution",
29
+ load: () => import("monaco-editor/esm/vs/editor/contrib/inlayHints/browser/inlayHintsContribution.js")
30
+ },
31
+ {
32
+ id: "treeViewsDndService",
33
+ load: () => import("monaco-editor/esm/vs/editor/common/services/treeViewsDndService.js")
34
+ },
35
+ {
36
+ id: "actionWidget",
37
+ load: () => import("monaco-editor/esm/vs/platform/actionWidget/browser/actionWidget.js")
18
38
  }
19
- ], d = {
39
+ ], f = c, m = c, p = {
20
40
  editor_full: {
21
41
  profile: "editor_full",
22
- modules: s
42
+ modules: f
23
43
  },
24
44
  preview_basic: {
25
45
  profile: "preview_basic",
26
- modules: []
46
+ modules: m
27
47
  }
28
48
  };
29
- function f(e) {
49
+ function M(e) {
30
50
  return e.suggestMemory === !1 && e.codeLensCache === !1 && e.inlayHintsCache === !1 && e.treeViewsDnd === !1 && e.actionWidget === !1;
31
51
  }
32
52
  function _(e) {
@@ -34,42 +54,50 @@ function _(e) {
34
54
  return e.profile;
35
55
  if (!e?.standaloneFeatures)
36
56
  return a;
37
- const n = u(e.standaloneFeatures);
38
- return f(n) ? "preview_basic" : a;
57
+ const n = d(e.standaloneFeatures);
58
+ return M(n) ? "preview_basic" : a;
39
59
  }
40
- function m(e) {
60
+ function E(e) {
41
61
  const n = _(e);
42
62
  return {
43
63
  profile: n,
44
64
  cacheKey: `profile:${n}`,
45
- blueprint: d[n]
65
+ blueprint: p[n]
46
66
  };
47
67
  }
48
- function M(e) {
68
+ function O(e) {
49
69
  const n = /* @__PURE__ */ new Map();
50
- return (i) => {
51
- const t = m(i), o = n.get(t.cacheKey);
52
- if (o) return o;
53
- const r = e(t).then(() => {
54
- }).catch((c) => {
55
- throw n.delete(t.cacheKey), c;
70
+ return (l) => {
71
+ const o = E(l), i = n.get(o.cacheKey);
72
+ if (i) return i;
73
+ const r = e(o).then(() => {
74
+ }).catch((u) => {
75
+ throw n.delete(o.cacheKey), u;
56
76
  });
57
- return n.set(t.cacheKey, r), r;
77
+ return n.set(o.cacheKey, r), r;
58
78
  };
59
79
  }
60
- function p(e) {
61
- return Promise.all(e.blueprint.modules.map((n) => n.load()));
80
+ function A(e) {
81
+ return Promise.all(e.blueprint.modules.map((n) => n.load())).then(() => {
82
+ });
62
83
  }
63
- const R = M(
64
- p
84
+ const h = O(
85
+ A
65
86
  );
87
+ let t = null;
88
+ async function L(e) {
89
+ return await h(e), t || (t = import("monaco-editor/esm/vs/editor/editor.api.js").catch((n) => {
90
+ throw t = null, n;
91
+ }), t);
92
+ }
66
93
  export {
67
94
  a as DEFAULT_MONACO_RUNTIME_PROFILE,
68
- l as DEFAULT_MONACO_STANDALONE_FEATURES,
69
- d as MONACO_RUNTIME_BLUEPRINTS,
70
- M as createMonacoStandaloneRuntime,
71
- R as ensureMonacoStandaloneRuntime,
72
- u as normalizeMonacoRuntimeFeatureSet,
95
+ s as DEFAULT_MONACO_STANDALONE_FEATURES,
96
+ p as MONACO_RUNTIME_BLUEPRINTS,
97
+ O as createMonacoStandaloneRuntime,
98
+ h as ensureMonacoStandaloneRuntime,
99
+ L as loadMonacoEditorApi,
100
+ d as normalizeMonacoRuntimeFeatureSet,
73
101
  _ as resolveMonacoRuntimeProfile,
74
- m as resolveMonacoRuntimeRequest
102
+ E as resolveMonacoRuntimeRequest
75
103
  };
@@ -1,4 +1,12 @@
1
- import type { WorkbenchState, WorkbenchInteractionAdapter, WorkbenchWidgetDefinition, WorkbenchWidgetItem, WorkbenchWidgetType } from './types';
1
+ import { type WorkbenchContextMenuItem } from './WorkbenchContextMenu';
2
+ import type { WorkbenchState, WorkbenchContextMenuState, WorkbenchInteractionAdapter, WorkbenchWidgetDefinition, WorkbenchWidgetItem, WorkbenchWidgetType } from './types';
3
+ export type WorkbenchContextMenuItemsResolver = (context: Readonly<{
4
+ menu: WorkbenchContextMenuState;
5
+ items: readonly WorkbenchContextMenuItem[];
6
+ widgets: readonly WorkbenchWidgetItem[];
7
+ widget: WorkbenchWidgetItem | null;
8
+ closeMenu: () => void;
9
+ }>) => readonly WorkbenchContextMenuItem[];
2
10
  export interface WorkbenchSurfaceApi {
3
11
  ensureWidget: (type: WorkbenchWidgetType, options?: {
4
12
  centerViewport?: boolean;
@@ -41,6 +49,7 @@ export interface WorkbenchSurfaceProps {
41
49
  widgetDefinitions?: readonly WorkbenchWidgetDefinition[];
42
50
  launcherWidgetTypes?: readonly WorkbenchWidgetType[];
43
51
  interactionAdapter?: WorkbenchInteractionAdapter;
52
+ resolveContextMenuItems?: WorkbenchContextMenuItemsResolver;
44
53
  onApiReady?: (api: WorkbenchSurfaceApi | null) => void;
45
54
  onRequestDelete?: (widgetId: string) => void;
46
55
  onLayoutInteractionStart?: () => void;
@@ -1,17 +1,18 @@
1
- import { use as T, spread as _, mergeProps as B, insert as f, createComponent as u, Portal as q, addEventListener as z, template as A, delegateEvents as $ } from "solid-js/web";
2
- import { createSignal as S, createMemo as w, untrack as h, createEffect as m, onCleanup as v, Show as V } from "solid-js";
3
- import { clientToCanvasWorld as N } from "../ui/canvasGeometry.js";
4
- import { WorkbenchCanvas as P } from "./WorkbenchCanvas.js";
5
- import { WorkbenchContextMenu as H } from "./WorkbenchContextMenu.js";
6
- import { WorkbenchFilterBar as X } from "./WorkbenchFilterBar.js";
7
- import { WorkbenchHud as Y } from "./WorkbenchHud.js";
8
- import { WorkbenchLockButton as K } from "./WorkbenchLockButton.js";
9
- import { installWorkbenchContextMenuDismissListeners as U } from "./workbenchContextMenuDismiss.js";
10
- import { useWorkbenchModel as Z } from "./useWorkbenchModel.js";
11
- import { resolveWorkbenchInteractionAdapter as G } from "./workbenchInteractionAdapter.js";
12
- var j = /* @__PURE__ */ A("<div class=workbench-menu-backdrop data-floe-workbench-boundary=true>"), J = /* @__PURE__ */ A("<div><div class=workbench-surface__body data-floe-workbench-canvas-frame=true>");
13
- const Q = "F1";
14
- function I(i) {
1
+ import { use as _, spread as B, mergeProps as q, insert as m, createComponent as u, Portal as N, addEventListener as z, template as A, delegateEvents as H } from "solid-js/web";
2
+ import { createSignal as M, createMemo as w, untrack as W, createEffect as v, onCleanup as h, Show as P } from "solid-js";
3
+ import { clientToCanvasWorld as X } from "../ui/canvasGeometry.js";
4
+ import { WorkbenchCanvas as $ } from "./WorkbenchCanvas.js";
5
+ import { WorkbenchContextMenu as V } from "./WorkbenchContextMenu.js";
6
+ import { WorkbenchFilterBar as Y } from "./WorkbenchFilterBar.js";
7
+ import { WorkbenchHud as K } from "./WorkbenchHud.js";
8
+ import { WorkbenchLockButton as U } from "./WorkbenchLockButton.js";
9
+ import { installWorkbenchContextMenuDismissListeners as Z } from "./workbenchContextMenuDismiss.js";
10
+ import { createContextMenuPosition as G, WORKBENCH_CONTEXT_MENU_WIDTH_PX as j, estimateContextMenuHeight as J } from "./workbenchHelpers.js";
11
+ import { useWorkbenchModel as Q } from "./useWorkbenchModel.js";
12
+ import { resolveWorkbenchInteractionAdapter as ee } from "./workbenchInteractionAdapter.js";
13
+ var te = /* @__PURE__ */ A("<div class=workbench-menu-backdrop data-floe-workbench-boundary=true>"), ne = /* @__PURE__ */ A("<div><div class=workbench-surface__body data-floe-workbench-canvas-frame=true>");
14
+ const re = "F1";
15
+ function x(i) {
15
16
  if (i)
16
17
  try {
17
18
  i.focus({
@@ -21,186 +22,205 @@ function I(i) {
21
22
  i.focus();
22
23
  }
23
24
  }
24
- function ge(i) {
25
- const t = Z({
25
+ function he(i) {
26
+ const t = Q({
26
27
  state: () => i.state(),
27
28
  setState: (e) => i.setState(e),
28
29
  widgetDefinitions: () => i.widgetDefinitions,
29
30
  onClose: () => {
30
31
  }
31
- }), [s, x] = S(null), a = w(() => G(i.interactionAdapter)), [p, l] = S(h(() => a().createInitialInputOwner())), W = w(() => {
32
+ }), [d, E] = M(null), s = w(() => ee(i.interactionAdapter)), [p, l] = M(W(() => s().createInitialInputOwner())), k = w(() => {
32
33
  const e = i.launcherWidgetTypes;
33
34
  return !e || e.length <= 0 ? null : new Set(e);
34
35
  }), D = w(() => {
35
- const e = t.widgetDefinitions(), r = W();
36
- return r ? e.filter((n) => r.has(n.type)) : e;
37
- }), E = w(() => {
38
- const e = t.contextMenu.items(), r = W();
39
- return r ? e.filter((n) => {
40
- if (n.kind !== "action")
36
+ const e = t.widgetDefinitions(), n = k();
37
+ return n ? e.filter((r) => n.has(r.type)) : e;
38
+ }), C = w(() => {
39
+ const e = t.contextMenu.state(), n = t.contextMenu.items(), r = k(), o = r ? n.filter((c) => {
40
+ if (c.kind !== "action")
41
41
  return !0;
42
- const o = /^add-(.+)$/.exec(String(n.id ?? ""));
43
- return o ? r.has(o[1]) : !0;
44
- }) : e;
45
- }), k = (e, r, n) => {
46
- const o = a(), c = o.findWidgetRoot(e), d = o.readWidgetId(c);
47
- if (d) {
48
- l(o.createWidgetInputOwner(d, r));
42
+ const f = /^add-(.+)$/.exec(String(c.id ?? ""));
43
+ return f ? r.has(f[1]) : !0;
44
+ }) : n;
45
+ if (!e || !i.resolveContextMenuItems)
46
+ return o;
47
+ const a = e.widgetId ? t.queries.findWidgetById(e.widgetId) : null;
48
+ return i.resolveContextMenuItems({
49
+ menu: e,
50
+ items: o,
51
+ widgets: t.widgets(),
52
+ widget: a,
53
+ closeMenu: t.contextMenu.close
54
+ });
55
+ }), b = w(() => {
56
+ const e = t.contextMenu.state();
57
+ if (!e) return;
58
+ const n = C(), r = n.filter((a) => a.kind === "action").length, o = n.filter((a) => a.kind === "separator").length;
59
+ return G({
60
+ clientX: e.clientX,
61
+ clientY: e.clientY,
62
+ menuWidth: j,
63
+ menuHeight: J(r, o)
64
+ });
65
+ }), I = (e, n, r) => {
66
+ const o = s(), a = o.findWidgetRoot(e), c = o.readWidgetId(a);
67
+ if (c) {
68
+ l(o.createWidgetInputOwner(c, n));
49
69
  return;
50
70
  }
51
- const y = s();
52
- y && e instanceof Node && y.contains(e) && l(o.createCanvasInputOwner(n));
53
- }, b = (e = "selection_cleared") => {
54
- const r = a(), n = s();
55
- t.selection.clear(), l(r.createCanvasInputOwner(e)), queueMicrotask(() => {
56
- if (!n || typeof document > "u") return;
71
+ const f = d();
72
+ f && e instanceof Node && f.contains(e) && l(o.createCanvasInputOwner(r));
73
+ }, y = (e = "selection_cleared") => {
74
+ const n = s(), r = d();
75
+ t.selection.clear(), l(n.createCanvasInputOwner(e)), queueMicrotask(() => {
76
+ if (!r || typeof document > "u") return;
57
77
  const o = document.activeElement;
58
- if (!(o instanceof HTMLElement) || !n.contains(o)) {
59
- I(n);
78
+ if (!(o instanceof HTMLElement) || !r.contains(o)) {
79
+ x(r);
60
80
  return;
61
81
  }
62
- const c = r.findWidgetRoot(o);
63
- I(n), c && document.activeElement === o && o.isConnected && o.blur();
82
+ const a = n.findWidgetRoot(o);
83
+ x(r), a && document.activeElement === o && o.isConnected && o.blur();
64
84
  });
65
85
  }, R = () => {
66
- const e = s()?.querySelector('[data-floe-workbench-canvas-frame="true"]'), r = t.viewport(), n = e?.getBoundingClientRect(), o = n?.width ?? 0, c = n?.height ?? 0;
86
+ const e = d()?.querySelector('[data-floe-workbench-canvas-frame="true"]'), n = t.viewport(), r = e?.getBoundingClientRect(), o = r?.width ?? 0, a = r?.height ?? 0;
67
87
  return {
68
- worldX: o > 0 ? (o / 2 - r.x) / r.scale : 240,
69
- worldY: c > 0 ? (c / 2 - r.y) / r.scale : 180
88
+ worldX: o > 0 ? (o / 2 - n.x) / n.scale : 240,
89
+ worldY: a > 0 ? (a / 2 - n.y) / n.scale : 180
70
90
  };
71
91
  }, g = (e) => {
72
- const r = h(a), n = h(s);
92
+ const n = W(s), r = W(d);
73
93
  queueMicrotask(() => {
74
- r.focusWidgetElement(n, e), l(r.createWidgetInputOwner(e, "activation"));
94
+ n.focusWidgetElement(r, e), l(n.createWidgetInputOwner(e, "activation"));
75
95
  });
76
- }, M = (e) => {
77
- const r = t.navigation.fitWidget(e);
78
- g(r.id);
79
- }, L = (e) => {
80
- const r = t.navigation.overviewWidget(e);
81
- g(r.id);
96
+ }, O = (e) => {
97
+ const n = t.navigation.fitWidget(e);
98
+ g(n.id);
99
+ }, T = (e) => {
100
+ const n = t.navigation.overviewWidget(e);
101
+ g(n.id);
82
102
  };
83
- m(() => {
103
+ v(() => {
84
104
  i.onApiReady?.({
85
- ensureWidget: (e, r) => t.widgetActions.ensureWidget(e, r) ?? null,
86
- createWidget: (e, r) => {
87
- const n = R(), o = t.widgetActions.addWidgetAtCursor(e, r?.worldX ?? n.worldX, r?.worldY ?? n.worldY) ?? null;
88
- return o && r?.centerViewport !== !1 && t.navigation.centerOnWidget(o), o;
89
- },
90
- clearSelection: () => b("selection_cleared"),
91
- focusWidget: (e, r) => {
92
- const n = t.navigation.focusWidget(e, r);
93
- return g(n.id), n;
105
+ ensureWidget: (e, n) => t.widgetActions.ensureWidget(e, n) ?? null,
106
+ createWidget: (e, n) => {
107
+ const r = R(), o = t.widgetActions.addWidgetAtCursor(e, n?.worldX ?? r.worldX, n?.worldY ?? r.worldY) ?? null;
108
+ return o && n?.centerViewport !== !1 && t.navigation.centerOnWidget(o), o;
109
+ },
110
+ clearSelection: () => y("selection_cleared"),
111
+ focusWidget: (e, n) => {
112
+ const r = t.navigation.focusWidget(e, n);
113
+ return g(r.id), r;
94
114
  },
95
115
  fitWidget: (e) => {
96
- const r = t.navigation.fitWidget(e);
97
- return g(r.id), r;
116
+ const n = t.navigation.fitWidget(e);
117
+ return g(n.id), n;
98
118
  },
99
119
  overviewWidget: (e) => {
100
- const r = t.navigation.overviewWidget(e);
101
- return g(r.id), r;
120
+ const n = t.navigation.overviewWidget(e);
121
+ return g(n.id), n;
102
122
  },
103
123
  findWidgetByType: (e) => t.queries.findWidgetByType(e),
104
124
  findWidgetById: (e) => t.queries.findWidgetById(e),
105
- updateWidgetTitle: (e, r) => {
106
- const n = String(e ?? "").trim(), o = String(r ?? "").trim();
107
- !n || !o || i.setState((c) => ({
108
- ...c,
109
- widgets: c.widgets.map((d) => d.id === n && d.title !== o ? {
110
- ...d,
125
+ updateWidgetTitle: (e, n) => {
126
+ const r = String(e ?? "").trim(), o = String(n ?? "").trim();
127
+ !r || !o || i.setState((a) => ({
128
+ ...a,
129
+ widgets: a.widgets.map((c) => c.id === r && c.title !== o ? {
130
+ ...c,
111
131
  title: o
112
- } : d)
132
+ } : c)
113
133
  }));
114
134
  }
115
- }), v(() => {
135
+ }), h(() => {
116
136
  i.onApiReady?.(null);
117
137
  });
118
138
  });
119
- const C = () => i.lockShortcut === void 0 ? Q : i.lockShortcut;
120
- m(() => {
139
+ const S = () => i.lockShortcut === void 0 ? re : i.lockShortcut;
140
+ v(() => {
121
141
  if (typeof window > "u" || !t.contextMenu.state()) return;
122
- const e = U({
142
+ const e = Z({
123
143
  ownerWindow: window,
124
144
  onDismiss: t.contextMenu.close
125
145
  });
126
- v(() => e());
127
- }), m(() => {
146
+ h(() => e());
147
+ }), v(() => {
128
148
  const e = p();
129
149
  if (e.kind !== "widget") return;
130
- t.widgets().some((n) => n.id === e.widgetId) || l(a().createCanvasInputOwner("widget_removed"));
131
- }), m(() => {
132
- const e = s();
150
+ t.widgets().some((r) => r.id === e.widgetId) || l(s().createCanvasInputOwner("widget_removed"));
151
+ }), v(() => {
152
+ const e = d();
133
153
  if (!e) return;
134
- const r = (o) => {
135
- k(o.target, "pointer", "background_pointer");
136
- }, n = (o) => {
137
- k(o.target, "focus", "background_focus");
154
+ const n = (o) => {
155
+ I(o.target, "pointer", "background_pointer");
156
+ }, r = (o) => {
157
+ I(o.target, "focus", "background_focus");
138
158
  };
139
- e.addEventListener("pointerdown", r, !0), e.addEventListener("focusin", n), v(() => {
140
- e.removeEventListener("pointerdown", r, !0), e.removeEventListener("focusin", n);
159
+ e.addEventListener("pointerdown", n, !0), e.addEventListener("focusin", r), h(() => {
160
+ e.removeEventListener("pointerdown", n, !0), e.removeEventListener("focusin", r);
141
161
  });
142
- }), m(() => {
162
+ }), v(() => {
143
163
  if (i.enableKeyboard === !1 || typeof document > "u") return;
144
- const e = C(), r = (n) => {
145
- if (!(n.defaultPrevented || n.isComposing)) {
146
- if (e !== null && n.key === e) {
147
- n.preventDefault(), t.lock.toggle();
164
+ const e = S(), n = (r) => {
165
+ if (!(r.defaultPrevented || r.isComposing)) {
166
+ if (e !== null && r.key === e) {
167
+ r.preventDefault(), t.lock.toggle();
148
168
  return;
149
169
  }
150
- if (!a().shouldBypassGlobalHotkeys({
151
- root: s(),
152
- target: n.target,
170
+ if (!s().shouldBypassGlobalHotkeys({
171
+ root: d(),
172
+ target: r.target,
153
173
  owner: p(),
154
- interactiveSelector: a().interactiveSelector
174
+ interactiveSelector: s().interactiveSelector
155
175
  }))
156
- switch (n.key) {
176
+ switch (r.key) {
157
177
  case "ArrowUp":
158
- n.preventDefault(), t.navigation.handleArrowNavigation("up");
178
+ r.preventDefault(), t.navigation.handleArrowNavigation("up");
159
179
  break;
160
180
  case "ArrowDown":
161
- n.preventDefault(), t.navigation.handleArrowNavigation("down");
181
+ r.preventDefault(), t.navigation.handleArrowNavigation("down");
162
182
  break;
163
183
  case "ArrowLeft":
164
- n.preventDefault(), t.navigation.handleArrowNavigation("left");
184
+ r.preventDefault(), t.navigation.handleArrowNavigation("left");
165
185
  break;
166
186
  case "ArrowRight":
167
- n.preventDefault(), t.navigation.handleArrowNavigation("right");
187
+ r.preventDefault(), t.navigation.handleArrowNavigation("right");
168
188
  break;
169
189
  case "Delete":
170
190
  case "Backspace":
171
- t.selectedWidgetId() && (n.preventDefault(), t.widgetActions.deleteSelected());
191
+ t.selectedWidgetId() && (r.preventDefault(), t.widgetActions.deleteSelected());
172
192
  break;
173
193
  }
174
194
  }
175
195
  };
176
- document.addEventListener("keydown", r, !0), v(() => document.removeEventListener("keydown", r, !0));
196
+ document.addEventListener("keydown", n, !0), h(() => document.removeEventListener("keydown", n, !0));
177
197
  });
178
- const F = (e, r) => {
179
- const n = s()?.querySelector('[data-floe-workbench-canvas-frame="true"]');
180
- if (!n) return null;
181
- const o = n.getBoundingClientRect();
182
- return N(o, t.viewport(), {
198
+ const L = (e, n) => {
199
+ const r = d()?.querySelector('[data-floe-workbench-canvas-frame="true"]');
200
+ if (!r) return null;
201
+ const o = r.getBoundingClientRect();
202
+ return X(o, t.viewport(), {
183
203
  clientX: e,
184
- clientY: r
204
+ clientY: n
185
205
  });
186
- }, O = (e, r, n) => {
187
- const o = F(r, n);
206
+ }, F = (e, n, r) => {
207
+ const o = L(n, r);
188
208
  o && t.widgetActions.addWidgetAtCursor(e, o.worldX, o.worldY);
189
209
  };
190
210
  return (() => {
191
- var e = J(), r = e.firstChild;
192
- return T(x, e), _(e, B({
211
+ var e = ne(), n = e.firstChild;
212
+ return _(E, e), B(e, q({
193
213
  get class() {
194
214
  return `workbench-surface${i.class ? ` ${i.class}` : ""}`;
195
215
  }
196
216
  }, () => ({
197
- [a().surfaceRootAttr]: "true"
217
+ [s().surfaceRootAttr]: "true"
198
218
  }), {
199
219
  get "data-workbench-theme"() {
200
220
  return t.theme();
201
221
  },
202
222
  tabIndex: -1
203
- }), !1, !0), f(r, u(P, {
223
+ }), !1, !0), m(n, u($, {
204
224
  get widgetDefinitions() {
205
225
  return t.widgetDefinitions();
206
226
  },
@@ -226,7 +246,7 @@ function ge(i) {
226
246
  return t.filters();
227
247
  },
228
248
  get interactionAdapter() {
229
- return a();
249
+ return s();
230
250
  },
231
251
  get setCanvasFrameRef() {
232
252
  return t.setCanvasFrameRef;
@@ -240,7 +260,7 @@ function ge(i) {
240
260
  get onCanvasContextMenu() {
241
261
  return t.canvas.openCanvasContextMenu;
242
262
  },
243
- onCanvasPointerDown: () => b("background_pointer"),
263
+ onCanvasPointerDown: () => y("background_pointer"),
244
264
  get onSelectWidget() {
245
265
  return t.canvas.selectWidget;
246
266
  },
@@ -259,8 +279,8 @@ function ge(i) {
259
279
  get onCommitResize() {
260
280
  return t.canvas.commitResize;
261
281
  },
262
- onRequestOverview: L,
263
- onRequestFit: M,
282
+ onRequestOverview: T,
283
+ onRequestFit: O,
264
284
  get onRequestDelete() {
265
285
  return i.onRequestDelete ?? t.widgetActions.deleteWidget;
266
286
  },
@@ -270,7 +290,7 @@ function ge(i) {
270
290
  get onLayoutInteractionEnd() {
271
291
  return i.onLayoutInteractionEnd;
272
292
  }
273
- })), f(e, u(K, {
293
+ })), m(e, u(U, {
274
294
  get locked() {
275
295
  return t.locked();
276
296
  },
@@ -278,9 +298,9 @@ function ge(i) {
278
298
  return t.lock.toggle;
279
299
  },
280
300
  get shortcutLabel() {
281
- return C() ?? void 0;
301
+ return S() ?? void 0;
282
302
  }
283
- }), null), f(e, u(X, {
303
+ }), null), m(e, u(Y, {
284
304
  get widgetDefinitions() {
285
305
  return D();
286
306
  },
@@ -296,8 +316,8 @@ function ge(i) {
296
316
  get onShowAll() {
297
317
  return t.filter.showAll;
298
318
  },
299
- onCreateAt: O
300
- }), null), f(e, u(Y, {
319
+ onCreateAt: F
320
+ }), null), m(e, u(K, {
301
321
  get scaleLabel() {
302
322
  return t.scaleLabel();
303
323
  },
@@ -310,26 +330,26 @@ function ge(i) {
310
330
  get activeTheme() {
311
331
  return t.theme();
312
332
  },
313
- onSelectTheme: (n) => t.appearance.setTheme(n)
314
- }), null), f(e, u(V, {
333
+ onSelectTheme: (r) => t.appearance.setTheme(r)
334
+ }), null), m(e, u(P, {
315
335
  get when() {
316
336
  return t.contextMenu.state();
317
337
  },
318
338
  get children() {
319
- return u(q, {
339
+ return u(N, {
320
340
  get children() {
321
341
  return [(() => {
322
- var n = j();
323
- return z(n, "contextmenu", t.contextMenu.retarget, !0), n;
324
- })(), u(H, {
342
+ var r = te();
343
+ return z(r, "contextmenu", t.contextMenu.retarget, !0), r;
344
+ })(), u(V, {
325
345
  get x() {
326
- return t.contextMenu.position()?.left ?? 0;
346
+ return b()?.left ?? 0;
327
347
  },
328
348
  get y() {
329
- return t.contextMenu.position()?.top ?? 0;
349
+ return b()?.top ?? 0;
330
350
  },
331
351
  get items() {
332
- return E();
352
+ return C();
333
353
  }
334
354
  })];
335
355
  }
@@ -338,7 +358,7 @@ function ge(i) {
338
358
  }), null), e;
339
359
  })();
340
360
  }
341
- $(["contextmenu"]);
361
+ H(["contextmenu"]);
342
362
  export {
343
- ge as WorkbenchSurface
363
+ he as WorkbenchSurface
344
364
  };
@@ -1,5 +1,5 @@
1
1
  export { WorkbenchOverlay, type WorkbenchOverlayProps, } from './WorkbenchOverlay';
2
- export { WorkbenchSurface, type WorkbenchSurfaceApi, type WorkbenchSurfaceProps, } from './WorkbenchSurface';
2
+ export { WorkbenchSurface, type WorkbenchSurfaceApi, type WorkbenchContextMenuItemsResolver, type WorkbenchSurfaceProps, } from './WorkbenchSurface';
3
3
  export { WorkbenchContextMenu, type WorkbenchContextMenuItem, type WorkbenchContextMenuProps, } from './WorkbenchContextMenu';
4
4
  export { useWorkbenchModel, type UseWorkbenchModelOptions } from './useWorkbenchModel';
5
5
  export { WIDGET_REGISTRY, createWorkbenchFilterState, getWidgetEntry, isValidWorkbenchWidgetType, resolveWorkbenchWidgetDefinitions, type WidgetRegistryEntry, } from './widgets/widgetRegistry';
@@ -1,6 +1,6 @@
1
1
  import { createSignal as A, createMemo as r, onCleanup as Ct } from "solid-js";
2
2
  import { ArrowUp as bt, Copy as kt, Trash as Ft } from "../icons/index.js";
3
- import { getTopZIndex as It, createContextMenuPosition as Mt, createWorkbenchId as vt, createWorkbenchViewportCenteredOnWidget as K, findNearestWidget as Xt, clampScale as Yt, WORKBENCH_CANVAS_ZOOM_STEP as L, WORKBENCH_MIN_SCALE as yt, createWorkbenchViewportFitForWidget as Ot, WORKBENCH_CONTEXT_MENU_WIDTH_PX as _t, estimateContextMenuHeight as zt } from "./workbenchHelpers.js";
3
+ import { getTopZIndex as It, createContextMenuPosition as Mt, createWorkbenchId as vt, createWorkbenchViewportCenteredOnWidget as K, findNearestWidget as Xt, WORKBENCH_CONTEXT_MENU_WIDTH_PX as Yt, estimateContextMenuHeight as yt, clampScale as Ot, WORKBENCH_CANVAS_ZOOM_STEP as L, WORKBENCH_MIN_SCALE as _t, createWorkbenchViewportFitForWidget as zt } from "./workbenchHelpers.js";
4
4
  import { resolveWorkbenchWidgetDefinitions as Tt, getWidgetEntry as j, createWorkbenchFilterState as Vt } from "./widgets/widgetRegistry.js";
5
5
  function Kt(c) {
6
6
  const [x, S] = A(null), [U, N] = A(null), [D, G] = A({ width: 0, height: 0 });
@@ -107,8 +107,8 @@ function Kt(c) {
107
107
  return Mt({
108
108
  clientX: t.clientX,
109
109
  clientY: t.clientY,
110
- menuWidth: _t,
111
- menuHeight: zt(n, i)
110
+ menuWidth: Yt,
111
+ menuHeight: yt(n, i)
112
112
  });
113
113
  }), v = (t, e, n) => {
114
114
  const i = j(t, w()), o = i.singleton ? C(t) : null;
@@ -167,7 +167,7 @@ function Kt(c) {
167
167
  }, y = (t) => {
168
168
  c.setState((e) => ({ ...e, viewport: t }));
169
169
  }, q = (t) => {
170
- const e = h(), n = a(), i = (n.width / 2 - e.x) / e.scale, o = (n.height / 2 - e.y) / e.scale, s = Yt(
170
+ const e = h(), n = a(), i = (n.width / 2 - e.x) / e.scale, o = (n.height / 2 - e.y) / e.scale, s = Ot(
171
171
  t === "in" ? e.scale * L : e.scale / L
172
172
  ), u = {
173
173
  x: n.width / 2 - i * s,
@@ -232,7 +232,7 @@ function Kt(c) {
232
232
  }));
233
233
  }, Wt = (t) => {
234
234
  const e = a();
235
- e.width === 0 || e.height === 0 || _(Ot({
235
+ e.width === 0 || e.height === 0 || _(zt({
236
236
  widget: t,
237
237
  frameWidth: e.width,
238
238
  frameHeight: e.height
@@ -241,7 +241,7 @@ function Kt(c) {
241
241
  const e = a();
242
242
  e.width === 0 || e.height === 0 || _(K({
243
243
  widget: t,
244
- scale: yt,
244
+ scale: _t,
245
245
  frameWidth: e.width,
246
246
  frameHeight: e.height
247
247
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-core",
3
- "version": "0.36.32",
3
+ "version": "0.36.34",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",