@fileverse-dev/ddoc 6.0.1 → 6.0.3
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/data-BCRDUrcS.mjs +59842 -0
- package/dist/{ddoc-persistence-C2ay3lLb.mjs → ddoc-persistence-DLdSviUr.mjs} +14 -13
- package/dist/headless-editor-utils.es.js +1 -1
- package/dist/index-DMZzrBLQ.mjs +14053 -0
- package/dist/index.es.js +10772 -21550
- package/dist/markdown-source-pane-BJbpMXo2.mjs +143 -0
- package/dist/package/extensions/emoji/components/emoji-utils.d.ts +2 -2
- package/dist/package/types.d.ts +3 -0
- package/dist/persistence.es.js +1 -1
- package/dist/{split-view-toolbar-DrK-Wp2F.mjs → split-view-toolbar-6aBSjsO2.mjs} +47 -46
- package/dist/tab-utils-BNFvrUAj.mjs +284 -0
- package/dist/use-headless-editor-CjWKprQH.mjs +44475 -0
- package/package.json +5 -2
- package/dist/index-By29BevC.mjs +0 -13126
- package/dist/markdown-source-pane-CYcEKMfr.mjs +0 -6069
- package/dist/tab-utils-CAcIp-Dt.mjs +0 -313
- package/dist/use-headless-editor-BIcZNvlS.mjs +0 -162510
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
var k = Object.defineProperty;
|
|
2
|
+
var v = (t, o, r) => o in t ? k(t, o, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[o] = r;
|
|
3
|
+
var d = (t, o, r) => v(t, typeof o != "symbol" ? o + "" : o, r);
|
|
4
|
+
import { jsx as C } from "react/jsx-runtime";
|
|
5
|
+
import { useRef as m, useEffect as f } from "react";
|
|
6
|
+
import { EditorState as b, Annotation as L, Transaction as S, RangeSetBuilder as y } from "@codemirror/state";
|
|
7
|
+
import { EditorView as u, lineNumbers as D, highlightActiveLine as E, highlightActiveLineGutter as w, keymap as H, ViewPlugin as P, placeholder as N, Decoration as A } from "@codemirror/view";
|
|
8
|
+
import { history as M, defaultKeymap as T, historyKeymap as W } from "@codemirror/commands";
|
|
9
|
+
import { markdown as $ } from "@codemirror/lang-markdown";
|
|
10
|
+
import { syntaxHighlighting as G, defaultHighlightStyle as K, syntaxTree as F } from "@codemirror/language";
|
|
11
|
+
const I = "Write your ideas. Watch them grow. 🌱", h = L.define(), O = /^https?:\/\/\S+$/i, R = u.domEventHandlers({
|
|
12
|
+
paste(t, o) {
|
|
13
|
+
var c, a;
|
|
14
|
+
const r = (a = (c = t.clipboardData) == null ? void 0 : c.getData("text/plain")) == null ? void 0 : a.trim();
|
|
15
|
+
if (!r || !O.test(r)) return !1;
|
|
16
|
+
const { from: s, to: e } = o.state.selection.main, l = o.state.sliceDoc(s, e), n = l ? `[${l}](${r})` : `<${r}>`;
|
|
17
|
+
return t.preventDefault(), o.dispatch({
|
|
18
|
+
changes: { from: s, to: e, insert: n },
|
|
19
|
+
selection: { anchor: s + n.length }
|
|
20
|
+
}), !0;
|
|
21
|
+
}
|
|
22
|
+
}), U = A.mark({ class: "cm-md-link" }), _ = /* @__PURE__ */ new Set(["Link", "Autolink"]), p = (t) => {
|
|
23
|
+
const o = new y();
|
|
24
|
+
for (const { from: r, to: s } of t.visibleRanges)
|
|
25
|
+
F(t.state).iterate({
|
|
26
|
+
from: r,
|
|
27
|
+
to: s,
|
|
28
|
+
enter: (e) => {
|
|
29
|
+
_.has(e.name) && e.to > e.from && o.add(e.from, e.to, U);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return o.finish();
|
|
33
|
+
}, j = P.fromClass(
|
|
34
|
+
class {
|
|
35
|
+
constructor(t) {
|
|
36
|
+
d(this, "decorations");
|
|
37
|
+
this.decorations = p(t);
|
|
38
|
+
}
|
|
39
|
+
update(t) {
|
|
40
|
+
(t.docChanged || t.viewportChanged) && (this.decorations = p(t.view));
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
{ decorations: (t) => t.decorations }
|
|
44
|
+
), z = u.theme({
|
|
45
|
+
"&": {
|
|
46
|
+
height: "100%",
|
|
47
|
+
fontSize: "14px",
|
|
48
|
+
backgroundColor: "transparent",
|
|
49
|
+
color: "hsl(var(--color-text-default))"
|
|
50
|
+
},
|
|
51
|
+
".cm-scroller": {
|
|
52
|
+
fontFamily: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",
|
|
53
|
+
lineHeight: "1.7",
|
|
54
|
+
padding: "12px 16px 12px 8px"
|
|
55
|
+
},
|
|
56
|
+
".cm-content": { caretColor: "hsl(var(--color-text-default))", padding: "0" },
|
|
57
|
+
"&.cm-focused": { outline: "none" },
|
|
58
|
+
".cm-gutters": {
|
|
59
|
+
backgroundColor: "transparent",
|
|
60
|
+
border: "none",
|
|
61
|
+
color: "hsl(var(--color-text-secondary))"
|
|
62
|
+
},
|
|
63
|
+
".cm-lineNumbers .cm-gutterElement": {
|
|
64
|
+
minWidth: "26px",
|
|
65
|
+
padding: "0 8px 0 4px"
|
|
66
|
+
},
|
|
67
|
+
".cm-activeLine": { backgroundColor: "hsl(var(--color-bg-secondary))" },
|
|
68
|
+
".cm-activeLineGutter": { backgroundColor: "transparent" },
|
|
69
|
+
".cm-cursor, .cm-dropCursor": {
|
|
70
|
+
borderLeftColor: "hsl(var(--color-text-default))"
|
|
71
|
+
},
|
|
72
|
+
// Markdown links use the editor's text-link token (override the default
|
|
73
|
+
// syntax color, incl. the inner highlight spans).
|
|
74
|
+
".cm-md-link, .cm-md-link span": {
|
|
75
|
+
color: "hsla(var(--color-text-link)) !important"
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
function tt({
|
|
79
|
+
value: t,
|
|
80
|
+
onChange: o,
|
|
81
|
+
onViewReady: r
|
|
82
|
+
}) {
|
|
83
|
+
const s = m(null), e = m(null), l = m(o);
|
|
84
|
+
l.current = o;
|
|
85
|
+
const n = m(r);
|
|
86
|
+
return n.current = r, f(() => {
|
|
87
|
+
var a;
|
|
88
|
+
if (!s.current) return;
|
|
89
|
+
const c = new u({
|
|
90
|
+
parent: s.current,
|
|
91
|
+
state: b.create({
|
|
92
|
+
doc: t,
|
|
93
|
+
extensions: [
|
|
94
|
+
D(),
|
|
95
|
+
E(),
|
|
96
|
+
w(),
|
|
97
|
+
M(),
|
|
98
|
+
// Swallow Ctrl/Cmd+S so it doesn't open the browser "Save page"
|
|
99
|
+
// dialog — there's no manual save in Split View (changes are live).
|
|
100
|
+
H.of([
|
|
101
|
+
{ key: "Mod-s", run: () => !0, preventDefault: !0 },
|
|
102
|
+
...T,
|
|
103
|
+
...W
|
|
104
|
+
]),
|
|
105
|
+
$(),
|
|
106
|
+
G(K),
|
|
107
|
+
j,
|
|
108
|
+
R,
|
|
109
|
+
N(I),
|
|
110
|
+
u.lineWrapping,
|
|
111
|
+
z,
|
|
112
|
+
u.updateListener.of((i) => {
|
|
113
|
+
const g = i.transactions.some(
|
|
114
|
+
(x) => x.annotation(h)
|
|
115
|
+
);
|
|
116
|
+
i.docChanged && !g && l.current(i.state.doc.toString());
|
|
117
|
+
})
|
|
118
|
+
]
|
|
119
|
+
})
|
|
120
|
+
});
|
|
121
|
+
return e.current = c, (a = n.current) == null || a.call(n, c), () => {
|
|
122
|
+
var i;
|
|
123
|
+
(i = n.current) == null || i.call(n, null), c.destroy(), e.current = null;
|
|
124
|
+
};
|
|
125
|
+
}, []), f(() => {
|
|
126
|
+
const c = e.current;
|
|
127
|
+
if (!c) return;
|
|
128
|
+
const a = c.state.doc.toString();
|
|
129
|
+
t !== a && c.dispatch({
|
|
130
|
+
changes: { from: 0, to: a.length, insert: t },
|
|
131
|
+
// Keep the seed out of the undo history: its base state is the empty
|
|
132
|
+
// mount-time doc, so an undo would revert the pane to empty and the
|
|
133
|
+
// change listener would replace the whole document with nothing.
|
|
134
|
+
annotations: [
|
|
135
|
+
h.of(!0),
|
|
136
|
+
S.addToHistory.of(!1)
|
|
137
|
+
]
|
|
138
|
+
});
|
|
139
|
+
}, [t]), /* @__PURE__ */ C("div", { ref: s, className: "w-full h-full overflow-auto" });
|
|
140
|
+
}
|
|
141
|
+
export {
|
|
142
|
+
tt as default
|
|
143
|
+
};
|
package/dist/package/types.d.ts
CHANGED
package/dist/persistence.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as n, a as o, d as D, g as a, m as r, r as d, b as C } from "./ddoc-persistence-
|
|
1
|
+
import { D as n, a as o, d as D, g as a, m as r, r as d, b as C } from "./ddoc-persistence-DLdSviUr.mjs";
|
|
2
2
|
export {
|
|
3
3
|
n as DDOC_STORE_REPAIRED,
|
|
4
4
|
o as DEFAULT_DDOC_PERSISTENCE_TIMEOUT_MS,
|
|
@@ -1,66 +1,67 @@
|
|
|
1
1
|
import { jsx as m, jsxs as L } from "react/jsx-runtime";
|
|
2
2
|
import { useRef as D, useState as E, useEffect as A } from "react";
|
|
3
3
|
import { DynamicDropdown as P, Tooltip as O, IconButton as T } from "@fileverse/ui";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
t.
|
|
4
|
+
import { EditorSelection as R } from "@codemirror/state";
|
|
5
|
+
import { redo as _, undo as w } from "@codemirror/commands";
|
|
6
|
+
const p = (e, t, o = t) => {
|
|
7
|
+
const { state: i } = e, l = i.changeByRange((n) => {
|
|
8
|
+
const d = i.sliceDoc(n.from, n.to), r = i.sliceDoc(
|
|
9
|
+
Math.max(0, n.from - t.length),
|
|
10
|
+
n.from
|
|
10
11
|
), u = i.sliceDoc(
|
|
11
|
-
|
|
12
|
-
Math.min(i.doc.length,
|
|
12
|
+
n.to,
|
|
13
|
+
Math.min(i.doc.length, n.to + o.length)
|
|
13
14
|
);
|
|
14
|
-
if (r ===
|
|
15
|
+
if (r === t && u === o)
|
|
15
16
|
return {
|
|
16
17
|
changes: [
|
|
17
|
-
{ from:
|
|
18
|
-
{ from:
|
|
18
|
+
{ from: n.from - t.length, to: n.from, insert: "" },
|
|
19
|
+
{ from: n.to, to: n.to + o.length, insert: "" }
|
|
19
20
|
],
|
|
20
21
|
range: R.range(
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
n.from - t.length,
|
|
23
|
+
n.to - t.length
|
|
23
24
|
)
|
|
24
25
|
};
|
|
25
|
-
const b =
|
|
26
|
+
const b = t + d + o;
|
|
26
27
|
return {
|
|
27
|
-
changes: { from:
|
|
28
|
+
changes: { from: n.from, to: n.to, insert: b },
|
|
28
29
|
range: R.range(
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
n.from + t.length,
|
|
31
|
+
n.from + t.length + d.length
|
|
31
32
|
)
|
|
32
33
|
};
|
|
33
34
|
});
|
|
34
35
|
e.dispatch(i.update(l, { scrollIntoView: !0 })), e.focus();
|
|
35
|
-
}, B = (e,
|
|
36
|
+
}, B = (e, t) => {
|
|
36
37
|
const { state: o } = e, i = [], l = /* @__PURE__ */ new Set();
|
|
37
|
-
for (const
|
|
38
|
-
let d =
|
|
38
|
+
for (const n of o.selection.ranges) {
|
|
39
|
+
let d = n.from;
|
|
39
40
|
for (; ; ) {
|
|
40
41
|
const r = o.doc.lineAt(d);
|
|
41
42
|
if (!l.has(r.number)) {
|
|
42
43
|
l.add(r.number);
|
|
43
|
-
const u =
|
|
44
|
+
const u = t(r.text, r.from);
|
|
44
45
|
u && i.push(u);
|
|
45
46
|
}
|
|
46
|
-
if (r.to >=
|
|
47
|
+
if (r.to >= n.to) break;
|
|
47
48
|
d = r.to + 1;
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
51
|
i.length && e.dispatch(o.update({ changes: i, scrollIntoView: !0 })), e.focus();
|
|
51
|
-
}, y = (e,
|
|
52
|
+
}, y = (e, t) => B(
|
|
52
53
|
e,
|
|
53
|
-
(o, i) => o.startsWith(
|
|
54
|
-
), z = (e,
|
|
55
|
-
const o = "#".repeat(
|
|
54
|
+
(o, i) => o.startsWith(t) ? { from: i, to: i + t.length, insert: "" } : { from: i, insert: t }
|
|
55
|
+
), z = (e, t) => {
|
|
56
|
+
const o = "#".repeat(t) + " ";
|
|
56
57
|
return B(e, (i, l) => {
|
|
57
|
-
const
|
|
58
|
-
return
|
|
58
|
+
const n = i.match(/^(#{1,6})\s/);
|
|
59
|
+
return n && n[1].length === t ? { from: l, to: l + n[0].length, insert: "" } : n ? { from: l, to: l + n[0].length, insert: o } : { from: l, insert: o };
|
|
59
60
|
});
|
|
60
|
-
}, f = (e,
|
|
61
|
+
}, f = (e, t) => {
|
|
61
62
|
const { state: o } = e, i = o.selection.main, r = `${o.doc.lineAt(i.from).text.trim() === "" ? "" : `
|
|
62
63
|
|
|
63
|
-
`}${
|
|
64
|
+
`}${t}
|
|
64
65
|
`;
|
|
65
66
|
e.dispatch(
|
|
66
67
|
o.update({
|
|
@@ -69,19 +70,19 @@ const p = (e, n, o = n) => {
|
|
|
69
70
|
scrollIntoView: !0
|
|
70
71
|
})
|
|
71
72
|
), e.focus();
|
|
72
|
-
}, G = (e,
|
|
73
|
+
}, G = (e, t) => {
|
|
73
74
|
const { state: o } = e, i = o.changeByRange((l) => {
|
|
74
|
-
const
|
|
75
|
+
const n = o.sliceDoc(l.from, l.to) || "text", d = t ?? "url", r = `[${n}](${d})`, u = l.from + 1 + n.length + 2;
|
|
75
76
|
return {
|
|
76
77
|
changes: { from: l.from, to: l.to, insert: r },
|
|
77
78
|
range: R.range(u, u + d.length)
|
|
78
79
|
};
|
|
79
80
|
});
|
|
80
81
|
e.dispatch(o.update(i, { scrollIntoView: !0 })), e.focus();
|
|
81
|
-
}, K = (e,
|
|
82
|
-
const o = `<img src="${
|
|
82
|
+
}, K = (e, t) => {
|
|
83
|
+
const o = `<img src="${t.src}" media-type="secure-img" encryptionKey="${t.encryptionKey}" nonce="${t.nonce}" ipfsUrl="${t.ipfsUrl}" ipfsHash="${t.ipfsHash}" version="2" authTag="${t.authTag}" mimeType="${t.mimeType}" />`;
|
|
83
84
|
f(e, o);
|
|
84
|
-
}, M = (e,
|
|
85
|
+
}, M = (e, t) => f(e, `<img src="${t}" media-type="img" />`), W = `| Column 1 | Column 2 |
|
|
85
86
|
| -------- | -------- |
|
|
86
87
|
| | |`, c = {
|
|
87
88
|
bold: (e) => p(e, "**"),
|
|
@@ -89,7 +90,7 @@ const p = (e, n, o = n) => {
|
|
|
89
90
|
strike: (e) => p(e, "~~"),
|
|
90
91
|
inlineCode: (e) => p(e, "`"),
|
|
91
92
|
underline: (e) => p(e, "<u>", "</u>"),
|
|
92
|
-
heading: (e,
|
|
93
|
+
heading: (e, t) => z(e, t),
|
|
93
94
|
bulletList: (e) => y(e, "- "),
|
|
94
95
|
orderedList: (e) => y(e, "1. "),
|
|
95
96
|
taskList: (e) => y(e, "- [ ] "),
|
|
@@ -97,7 +98,7 @@ const p = (e, n, o = n) => {
|
|
|
97
98
|
codeBlock: (e) => f(e, "```\n\n```"),
|
|
98
99
|
horizontalRule: (e) => f(e, "---"),
|
|
99
100
|
table: (e) => f(e, W),
|
|
100
|
-
link: (e,
|
|
101
|
+
link: (e, t) => G(e, t),
|
|
101
102
|
undo: (e) => {
|
|
102
103
|
w(e), e.focus();
|
|
103
104
|
},
|
|
@@ -105,7 +106,7 @@ const p = (e, n, o = n) => {
|
|
|
105
106
|
_(e), e.focus();
|
|
106
107
|
},
|
|
107
108
|
// Highlight → inline HTML (round-trips via our turndown/DOMPurify rules).
|
|
108
|
-
highlight: (e,
|
|
109
|
+
highlight: (e, t) => t ? p(e, `<mark style="background-color: ${t}">`, "</mark>") : p(e, "<mark>", "</mark>")
|
|
109
110
|
}, H = [
|
|
110
111
|
[
|
|
111
112
|
{ icon: "Undo", label: "Undo", run: (e) => c.undo(e) },
|
|
@@ -188,9 +189,9 @@ const p = (e, n, o = n) => {
|
|
|
188
189
|
}
|
|
189
190
|
]
|
|
190
191
|
], $ = 3, V = H.slice(0, $), U = H.slice($), S = "!h-6 !w-6 !min-w-0", j = 560, C = () => /* @__PURE__ */ m("div", { className: "w-[1px] h-4 vertical-divider mx-1" });
|
|
191
|
-
function
|
|
192
|
+
function J({
|
|
192
193
|
view: e,
|
|
193
|
-
ipfsImageUploadFn:
|
|
194
|
+
ipfsImageUploadFn: t,
|
|
194
195
|
onError: o
|
|
195
196
|
}) {
|
|
196
197
|
const i = (s) => {
|
|
@@ -200,8 +201,8 @@ function X({
|
|
|
200
201
|
const h = (x = a.files) == null ? void 0 : x[0];
|
|
201
202
|
if (!(!h || !h.type.includes("image/")))
|
|
202
203
|
try {
|
|
203
|
-
if (
|
|
204
|
-
const g = await
|
|
204
|
+
if (t) {
|
|
205
|
+
const g = await t(h);
|
|
205
206
|
K(s, {
|
|
206
207
|
src: URL.createObjectURL(h),
|
|
207
208
|
ipfsUrl: g.ipfsUrl,
|
|
@@ -228,9 +229,9 @@ function X({
|
|
|
228
229
|
return;
|
|
229
230
|
}
|
|
230
231
|
s.run(a);
|
|
231
|
-
},
|
|
232
|
+
}, n = D(null), [d, r] = E(!1);
|
|
232
233
|
A(() => {
|
|
233
|
-
const s =
|
|
234
|
+
const s = n.current;
|
|
234
235
|
if (!s || typeof ResizeObserver > "u") return;
|
|
235
236
|
const a = () => r(s.clientWidth < j);
|
|
236
237
|
a();
|
|
@@ -254,7 +255,7 @@ function X({
|
|
|
254
255
|
return /* @__PURE__ */ m("div", { className: "flex items-center px-2 py-2 border-b color-border-default shrink-0", children: /* @__PURE__ */ L(
|
|
255
256
|
"div",
|
|
256
257
|
{
|
|
257
|
-
ref:
|
|
258
|
+
ref: n,
|
|
258
259
|
className: "flex items-center gap-0.5 flex-1 min-w-0 overflow-hidden",
|
|
259
260
|
children: [
|
|
260
261
|
V.map((s, a) => b(s, a > 0)),
|
|
@@ -285,5 +286,5 @@ function X({
|
|
|
285
286
|
) });
|
|
286
287
|
}
|
|
287
288
|
export {
|
|
288
|
-
|
|
289
|
+
J as default
|
|
289
290
|
};
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { fromUint8Array as R, toUint8Array as p } from "js-base64";
|
|
2
|
+
import * as d from "yjs";
|
|
3
|
+
const M = "default", E = "Tab 1", Y = "ddocTabs", F = "tabs_order", S = "tabs_name_registry", N = "tabs_emoji_registry", U = "tabs_state", L = "tabs_delete_registry", A = "activeTabId";
|
|
4
|
+
function m(e) {
|
|
5
|
+
return {
|
|
6
|
+
order: e.getArray(F),
|
|
7
|
+
nameById: e.getMap(S),
|
|
8
|
+
emojiById: e.getMap(N),
|
|
9
|
+
tabState: e.getMap(U),
|
|
10
|
+
// Soft-deleted tabs keep their fragment for undo and late peer updates.
|
|
11
|
+
// This tombstone stops self-heal from resurrecting deleted tabs from stale tab metadata.
|
|
12
|
+
deletedById: e.getMap(L)
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function h(e, t) {
|
|
16
|
+
if (e)
|
|
17
|
+
try {
|
|
18
|
+
if (Array.isArray(e)) {
|
|
19
|
+
const n = e.map((r) => p(r));
|
|
20
|
+
d.applyUpdate(t, d.mergeUpdates(n), "self");
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
d.applyUpdate(t, p(e), "self");
|
|
24
|
+
} catch (n) {
|
|
25
|
+
console.log(n);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function g(e) {
|
|
29
|
+
return e ? e.toArray().filter((t) => typeof t == "string") : [];
|
|
30
|
+
}
|
|
31
|
+
function C(e) {
|
|
32
|
+
const t = e.getMap(Y), n = t.get("order"), r = t.get("tabs"), s = t.get("activeTabId"), l = g(
|
|
33
|
+
n instanceof d.Array ? n : null
|
|
34
|
+
), o = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
|
|
35
|
+
return r instanceof d.Map && r.forEach((u, a) => {
|
|
36
|
+
if (!(u instanceof d.Map) || typeof a != "string") return;
|
|
37
|
+
const i = u.get("name"), c = u.get("emoji");
|
|
38
|
+
typeof i == "string" && o.set(a, i), (typeof c == "string" || c === null) && f.set(a, c);
|
|
39
|
+
}), {
|
|
40
|
+
order: l,
|
|
41
|
+
names: o,
|
|
42
|
+
emojis: f,
|
|
43
|
+
activeTabId: s instanceof d.Text && s.toString() || null,
|
|
44
|
+
deletedIds: /* @__PURE__ */ new Set(),
|
|
45
|
+
hasData: l.length > 0 || o.size > 0 || f.size > 0 || s instanceof d.Text && s.length > 0
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function I(e) {
|
|
49
|
+
const t = m(e), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Set();
|
|
50
|
+
t.nameById.forEach((f, u) => {
|
|
51
|
+
typeof f == "string" && n.set(u, f);
|
|
52
|
+
}), t.emojiById.forEach((f, u) => {
|
|
53
|
+
(typeof f == "string" || f === null) && r.set(u, f);
|
|
54
|
+
}), t.deletedById.forEach((f, u) => {
|
|
55
|
+
f === !0 && s.add(u);
|
|
56
|
+
});
|
|
57
|
+
const l = t.tabState.get(A), o = typeof l == "string" ? l : null;
|
|
58
|
+
return {
|
|
59
|
+
order: g(t.order),
|
|
60
|
+
names: n,
|
|
61
|
+
emojis: r,
|
|
62
|
+
activeTabId: o,
|
|
63
|
+
deletedIds: s,
|
|
64
|
+
hasData: t.order.length > 0 || t.nameById.size > 0 || t.emojiById.size > 0 || t.deletedById.size > 0 || o !== null
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function _(e) {
|
|
68
|
+
const t = /* @__PURE__ */ new Set(), n = [];
|
|
69
|
+
return e.forEach((r) => {
|
|
70
|
+
t.has(r) || (t.add(r), n.push(r));
|
|
71
|
+
}), n;
|
|
72
|
+
}
|
|
73
|
+
function j(e) {
|
|
74
|
+
return e === 0 ? E : `Tab ${e + 1}`;
|
|
75
|
+
}
|
|
76
|
+
function K(e, t) {
|
|
77
|
+
return _([
|
|
78
|
+
...e.order,
|
|
79
|
+
...t.order,
|
|
80
|
+
...Array.from(e.names.keys()),
|
|
81
|
+
...Array.from(e.emojis.keys()),
|
|
82
|
+
...Array.from(t.names.keys()),
|
|
83
|
+
...Array.from(t.emojis.keys())
|
|
84
|
+
]);
|
|
85
|
+
}
|
|
86
|
+
function b(e, t) {
|
|
87
|
+
const n = new Set(e.deletedIds);
|
|
88
|
+
t.forEach((a) => {
|
|
89
|
+
a.deletedIds.forEach((i) => n.add(i));
|
|
90
|
+
});
|
|
91
|
+
const r = /* @__PURE__ */ new Set(), s = [];
|
|
92
|
+
e.order.forEach((a) => {
|
|
93
|
+
!n.has(a) && !r.has(a) && (r.add(a), s.push(a));
|
|
94
|
+
});
|
|
95
|
+
const l = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
|
|
96
|
+
e.names.forEach((a, i) => {
|
|
97
|
+
n.has(i) || l.set(i, a);
|
|
98
|
+
}), e.emojis.forEach((a, i) => {
|
|
99
|
+
n.has(i) || o.set(i, a);
|
|
100
|
+
}), t.forEach((a) => {
|
|
101
|
+
a.order.forEach((i) => {
|
|
102
|
+
n.has(i) || (r.has(i) || (r.add(i), s.push(i)), !l.has(i) && a.names.has(i) && l.set(i, a.names.get(i) ?? E), o.has(i) || o.set(
|
|
103
|
+
i,
|
|
104
|
+
a.emojis.has(i) ? a.emojis.get(i) ?? null : null
|
|
105
|
+
));
|
|
106
|
+
});
|
|
107
|
+
}), s.forEach((a, i) => {
|
|
108
|
+
l.has(a) || l.set(a, j(i)), (!o.has(a) || o.get(a) === void 0) && o.set(a, null);
|
|
109
|
+
});
|
|
110
|
+
const u = [
|
|
111
|
+
e.activeTabId,
|
|
112
|
+
...t.map((a) => a.activeTabId)
|
|
113
|
+
].find(
|
|
114
|
+
(a) => !!a && r.has(a) && !n.has(a)
|
|
115
|
+
) ?? s[0] ?? null;
|
|
116
|
+
return {
|
|
117
|
+
order: s,
|
|
118
|
+
names: l,
|
|
119
|
+
emojis: o,
|
|
120
|
+
activeTabId: u,
|
|
121
|
+
deletedIds: n
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
function z(e, t, n) {
|
|
125
|
+
const r = (n == null ? void 0 : n.createDefaultTabIfMissing) ?? !1, s = new Set(e.deletedIds), l = K(
|
|
126
|
+
e,
|
|
127
|
+
t
|
|
128
|
+
).filter((c) => !s.has(c)), o = _([
|
|
129
|
+
...e.order,
|
|
130
|
+
...t.order
|
|
131
|
+
]);
|
|
132
|
+
l.forEach((c) => {
|
|
133
|
+
o.includes(c) || o.push(c);
|
|
134
|
+
}), o.length === 0 && r && o.push(M);
|
|
135
|
+
const f = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map();
|
|
136
|
+
o.forEach((c, D) => {
|
|
137
|
+
const B = e.names.get(c) ?? t.names.get(c) ?? j(D), O = e.emojis.has(c) ? e.emojis.get(c) ?? null : t.emojis.has(c) ? t.emojis.get(c) ?? null : null;
|
|
138
|
+
f.set(c, B), u.set(c, O);
|
|
139
|
+
});
|
|
140
|
+
const i = [
|
|
141
|
+
e.activeTabId,
|
|
142
|
+
t.activeTabId
|
|
143
|
+
].find(
|
|
144
|
+
(c) => !!c && o.includes(c)
|
|
145
|
+
) ?? o[0] ?? null;
|
|
146
|
+
return {
|
|
147
|
+
order: o,
|
|
148
|
+
names: f,
|
|
149
|
+
emojis: u,
|
|
150
|
+
activeTabId: i,
|
|
151
|
+
deletedIds: s
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
function k(e, t) {
|
|
155
|
+
return e.length !== t.length ? !1 : e.every((n, r) => n === t[r]);
|
|
156
|
+
}
|
|
157
|
+
function V(e, t) {
|
|
158
|
+
const n = g(e);
|
|
159
|
+
return k(n, t) ? !1 : (e.length > 0 && e.delete(0, e.length), t.length > 0 && e.insert(0, t), !0);
|
|
160
|
+
}
|
|
161
|
+
function W(e, t, n) {
|
|
162
|
+
const r = e.get(t);
|
|
163
|
+
return n === null ? r === void 0 ? !1 : (e.delete(t), !0) : r === n ? !1 : (e.set(t, n), !0);
|
|
164
|
+
}
|
|
165
|
+
function T(e, t) {
|
|
166
|
+
let n = !1;
|
|
167
|
+
return Array.from(e.keys()).forEach((r) => {
|
|
168
|
+
t.has(r) || (e.delete(r), n = !0);
|
|
169
|
+
}), t.forEach((r, s) => {
|
|
170
|
+
e.get(s) !== r && (e.set(s, r), n = !0);
|
|
171
|
+
}), n;
|
|
172
|
+
}
|
|
173
|
+
function v(e, t, n = "self") {
|
|
174
|
+
const r = m(e);
|
|
175
|
+
let s = !1;
|
|
176
|
+
const l = new Map(
|
|
177
|
+
Array.from(t.deletedIds, (o) => [o, !0])
|
|
178
|
+
);
|
|
179
|
+
return e.transact(() => {
|
|
180
|
+
t.order.forEach((o) => {
|
|
181
|
+
e.getXmlFragment(o);
|
|
182
|
+
}), s = V(r.order, t.order) || s, s = T(r.nameById, t.names) || s, s = T(r.emojiById, t.emojis) || s, s = W(
|
|
183
|
+
r.tabState,
|
|
184
|
+
A,
|
|
185
|
+
t.activeTabId
|
|
186
|
+
) || s, s = T(r.deletedById, l) || s;
|
|
187
|
+
}, n), s;
|
|
188
|
+
}
|
|
189
|
+
function y(e, t) {
|
|
190
|
+
const n = I(e), r = C(e), s = z(
|
|
191
|
+
n,
|
|
192
|
+
r,
|
|
193
|
+
t
|
|
194
|
+
);
|
|
195
|
+
return {
|
|
196
|
+
tabSnapshotV2: n,
|
|
197
|
+
legacySnapshot: r,
|
|
198
|
+
resolvedTabState: s
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
function w(e, t, n = "self") {
|
|
202
|
+
const { resolvedTabState: r } = y(e, t);
|
|
203
|
+
return v(e, r, n);
|
|
204
|
+
}
|
|
205
|
+
function P(e, t, n) {
|
|
206
|
+
h(e, t);
|
|
207
|
+
const r = w(t, {
|
|
208
|
+
...n,
|
|
209
|
+
createDefaultTabIfMissing: (n == null ? void 0 : n.createDefaultTabIfMissing) ?? !0
|
|
210
|
+
}), s = m(t);
|
|
211
|
+
return {
|
|
212
|
+
tabList: q(s),
|
|
213
|
+
activeTabId: X(s) || M,
|
|
214
|
+
didWrite: r
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
function $(e) {
|
|
218
|
+
return m(e);
|
|
219
|
+
}
|
|
220
|
+
function H(e, t, n = "self") {
|
|
221
|
+
const r = w(e, t, n);
|
|
222
|
+
return {
|
|
223
|
+
...m(e),
|
|
224
|
+
didWrite: r
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
function Q(e, t) {
|
|
228
|
+
const n = e.map((o) => {
|
|
229
|
+
const f = new d.Doc();
|
|
230
|
+
return h(o, f), y(f, t).resolvedTabState;
|
|
231
|
+
}), r = new d.Doc();
|
|
232
|
+
h(e, r);
|
|
233
|
+
const { resolvedTabState: s } = y(
|
|
234
|
+
r,
|
|
235
|
+
t
|
|
236
|
+
), l = b(
|
|
237
|
+
s,
|
|
238
|
+
n
|
|
239
|
+
);
|
|
240
|
+
return v(r, l), R(d.encodeStateAsUpdate(r));
|
|
241
|
+
}
|
|
242
|
+
function X(e) {
|
|
243
|
+
const t = e.tabState.get(A);
|
|
244
|
+
return typeof t == "string" ? t : null;
|
|
245
|
+
}
|
|
246
|
+
function G(e, t) {
|
|
247
|
+
return e.nameById.has(t) ? {
|
|
248
|
+
name: e.nameById.get(t) ?? E,
|
|
249
|
+
emoji: e.emojiById.has(t) ? e.emojiById.get(t) ?? null : null
|
|
250
|
+
} : null;
|
|
251
|
+
}
|
|
252
|
+
function q(e) {
|
|
253
|
+
const t = /* @__PURE__ */ new Set();
|
|
254
|
+
return g(e.order).filter((n) => t.has(n) ? !1 : (t.add(n), !0)).map((n) => {
|
|
255
|
+
const r = G(
|
|
256
|
+
e,
|
|
257
|
+
n
|
|
258
|
+
);
|
|
259
|
+
return r ? {
|
|
260
|
+
id: n,
|
|
261
|
+
name: r.name,
|
|
262
|
+
emoji: r.emoji
|
|
263
|
+
} : null;
|
|
264
|
+
}).filter((n) => n !== null);
|
|
265
|
+
}
|
|
266
|
+
function Z(e) {
|
|
267
|
+
return e.toArray().map((t) => t instanceof d.XmlElement || t instanceof d.XmlText ? t.clone() : null).filter((t) => t !== null);
|
|
268
|
+
}
|
|
269
|
+
export {
|
|
270
|
+
A,
|
|
271
|
+
M as D,
|
|
272
|
+
Y as L,
|
|
273
|
+
F as O,
|
|
274
|
+
U as S,
|
|
275
|
+
G as a,
|
|
276
|
+
X as b,
|
|
277
|
+
Z as c,
|
|
278
|
+
P as d,
|
|
279
|
+
q as e,
|
|
280
|
+
E as f,
|
|
281
|
+
$ as g,
|
|
282
|
+
Q as m,
|
|
283
|
+
H as s
|
|
284
|
+
};
|