@floegence/floe-webapp-core 0.36.32 → 0.36.33

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
  };
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.33",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",