@floegence/floe-webapp-core 0.81.5 → 0.82.0

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
+ };
@@ -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 {
@@ -1,8 +1,8 @@
1
- function F(a) {
2
- const { surface: l } = a, I = l.ownerDocument, s = I.defaultView;
3
- if (!s) throw new Error("Remote pointer requires an attached document");
4
- let o = null, f = null, u = null, p = null, k = 0, z = !1, L = 0, M = 0, C = !1, H = !1, D = 0, b = !1;
5
- const g = /* @__PURE__ */ new Set(), O = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Map(), K = [], w = (e) => !H && a.isTargetValid(e), E = (e, t) => Math.hypot(e.clientX - t.clientX, e.clientY - t.clientY), v = (e) => ({
1
+ function R(d) {
2
+ const { surface: l } = d, I = l.ownerDocument, c = I.defaultView;
3
+ if (!c) throw new Error("Remote pointer requires an attached document");
4
+ let o = null, f = null, u = null, p = null, y = 0, z = !1, L = 0, O = 0, H = !1, K = !1, b = 0, D = !1;
5
+ const m = /* @__PURE__ */ new Set(), E = /* @__PURE__ */ new Set(), g = /* @__PURE__ */ new Map(), P = [], k = (e) => !K && d.isTargetValid(e), x = (e, t) => Math.hypot(e.clientX - t.clientX, e.clientY - t.clientY), h = (e) => ({
6
6
  clientX: e.clientX,
7
7
  clientY: e.clientY,
8
8
  shiftKey: e.shiftKey,
@@ -11,200 +11,203 @@ function F(a) {
11
11
  metaKey: e.metaKey,
12
12
  pointerType: "pointerType" in e ? String(e.pointerType) : "mouse"
13
13
  });
14
- function d(e, t, n, i = !1) {
15
- const c = n;
16
- e.addEventListener(t, c, { capture: i, passive: !1 }), K.push(() => e.removeEventListener(t, c, i));
14
+ function a(e, t, n, i = !1) {
15
+ const s = n;
16
+ e.addEventListener(t, s, { capture: i, passive: !1 }), P.push(() => e.removeEventListener(t, s, i));
17
17
  }
18
- function Y(e, t) {
19
- const n = w(t) && a.sendPointer(e, t) !== !1;
18
+ function _(e, t) {
19
+ const n = k(t) && d.sendPointer(e, t) !== !1;
20
20
  if (n && e.kind === "move")
21
- for (const i of h.values()) i.target === t && (i.command = { ...i.command, ...v(e) });
21
+ for (const i of g.values()) i.target === t && (i.command = { ...i.command, ...h(e) });
22
22
  return n;
23
23
  }
24
- function P() {
25
- s.clearTimeout(M), M = 0, C && (C = !1, a.onHoldChange?.(null));
24
+ function X() {
25
+ c.clearTimeout(O), O = 0, H && (H = !1, d.onHoldChange?.(null));
26
26
  }
27
- function _(e) {
28
- O.delete(e), l.hasPointerCapture?.(e) && l.releasePointerCapture(e);
27
+ function A(e) {
28
+ E.delete(e), l.hasPointerCapture?.(e) && l.releasePointerCapture(e);
29
29
  }
30
- function q(e) {
31
- l.setPointerCapture?.(e), O.add(e);
30
+ function N(e) {
31
+ l.setPointerCapture?.(e), E.add(e);
32
32
  }
33
- function y() {
34
- L++, z = !1, k && s.cancelAnimationFrame(k), k = 0;
33
+ function v() {
34
+ L++, z = !1, y && c.cancelAnimationFrame(y), y = 0;
35
35
  const e = f;
36
- f = null, e && !Y(e.command, e.target) && r();
36
+ f = null, e && !_(e.command, e.target) && r();
37
37
  }
38
- function x(e, t) {
39
- if (f && (f.target !== t || f.command.kind !== e.kind) && y(), !!w(t)) {
38
+ function C(e, t) {
39
+ if (f && (f.target !== t || f.command.kind !== e.kind) && v(), !!k(t)) {
40
40
  if (e.kind === "scroll" && f?.command.kind === "scroll" && (e = { ...e, dx: f.command.dx + e.dx, dy: f.command.dy + e.dy }), f = { target: t, command: e }, e.kind === "move") {
41
41
  if (!z) {
42
42
  z = !0;
43
43
  const n = L;
44
- s.queueMicrotask(() => {
45
- n === L && y();
44
+ c.queueMicrotask(() => {
45
+ n === L && v();
46
46
  });
47
47
  }
48
48
  return;
49
49
  }
50
- if (!k) {
51
- const n = D, i = s.requestAnimationFrame(() => {
52
- n === D && k === i && y();
50
+ if (!y) {
51
+ const n = b, i = c.requestAnimationFrame(() => {
52
+ n === b && y === i && v();
53
53
  });
54
- k = i;
54
+ y = i;
55
55
  }
56
56
  }
57
57
  }
58
- function T(e, t, n, i, c = 1) {
59
- const m = h.get(i);
60
- if (!e && !m) return;
61
- e || h.delete(i);
62
- const U = { ...t, kind: e ? "down" : "up", button: i, clicks: c };
63
- Y(U, n) && e && h.set(i, { target: n, command: U });
58
+ function T(e, t, n, i, s = 1) {
59
+ const w = g.get(i);
60
+ if (!e && !w) return;
61
+ e || g.delete(i);
62
+ const M = { ...t, kind: e ? "down" : "up", button: i, clicks: s };
63
+ _(M, n) && e && g.set(i, { target: n, command: M });
64
64
  }
65
- function X(e, t) {
66
- const n = D;
67
- return a.onActivate?.(e, t), n === D && w(t);
65
+ function Y(e, t) {
66
+ const n = b;
67
+ return d.onActivate?.(e, t), n === b && k(t);
68
68
  }
69
- function A(e, t, n, i = 1) {
70
- X(e, t) && (T(!0, e, t, n, i), T(!1, e, t, n, i));
69
+ function B(e, t, n, i = 1) {
70
+ Y(e, t) && (T(!0, e, t, n, i), T(!1, e, t, n, i));
71
71
  }
72
72
  function r() {
73
- D++, L++, z = !1, P(), k && s.cancelAnimationFrame(k), k = 0;
73
+ b++, L++, z = !1, X(), y && c.cancelAnimationFrame(y), y = 0;
74
74
  const e = /* @__PURE__ */ new Set();
75
- o && e.add(o.target), f && e.add(f.target), u !== null && e.add(u), f = null, o = null, u = null, p = null, b = g.size > 0;
76
- for (const [t, n] of h)
75
+ o && e.add(o.target), f && e.add(f.target), u !== null && e.add(u), f = null, o = null, u = null, p = null, D = m.size > 0;
76
+ for (const [t, n] of g)
77
77
  e.add(n.target), T(!1, n.command, n.target, t);
78
- for (const t of e) a.release(t);
79
- for (const t of [...O]) _(t);
78
+ for (const t of e) d.release(t);
79
+ for (const t of [...E]) A(t);
80
80
  }
81
81
  function S(e) {
82
- g.delete(e), _(e), g.size || (b = !1);
82
+ m.delete(e), A(e), m.size || (D = !1);
83
83
  }
84
- function B(e) {
84
+ function U(e) {
85
85
  const t = o;
86
86
  if (!t || t.id !== e.pointerId) return;
87
- if (!w(t.target)) {
87
+ if (!k(t.target)) {
88
88
  r();
89
89
  return;
90
90
  }
91
- const n = v(e);
92
- if ((t.mode === "pending" || t.mode === "hold") && E(t.origin, n) > 8) {
91
+ const n = h(e);
92
+ if ((t.mode === "pending" || t.mode === "hold") && x(t.origin, n) > 8) {
93
93
  const i = t.mode === "hold";
94
- if (P(), p = null, t.mode = i ? "drag" : "scroll", i && X(t.origin, t.target) && T(!0, t.origin, t.target, 0), o !== t) return;
94
+ if (X(), p = null, t.mode = i ? "drag" : "scroll", i && Y(t.origin, t.target) && T(!0, t.origin, t.target, 0), o !== t) return;
95
95
  }
96
96
  if (t.mode === "scroll") {
97
- const i = t.last, c = i.clientX - n.clientX, m = i.clientY - n.clientY;
98
- (c || m) && x({ ...t.origin, kind: "scroll", dx: c, dy: m }, t.target), t.last = n;
99
- } else t.mode === "drag" && (x({ ...n, kind: "move" }, t.target), t.last = n);
97
+ const i = t.last, s = i.clientX - n.clientX, w = i.clientY - n.clientY;
98
+ (s || w) && C({ ...t.origin, kind: "scroll", dx: s, dy: w }, t.target), t.last = n;
99
+ } else t.mode === "drag" && (C({ ...n, kind: "move" }, t.target), t.last = n);
100
100
  }
101
- d(l, "pointerdown", (e) => {
102
- const t = a.resolveTarget(e);
103
- if (t === null || !w(t)) return;
104
- const n = v(e);
101
+ a(l, "pointerdown", (e) => {
102
+ const t = d.resolveTarget(e);
103
+ if (t === null || !k(t)) return;
104
+ const n = h(e);
105
105
  if (e.pointerType === "touch") {
106
- if (g.add(e.pointerId), g.size > 1 || b) {
106
+ if (m.add(e.pointerId), m.size > 1 || D) {
107
107
  r();
108
108
  return;
109
109
  }
110
- (o || h.size) && r(), y(), u !== null && (a.release(u), u = null), b = !1, o = { id: e.pointerId, target: t, origin: n, last: n, mode: "pending" };
110
+ (o || g.size) && r(), v(), u !== null && (d.release(u), u = null), D = !1, o = { id: e.pointerId, target: t, origin: n, last: n, mode: "pending" };
111
111
  const i = o;
112
- M = s.setTimeout(() => {
113
- if (M = 0, o === i) {
114
- if (!w(t)) {
112
+ O = c.setTimeout(() => {
113
+ if (O = 0, o === i) {
114
+ if (!k(t)) {
115
115
  r();
116
116
  return;
117
117
  }
118
- i.mode = "hold", C = !0, a.onHoldChange?.({ ...n, target: t });
118
+ i.mode = "hold", H = !0, d.onHoldChange?.({ ...n, target: t });
119
119
  }
120
120
  }, 450);
121
121
  } else {
122
- if (g.size) {
122
+ if (m.size) {
123
123
  r();
124
124
  return;
125
125
  }
126
- o && (o.id !== e.pointerId || o.target !== t) && r(), y(), u !== null && (a.release(u), u = null), o = { id: e.pointerId, target: t, origin: n, last: n, mode: "direct" };
127
- const i = e.button === 0 && p?.target === t && s.performance.now() - p.time <= 350 && E(p.position, n) <= 16;
128
- X(n, t) && T(!0, n, t, e.button, Math.max(1, e.detail, i ? 2 : 1));
126
+ o && (o.id !== e.pointerId || o.target !== t) && r(), v(), u !== null && (d.release(u), u = null), o = { id: e.pointerId, target: t, origin: n, last: n, mode: "direct" };
127
+ const i = e.button === 0 && p?.target === t && c.performance.now() - p.time <= 350 && x(p.position, n) <= 16;
128
+ Y(n, t) && T(!0, n, t, e.button, Math.max(1, e.detail, i ? 2 : 1));
129
129
  }
130
- q(e.pointerId), e.pointerType === "touch" && e.preventDefault();
131
- }), d(l, "pointermove", (e) => {
132
- if (e.pointerType === "touch") {
133
- B(e);
134
- return;
135
- }
136
- if (b || g.size) return;
137
- const t = o?.target ?? a.resolveTarget(e);
138
- if (t === null || !w(t)) {
130
+ N(e.pointerId), e.pointerType === "touch" && e.preventDefault();
131
+ });
132
+ const q = "onpointerrawupdate" in c;
133
+ function F(e, t) {
134
+ if (D || m.size) return;
135
+ const n = o?.target ?? d.resolveTarget(e);
136
+ if (n === null || !k(n)) {
139
137
  o && r();
140
138
  return;
141
139
  }
142
- const n = v(e);
140
+ const i = h(e);
143
141
  if (o) {
144
- o.last = n;
145
- for (const [i, c] of [[0, 1], [1, 4], [2, 2], [3, 8], [4, 16]]) {
146
- const m = !!(e.buttons & c);
147
- m !== h.has(i) && (y(), T(m, n, t, i));
142
+ t && (o.last = i);
143
+ for (const [s, w] of [[0, 1], [1, 4], [2, 2], [3, 8], [4, 16]]) {
144
+ const M = !!(e.buttons & w);
145
+ M !== g.has(s) && (v(), T(M, i, n, s));
148
146
  }
149
147
  }
150
- x({ ...n, kind: "move" }, t);
151
- }), d(l, "pointerup", (e) => {
148
+ t && C({ ...i, kind: "move" }, n);
149
+ }
150
+ q && a(l, "pointerrawupdate", (e) => {
151
+ e.pointerType !== "touch" && F(e, !0);
152
+ }), a(l, "pointermove", (e) => {
153
+ e.pointerType === "touch" ? U(e) : F(e, !q);
154
+ }), a(l, "pointerup", (e) => {
152
155
  const t = o;
153
- if (t?.id === e.pointerId && !b)
154
- if (!w(t.target)) r();
156
+ if (t?.id === e.pointerId && !D)
157
+ if (!k(t.target)) r();
155
158
  else if (e.pointerType === "touch") {
156
- B(e), P();
157
- const n = v(e);
159
+ U(e), X();
160
+ const n = h(e);
158
161
  if (t.mode === "pending") {
159
- const i = s.performance.now(), c = p?.target === t.target && i - p.time <= 350 && E(p.position, n) <= 16;
160
- A(n, t.target, 0, c ? 2 : 1), p = c ? null : { target: t.target, position: n, time: i };
161
- } else t.mode === "hold" ? (p = null, A(n, t.target, 2)) : (y(), t.mode === "drag" && T(!1, n, t.target, 0));
162
- a.release(t.target), o = null;
162
+ const i = c.performance.now(), s = p?.target === t.target && i - p.time <= 350 && x(p.position, n) <= 16;
163
+ B(n, t.target, 0, s ? 2 : 1), p = s ? null : { target: t.target, position: n, time: i };
164
+ } else t.mode === "hold" ? (p = null, B(n, t.target, 2)) : (v(), t.mode === "drag" && T(!1, n, t.target, 0));
165
+ d.release(t.target), o = null;
163
166
  } else {
164
- f?.command.kind === "move" && (f.command = { ...v(e), kind: "move" }), y();
165
- const n = h.get(e.button)?.command;
166
- for (const i of [...h.keys()]) T(!1, v(e), t.target, i, n && "clicks" in n ? n.clicks : 1);
167
- p = e.button === 0 && n && "clicks" in n && n.clicks === 1 && E(t.origin, v(e)) <= 8 ? { target: t.target, position: v(e), time: s.performance.now() } : null, h.size || (o = null);
167
+ f?.command.kind === "move" && (f.command = { ...h(e), kind: "move" }), v();
168
+ const n = g.get(e.button)?.command;
169
+ for (const i of [...g.keys()]) T(!1, h(e), t.target, i, n && "clicks" in n ? n.clicks : 1);
170
+ p = e.button === 0 && n && "clicks" in n && n.clicks === 1 && x(t.origin, h(e)) <= 8 ? { target: t.target, position: h(e), time: c.performance.now() } : null, g.size || (o = null);
168
171
  }
169
172
  (!o || o.id !== e.pointerId) && S(e.pointerId);
170
- }), d(l, "pointercancel", (e) => {
173
+ }), a(l, "pointercancel", (e) => {
171
174
  r(), S(e.pointerId);
172
- }), d(l, "lostpointercapture", (e) => {
173
- O.has(e.pointerId) && (r(), S(e.pointerId));
174
- }), d(I, "pointerup", (e) => {
175
+ }), a(l, "lostpointercapture", (e) => {
176
+ E.has(e.pointerId) && (r(), S(e.pointerId));
177
+ }), a(I, "pointerup", (e) => {
175
178
  o?.id !== e.pointerId && S(e.pointerId);
176
- }), d(I, "pointercancel", (e) => S(e.pointerId)), d(I, "pointerdown", (e) => {
177
- o && (e.pointerType === "touch" && e.pointerId !== o.id ? (g.add(e.pointerId), r()) : l.contains(e.target) || r());
178
- }, !0), d(l, "wheel", (e) => {
179
- const t = a.resolveTarget(e);
180
- if (t === null || !w(t) || (e.preventDefault(), o || g.size)) return;
181
- p = null, u !== null && u !== t && (y(), a.release(u)), u = t;
182
- const n = e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? l.clientWidth || s.innerWidth : 1, i = e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? l.clientHeight || s.innerHeight : 1, c = e.deltaX * n, m = e.deltaY * i;
183
- Number.isFinite(c) && Number.isFinite(m) && (c || m) && x({ ...v(e), kind: "scroll", dx: c, dy: m }, t);
179
+ }), a(I, "pointercancel", (e) => S(e.pointerId)), a(I, "pointerdown", (e) => {
180
+ o && (e.pointerType === "touch" && e.pointerId !== o.id ? (m.add(e.pointerId), r()) : l.contains(e.target) || r());
181
+ }, !0), a(l, "wheel", (e) => {
182
+ const t = d.resolveTarget(e);
183
+ if (t === null || !k(t) || (e.preventDefault(), o || m.size)) return;
184
+ p = null, u !== null && u !== t && (v(), d.release(u)), u = t;
185
+ const n = e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? l.clientWidth || c.innerWidth : 1, i = e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? l.clientHeight || c.innerHeight : 1, s = e.deltaX * n, w = e.deltaY * i;
186
+ Number.isFinite(s) && Number.isFinite(w) && (s || w) && C({ ...h(e), kind: "scroll", dx: s, dy: w }, t);
184
187
  });
185
188
  for (const e of ["mousedown", "mouseup", "click", "dblclick", "contextmenu", "dragstart", "selectstart"])
186
- d(l, e, (t) => {
187
- a.resolveTarget(t) !== null && t.preventDefault();
189
+ a(l, e, (t) => {
190
+ d.resolveTarget(t) !== null && t.preventDefault();
188
191
  });
189
- for (const e of ["blur", "pagehide", "resize", "orientationchange"]) d(s, e, r);
190
- if (d(I, "visibilitychange", () => {
192
+ for (const e of ["blur", "pagehide", "resize", "orientationchange"]) a(c, e, r);
193
+ if (a(I, "visibilitychange", () => {
191
194
  I.hidden && r();
192
- }), d(s, "scroll", r, !0), s.visualViewport && (d(s.visualViewport, "resize", r), d(s.visualViewport, "scroll", r)), typeof ResizeObserver < "u") {
195
+ }), a(c, "scroll", r, !0), c.visualViewport && (a(c.visualViewport, "resize", r), a(c.visualViewport, "scroll", r)), typeof ResizeObserver < "u") {
193
196
  let e = `${l.clientWidth}:${l.clientHeight}`;
194
197
  const t = new ResizeObserver(() => {
195
198
  const n = `${l.clientWidth}:${l.clientHeight}`;
196
199
  n !== e && (e = n, r());
197
200
  });
198
- t.observe(l), K.push(() => t.disconnect());
201
+ t.observe(l), P.push(() => t.disconnect());
199
202
  }
200
- return { flush: y, reset: r, dispose() {
201
- if (!H) {
202
- r(), H = !0;
203
- for (const e of K) e();
204
- g.clear();
203
+ return { flush: v, reset: r, dispose() {
204
+ if (!K) {
205
+ r(), K = !0;
206
+ for (const e of P) e();
207
+ m.clear();
205
208
  }
206
209
  } };
207
210
  }
208
211
  export {
209
- F as createRemotePointer
212
+ R as createRemotePointer
210
213
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-core",
3
- "version": "0.81.5",
3
+ "version": "0.82.0",
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)}})})();