@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.
- package/dist/components/chat/blocks/MermaidBlock.d.ts +4 -0
- package/dist/components/chat/blocks/MermaidBlock.js +23 -198
- package/dist/components/chat/hooks/useMermaid.d.ts +3 -2
- package/dist/components/chat/hooks/useMermaid.js +48 -45
- package/dist/components/chat/markdown/fence.d.ts +2 -0
- package/dist/components/chat/markdown/fence.js +14 -0
- package/dist/components/layout/splitWorkspaceModel.d.ts +7 -0
- package/dist/components/layout/splitWorkspaceModel.js +137 -74
- package/dist/diagrams/Diagram.d.ts +30 -0
- package/dist/diagrams/Diagram.js +224 -0
- package/dist/diagrams/render.d.ts +27 -0
- package/dist/diagrams/render.js +107 -0
- package/dist/diagrams.css +29 -0
- package/dist/diagrams.d.ts +4 -0
- package/dist/diagrams.js +9 -0
- package/dist/floe-webapp-core.css +1 -0
- package/dist/full.js +123 -122
- package/dist/layout.js +27 -26
- package/dist/markdown.d.ts +1 -0
- package/dist/markdown.js +9 -7
- package/package.json +23 -6
|
@@ -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 {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { renderMermaid as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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:
|
|
14
|
-
|
|
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
|
-
}),
|
|
19
|
+
}), d;
|
|
19
20
|
}
|
|
20
|
-
function
|
|
21
|
-
|
|
21
|
+
function R(r) {
|
|
22
|
+
l = r;
|
|
22
23
|
}
|
|
23
|
-
async function
|
|
24
|
-
return a ? f ? !0 :
|
|
24
|
+
async function M() {
|
|
25
|
+
return a ? f ? !0 : d ? (await d, !0) : !1 : !1;
|
|
25
26
|
}
|
|
26
|
-
async function
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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:
|
|
41
|
-
}), a.postMessage({ id:
|
|
39
|
+
reject: t
|
|
40
|
+
}), a.postMessage({ id: i, content: r, theme: o });
|
|
42
41
|
});
|
|
43
|
-
if (
|
|
42
|
+
if (l)
|
|
44
43
|
try {
|
|
45
|
-
const
|
|
46
|
-
return
|
|
47
|
-
} catch (
|
|
48
|
-
const
|
|
49
|
-
throw new Error(
|
|
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
|
-
|
|
50
|
+
return (await k(r, e)).svg;
|
|
52
51
|
}
|
|
53
|
-
function
|
|
54
|
-
const [
|
|
52
|
+
function S() {
|
|
53
|
+
const [r, o] = y(!1);
|
|
55
54
|
return {
|
|
56
|
-
render: async (
|
|
55
|
+
render: async (s, n) => {
|
|
57
56
|
o(!0);
|
|
58
57
|
try {
|
|
59
|
-
return await
|
|
58
|
+
return await v(s, n);
|
|
60
59
|
} finally {
|
|
61
60
|
o(!1);
|
|
62
61
|
}
|
|
63
62
|
},
|
|
64
|
-
isLoading:
|
|
63
|
+
isLoading: r
|
|
65
64
|
};
|
|
66
65
|
}
|
|
67
|
-
function
|
|
68
|
-
|
|
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
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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,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[];
|