@floegence/floe-webapp-core 0.86.73 → 0.86.75

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,10 @@
1
1
  import { type Component } from 'solid-js';
2
+ import { type DiagramLabels } from '../../../diagrams/Diagram';
3
+ import '../../../styles/diagrams.css';
2
4
  export interface MermaidBlockProps {
3
5
  content: string;
4
6
  class?: string;
7
+ labels?: DiagramLabels;
5
8
  }
9
+ /** Existing public component, now backed by the shared diagram surface. */
6
10
  export declare const MermaidBlock: Component<MermaidBlockProps>;
@@ -1,200 +1,25 @@
1
- import { insert as a, memo as k, createComponent as u, effect as D, className as ae, Portal as ce, setStyleProperty as W, template as o, delegateEvents as se } from "solid-js/web";
2
- import { createSignal as h, createEffect as O, onCleanup as R, Show as de } from "solid-js";
3
- import { cn as ue } from "../../../utils/cn.js";
4
- import { renderMermaid as me } from "../hooks/useMermaid.js";
5
- import { lockBodyStyle as he } from "../../../utils/bodyStyleLock.js";
6
- import { deferNonBlocking as pe } from "../../../utils/defer.js";
7
- var fe = /* @__PURE__ */ o("<div>"), ge = /* @__PURE__ */ o("<div class=chat-image-dialog-backdrop>"), ye = /* @__PURE__ */ o('<div class=chat-image-dialog><div class=chat-image-dialog-toolbar><button type=button class=chat-image-dialog-btn title="Zoom out (-)"></button><span class=chat-image-dialog-scale>%</span><button type=button class=chat-image-dialog-btn title="Zoom in (+)"></button><button type=button class=chat-image-dialog-btn title="Reset (0)"></button><div class=chat-image-dialog-separator></div><button type=button class=chat-image-dialog-btn title="Close (Esc)"></button></div><div class=chat-image-dialog-content style=touch-action:none><div class=chat-mermaid-dialog-svg></div></div><div class=chat-image-dialog-hint>Scroll/pinch to zoom · Drag to pan · Press Esc to close'), ve = /* @__PURE__ */ o("<div class=chat-mermaid-loading><span>Rendering diagram..."), xe = /* @__PURE__ */ o("<div class=chat-mermaid-error><span>"), $e = /* @__PURE__ */ o('<div class="chat-mermaid-content chat-mermaid-clickable">'), be = /* @__PURE__ */ o('<svg class="animate-spin h-5 w-5"viewBox="0 0 24 24"fill=none><circle class=opacity-25 cx=12 cy=12 r=10 stroke=currentColor stroke-width=4></circle><path class=opacity-75 fill=currentColor d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z">'), ke = /* @__PURE__ */ o('<svg width=16 height=16 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2><circle cx=12 cy=12 r=10></circle><line x1=12 y1=8 x2=12 y2=12></line><line x1=12 y1=16 x2=12.01 y2=16>'), _e = /* @__PURE__ */ o('<svg width=20 height=20 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2><line x1=18 y1=6 x2=6 y2=18></line><line x1=6 y1=6 x2=18 y2=18>'), we = /* @__PURE__ */ o('<svg width=20 height=20 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2><circle cx=11 cy=11 r=8></circle><line x1=21 y1=21 x2=16.65 y2=16.65></line><line x1=11 y1=8 x2=11 y2=14></line><line x1=8 y1=11 x2=14 y2=11>'), Ce = /* @__PURE__ */ o('<svg width=20 height=20 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2><circle cx=11 cy=11 r=8></circle><line x1=21 y1=21 x2=16.65 y2=16.65></line><line x1=8 y1=11 x2=14 y2=11>'), Se = /* @__PURE__ */ o('<svg width=20 height=20 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"></path><path d="M3 3v5h5">');
8
- const Xe = (T) => {
9
- const [$, X] = h(null), [_, Y] = h(null), [j, b] = h(!0), [w, F] = h(!1), [r, C] = h(1), [y, v] = h({
10
- x: 0,
11
- y: 0
12
- }), [G, d] = h(!1);
13
- let S = 0, p = null, I = {
14
- x: 0,
15
- y: 0
16
- };
17
- const i = /* @__PURE__ */ new Map();
18
- let c = null, s = null, f = 0, x = 1;
19
- const J = 0.5, Q = 5, Z = 0.25, ee = (e) => Math.max(J, Math.min(e, Q)), M = (e) => {
20
- const t = ee(e);
21
- C(t), t <= 1 && (v({
22
- x: 0,
23
- y: 0
24
- }), d(!1));
25
- };
26
- O(() => {
27
- const e = ++S, t = T.content;
28
- if (!t) {
29
- X(null), b(!1);
30
- return;
31
- }
32
- b(!0), Y(null), pe(() => {
33
- me(t).then((n) => {
34
- e === S && (X(n), b(!1));
35
- }).catch((n) => {
36
- e === S && (Y(n.message || "Failed to render diagram"), b(!1));
37
- });
38
- });
39
- });
40
- const te = () => {
41
- C(1), v({
42
- x: 0,
43
- y: 0
44
- }), F(!0);
45
- }, E = () => {
46
- F(!1);
47
- }, L = () => {
48
- M(r() + Z);
49
- }, z = () => {
50
- M(r() - Z);
51
- }, N = () => {
52
- C(1), v({
53
- x: 0,
54
- y: 0
55
- }), d(!1);
56
- }, ne = (e) => {
57
- e.preventDefault(), e.deltaY < 0 ? L() : z();
58
- }, ie = (e) => {
59
- if (e.pointerType === "mouse" && e.button !== 0) return;
60
- e.preventDefault();
61
- const t = e.currentTarget;
62
- i.set(e.pointerId, {
63
- x: e.clientX,
64
- y: e.clientY
65
- });
66
- try {
67
- t.setPointerCapture(e.pointerId);
68
- } catch {
69
- }
70
- if (i.size === 1) {
71
- c = {
72
- x: e.clientX,
73
- y: e.clientY
74
- }, s = {
75
- ...y()
76
- }, d(r() > 1);
77
- return;
78
- }
79
- if (i.size === 2) {
80
- const [n, l] = Array.from(i.values());
81
- f = Math.hypot(n.x - l.x, n.y - l.y), x = r(), c = null, s = null, d(!1);
82
- }
83
- }, re = (e) => {
84
- if (i.has(e.pointerId)) {
85
- if (i.set(e.pointerId, {
86
- x: e.clientX,
87
- y: e.clientY
88
- }), i.size === 2) {
89
- const [t, n] = Array.from(i.values()), l = Math.hypot(t.x - n.x, t.y - n.y);
90
- f > 0 && M(x * (l / f));
91
- return;
92
- }
93
- if (!(i.size !== 1 || r() <= 1) && (d(!0), (!c || !s) && (c = {
94
- x: e.clientX,
95
- y: e.clientY
96
- }, s = {
97
- ...y()
98
- }), I = {
99
- x: s.x + (e.clientX - c.x),
100
- y: s.y + (e.clientY - c.y)
101
- }, p === null)) {
102
- if (typeof requestAnimationFrame > "u") {
103
- v(I);
104
- return;
105
- }
106
- p = requestAnimationFrame(() => {
107
- p = null, !(i.size !== 1 || r() <= 1) && v(I);
108
- });
109
- }
110
- }
111
- }, q = (e) => {
112
- i.delete(e.pointerId);
113
- try {
114
- e.currentTarget.releasePointerCapture(e.pointerId);
115
- } catch {
116
- }
117
- if (i.size === 0) {
118
- d(!1), c = null, s = null, f = 0, x = r();
119
- return;
120
- }
121
- if (i.size === 1) {
122
- const t = Array.from(i.values())[0];
123
- c = {
124
- x: t.x,
125
- y: t.y
126
- }, s = {
127
- ...y()
128
- }, d(r() > 1), f = 0, x = r();
129
- return;
130
- }
131
- if (i.size === 2) {
132
- const [t, n] = Array.from(i.values());
133
- f = Math.hypot(t.x - n.x, t.y - n.y), x = r(), c = null, s = null, d(!1);
134
- }
135
- };
136
- return R(() => {
137
- p !== null && typeof cancelAnimationFrame < "u" && (cancelAnimationFrame(p), p = null), i.clear();
138
- }), O(() => {
139
- if (!w()) return;
140
- const e = (t) => {
141
- t.key === "Escape" ? E() : t.key === "+" || t.key === "=" ? L() : t.key === "-" ? z() : t.key === "0" && N();
142
- };
143
- document.addEventListener("keydown", e), R(() => document.removeEventListener("keydown", e));
144
- }), O(() => {
145
- if (!w()) return;
146
- const e = he({
147
- overflow: "hidden"
148
- });
149
- R(e);
150
- }), [(() => {
151
- var e = fe();
152
- return a(e, (() => {
153
- var t = k(() => !!j());
154
- return () => t() && (() => {
155
- var n = ve(), l = n.firstChild;
156
- return a(n, u(Ie, {}), l), n;
157
- })();
158
- })(), null), a(e, (() => {
159
- var t = k(() => !!_());
160
- return () => t() && (() => {
161
- var n = xe(), l = n.firstChild;
162
- return a(n, u(Me, {}), l), a(l, _), n;
163
- })();
164
- })(), null), a(e, (() => {
165
- var t = k(() => !!($() && !_()));
166
- return () => t() && (() => {
167
- var n = $e();
168
- return n.$$click = te, D(() => n.innerHTML = $()), n;
169
- })();
170
- })(), null), D(() => ae(e, ue("chat-mermaid-block", T.class))), e;
171
- })(), u(de, {
172
- get when() {
173
- return k(() => !!w())() && $();
174
- },
175
- get children() {
176
- return u(ce, {
177
- get children() {
178
- return [(() => {
179
- var e = ge();
180
- return e.$$click = E, e;
181
- })(), (() => {
182
- var e = ye(), t = e.firstChild, n = t.firstChild, l = n.nextSibling, le = l.firstChild, A = l.nextSibling, P = A.nextSibling, oe = P.nextSibling, H = oe.nextSibling, g = t.nextSibling, B = g.firstChild;
183
- return n.$$click = z, a(n, u(ze, {})), a(l, () => Math.round(r() * 100), le), A.$$click = L, a(A, u(Le, {})), P.$$click = N, a(P, u(Ae, {})), H.$$click = E, a(H, u(Ee, {})), g.addEventListener("pointercancel", q), g.$$pointerup = q, g.$$pointermove = re, g.$$pointerdown = ie, g.addEventListener("wheel", ne), D((m) => {
184
- var K = `translate(${y().x}px, ${y().y}px) scale(${r()})`, U = r() > 1 ? G() ? "grabbing" : "grab" : "default", V = $();
185
- return K !== m.e && W(B, "transform", m.e = K), U !== m.t && W(B, "cursor", m.t = U), V !== m.a && (B.innerHTML = m.a = V), m;
186
- }, {
187
- e: void 0,
188
- t: void 0,
189
- a: void 0
190
- }), e;
191
- })()];
192
- }
193
- });
194
- }
195
- })];
196
- }, Ie = () => be(), Me = () => ke(), Ee = () => _e(), Le = () => we(), ze = () => Ce(), Ae = () => Se();
197
- se(["click", "pointerdown", "pointermove", "pointerup"]);
1
+ import { createComponent as a } from "solid-js/web";
2
+ import "solid-js";
3
+ import { Diagram as m, diagramLabelsEnUS as n } from "../../../diagrams/Diagram.js";
4
+ import { renderMermaid as o } from "../hooks/useMermaid.js";
5
+ /* empty css */
6
+ const i = (e, r) => o(e, "default", r).then((t) => ({
7
+ svg: t,
8
+ width: 0,
9
+ height: 0,
10
+ type: "mermaid"
11
+ })), u = (e) => a(m, {
12
+ get source() {
13
+ return e.content;
14
+ },
15
+ get class() {
16
+ return e.class;
17
+ },
18
+ get labels() {
19
+ return e.labels ?? n;
20
+ },
21
+ render: i
22
+ });
198
23
  export {
199
- Xe as MermaidBlock
24
+ u as MermaidBlock
200
25
  };
@@ -1,10 +1,11 @@
1
+ import { type DiagramRenderOptions } from '../../../diagrams/render';
1
2
  /**
2
3
  * Configure the Mermaid worker.
3
4
  * Call this during app initialization to enable worker mode.
4
5
  */
5
6
  export declare function configureMermaidWorker(worker: Worker): Promise<void>;
6
7
  /**
7
- * Configure a synchronous Mermaid renderer (fallback).
8
+ * Configure an explicit host Mermaid renderer.
8
9
  * If you don't use a worker, pass a Mermaid instance directly.
9
10
  */
10
11
  export declare function configureSyncMermaid(mermaid: {
@@ -12,7 +13,7 @@ export declare function configureSyncMermaid(mermaid: {
12
13
  svg: string;
13
14
  }>;
14
15
  }): void;
15
- export declare function renderMermaid(content: string, theme?: string): Promise<string>;
16
+ export declare function renderMermaid(content: string, theme?: string, options?: DiagramRenderOptions): Promise<string>;
16
17
  export declare function useMermaid(): {
17
18
  render: (content: string, theme?: string) => Promise<string>;
18
19
  isLoading: import("solid-js").Accessor<boolean>;
@@ -1,76 +1,79 @@
1
1
  import { secureRandomUUID as w } from "../../../utils/secureRandom.js";
2
- import { createSignal as M } from "solid-js";
3
- let a = null, f = !1, c = null;
4
- const l = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), k = 200;
5
- let u = null, p = 0;
6
- function v(n) {
7
- return a = n, c = new Promise((o) => {
2
+ import { createSignal as y } from "solid-js";
3
+ import { sanitizeDiagramSvg as m, renderDiagram as k } from "../../../diagrams/render.js";
4
+ let a = null, f = !1, d = null;
5
+ const c = /* @__PURE__ */ new Map();
6
+ let l = null, p = 0;
7
+ function D(r) {
8
+ return a = r, d = new Promise((o) => {
8
9
  a.onmessage = (e) => {
9
10
  if ("type" in e.data && e.data.type === "ready") {
10
11
  f = !0, o();
11
12
  return;
12
13
  }
13
- const { id: i, svg: d, error: t } = e.data, r = l.get(i);
14
- r && (l.delete(i), t ? r.reject(new Error(t)) : r.resolve(d));
14
+ const { id: s, svg: n, error: t } = e.data, i = c.get(s);
15
+ i && (c.delete(s), t ? i.reject(new Error(t)) : i.resolve(n));
15
16
  }, a.onerror = (e) => {
16
17
  console.error("Mermaid worker error:", e);
17
18
  };
18
- }), c;
19
+ }), d;
19
20
  }
20
- function I(n) {
21
- u = n;
21
+ function R(r) {
22
+ l = r;
22
23
  }
23
- async function h() {
24
- return a ? f ? !0 : c ? (await c, !0) : !1 : !1;
24
+ async function M() {
25
+ return a ? f ? !0 : d ? (await d, !0) : !1 : !1;
25
26
  }
26
- async function W(n, o = "default") {
27
- const e = `${o}:${n}`, i = s.get(e);
28
- if (i) return i;
29
- if (await h() && a)
30
- return new Promise((t, r) => {
31
- const m = w();
32
- l.set(m, {
27
+ async function v(r, o = "default", e = {}) {
28
+ if (await M() && a)
29
+ return new Promise((n, t) => {
30
+ const i = w();
31
+ c.set(i, {
33
32
  resolve: (g) => {
34
- if (s.size >= k) {
35
- const y = s.keys().next().value;
36
- y && s.delete(y);
33
+ try {
34
+ n(m(g, e.document));
35
+ } catch (u) {
36
+ t(u instanceof Error ? u : new Error(String(u)));
37
37
  }
38
- s.set(e, g), t(g);
39
38
  },
40
- reject: r
41
- }), a.postMessage({ id: m, content: n, theme: o });
39
+ reject: t
40
+ }), a.postMessage({ id: i, content: r, theme: o });
42
41
  });
43
- if (u)
42
+ if (l)
44
43
  try {
45
- const t = `mermaid-sync-${p++}`, { svg: r } = await u.render(t, n);
46
- return s.set(e, r), r;
47
- } catch (t) {
48
- const r = t instanceof Error ? t.message : "Failed to render diagram";
49
- throw new Error(r);
44
+ const n = `mermaid-sync-${p++}`, { svg: t } = await l.render(n, r);
45
+ return m(t, e.document);
46
+ } catch (n) {
47
+ const t = n instanceof Error ? n.message : "Failed to render diagram";
48
+ throw new Error(t);
50
49
  }
51
- throw new Error("Mermaid renderer not configured. Call configureMermaidWorker() or configureSyncMermaid() first.");
50
+ return (await k(r, e)).svg;
52
51
  }
53
- function R() {
54
- const [n, o] = M(!1);
52
+ function S() {
53
+ const [r, o] = y(!1);
55
54
  return {
56
- render: async (i, d) => {
55
+ render: async (s, n) => {
57
56
  o(!0);
58
57
  try {
59
- return await W(i, d);
58
+ return await v(s, n);
60
59
  } finally {
61
60
  o(!1);
62
61
  }
63
62
  },
64
- isLoading: n
63
+ isLoading: r
65
64
  };
66
65
  }
67
- function S() {
68
- a && (a.terminate(), a = null, f = !1, c = null, l.clear()), s.clear();
66
+ function I() {
67
+ if (a) {
68
+ a.terminate(), a = null, f = !1, d = null;
69
+ for (const r of c.values()) r.reject(new Error("Diagram worker terminated."));
70
+ c.clear();
71
+ }
69
72
  }
70
73
  export {
71
- v as configureMermaidWorker,
72
- I as configureSyncMermaid,
73
- W as renderMermaid,
74
- S as terminateMermaidWorker,
75
- R as useMermaid
74
+ D as configureMermaidWorker,
75
+ R as configureSyncMermaid,
76
+ v as renderMermaid,
77
+ I as terminateMermaidWorker,
78
+ S as useMermaid
76
79
  };
@@ -0,0 +1,2 @@
1
+ /** A matching CommonMark fence, independent of whether streaming has ended. */
2
+ export declare function isClosedMarkdownFence(raw: string): boolean;
@@ -0,0 +1,14 @@
1
+ function r(s) {
2
+ const e = s.replace(/\r\n?/g, `
3
+ `).split(`
4
+ `), t = e[0]?.match(/^[ ]{0,3}(\x60{3,}|~{3,})/);
5
+ if (!t) return !1;
6
+ const c = t[1];
7
+ return e.slice(1).some((o) => {
8
+ const n = o.match(/^[ ]{0,3}(\x60+|~+)[ \t]*$/)?.[1];
9
+ return !!n && n[0] === c[0] && n.length >= c.length;
10
+ });
11
+ }
12
+ export {
13
+ r as isClosedMarkdownFence
14
+ };
@@ -36,3 +36,10 @@ export declare function measureSplitWorkspace(layout: SplitWorkspaceLayout | nul
36
36
  panes: Map<string, SplitWorkspaceRect>;
37
37
  dividers: SplitWorkspaceDivider[];
38
38
  };
39
+ export interface SplitWorkspaceArrangement {
40
+ id: string;
41
+ kind: 'rows' | 'columns' | 'grid' | 'main-left' | 'main-right' | 'main-top' | 'main-bottom';
42
+ layout: SplitWorkspaceLayout;
43
+ }
44
+ /** Bounded alternatives that preserve every item in visual reading order. */
45
+ export declare function createSplitWorkspaceArrangements(itemIds: readonly string[], id: () => string): SplitWorkspaceArrangement[];