@floegence/floe-webapp-core 0.101.11 → 0.101.13

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,6 +1,6 @@
1
1
  import { effect as V, className as q, style as U, template as $, use as k } from "solid-js/web";
2
2
  import { useContextMenuActions as B } from "../ui/ContextMenuActions.js";
3
- import { onMount as N, onCleanup as P, createEffect as M } from "solid-js";
3
+ import { onMount as N, onCleanup as P, createEffect as C } from "solid-js";
4
4
  import { useTheme as _ } from "../../context/ThemeContext.js";
5
5
  import { useResizeObserver as H } from "../../hooks/useResizeObserver.js";
6
6
  import { resolveCodeEditorLanguageSpec as K } from "./languages.js";
@@ -9,7 +9,7 @@ import { ensureMonacoEnvironment as X } from "./monacoEnvironment.js";
9
9
  import { loadMonacoEditorApi as Y } from "./monacoStandaloneRuntime.js";
10
10
  import { ensureFloeMonacoHover as j } from "./monacoHover.js";
11
11
  var J = /* @__PURE__ */ $("<div>");
12
- const A = {
12
+ const w = {
13
13
  readOnly: !0,
14
14
  automaticLayout: !1,
15
15
  minimap: {
@@ -22,69 +22,69 @@ const A = {
22
22
  fontFamily: "var(--font-mono)"
23
23
  };
24
24
  let Q = 0;
25
- function W(t, f, c) {
26
- return t.Uri.parse(`inmemory://model/${f}/${encodeURIComponent(c)}`);
25
+ function W(t, f, s) {
26
+ return t.Uri.parse(`inmemory://model/${f}/${encodeURIComponent(s)}`);
27
27
  }
28
- function R(t, f) {
28
+ function A(t, f) {
29
29
  if (!t || !f) return "";
30
- const c = t.getSelection();
31
- return !c || c.isEmpty() ? "" : f.getValueInRange(c);
30
+ const s = t.getSelection();
31
+ return !s || s.isEmpty() ? "" : f.getValueInRange(s);
32
32
  }
33
33
  function ue(t) {
34
- const f = _(), c = B();
34
+ const f = _(), s = B();
35
35
  let m;
36
- const F = ++Q;
37
- let s, o, i, h, S = null, E = 0;
38
- const O = H(() => m), p = () => {
36
+ const R = ++Q;
37
+ let d, o, i, h, x = null, M = 0;
38
+ const F = H(() => m), S = () => {
39
39
  const e = f.resolvedTheme(), a = f.shellPreset();
40
- s && G(s.editor, e, a);
40
+ d && G(d.editor, e, a);
41
41
  }, y = () => !o || !i ? null : {
42
42
  editor: o,
43
43
  model: i,
44
44
  getValue: () => o.getValue(),
45
- getSelectedText: () => R(o, i),
45
+ getSelectedText: () => A(o, i),
46
46
  focus: () => o.focus()
47
- }, L = () => {
47
+ }, p = () => {
48
48
  const e = y();
49
49
  if (!e) return;
50
50
  const a = e.model.uri.toString();
51
- a !== S && (S = a, t.onReady?.(e));
52
- }, b = () => {
51
+ a !== x && (x = a, t.onReady?.(e));
52
+ }, L = () => {
53
53
  const e = y();
54
54
  e && t.onSelectionChange?.(e.getSelectedText(), e);
55
- }, I = async () => {
56
- if (!o || !s) return;
57
- const e = ++E, a = K(t.language);
55
+ }, b = async () => {
56
+ if (!o || !d) return;
57
+ const e = ++M, a = K(t.language);
58
58
  let l = a.id;
59
59
  try {
60
60
  await a.load?.();
61
61
  } catch {
62
- if (e !== E) return;
62
+ if (e !== M) return;
63
63
  l = "plaintext";
64
64
  }
65
- if (!o || e !== E) return;
66
- const u = W(s, F, t.path);
65
+ if (!o || e !== M) return;
66
+ const u = W(d, R, t.path);
67
67
  if (i && i.uri.toString() === u.toString()) {
68
- i.getLanguageId() !== l && s.editor.setModelLanguage(i, l), i.getValue() !== t.value && i.setValue(t.value), L(), b();
68
+ i.getLanguageId() !== l && d.editor.setModelLanguage(i, l), i.getValue() !== t.value && i.setValue(t.value), p(), L();
69
69
  return;
70
70
  }
71
- const g = s.editor.createModel(t.value, l, u);
72
- i?.dispose(), i = g, o.setModel(i), L(), b();
71
+ const g = d.editor.createModel(t.value, l, u);
72
+ i?.dispose(), i = g, o.setModel(i), p(), L();
73
73
  };
74
74
  return N(() => {
75
- let e = !1, a, l, u, g = [], x = [];
75
+ let e = !1, a, l, u, g = [], E = [];
76
76
  (async () => {
77
- if (!m || (X(), j(), s = await Y(t.runtimeOptions), e || !m)) return;
78
- o = s.editor.create(m, {
77
+ if (!m || (X(), j(), d = await Y(t.runtimeOptions), e || !m)) return;
78
+ o = d.editor.create(m, {
79
79
  model: null,
80
- ...A,
80
+ ...w,
81
81
  ...t.options ?? {}
82
82
  });
83
- const r = m, T = r.getBoundingClientRect();
84
- g = (c?.resolve({
83
+ const r = m, I = r.getBoundingClientRect();
84
+ g = (s?.resolve({
85
85
  target: r,
86
- x: T.left,
87
- y: T.top,
86
+ x: I.left,
87
+ y: I.top,
88
88
  selection: ""
89
89
  }) ?? []).map((n) => o.addAction({
90
90
  id: n.id,
@@ -92,47 +92,48 @@ function ue(t) {
92
92
  contextMenuGroupId: "navigation",
93
93
  contextMenuOrder: 0,
94
94
  run: () => {
95
- const d = x.find((C) => C.id === n.id);
96
- d && !d.disabled && d.onSelect();
95
+ const c = E.find((D) => D.id === n.id);
96
+ c && !c.disabled && c.onSelect();
97
97
  }
98
98
  }));
99
99
  const v = (n) => {
100
100
  if (n instanceof KeyboardEvent && n.key !== "ContextMenu" && !(n.shiftKey && n.key === "F10") || n instanceof MouseEvent && n.type === "pointerdown" && n.button !== 2) return;
101
- const d = c?.claim(), C = r.getBoundingClientRect();
102
- x = d?.actions ?? c?.resolve({
101
+ s?.claim();
102
+ const c = r.getBoundingClientRect();
103
+ E = s?.resolve({
103
104
  target: r,
104
- x: n instanceof MouseEvent ? n.clientX : C.left + 8,
105
- y: n instanceof MouseEvent ? n.clientY : C.top + 24,
106
- selection: R(o, i)
105
+ x: n instanceof MouseEvent ? n.clientX : c.left + 8,
106
+ y: n instanceof MouseEvent ? n.clientY : c.top + 24,
107
+ selection: A(o, i)
107
108
  }) ?? [];
108
109
  };
109
110
  if (r.addEventListener("pointerdown", v, !0), r.addEventListener("contextmenu", v, !0), r.addEventListener("keydown", v, !0), u = () => {
110
- x = [], r.removeEventListener("pointerdown", v, !0), r.removeEventListener("contextmenu", v, !0), r.removeEventListener("keydown", v, !0);
111
- }, p(), await I(), e || !o) return;
112
- const z = t.onContentChange, w = t.onChange, D = t.onSelectionChange;
111
+ E = [], r.removeEventListener("pointerdown", v, !0), r.removeEventListener("contextmenu", v, !0), r.removeEventListener("keydown", v, !0);
112
+ }, S(), await b(), e || !o) return;
113
+ const O = t.onContentChange, T = t.onChange, z = t.onSelectionChange;
113
114
  a = o.onDidChangeModelContent((n) => {
114
- const d = y();
115
- d && (z?.(n, d), w && w(d.getValue()));
115
+ const c = y();
116
+ c && (O?.(n, c), T && T(c.getValue()));
116
117
  }), l = o.onDidChangeCursorSelection(() => {
117
118
  const n = y();
118
- n && D?.(n.getSelectedText(), n);
119
+ n && z?.(n.getSelectedText(), n);
119
120
  });
120
121
  })().catch((r) => {
121
122
  console.error("Failed to initialize Monaco editor runtime", r);
122
123
  }), P(() => {
123
- e = !0, a?.dispose(), l?.dispose(), u?.(), g.forEach((r) => r.dispose()), h && cancelAnimationFrame(h), o?.dispose(), i?.dispose(), s = void 0, o = void 0, i = void 0;
124
+ e = !0, a?.dispose(), l?.dispose(), u?.(), g.forEach((r) => r.dispose()), h && cancelAnimationFrame(h), o?.dispose(), i?.dispose(), d = void 0, o = void 0, i = void 0;
124
125
  });
125
- }), M(() => {
126
- p();
127
- }), M(() => {
126
+ }), C(() => {
127
+ S();
128
+ }), C(() => {
128
129
  o && o.updateOptions({
129
- ...A,
130
+ ...w,
130
131
  ...t.options ?? {}
131
132
  });
132
- }), M(() => {
133
- t.path, t.language, t.value, I();
134
- }), M(() => {
135
- const e = O();
133
+ }), C(() => {
134
+ t.path, t.language, t.value, b();
135
+ }), C(() => {
136
+ const e = F();
136
137
  !e || !o || (h && cancelAnimationFrame(h), h = requestAnimationFrame(() => {
137
138
  o?.layout({
138
139
  width: e.width,
@@ -10,45 +10,45 @@ function A(t) {
10
10
  function E(t, o, c) {
11
11
  return c ? c(o) : !t || !A(o) ? !1 : t.contains(o);
12
12
  }
13
- function W(t, o, c, f) {
14
- return c === "none" ? !1 : c === "all" ? !0 : !E(t, o, f);
13
+ function W(t, o, c, l) {
14
+ return c === "none" ? !1 : c === "all" ? !0 : !E(t, o, l);
15
15
  }
16
16
  function $(t) {
17
17
  return typeof t == "function" ? t() ?? [] : t ?? [];
18
18
  }
19
- function s(t, o) {
19
+ function i(t, o) {
20
20
  return typeof t == "function" ? t() ?? o : t ?? o;
21
21
  }
22
22
  function ee(t, o) {
23
23
  for (const c of $(o)) {
24
- const f = c.trim();
25
- if (f && _(t, f))
24
+ const l = c.trim();
25
+ if (l && _(t, l))
26
26
  return !0;
27
27
  }
28
28
  return !1;
29
29
  }
30
30
  function se(t) {
31
- const o = () => s(t.lockBodyScroll, !0), c = () => s(t.trapFocus, !0), f = () => {
32
- const l = s(
31
+ const o = () => i(t.lockBodyScroll, !0), c = () => i(t.trapFocus, !0), l = () => {
32
+ const d = i(
33
33
  t.closeOnEscape,
34
34
  !0
35
35
  );
36
- return l === !1 ? "none" : l === "inside" ? "inside" : l === "none" ? "none" : "always";
37
- }, R = () => s(t.blockHotkeys, !0), N = () => s(t.restoreFocus, !0), q = () => s(t.blockWheel, "none"), j = () => s(t.blockTouchMove, "none"), z = () => s(t.autoFocus, !0);
36
+ return d === !1 ? "none" : d === "inside" ? "inside" : d === "none" ? "none" : "always";
37
+ }, R = () => i(t.blockHotkeys, !0), N = () => i(t.restoreFocus, !0), q = () => i(t.blockWheel, "none"), j = () => i(t.blockTouchMove, "none"), z = () => i(t.autoFocus, !0);
38
38
  U(() => {
39
39
  if (!t.open() || typeof document > "u") return;
40
- const l = o(), O = c(), v = f(), y = s(t.escapeKeyPhase, "capture"), V = R(), G = N(), k = q(), b = j(), w = z(), d = L.get(document) ?? [];
41
- L.set(document, d);
42
- const h = {
43
- global: l || v === "always",
40
+ const d = o(), O = c(), h = l(), y = i(t.escapeKeyPhase, "capture"), V = R(), G = N(), k = q(), b = j(), w = z(), m = L.get(document) ?? [];
41
+ L.set(document, m);
42
+ const v = {
43
+ global: d || h === "always",
44
44
  contains: (e) => E(t.root(), e, t.containsTarget)
45
45
  };
46
- d.push(h);
46
+ m.push(v);
47
47
  let T = !0;
48
- const a = (e) => T && !d.slice(d.indexOf(h) + 1).some((n) => n.global || n.contains(e)), p = document.activeElement instanceof HTMLElement ? document.activeElement : null, J = l ? Y({ overflow: "hidden" }) : null;
48
+ const u = (e) => T && !m.slice(m.indexOf(v) + 1).some((n) => n.global || n.contains(e)), p = document.activeElement instanceof HTMLElement ? document.activeElement : null, J = d ? Y({ overflow: "hidden" }) : null;
49
49
  I(() => {
50
50
  const e = t.root();
51
- if (!e?.isConnected || !a(e) || w === !1 || h.contains(document.activeElement)) return;
51
+ if (!e?.isConnected || !u(e) || w === !1 || v.contains(document.activeElement)) return;
52
52
  const n = typeof w == "object" ? w.selector : void 0, r = (n ? e.querySelector(n) : null) ?? e.querySelector("[data-floe-autofocus]") ?? Z(e) ?? e;
53
53
  try {
54
54
  r.focus({ preventScroll: !0 });
@@ -56,10 +56,10 @@ function se(t) {
56
56
  }
57
57
  });
58
58
  const M = (e) => {
59
- if (e.key !== "Tab" || !a(e.target)) return;
59
+ if (e.key !== "Tab" || !u(e.target)) return;
60
60
  const n = t.root();
61
61
  if (!n) return;
62
- const m = t.focusRoots?.() ?? [n], r = t.focusRoots ? [...new Set(m.flatMap(H))].filter((u) => u.tabIndex >= 0 && !u.closest('[hidden], [inert], [aria-hidden="true"]')) : H(n);
62
+ const s = t.focusRoots?.() ?? [n], r = t.focusRoots ? [...new Set(s.flatMap(H))].filter((a) => a.tabIndex >= 0 && !a.closest('[hidden], [inert], [aria-hidden="true"]')) : H(n);
63
63
  if (!r.length) {
64
64
  e.preventDefault();
65
65
  try {
@@ -68,21 +68,21 @@ function se(t) {
68
68
  }
69
69
  return;
70
70
  }
71
- const K = r[0], x = r[r.length - 1], i = document.activeElement instanceof HTMLElement ? document.activeElement : null;
71
+ const K = r[0], x = r[r.length - 1], f = document.activeElement instanceof HTMLElement ? document.activeElement : null;
72
72
  if (t.focusRoots) {
73
- const u = i ? r.indexOf(i) : -1, Q = u < 0 ? e.shiftKey ? r.length - 1 : 0 : (u + (e.shiftKey ? -1 : 1) + r.length) % r.length;
73
+ const a = f ? r.indexOf(f) : -1, Q = a < 0 ? e.shiftKey ? r.length - 1 : 0 : (a + (e.shiftKey ? -1 : 1) + r.length) % r.length;
74
74
  e.preventDefault(), r[Q]?.focus({ preventScroll: !0 });
75
75
  return;
76
76
  }
77
77
  if (e.shiftKey) {
78
- if (i === K || !i || !m.some((u) => u.contains(i))) {
78
+ if (f === K || !f || !s.some((a) => a.contains(f))) {
79
79
  e.preventDefault();
80
80
  try {
81
81
  x.focus();
82
82
  } catch {
83
83
  }
84
84
  }
85
- } else if (i === x || !i || !m.some((u) => u.contains(i))) {
85
+ } else if (f === x || !f || !s.some((a) => a.contains(f))) {
86
86
  e.preventDefault();
87
87
  try {
88
88
  K.focus();
@@ -90,14 +90,14 @@ function se(t) {
90
90
  }
91
91
  }
92
92
  }, B = (e) => {
93
- if (e.key !== "Escape" || !a(e.target) || y === "bubble" && (e.defaultPrevented || e.isComposing) || v === "none") return;
94
- const n = t.root(), m = E(
93
+ if (e.key !== "Escape" || !u(e.target) || y === "bubble" && (e.defaultPrevented || e.isComposing) || h === "none") return;
94
+ const n = t.root(), s = E(
95
95
  n,
96
96
  A(e.target) ? e.target : document.activeElement,
97
97
  t.containsTarget
98
98
  );
99
- if (v === "inside") {
100
- if (m) {
99
+ if (h === "inside") {
100
+ if (s) {
101
101
  e.preventDefault(), e.stopImmediatePropagation(), t.onClose?.();
102
102
  return;
103
103
  }
@@ -106,37 +106,37 @@ function se(t) {
106
106
  }
107
107
  e.preventDefault(), e.stopImmediatePropagation(), t.onClose?.();
108
108
  }, F = (e) => {
109
- if (!a(e.target)) return;
109
+ if (!u(e.target)) return;
110
110
  const n = t.root();
111
111
  n && V && E(n, e.target, t.containsTarget) && (ee(e, t.allowHotkeys) || e.stopPropagation());
112
112
  }, S = (e) => {
113
- if (!a(e.target)) return;
113
+ if (!u(e.target)) return;
114
114
  const n = t.root();
115
115
  W(n, e.target, k, t.containsTarget) && e.cancelable && e.preventDefault();
116
116
  }, C = (e) => {
117
- a(e.target) && e.stopPropagation();
118
- }, D = (e) => {
119
- if (!a(e.target)) return;
117
+ u(e.target) && e.stopPropagation();
118
+ }, P = (e) => {
119
+ if (!u(e.target)) return;
120
120
  const n = t.root();
121
121
  W(n, e.target, b, t.containsTarget) && e.cancelable && e.preventDefault();
122
122
  }, g = (e) => {
123
- a(e.target) && !h.contains(e.target) && t.onInteractOutside?.(e);
123
+ e.composedPath().some((s) => !u(s) || v.contains(s)) || u(e.target) && !v.contains(e.target) && t.onInteractOutside?.(e);
124
124
  };
125
125
  t.onInteractOutside && (document.addEventListener("pointerdown", g, !0), document.addEventListener("focusin", g)), O && document.addEventListener("keydown", M, !0);
126
- const P = y === "capture" ? window : document;
127
- v !== "none" && P.addEventListener(
126
+ const D = y === "capture" ? window : document;
127
+ h !== "none" && D.addEventListener(
128
128
  "keydown",
129
129
  B,
130
130
  y === "capture"
131
- ), document.addEventListener("keydown", F), k !== "none" && (document.addEventListener("wheel", S, { capture: !0, passive: !1 }), document.addEventListener("wheel", C)), b !== "none" && document.addEventListener("touchmove", D, {
131
+ ), document.addEventListener("keydown", F), k !== "none" && (document.addEventListener("wheel", S, { capture: !0, passive: !1 }), document.addEventListener("wheel", C)), b !== "none" && document.addEventListener("touchmove", P, {
132
132
  capture: !0,
133
133
  passive: !1
134
134
  }), X(() => {
135
- T = !1, document.removeEventListener("pointerdown", g, !0), document.removeEventListener("focusin", g), d.splice(d.indexOf(h), 1), O && document.removeEventListener("keydown", M, !0), v !== "none" && P.removeEventListener(
135
+ T = !1, document.removeEventListener("pointerdown", g, !0), document.removeEventListener("focusin", g), m.splice(m.indexOf(v), 1), O && document.removeEventListener("keydown", M, !0), h !== "none" && D.removeEventListener(
136
136
  "keydown",
137
137
  B,
138
138
  y === "capture"
139
- ), document.removeEventListener("keydown", F), k !== "none" && (document.removeEventListener("wheel", S, !0), document.removeEventListener("wheel", C)), b !== "none" && document.removeEventListener("touchmove", D, !0), J?.(), G && p && p.isConnected && I(() => {
139
+ ), document.removeEventListener("keydown", F), k !== "none" && (document.removeEventListener("wheel", S, !0), document.removeEventListener("wheel", C)), b !== "none" && document.removeEventListener("touchmove", P, !0), J?.(), G && p && p.isConnected && I(() => {
140
140
  if (typeof document > "u" || L.get(document)?.some((n) => !n.contains(p))) return;
141
141
  const e = document.activeElement;
142
142
  if (!(e && e !== document.body && e !== document.documentElement))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-core",
3
- "version": "0.101.11",
3
+ "version": "0.101.13",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",