@floegence/floe-webapp-core 0.81.6 → 0.82.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.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { type CodeColorToken } from './tokens';
2
+ /** Worker-only tokenizer. Offsets refer to the original source, including CRLF. */
3
+ export declare function tokenizeCode(code: string, language: string): Promise<CodeColorToken[] | null>;
@@ -0,0 +1,17 @@
1
+ export interface CodeColorToken {
2
+ start: number;
3
+ end: number;
4
+ light: string;
5
+ dark: string;
6
+ }
7
+ export declare const MAX_CODE_TOKENS = 4096;
8
+ export declare function canHighlightCode(code: string, language: string): boolean;
9
+ export interface CodeColorRequest {
10
+ id: number;
11
+ code: string;
12
+ language: string;
13
+ }
14
+ export interface CodeColorResponse {
15
+ id: number;
16
+ tokens: CodeColorToken[] | null;
17
+ }
@@ -0,0 +1,8 @@
1
+ const i = 4096;
2
+ function l(t, n) {
3
+ return !!n && !/^(?:text|txt|plain|plaintext)$/i.test(n) && t.length > 0 && t.length <= 32768 && t.split(/\r?\n/).every((e) => e.length <= 2e3);
4
+ }
5
+ export {
6
+ i as MAX_CODE_TOKENS,
7
+ l as canHighlightCode
8
+ };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Color an existing, immutable plain-text code element when visible. The host
3
+ * keeps its frame, controls and layout. Dispose before replacing/removing it.
4
+ * Parsing runs in a lazy shared worker; unsupported or bounded-out input stays
5
+ * readable. Colors follow the inherited CSS color-scheme without DOM changes.
6
+ * Only call for committed content, never an actively growing streaming tail.
7
+ */
8
+ export declare function enhanceCodeBlock(code: HTMLElement, language: string): () => void;
@@ -0,0 +1,96 @@
1
+ import { canHighlightCode as O, MAX_CODE_TOKENS as T } from "./code-highlight/tokens.js";
2
+ const c = [];
3
+ let s, l, x = !1, j = 0, w;
4
+ function p() {
5
+ x = !0, clearTimeout(w), l?.terminate(), l = void 0, s?.resolve(null), s = void 0;
6
+ for (const e of c.splice(0)) e.resolve(null);
7
+ }
8
+ function L() {
9
+ if (!(s || x || !c.length))
10
+ try {
11
+ l || (l = new Worker(new URL(
12
+ /* @vite-ignore */
13
+ "" + new URL("assets/highlight.worker-BasxZ52k.js", import.meta.url).href,
14
+ import.meta.url
15
+ ), { type: "module" }), l.onerror = p, l.onmessageerror = p, l.onmessage = ({ data: r }) => {
16
+ if (r.id !== s?.id) return;
17
+ clearTimeout(w);
18
+ const i = s;
19
+ s = void 0, i.resolve(r.tokens), setTimeout(L, 0);
20
+ }), s = c.shift();
21
+ const { id: e, code: o, language: n } = s;
22
+ w = setTimeout(p, 15e3), l.postMessage({ id: e, code: o, language: n });
23
+ } catch {
24
+ p();
25
+ }
26
+ }
27
+ function A(e, o, n) {
28
+ if (x || c.length >= 128)
29
+ return n(null), () => {
30
+ };
31
+ const r = { id: ++j, code: e, language: o, resolve: n };
32
+ return c.push(r), L(), () => {
33
+ const i = c.indexOf(r);
34
+ i >= 0 && c.splice(i, 1), r.resolve = () => {
35
+ };
36
+ };
37
+ }
38
+ let m;
39
+ const v = /* @__PURE__ */ new WeakMap();
40
+ function I(e, o) {
41
+ return typeof IntersectionObserver > "u" ? (o(), () => {
42
+ }) : (m ??= new IntersectionObserver((n) => {
43
+ for (const r of n) {
44
+ if (!r.isIntersecting) continue;
45
+ const i = v.get(r.target);
46
+ v.delete(r.target), m.unobserve(r.target), i?.();
47
+ }
48
+ }), v.set(e, o), m.observe(e), () => {
49
+ m.unobserve(e), v.delete(e);
50
+ });
51
+ }
52
+ function $(e, o) {
53
+ const n = e.textContent ?? "", r = o.trim().toLowerCase();
54
+ if (!O(n, r) || e.children.length || e.hasAttribute("data-floe-code-highlighted")) return () => {
55
+ };
56
+ const i = e.ownerDocument;
57
+ let f = !1, y, a = null, g = !1;
58
+ const b = () => {
59
+ g && (i.removeEventListener("selectionchange", C), g = !1);
60
+ }, C = () => {
61
+ if (f || !a) return;
62
+ if (!e.isConnected || e.textContent !== n || e.children.length) {
63
+ a = null, b();
64
+ return;
65
+ }
66
+ const u = i.getSelection();
67
+ for (let t = 0; u && t < u.rangeCount; t++)
68
+ if (u.getRangeAt(t).intersectsNode(e)) {
69
+ g || (i.addEventListener("selectionchange", C), g = !0);
70
+ return;
71
+ }
72
+ b();
73
+ const d = i.createDocumentFragment();
74
+ let h = 0;
75
+ for (const t of a) {
76
+ if (t.start < h || t.end <= t.start || t.end > n.length || !/^#[\da-f]{6,8}$/i.test(t.light) || !/^#[\da-f]{6,8}$/i.test(t.dark)) {
77
+ a = null;
78
+ return;
79
+ }
80
+ d.append(n.slice(h, t.start));
81
+ const k = i.createElement("span");
82
+ k.style.color = `light-dark(${t.light}, ${t.dark})`, k.textContent = n.slice(t.start, t.end), d.append(k), h = t.end;
83
+ }
84
+ d.append(n.slice(h)), a = null, e.replaceChildren(d), e.setAttribute("data-floe-code-highlighted", "");
85
+ }, E = I(e, () => {
86
+ f || !e.isConnected || e.textContent !== n || (y = A(n, r, (u) => {
87
+ f || !u?.length || u.length > T || (a = u, C());
88
+ }));
89
+ });
90
+ return () => {
91
+ f = !0, a = null, E(), y?.(), b();
92
+ };
93
+ }
94
+ export {
95
+ $ as enhanceCodeBlock
96
+ };
@@ -35,6 +35,7 @@ export interface ResolvedMarkdownMedia {
35
35
  export interface MarkdownMediaProps {
36
36
  source: MarkdownMediaSource;
37
37
  labels: MarkdownMediaLabels;
38
+ /** Replace this callback when its authorization or resource context changes. Reads inside it do not trigger reloads. */
38
39
  resolve?: (source: MarkdownMediaSource, signal: AbortSignal) => Promise<ResolvedMarkdownMedia>;
39
40
  class?: string;
40
41
  }
@@ -1,141 +1,139 @@
1
- import { use as F, insert as s, createComponent as o, effect as u, setAttribute as n, memo as _, className as K, template as v, delegateEvents as P } from "solid-js/web";
2
- import { createSignal as x, onMount as Q, onCleanup as B, createMemo as X, createEffect as Y, Switch as D, Match as w, Show as S } from "solid-js";
3
- import { FloatingWindow as Z } from "../../ui/FloatingWindow.js";
4
- import { Refresh as p, FolderOpen as ee, Eye as re, Maximize as te, ExternalLink as ae } from "../../icons/index.js";
5
- import { cn as le } from "../../../utils/cn.js";
6
- import { sandboxedMarkdownHtml as N, safeMarkdownMediaURL as ne } from "../markdown/media.js";
7
- var ie = /* @__PURE__ */ v("<span class=chat-media-placeholder role=status>"), oe = /* @__PURE__ */ v("<span class=chat-media-placeholder role=status><span></span><button type=button class=chat-media-retry>"), se = /* @__PURE__ */ v("<button type=button class=chat-media-image-button><img class=chat-media-image loading=lazy decoding=async referrerpolicy=no-referrer>", !0, !1, !1), ce = /* @__PURE__ */ v("<video class=chat-media-video controls playsinline preload=metadata>"), de = /* @__PURE__ */ v("<audio class=chat-media-audio controls preload=metadata>"), ue = /* @__PURE__ */ v("<iframe class=chat-media-html sandbox=allow-scripts referrerpolicy=no-referrer>"), H = /* @__PURE__ */ v("<button type=button class=chat-media-action>"), ve = /* @__PURE__ */ v("<div class=chat-media-preview-content><img referrerpolicy=no-referrer class=chat-media-full-image>"), he = /* @__PURE__ */ v("<span><span class=chat-media-viewport></span><span class=chat-media-header><span class=chat-media-heading><span class=chat-media-kind></span><span class=chat-media-title></span></span><span class=chat-media-actions>"), me = /* @__PURE__ */ v('<a class=chat-media-action target=_blank rel="noopener noreferrer">');
8
- async function ge(a) {
9
- const f = ne(a.src ?? "");
1
+ import { use as B, insert as o, createComponent as i, effect as u, setAttribute as n, memo as R, className as P, template as h, delegateEvents as Q } from "solid-js/web";
2
+ import { createSignal as M, onMount as X, onCleanup as D, createMemo as Y, createEffect as Z, on as q, Switch as N, Match as k, Show as E } from "solid-js";
3
+ import { FloatingWindow as p } from "../../ui/FloatingWindow.js";
4
+ import { Refresh as ee, FolderOpen as re, Eye as te, Maximize as ae, ExternalLink as le } from "../../icons/index.js";
5
+ import { cn as ne } from "../../../utils/cn.js";
6
+ import { sandboxedMarkdownHtml as V, safeMarkdownMediaURL as ie } from "../markdown/media.js";
7
+ var oe = /* @__PURE__ */ h("<span class=chat-media-placeholder role=status>"), se = /* @__PURE__ */ h("<span class=chat-media-placeholder role=status><span></span><button type=button class=chat-media-retry>"), ce = /* @__PURE__ */ h("<button type=button class=chat-media-image-button><img class=chat-media-image loading=lazy decoding=async referrerpolicy=no-referrer>", !0, !1, !1), de = /* @__PURE__ */ h("<video class=chat-media-video controls playsinline preload=metadata>"), ve = /* @__PURE__ */ h("<audio class=chat-media-audio controls preload=metadata>"), ue = /* @__PURE__ */ h("<iframe class=chat-media-html sandbox=allow-scripts referrerpolicy=no-referrer>"), z = /* @__PURE__ */ h("<button type=button class=chat-media-action>"), he = /* @__PURE__ */ h("<div class=chat-media-preview-content><img referrerpolicy=no-referrer class=chat-media-full-image>"), me = /* @__PURE__ */ h("<span><span class=chat-media-viewport></span><span class=chat-media-header><span class=chat-media-heading><span class=chat-media-kind></span><span class=chat-media-title></span></span><span class=chat-media-actions>"), ge = /* @__PURE__ */ h('<a class=chat-media-action target=_blank rel="noopener noreferrer">');
8
+ async function fe(a) {
9
+ const f = ie(a.src ?? "");
10
10
  if (!f || a.kind === "html") throw new Error("A host resolver is required");
11
11
  return {
12
12
  src: f,
13
13
  openURL: f
14
14
  };
15
15
  }
16
- const xe = (a) => {
17
- let f, q;
18
- const [V, z] = x(!1);
19
- Q(() => {
16
+ const Me = (a) => {
17
+ let f, I;
18
+ const [W, O] = M(!1);
19
+ X(() => {
20
20
  if (typeof IntersectionObserver > "u") {
21
- z(!0);
21
+ O(!0);
22
22
  return;
23
23
  }
24
- const i = new IntersectionObserver((g) => {
25
- g.some((d) => d.isIntersecting) && (z(!0), i.disconnect());
24
+ const s = new IntersectionObserver((c) => {
25
+ c.some((L) => L.isIntersecting) && (O(!0), s.disconnect());
26
26
  }, {
27
27
  rootMargin: "400px"
28
28
  });
29
- i.observe(f), B(() => i.disconnect());
29
+ s.observe(f), D(() => s.disconnect());
30
30
  });
31
- const [h, I] = x(), [W, R] = x(), [k, y] = x("loading"), [j, G] = x(0), [$, E] = x(!1), m = () => a.source.title || a.labels[a.source.kind], J = X(() => a.source), T = () => h()?.preview?.label || a.labels.previewImage || a.labels.expand, O = (i) => {
32
- q = i.currentTarget;
33
- const g = h()?.preview;
34
- g ? g.onSelect() : E(!0);
31
+ const [m, U] = M(), [j, T] = M(), [y, $] = M("loading"), [G, J] = M(0), [x, C] = M(!1), g = () => a.source.title || a.labels[a.source.kind], K = Y(() => a.source), H = () => m()?.preview?.label || a.labels.previewImage || a.labels.expand, A = (s) => {
32
+ I = s.currentTarget;
33
+ const c = m()?.preview;
34
+ c ? c.onSelect() : C(!0);
35
35
  };
36
- return Y(() => {
37
- if (!V()) return;
38
- const i = J(), g = a.resolve ?? ge;
39
- j();
40
- const d = new AbortController();
41
- B(() => d.abort()), I(void 0), R(void 0), y("loading"), E(!1), (async () => {
42
- if (i.kind === "html" && i.html !== void 0) {
43
- if (i.html.length > 1e6) throw new Error("HTML preview is too large");
44
- d.signal.aborted || R(N(i.html));
36
+ return Z(q([W, K, () => a.resolve, G], ([s, c, L]) => {
37
+ if (!s) return;
38
+ const _ = L ?? fe, v = new AbortController();
39
+ D(() => v.abort()), U(void 0), T(void 0), $("loading"), C(!1), (async () => {
40
+ if (c.kind === "html" && c.html !== void 0) {
41
+ if (c.html.length > 1e6) throw new Error("HTML preview is too large");
42
+ v.signal.aborted || T(V(c.html));
45
43
  } else {
46
- const b = await g(i, d.signal);
47
- if (d.signal.aborted) return;
48
- if (i.kind === "html") {
44
+ const b = await _(c, v.signal);
45
+ if (v.signal.aborted) return;
46
+ if (c.kind === "html") {
49
47
  if (!b.loadHTML) throw new Error("HTML loader is required");
50
- const M = await b.loadHTML(d.signal);
51
- if (d.signal.aborted) return;
52
- if (M.length > 1e6) throw new Error("HTML preview is too large");
53
- R(N(M));
48
+ const w = await b.loadHTML(v.signal);
49
+ if (v.signal.aborted) return;
50
+ if (w.length > 1e6) throw new Error("HTML preview is too large");
51
+ T(V(w));
54
52
  } else if (!b.src) throw new Error("Media URL is required");
55
- I(b);
53
+ U(b);
56
54
  }
57
- d.signal.aborted || y("ready");
55
+ v.signal.aborted || $("ready");
58
56
  })().catch(() => {
59
- d.signal.aborted || y("error");
57
+ v.signal.aborted || $("error");
60
58
  });
61
- }), (() => {
62
- var i = he(), g = i.firstChild, d = g.nextSibling, b = d.firstChild, M = b.firstChild, U = M.nextSibling, C = b.nextSibling, A = f;
63
- return typeof A == "function" ? F(A, i) : f = i, s(g, o(D, {
59
+ })), (() => {
60
+ var s = me(), c = s.firstChild, L = c.nextSibling, _ = L.firstChild, v = _.firstChild, b = v.nextSibling, w = _.nextSibling, F = f;
61
+ return typeof F == "function" ? B(F, s) : f = s, o(c, i(N, {
64
62
  get children() {
65
- return [o(w, {
63
+ return [i(k, {
66
64
  get when() {
67
- return k() === "loading";
65
+ return y() === "loading";
68
66
  },
69
67
  get children() {
70
- var e = ie();
71
- return s(e, () => a.labels.loading), e;
68
+ var e = oe();
69
+ return o(e, () => a.labels.loading), e;
72
70
  }
73
- }), o(w, {
71
+ }), i(k, {
74
72
  get when() {
75
- return k() === "error";
73
+ return y() === "error";
76
74
  },
77
75
  get children() {
78
- var e = oe(), r = e.firstChild, t = r.nextSibling;
79
- return s(r, () => a.labels.unavailable), t.$$click = () => G((l) => l + 1), s(t, o(p, {}), null), s(t, () => a.labels.retry, null), e;
76
+ var e = se(), r = e.firstChild, t = r.nextSibling;
77
+ return o(r, () => a.labels.unavailable), t.$$click = () => J((l) => l + 1), o(t, i(ee, {}), null), o(t, () => a.labels.retry, null), e;
80
78
  }
81
- }), o(w, {
79
+ }), i(k, {
82
80
  get when() {
83
- return k() === "ready";
81
+ return y() === "ready";
84
82
  },
85
83
  get children() {
86
- return o(D, {
84
+ return i(N, {
87
85
  get children() {
88
- return [o(w, {
86
+ return [i(k, {
89
87
  get when() {
90
88
  return a.source.kind === "image";
91
89
  },
92
90
  get children() {
93
- var e = se(), r = e.firstChild;
94
- return e.$$click = O, r.addEventListener("error", () => y("error")), u((t) => {
95
- var l = `${T()}: ${m()}`, c = h()?.src, L = m();
96
- return l !== t.e && n(e, "aria-label", t.e = l), c !== t.t && n(r, "src", t.t = c), L !== t.a && n(r, "alt", t.a = L), t;
91
+ var e = ce(), r = e.firstChild;
92
+ return e.$$click = A, r.addEventListener("error", () => $("error")), u((t) => {
93
+ var l = `${H()}: ${g()}`, d = m()?.src, S = g();
94
+ return l !== t.e && n(e, "aria-label", t.e = l), d !== t.t && n(r, "src", t.t = d), S !== t.a && n(r, "alt", t.a = S), t;
97
95
  }, {
98
96
  e: void 0,
99
97
  t: void 0,
100
98
  a: void 0
101
99
  }), e;
102
100
  }
103
- }), o(w, {
101
+ }), i(k, {
104
102
  get when() {
105
103
  return a.source.kind === "video";
106
104
  },
107
105
  get children() {
108
- var e = ce();
109
- return e.addEventListener("error", () => y("error")), u((r) => {
110
- var t = h()?.src, l = m();
106
+ var e = de();
107
+ return e.addEventListener("error", () => $("error")), u((r) => {
108
+ var t = m()?.src, l = g();
111
109
  return t !== r.e && n(e, "src", r.e = t), l !== r.t && n(e, "aria-label", r.t = l), r;
112
110
  }, {
113
111
  e: void 0,
114
112
  t: void 0
115
113
  }), e;
116
114
  }
117
- }), o(w, {
115
+ }), i(k, {
118
116
  get when() {
119
117
  return a.source.kind === "audio";
120
118
  },
121
119
  get children() {
122
- var e = de();
123
- return e.addEventListener("error", () => y("error")), u((r) => {
124
- var t = h()?.src, l = m();
120
+ var e = ve();
121
+ return e.addEventListener("error", () => $("error")), u((r) => {
122
+ var t = m()?.src, l = g();
125
123
  return t !== r.e && n(e, "src", r.e = t), l !== r.t && n(e, "aria-label", r.t = l), r;
126
124
  }, {
127
125
  e: void 0,
128
126
  t: void 0
129
127
  }), e;
130
128
  }
131
- }), o(w, {
129
+ }), i(k, {
132
130
  get when() {
133
131
  return a.source.kind === "html";
134
132
  },
135
133
  get children() {
136
134
  var e = ue();
137
135
  return u((r) => {
138
- var t = m(), l = W();
136
+ var t = g(), l = j();
139
137
  return t !== r.e && n(e, "title", r.e = t), l !== r.t && n(e, "srcdoc", r.t = l), r;
140
138
  }, {
141
139
  e: void 0,
@@ -148,80 +146,80 @@ const xe = (a) => {
148
146
  }
149
147
  })];
150
148
  }
151
- })), s(M, () => a.labels[a.source.kind]), s(U, m), s(C, o(S, {
149
+ })), o(v, () => a.labels[a.source.kind]), o(b, g), o(w, i(E, {
152
150
  get when() {
153
- return _(() => k() === "ready")() && h()?.reveal;
151
+ return R(() => y() === "ready")() && m()?.reveal;
154
152
  },
155
153
  children: (e) => (() => {
156
- var r = H();
157
- return r.$$click = () => e().onSelect(), s(r, o(ee, {})), u((t) => {
158
- var l = e().label, c = e().label;
159
- return l !== t.e && n(r, "aria-label", t.e = l), c !== t.t && n(r, "title", t.t = c), t;
154
+ var r = z();
155
+ return r.$$click = () => e().onSelect(), o(r, i(re, {})), u((t) => {
156
+ var l = e().label, d = e().label;
157
+ return l !== t.e && n(r, "aria-label", t.e = l), d !== t.t && n(r, "title", t.t = d), t;
160
158
  }, {
161
159
  e: void 0,
162
160
  t: void 0
163
161
  }), r;
164
162
  })()
165
- }), null), s(C, o(S, {
163
+ }), null), o(w, i(E, {
166
164
  get when() {
167
- return _(() => k() === "ready")() && a.source.kind === "image";
165
+ return R(() => y() === "ready")() && a.source.kind === "image";
168
166
  },
169
167
  get children() {
170
- var e = H();
171
- return e.$$click = O, s(e, o(re, {})), u((r) => {
172
- var t = T(), l = T();
168
+ var e = z();
169
+ return e.$$click = A, o(e, i(te, {})), u((r) => {
170
+ var t = H(), l = H();
173
171
  return t !== r.e && n(e, "aria-label", r.e = t), l !== r.t && n(e, "title", r.t = l), r;
174
172
  }, {
175
173
  e: void 0,
176
174
  t: void 0
177
175
  }), e;
178
176
  }
179
- }), null), s(C, o(S, {
177
+ }), null), o(w, i(E, {
180
178
  get when() {
181
- return _(() => k() === "ready")() && a.source.kind === "html";
179
+ return R(() => y() === "ready")() && a.source.kind === "html";
182
180
  },
183
181
  get children() {
184
- var e = H();
185
- return e.$$click = () => E(!$()), s(e, o(te, {})), u((r) => {
186
- var t = $() ? a.labels.collapse : a.labels.expand, l = $() ? a.labels.collapse : a.labels.expand, c = $();
187
- return t !== r.e && n(e, "aria-label", r.e = t), l !== r.t && n(e, "title", r.t = l), c !== r.a && n(e, "aria-expanded", r.a = c), r;
182
+ var e = z();
183
+ return e.$$click = () => C(!x()), o(e, i(ae, {})), u((r) => {
184
+ var t = x() ? a.labels.collapse : a.labels.expand, l = x() ? a.labels.collapse : a.labels.expand, d = x();
185
+ return t !== r.e && n(e, "aria-label", r.e = t), l !== r.t && n(e, "title", r.t = l), d !== r.a && n(e, "aria-expanded", r.a = d), r;
188
186
  }, {
189
187
  e: void 0,
190
188
  t: void 0,
191
189
  a: void 0
192
190
  }), e;
193
191
  }
194
- }), null), s(C, o(S, {
192
+ }), null), o(w, i(E, {
195
193
  get when() {
196
- return _(() => a.source.kind !== "image" && !h()?.reveal)() && h()?.openURL;
194
+ return R(() => a.source.kind !== "image" && !m()?.reveal)() && m()?.openURL;
197
195
  },
198
196
  children: (e) => (() => {
199
- var r = me();
200
- return s(r, o(ae, {})), u((t) => {
201
- var l = e(), c = a.labels.open, L = a.labels.open;
202
- return l !== t.e && n(r, "href", t.e = l), c !== t.t && n(r, "aria-label", t.t = c), L !== t.a && n(r, "title", t.a = L), t;
197
+ var r = ge();
198
+ return o(r, i(le, {})), u((t) => {
199
+ var l = e(), d = a.labels.open, S = a.labels.open;
200
+ return l !== t.e && n(r, "href", t.e = l), d !== t.t && n(r, "aria-label", t.t = d), S !== t.a && n(r, "title", t.a = S), t;
203
201
  }, {
204
202
  e: void 0,
205
203
  t: void 0,
206
204
  a: void 0
207
205
  }), r;
208
206
  })()
209
- }), null), s(i, o(S, {
207
+ }), null), o(s, i(E, {
210
208
  get when() {
211
209
  return a.source.kind === "image";
212
210
  },
213
211
  get children() {
214
- return o(Z, {
212
+ return i(p, {
215
213
  get open() {
216
- return $();
214
+ return x();
217
215
  },
218
216
  onOpenChange: (e) => {
219
- E(e), e || q?.focus({
217
+ C(e), e || I?.focus({
220
218
  preventScroll: !0
221
219
  });
222
220
  },
223
221
  get title() {
224
- return m();
222
+ return g();
225
223
  },
226
224
  get labels() {
227
225
  return {
@@ -241,12 +239,12 @@ const xe = (a) => {
241
239
  compactBelow: 640,
242
240
  class: "chat-media-preview-window",
243
241
  get children() {
244
- var e = ve(), r = e.firstChild;
245
- return F((t) => queueMicrotask(() => t.closest('[role="dialog"]')?.focus({
242
+ var e = he(), r = e.firstChild;
243
+ return B((t) => queueMicrotask(() => t.closest('[role="dialog"]')?.focus({
246
244
  preventScroll: !0
247
245
  })), e), u((t) => {
248
- var l = h()?.src, c = m();
249
- return l !== t.e && n(r, "src", t.e = l), c !== t.t && n(r, "alt", t.t = c), t;
246
+ var l = m()?.src, d = g();
247
+ return l !== t.e && n(r, "src", t.e = l), d !== t.t && n(r, "alt", t.t = d), t;
250
248
  }, {
251
249
  e: void 0,
252
250
  t: void 0
@@ -255,16 +253,16 @@ const xe = (a) => {
255
253
  });
256
254
  }
257
255
  }), null), u((e) => {
258
- var r = le("chat-media", $() && a.source.kind === "html" && "chat-media-expanded", a.class), t = a.source.kind, l = m();
259
- return r !== e.e && K(i, e.e = r), t !== e.t && n(i, "data-media-kind", e.t = t), l !== e.a && n(U, "title", e.a = l), e;
256
+ var r = ne("chat-media", x() && a.source.kind === "html" && "chat-media-expanded", a.class), t = a.source.kind, l = g();
257
+ return r !== e.e && P(s, e.e = r), t !== e.t && n(s, "data-media-kind", e.t = t), l !== e.a && n(b, "title", e.a = l), e;
260
258
  }, {
261
259
  e: void 0,
262
260
  t: void 0,
263
261
  a: void 0
264
- }), i;
262
+ }), s;
265
263
  })();
266
264
  };
267
- P(["click"]);
265
+ Q(["click"]);
268
266
  export {
269
- xe as MarkdownMedia
267
+ Me as MarkdownMedia
270
268
  };
@@ -7,7 +7,7 @@ function R() {
7
7
  try {
8
8
  return new Worker(new URL(
9
9
  /* @vite-ignore */
10
- "" + new URL("../../../assets/diff.worker-DCUP7uh3.js", import.meta.url).href,
10
+ "" + new URL("../../../assets/diff.worker-D_WqMZMe.js", import.meta.url).href,
11
11
  import.meta.url
12
12
  ), { type: "module" });
13
13
  } catch {
@@ -34,13 +34,13 @@ function U() {
34
34
  async function D() {
35
35
  return n ? a ? !0 : u ? (await u, !0) : !1 : !1;
36
36
  }
37
- function P(t, r) {
37
+ function $(t, r) {
38
38
  const e = d(t, r), o = i.get(e);
39
39
  if (o) return o;
40
40
  const c = y(t, r);
41
41
  return m(e, c), c;
42
42
  }
43
- async function $(t, r) {
43
+ async function v(t, r) {
44
44
  const e = d(t, r), o = i.get(e);
45
45
  if (o) return o;
46
46
  if (!await D() || !n) {
@@ -57,7 +57,7 @@ async function $(t, r) {
57
57
  }), n.postMessage({ id: h, oldCode: t, newCode: r });
58
58
  });
59
59
  }
60
- function v() {
60
+ function A() {
61
61
  n && (n.terminate(), n = null), a = !1, u = null, l.clear(), i.clear();
62
62
  }
63
63
  function d(t, r) {
@@ -77,11 +77,11 @@ function p(t) {
77
77
  return (r >>> 0).toString(36);
78
78
  }
79
79
  export {
80
- $ as computeCodeDiff,
81
- P as computeCodeDiffSync,
80
+ v as computeCodeDiff,
81
+ $ as computeCodeDiffSync,
82
82
  S as configureDiffWorker,
83
83
  R as createDiffWorker,
84
84
  U as hasDiffWorker,
85
- v as terminateDiffWorker,
85
+ A as terminateDiffWorker,
86
86
  D as waitForDiffWorker
87
87
  };
@@ -7,7 +7,7 @@ function h() {
7
7
  try {
8
8
  return new Worker(new URL(
9
9
  /* @vite-ignore */
10
- "" + new URL("../../../assets/markdown.worker-DurayC72.js", import.meta.url).href,
10
+ "" + new URL("../../../assets/markdown.worker-D2sIOyGt.js", import.meta.url).href,
11
11
  import.meta.url
12
12
  ), { type: "module" });
13
13
  } catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-core",
3
- "version": "0.81.6",
3
+ "version": "0.82.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -130,7 +130,11 @@
130
130
  "types": "./dist/remote-pointer.d.ts",
131
131
  "import": "./dist/remote-pointer.js"
132
132
  },
133
- "./remote-pointer.css": "./dist/remote-pointer.css"
133
+ "./remote-pointer.css": "./dist/remote-pointer.css",
134
+ "./code-highlight": {
135
+ "types": "./dist/code-highlight.d.ts",
136
+ "import": "./dist/code-highlight.js"
137
+ }
134
138
  },
135
139
  "files": [
136
140
  "dist",
@@ -1,7 +0,0 @@
1
- (function(){"use strict";class N{diff(e,t,n={}){let o;typeof n=="function"?(o=n,n={}):"callback"in n&&(o=n.callback);const i=this.castInput(e,n),u=this.castInput(t,n),c=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(u,n));return this.diffWithOptionsObj(c,s,n,o)}diffWithOptionsObj(e,t,n,o){var i;const u=l=>{if(l=this.postProcess(l,n),o){setTimeout(function(){o(l)},0);return}else return l},c=t.length,s=e.length;let d=1,r=c+s;n.maxEditLength!=null&&(r=Math.min(r,n.maxEditLength));const p=(i=n.timeout)!==null&&i!==void 0?i:1/0,f=Date.now()+p,m=[{oldPos:-1,lastComponent:void 0}];let h=this.extractCommon(m[0],t,e,0,n);if(m[0].oldPos+1>=s&&h+1>=c)return u(this.buildValues(m[0].lastComponent,t,e));let v=-1/0,L=1/0;const w=()=>{for(let l=Math.max(v,-d);l<=Math.min(L,d);l+=2){let g;const C=m[l-1],P=m[l+1];C&&(m[l-1]=void 0);let x=!1;if(P){const b=P.oldPos-l;x=P&&0<=b&&b<c}const y=C&&C.oldPos+1<s;if(!x&&!y){m[l]=void 0;continue}if(!y||x&&C.oldPos<P.oldPos?g=this.addToPath(P,!0,!1,0,n):g=this.addToPath(C,!1,!0,1,n),h=this.extractCommon(g,t,e,l,n),g.oldPos+1>=s&&h+1>=c)return u(this.buildValues(g.lastComponent,t,e))||!0;m[l]=g,g.oldPos+1>=s&&(L=Math.min(L,l-1)),h+1>=c&&(v=Math.max(v,l+1))}d++};if(o)(function l(){setTimeout(function(){if(d>r||Date.now()>f)return o(void 0);w()||l()},0)})();else for(;d<=r&&Date.now()<=f;){const l=w();if(l)return l}}addToPath(e,t,n,o,i){const u=e.lastComponent;return u&&!i.oneChangePerToken&&u.added===t&&u.removed===n?{oldPos:e.oldPos+o,lastComponent:{count:u.count+1,added:t,removed:n,previousComponent:u.previousComponent}}:{oldPos:e.oldPos+o,lastComponent:{count:1,added:t,removed:n,previousComponent:u}}}extractCommon(e,t,n,o,i){const u=t.length,c=n.length;let s=e.oldPos,d=s-o,r=0;for(;d+1<u&&s+1<c&&this.equals(n[s+1],t[d+1],i);)d++,s++,r++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return r&&!i.oneChangePerToken&&(e.lastComponent={count:r,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,d}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){const t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join("")}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){const o=[];let i;for(;e;)o.push(e),i=e.previousComponent,delete e.previousComponent,e=i;o.reverse();const u=o.length;let c=0,s=0,d=0;for(;c<u;c++){const r=o[c];if(r.removed)r.value=this.join(n.slice(d,d+r.count)),d+=r.count;else{if(!r.added&&this.useLongestToken){let p=t.slice(s,s+r.count);p=p.map(function(f,m){const h=n[d+m];return h.length>f.length?h:f}),r.value=this.join(p)}else r.value=this.join(t.slice(s,s+r.count));s+=r.count,r.added||(d+=r.count)}}return o}}class E extends N{constructor(){super(...arguments),this.tokenize=I}equals(e,t,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
2
- `))&&(e=e.trim()),(!n.newlineIsToken||!t.includes(`
3
- `))&&(t=t.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(e.endsWith(`
4
- `)&&(e=e.slice(0,-1)),t.endsWith(`
5
- `)&&(t=t.slice(0,-1))),super.equals(e,t,n)}}const T=new E;function D(a,e,t){return T.diff(a,e,t)}function I(a,e){e.stripTrailingCr&&(a=a.replace(/\r\n/g,`
6
- `));const t=[],n=a.split(/(\n|\r\n)/);n[n.length-1]||n.pop();for(let o=0;o<n.length;o++){const i=n[o];o%2&&!e.newlineIsToken?t[t.length-1]+=i:t.push(i)}return t}function M(a){const e=a.split(`
7
- `);return e.length>0&&e[e.length-1]===""&&e.pop(),e}function j(a){return a.added?"added":a.removed?"removed":"context"}function z(a,e){const t=D(a,e),n=[],o=[],i=[];let u=0,c=0,s=0,d=0,r=0;for(const p of t){const f=j(p),m=M(p.value);f==="added"&&(d+=m.length),f==="removed"&&(r+=m.length);for(const h of m){if(f==="context"&&(u+=1),n.push({type:f,sign:f==="added"?"+":f==="removed"?"-":" ",lineNumber:f==="context"?u:null,content:h||" "}),f==="added"){s+=1,o.push({type:"empty",content:"",lineNumber:null}),i.push({type:"added",content:h||" ",lineNumber:s});continue}if(f==="removed"){c+=1,o.push({type:"removed",content:h||" ",lineNumber:c}),i.push({type:"empty",content:"",lineNumber:null});continue}c+=1,s+=1,o.push({type:"context",content:h||" ",lineNumber:c}),i.push({type:"context",content:h||" ",lineNumber:s})}}return{unifiedLines:n,split:{left:o,right:i},stats:{added:d,removed:r}}}postMessage({type:"ready"}),addEventListener("message",a=>{const{id:e,oldCode:t,newCode:n}=a.data;try{const o=z(t,n);postMessage({id:e,model:o})}catch(o){const i={id:e,model:{unifiedLines:[],split:{left:[],right:[]},stats:{added:0,removed:0}},error:o instanceof Error?o.message:"Failed to compute diff"};postMessage(i)}})})();