@tabula-md/tabula 0.2.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.
- package/README.md +106 -0
- package/dist/activeDocumentRuntime.d.ts +50 -0
- package/dist/activeDocumentRuntime.d.ts.map +1 -0
- package/dist/collabCollaborators.d.ts +16 -0
- package/dist/collabCollaborators.d.ts.map +1 -0
- package/dist/collabConnectionModel.d.ts +11 -0
- package/dist/collabConnectionModel.d.ts.map +1 -0
- package/dist/collabSessionState.d.ts +24 -0
- package/dist/collabSessionState.d.ts.map +1 -0
- package/dist/collaboration.d.ts +8 -0
- package/dist/collaboration.d.ts.map +1 -0
- package/dist/collaboration.js +78 -0
- package/dist/collaboration.js.map +1 -0
- package/dist/collaborationPresence.d.ts +7 -0
- package/dist/collaborationPresence.d.ts.map +1 -0
- package/dist/collaborationTypes.d.ts +27 -0
- package/dist/collaborationTypes.d.ts.map +1 -0
- package/dist/commentRuntimeModel.d.ts +53 -0
- package/dist/commentRuntimeModel.d.ts.map +1 -0
- package/dist/data/base64Url.d.ts +3 -0
- package/dist/data/base64Url.d.ts.map +1 -0
- package/dist/data/encode.d.ts +20 -0
- package/dist/data/encode.d.ts.map +1 -0
- package/dist/data/encode.js +61 -0
- package/dist/data/encode.js.map +1 -0
- package/dist/data/encryption.d.ts +20 -0
- package/dist/data/encryption.d.ts.map +1 -0
- package/dist/data/encryption.js +13 -0
- package/dist/data/encryption.js.map +1 -0
- package/dist/data/json.d.ts +18 -0
- package/dist/data/json.d.ts.map +1 -0
- package/dist/data/json.js +18 -0
- package/dist/data/json.js.map +1 -0
- package/dist/data/restore.d.ts +3 -0
- package/dist/data/restore.d.ts.map +1 -0
- package/dist/data/restore.js +6 -0
- package/dist/data/restore.js.map +1 -0
- package/dist/documentBuffer.d.ts +68 -0
- package/dist/documentBuffer.d.ts.map +1 -0
- package/dist/documentControlsModel.d.ts +58 -0
- package/dist/documentControlsModel.d.ts.map +1 -0
- package/dist/documentMetrics.d.ts +2 -0
- package/dist/documentMetrics.d.ts.map +1 -0
- package/dist/documentPrimitives.d.ts +9 -0
- package/dist/documentPrimitives.d.ts.map +1 -0
- package/dist/documentSurfaceModel.d.ts +44 -0
- package/dist/documentSurfaceModel.d.ts.map +1 -0
- package/dist/encryption-B0xRVvlF.js +82 -0
- package/dist/encryption-B0xRVvlF.js.map +1 -0
- package/dist/index.d.ts +85 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2474 -0
- package/dist/index.js.map +1 -0
- package/dist/jsonShareLinkModel.d.ts +36 -0
- package/dist/jsonShareLinkModel.d.ts.map +1 -0
- package/dist/lineSurfaceModel.d.ts +73 -0
- package/dist/lineSurfaceModel.d.ts.map +1 -0
- package/dist/markdown/editing.d.ts +12 -0
- package/dist/markdown/editing.d.ts.map +1 -0
- package/dist/markdown/links.d.ts +23 -0
- package/dist/markdown/links.d.ts.map +1 -0
- package/dist/markdown/tasks.d.ts +22 -0
- package/dist/markdown/tasks.d.ts.map +1 -0
- package/dist/markdown.d.ts +25 -0
- package/dist/markdown.d.ts.map +1 -0
- package/dist/markdownEditing.d.ts +2 -0
- package/dist/markdownEditing.d.ts.map +1 -0
- package/dist/markdownFormatting.d.ts +11 -0
- package/dist/markdownFormatting.d.ts.map +1 -0
- package/dist/previewBlockModel.d.ts +66 -0
- package/dist/previewBlockModel.d.ts.map +1 -0
- package/dist/productPerformancePolicy.d.ts +14 -0
- package/dist/productPerformancePolicy.d.ts.map +1 -0
- package/dist/rightPanelCommentViewModel.d.ts +39 -0
- package/dist/rightPanelCommentViewModel.d.ts.map +1 -0
- package/dist/room/envelope.d.ts +27 -0
- package/dist/room/envelope.d.ts.map +1 -0
- package/dist/room/envelope.js +38 -0
- package/dist/room/envelope.js.map +1 -0
- package/dist/roomBinaryProtocol.d.ts +43 -0
- package/dist/roomBinaryProtocol.d.ts.map +1 -0
- package/dist/roomCollaboration.d.ts +39 -0
- package/dist/roomCollaboration.d.ts.map +1 -0
- package/dist/roomProtocol.d.ts +11 -0
- package/dist/roomProtocol.d.ts.map +1 -0
- package/dist/roomShareLinkModel.d.ts +20 -0
- package/dist/roomShareLinkModel.d.ts.map +1 -0
- package/dist/shareLinkViewModel.d.ts +8 -0
- package/dist/shareLinkViewModel.d.ts.map +1 -0
- package/dist/shareSnapshotPayload-CsTw9sRq.js +209 -0
- package/dist/shareSnapshotPayload-CsTw9sRq.js.map +1 -0
- package/dist/shareSnapshotPayload.d.ts +75 -0
- package/dist/shareSnapshotPayload.d.ts.map +1 -0
- package/dist/shareViewModel.d.ts +33 -0
- package/dist/shareViewModel.d.ts.map +1 -0
- package/dist/sourceScrollTransfer.d.ts +54 -0
- package/dist/sourceScrollTransfer.d.ts.map +1 -0
- package/dist/statusBarViewModel.d.ts +13 -0
- package/dist/statusBarViewModel.d.ts.map +1 -0
- package/dist/textPatches.d.ts +16 -0
- package/dist/textPatches.d.ts.map +1 -0
- package/dist/workspaceFileRuntimeModel.d.ts +11 -0
- package/dist/workspaceFileRuntimeModel.d.ts.map +1 -0
- package/dist/workspaceIoModel.d.ts +37 -0
- package/dist/workspaceIoModel.d.ts.map +1 -0
- package/dist/workspaceModel.d.ts +112 -0
- package/dist/workspaceModel.d.ts.map +1 -0
- package/dist/workspaceRoomCheckpoint.d.ts +46 -0
- package/dist/workspaceRoomCheckpoint.d.ts.map +1 -0
- package/dist/workspaceRoomCrdt.d.ts +55 -0
- package/dist/workspaceRoomCrdt.d.ts.map +1 -0
- package/dist/workspaceRoomModel-CO-5ZOpS.js +78 -0
- package/dist/workspaceRoomModel-CO-5ZOpS.js.map +1 -0
- package/dist/workspaceRoomModel.d.ts +69 -0
- package/dist/workspaceRoomModel.d.ts.map +1 -0
- package/dist/workspaceRoomSync-B3niC7cn.js +758 -0
- package/dist/workspaceRoomSync-B3niC7cn.js.map +1 -0
- package/dist/workspaceRoomSync.d.ts +98 -0
- package/dist/workspaceRoomSync.d.ts.map +1 -0
- package/dist/workspaceViewModel.d.ts +13 -0
- package/dist/workspaceViewModel.d.ts.map +1 -0
- package/package.json +82 -0
|
@@ -0,0 +1,758 @@
|
|
|
1
|
+
import { decodeEncryptedData as Ue, encodeEncryptedData as De } from "./data/encode.js";
|
|
2
|
+
import { h as T, e as ie, a as U, g as m, W as Le } from "./workspaceRoomModel-CO-5ZOpS.js";
|
|
3
|
+
import * as g from "yjs";
|
|
4
|
+
import * as A from "lib0/decoding";
|
|
5
|
+
import * as p from "lib0/encoding";
|
|
6
|
+
import { encodeAwarenessUpdate as We, applyAwarenessUpdate as Pe } from "y-protocols/awareness";
|
|
7
|
+
import * as v from "y-protocols/sync";
|
|
8
|
+
import { validateRoomPayload as Ve } from "./room/envelope.js";
|
|
9
|
+
const le = 2, D = 256 * 1024, x = D - 1024, w = 16 * 1024 * 1024, Be = 12 * 1024 * 1024, ue = 64, ve = 4, xe = 1e4, Fe = 64 * 1024 * 1024, ze = {
|
|
10
|
+
"sync.message": 0,
|
|
11
|
+
"awareness.updated": 1,
|
|
12
|
+
"sync.chunk": 2
|
|
13
|
+
}, He = /* @__PURE__ */ new Map([
|
|
14
|
+
[0, "sync.message"],
|
|
15
|
+
[1, "awareness.updated"],
|
|
16
|
+
[2, "sync.chunk"]
|
|
17
|
+
]), fe = (e) => e.length > 0 && e.length <= 120 && !e.includes("\0") && !/[\r\n]/.test(e), se = (e) => {
|
|
18
|
+
if (!fe(e.senderId))
|
|
19
|
+
throw new Error("Room packet sender is invalid.");
|
|
20
|
+
if (e.payload.byteLength > w)
|
|
21
|
+
throw new Error("Room packet exceeds the maximum message size.");
|
|
22
|
+
const t = p.createEncoder();
|
|
23
|
+
return p.writeVarUint(t, le), p.writeVarUint(t, ze[e.type]), p.writeVarString(t, e.senderId), e.type === "sync.chunk" && (p.writeVarString(t, e.messageId), p.writeVarUint(t, e.chunkIndex), p.writeVarUint(t, e.chunkCount), p.writeVarUint(t, e.totalBytes)), p.writeVarUint8Array(t, e.payload), p.toUint8Array(t);
|
|
24
|
+
}, he = (e) => {
|
|
25
|
+
if (e.byteLength === 0 || e.byteLength > w + 1024)
|
|
26
|
+
return { ok: !1, reason: e.byteLength === 0 ? "invalid" : "oversized" };
|
|
27
|
+
try {
|
|
28
|
+
const t = A.createDecoder(e);
|
|
29
|
+
if (A.readVarUint(t) !== le)
|
|
30
|
+
return { ok: !1, reason: "unsupported" };
|
|
31
|
+
const o = He.get(A.readVarUint(t)), s = A.readVarString(t);
|
|
32
|
+
if (!o || !fe(s))
|
|
33
|
+
return { ok: !1, reason: "invalid" };
|
|
34
|
+
if (o !== "sync.chunk") {
|
|
35
|
+
const u = A.readVarUint8Array(t);
|
|
36
|
+
return u.byteLength <= w && !A.hasContent(t) ? { ok: !0, packet: { type: o, senderId: s, payload: u } } : { ok: !1, reason: u.byteLength > w ? "oversized" : "invalid" };
|
|
37
|
+
}
|
|
38
|
+
const r = A.readVarString(t), c = A.readVarUint(t), d = A.readVarUint(t), i = A.readVarUint(t), R = A.readVarUint8Array(t);
|
|
39
|
+
return !r || r.length > 120 || d < 2 || d > ue || c >= d || i <= D || i > w || R.byteLength > x || A.hasContent(t) ? { ok: !1, reason: i > w ? "oversized" : "invalid" } : {
|
|
40
|
+
ok: !0,
|
|
41
|
+
packet: {
|
|
42
|
+
type: o,
|
|
43
|
+
senderId: s,
|
|
44
|
+
messageId: r,
|
|
45
|
+
chunkIndex: c,
|
|
46
|
+
chunkCount: d,
|
|
47
|
+
totalBytes: i,
|
|
48
|
+
payload: R
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
} catch {
|
|
52
|
+
return { ok: !1, reason: "invalid" };
|
|
53
|
+
}
|
|
54
|
+
}, Ke = (e, t) => {
|
|
55
|
+
const n = se(e);
|
|
56
|
+
if (n.byteLength <= D)
|
|
57
|
+
return [n];
|
|
58
|
+
if (n.byteLength > w)
|
|
59
|
+
throw new Error("Room packet exceeds the maximum message size.");
|
|
60
|
+
const o = Math.ceil(n.byteLength / x);
|
|
61
|
+
if (o > ue)
|
|
62
|
+
throw new Error("Room packet exceeds the maximum chunk count.");
|
|
63
|
+
const s = t();
|
|
64
|
+
return Array.from({ length: o }, (r, c) => {
|
|
65
|
+
const d = se({
|
|
66
|
+
type: "sync.chunk",
|
|
67
|
+
senderId: e.senderId,
|
|
68
|
+
messageId: s,
|
|
69
|
+
chunkIndex: c,
|
|
70
|
+
chunkCount: o,
|
|
71
|
+
totalBytes: n.byteLength,
|
|
72
|
+
payload: n.subarray(
|
|
73
|
+
c * x,
|
|
74
|
+
Math.min(n.byteLength, (c + 1) * x)
|
|
75
|
+
)
|
|
76
|
+
});
|
|
77
|
+
if (d.byteLength > D)
|
|
78
|
+
throw new Error("Encoded room chunk exceeds the maximum chunk size.");
|
|
79
|
+
return d;
|
|
80
|
+
});
|
|
81
|
+
}, je = () => {
|
|
82
|
+
const e = /* @__PURE__ */ new Map(), t = (n = Date.now()) => {
|
|
83
|
+
for (const [o, s] of e)
|
|
84
|
+
n - s.createdAt >= xe && e.delete(o);
|
|
85
|
+
};
|
|
86
|
+
return {
|
|
87
|
+
get pendingCount() {
|
|
88
|
+
return e.size;
|
|
89
|
+
},
|
|
90
|
+
clear() {
|
|
91
|
+
e.clear();
|
|
92
|
+
},
|
|
93
|
+
prune: t,
|
|
94
|
+
push(n, o = Date.now()) {
|
|
95
|
+
t(o);
|
|
96
|
+
const s = `${n.senderId}\0${n.messageId}`;
|
|
97
|
+
let r = e.get(s);
|
|
98
|
+
if (!r) {
|
|
99
|
+
const R = Array.from(e.values()).filter((y) => y.senderId === n.senderId).sort((y, _) => y.createdAt - _.createdAt);
|
|
100
|
+
for (; R.length >= ve; ) {
|
|
101
|
+
const y = R.shift();
|
|
102
|
+
y && e.delete(`${y.senderId}\0${y.messageId}`);
|
|
103
|
+
}
|
|
104
|
+
if (Array.from(e.values()).reduce((y, _) => y + _.totalBytes, 0) + n.totalBytes > Fe) return null;
|
|
105
|
+
r = {
|
|
106
|
+
senderId: n.senderId,
|
|
107
|
+
messageId: n.messageId,
|
|
108
|
+
chunkCount: n.chunkCount,
|
|
109
|
+
totalBytes: n.totalBytes,
|
|
110
|
+
createdAt: o,
|
|
111
|
+
chunks: /* @__PURE__ */ new Map()
|
|
112
|
+
}, e.set(s, r);
|
|
113
|
+
}
|
|
114
|
+
if (r.chunkCount !== n.chunkCount || r.totalBytes !== n.totalBytes)
|
|
115
|
+
return e.delete(s), null;
|
|
116
|
+
if (r.chunks.has(n.chunkIndex) || r.chunks.set(n.chunkIndex, n.payload.slice()), r.chunks.size !== r.chunkCount)
|
|
117
|
+
return null;
|
|
118
|
+
const c = new Uint8Array(r.totalBytes);
|
|
119
|
+
let d = 0;
|
|
120
|
+
for (let R = 0; R < r.chunkCount; R += 1) {
|
|
121
|
+
const u = r.chunks.get(R);
|
|
122
|
+
if (!u || d + u.byteLength > c.byteLength)
|
|
123
|
+
return e.delete(s), null;
|
|
124
|
+
c.set(u, d), d += u.byteLength;
|
|
125
|
+
}
|
|
126
|
+
if (e.delete(s), d !== c.byteLength)
|
|
127
|
+
return null;
|
|
128
|
+
const i = he(c);
|
|
129
|
+
return i.ok && i.packet.type !== "sync.chunk" && i.packet.senderId === n.senderId ? i.packet : null;
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}, Xe = [
|
|
133
|
+
"presence",
|
|
134
|
+
"read",
|
|
135
|
+
"write"
|
|
136
|
+
], Ye = [
|
|
137
|
+
"presence",
|
|
138
|
+
"read",
|
|
139
|
+
"write"
|
|
140
|
+
], Ge = "tabula-md", $e = "tabula-mcp", re = [
|
|
141
|
+
"Bright",
|
|
142
|
+
"Calm",
|
|
143
|
+
"Careful",
|
|
144
|
+
"Clear",
|
|
145
|
+
"Clever",
|
|
146
|
+
"Curious",
|
|
147
|
+
"Gentle",
|
|
148
|
+
"Kind",
|
|
149
|
+
"Lively",
|
|
150
|
+
"Nimble",
|
|
151
|
+
"Patient",
|
|
152
|
+
"Quiet",
|
|
153
|
+
"Ready",
|
|
154
|
+
"Sharp",
|
|
155
|
+
"Steady",
|
|
156
|
+
"Thoughtful",
|
|
157
|
+
"Warm",
|
|
158
|
+
"Wise"
|
|
159
|
+
], q = [
|
|
160
|
+
"#0f766e",
|
|
161
|
+
"#2563eb",
|
|
162
|
+
"#7c3aed",
|
|
163
|
+
"#c2410c",
|
|
164
|
+
"#be123c",
|
|
165
|
+
"#047857",
|
|
166
|
+
"#0e7490",
|
|
167
|
+
"#4f46e5",
|
|
168
|
+
"#9333ea",
|
|
169
|
+
"#b45309"
|
|
170
|
+
], Rt = "Curious Human", Qe = q[0], me = 128, pe = 40, ge = /^#[0-9a-f]{6}$/i, qe = (e) => !!e && typeof e == "object" && !Array.isArray(e), Je = (e) => e === "human" || e === "agent", Ze = (e) => e === "tabula-md" || e === "tabula-mcp" || e === "custom", ye = (e) => e === "presence" || e === "read" || e === "write", J = (e) => e === "agent" ? [...Ye] : [...Xe], Et = (e, t = "human") => {
|
|
171
|
+
if (!Array.isArray(e))
|
|
172
|
+
return J(t);
|
|
173
|
+
const n = e.filter(ye);
|
|
174
|
+
return n.length > 0 ? [...new Set(n)] : J(t);
|
|
175
|
+
}, et = (e, t) => !!(e != null && e.capabilities.includes(t)), Ae = (e, t) => {
|
|
176
|
+
let n = 2166136261;
|
|
177
|
+
for (let o = 0; o < e.length; o += 1)
|
|
178
|
+
n ^= e.charCodeAt(o), n = Math.imul(n, 16777619);
|
|
179
|
+
return Math.abs(n >>> 0) % t;
|
|
180
|
+
}, tt = (e = "human", t = "") => `${re[Ae(t.trim() || e, re.length)] ?? "Curious"} ${e === "agent" ? "Agent" : "Human"}`, Re = (e = "") => q[Ae(e.trim() || "actor", q.length)] ?? Qe, It = ({
|
|
181
|
+
id: e,
|
|
182
|
+
kind: t = "human",
|
|
183
|
+
name: n,
|
|
184
|
+
color: o,
|
|
185
|
+
client: s,
|
|
186
|
+
capabilities: r,
|
|
187
|
+
joinedAt: c
|
|
188
|
+
}) => {
|
|
189
|
+
var i;
|
|
190
|
+
const d = e.trim() || "actor";
|
|
191
|
+
return {
|
|
192
|
+
id: d.slice(0, me),
|
|
193
|
+
kind: t,
|
|
194
|
+
name: ((n == null ? void 0 : n.trim()) || tt(t, d)).slice(0, pe),
|
|
195
|
+
color: ((i = o == null ? void 0 : o.trim().match(ge)) == null ? void 0 : i[0]) || Re(d),
|
|
196
|
+
client: s ?? (t === "agent" ? $e : Ge),
|
|
197
|
+
capabilities: r != null && r.length ? [...new Set(r)] : J(t),
|
|
198
|
+
joinedAt: c || (/* @__PURE__ */ new Date(0)).toISOString()
|
|
199
|
+
};
|
|
200
|
+
}, Ct = (e) => {
|
|
201
|
+
if (!qe(e) || typeof e.id != "string" || e.id.trim() === "" || e.id.trim().length > me || !Je(e.kind) || typeof e.name != "string" || e.name.trim() === "" || e.name.trim().length > pe || !Ze(e.client) || !Array.isArray(e.capabilities) || typeof e.joinedAt != "string" || e.joinedAt.trim() === "" || e.joinedAt.length > 64 || !Number.isFinite(Date.parse(e.joinedAt)))
|
|
202
|
+
return null;
|
|
203
|
+
const t = e.capabilities.filter(ye);
|
|
204
|
+
return t.length !== e.capabilities.length || t.length === 0 || t.length > 3 || typeof e.color == "string" && !ge.test(e.color.trim()) ? null : {
|
|
205
|
+
id: e.id.trim(),
|
|
206
|
+
kind: e.kind,
|
|
207
|
+
name: e.name.trim(),
|
|
208
|
+
color: typeof e.color == "string" && e.color.trim() ? e.color.trim() : Re(e.id),
|
|
209
|
+
client: e.client,
|
|
210
|
+
capabilities: [...new Set(t)],
|
|
211
|
+
joinedAt: e.joinedAt
|
|
212
|
+
};
|
|
213
|
+
}, _t = 10080 * 60 * 1e3, Ee = (e) => new TextEncoder().encode(
|
|
214
|
+
`tabula.workspace-room-crdt:v${T}:${e}`
|
|
215
|
+
), St = async ({
|
|
216
|
+
roomId: e,
|
|
217
|
+
update: t,
|
|
218
|
+
roomKey: n
|
|
219
|
+
}) => De(t, {
|
|
220
|
+
encryptionKey: n,
|
|
221
|
+
metadata: {
|
|
222
|
+
kind: "workspace-room-crdt",
|
|
223
|
+
roomId: e,
|
|
224
|
+
schemaVersion: T
|
|
225
|
+
},
|
|
226
|
+
additionalData: Ee(e)
|
|
227
|
+
}), Ot = async ({
|
|
228
|
+
encryptedCheckpoint: e,
|
|
229
|
+
roomId: t,
|
|
230
|
+
roomKey: n
|
|
231
|
+
}) => {
|
|
232
|
+
const o = await Ue(
|
|
233
|
+
e,
|
|
234
|
+
{
|
|
235
|
+
decryptionKey: n,
|
|
236
|
+
additionalData: Ee(t)
|
|
237
|
+
}
|
|
238
|
+
);
|
|
239
|
+
if (o.metadata.kind !== "workspace-room-crdt" || o.metadata.roomId !== t || o.metadata.schemaVersion !== T)
|
|
240
|
+
throw new Error("Room checkpoint failed: unsupported checkpoint metadata");
|
|
241
|
+
return o.data;
|
|
242
|
+
}, I = (e, t = "") => typeof e == "string" ? e : t, nt = (e, t = 0) => typeof e == "number" && Number.isFinite(e) ? e : t, S = (e) => typeof e == "string" && e.length > 0 ? e : void 0, Ie = (e, t) => {
|
|
243
|
+
const n = e.trim().split("\0").join(" ").replace(/[/\\]/g, " ").replace(/\s+/g, " ");
|
|
244
|
+
return n && n !== "." && n !== ".." ? n.slice(0, 120) : t;
|
|
245
|
+
}, F = ({
|
|
246
|
+
id: e,
|
|
247
|
+
type: t,
|
|
248
|
+
parentId: n = m,
|
|
249
|
+
title: o,
|
|
250
|
+
order: s = 0,
|
|
251
|
+
createdAt: r = (/* @__PURE__ */ new Date()).toISOString(),
|
|
252
|
+
updatedAt: c = r
|
|
253
|
+
}) => {
|
|
254
|
+
const d = new g.Map();
|
|
255
|
+
return d.set("id", e), d.set("type", t), d.set("parentId", t === "folder" && e === m ? null : n), d.set("title", Ie(o, t === "folder" ? "Folder" : "Untitled.md")), d.set("order", s), d.set("createdAt", r), d.set("updatedAt", c), d;
|
|
256
|
+
}, Ce = (e, t) => {
|
|
257
|
+
const n = t.get("type");
|
|
258
|
+
if (n !== "folder" && n !== "document")
|
|
259
|
+
return null;
|
|
260
|
+
const o = t.get("parentId");
|
|
261
|
+
return {
|
|
262
|
+
id: e,
|
|
263
|
+
type: n,
|
|
264
|
+
parentId: o === null || typeof o == "string" ? o : m,
|
|
265
|
+
title: I(t.get("title"), n === "folder" ? "Folder" : "Untitled.md"),
|
|
266
|
+
order: nt(t.get("order")),
|
|
267
|
+
createdAt: I(t.get("createdAt"), (/* @__PURE__ */ new Date(0)).toISOString()),
|
|
268
|
+
updatedAt: I(t.get("updatedAt"), (/* @__PURE__ */ new Date(0)).toISOString())
|
|
269
|
+
};
|
|
270
|
+
}, ot = (e, t) => e.order - t.order || e.title.localeCompare(t.title, void 0, { numeric: !0, sensitivity: "base" }) || e.id.localeCompare(t.id), bt = ({
|
|
271
|
+
roomId: e,
|
|
272
|
+
doc: t = new g.Doc(),
|
|
273
|
+
initialize: n = !0
|
|
274
|
+
}) => {
|
|
275
|
+
const o = t.getMap("tabula.meta"), s = t.getMap("tabula.nodes"), r = t.getMap("tabula.documents"), c = t.getMap("tabula.comments");
|
|
276
|
+
return n && t.transact(() => {
|
|
277
|
+
o.has("schemaVersion") || o.set("schemaVersion", T), o.has("roomId") || o.set("roomId", e), o.has("rootId") || o.set("rootId", m), s.has(m) || s.set(m, F({
|
|
278
|
+
id: m,
|
|
279
|
+
type: "folder",
|
|
280
|
+
parentId: null,
|
|
281
|
+
title: "Workspace",
|
|
282
|
+
order: 0,
|
|
283
|
+
createdAt: (/* @__PURE__ */ new Date(0)).toISOString()
|
|
284
|
+
}));
|
|
285
|
+
}, "tabula.bootstrap"), { doc: t, meta: o, nodes: s, documents: r, comments: c };
|
|
286
|
+
}, wt = (e, t) => {
|
|
287
|
+
var o, s;
|
|
288
|
+
if (e.meta.get("schemaVersion") !== T || e.meta.get("roomId") !== t || e.meta.get("rootId") !== m)
|
|
289
|
+
return { ok: !1, message: "This room uses an unsupported workspace format." };
|
|
290
|
+
const n = e.nodes.get(m);
|
|
291
|
+
if ((n == null ? void 0 : n.get("type")) !== "folder" || n.get("parentId") !== null)
|
|
292
|
+
return { ok: !1, message: "This room has an invalid workspace root." };
|
|
293
|
+
for (const [r, c] of e.nodes) {
|
|
294
|
+
const d = Ce(r, c);
|
|
295
|
+
if (!d)
|
|
296
|
+
return { ok: !1, message: "This room contains an invalid workspace node." };
|
|
297
|
+
if (r !== m) {
|
|
298
|
+
const i = d.parentId ? e.nodes.get(d.parentId) : void 0;
|
|
299
|
+
if ((i == null ? void 0 : i.get("type")) !== "folder")
|
|
300
|
+
return { ok: !1, message: "This room contains an invalid folder relationship." };
|
|
301
|
+
}
|
|
302
|
+
if (d.type === "document" && !(e.documents.get(r) instanceof g.Text))
|
|
303
|
+
return { ok: !1, message: "This room contains a document without Markdown content." };
|
|
304
|
+
if (d.type === "folder" && e.documents.has(r))
|
|
305
|
+
return { ok: !1, message: "This room contains invalid folder content." };
|
|
306
|
+
}
|
|
307
|
+
for (const r of e.documents.keys())
|
|
308
|
+
if (((o = e.nodes.get(r)) == null ? void 0 : o.get("type")) !== "document")
|
|
309
|
+
return { ok: !1, message: "This room contains orphaned Markdown content." };
|
|
310
|
+
for (const r of e.comments.values()) {
|
|
311
|
+
const c = I(r.get("fileId"));
|
|
312
|
+
if (((s = e.nodes.get(c)) == null ? void 0 : s.get("type")) !== "document")
|
|
313
|
+
return { ok: !1, message: "This room contains an orphaned comment." };
|
|
314
|
+
}
|
|
315
|
+
return { ok: !0 };
|
|
316
|
+
}, kt = (e, {
|
|
317
|
+
nodes: t,
|
|
318
|
+
comments: n = []
|
|
319
|
+
}) => {
|
|
320
|
+
e.doc.transact(() => {
|
|
321
|
+
for (const o of t)
|
|
322
|
+
if (!(!o.id || o.id === m) && (e.nodes.set(o.id, F(o)), o.type === "document")) {
|
|
323
|
+
const s = new g.Text();
|
|
324
|
+
o.markdown && s.insert(0, o.markdown), e.documents.set(o.id, s);
|
|
325
|
+
}
|
|
326
|
+
for (const o of n)
|
|
327
|
+
at(e, o);
|
|
328
|
+
}, "tabula.initialize");
|
|
329
|
+
}, Mt = (e, t) => e.documents.get(t) ?? null, Tt = (e, t) => {
|
|
330
|
+
var o;
|
|
331
|
+
const n = t.parentId ?? m;
|
|
332
|
+
return !t.id || t.id === m || e.nodes.has(t.id) || ((o = e.nodes.get(n)) == null ? void 0 : o.get("type")) !== "folder" ? !1 : (e.doc.transact(() => {
|
|
333
|
+
e.nodes.set(t.id, F({ ...t, parentId: n, type: "folder" }));
|
|
334
|
+
}, "tabula.folder.create"), !0);
|
|
335
|
+
}, Nt = (e, t) => {
|
|
336
|
+
var o;
|
|
337
|
+
const n = t.parentId ?? m;
|
|
338
|
+
return !t.id || t.id === m || e.nodes.has(t.id) || ((o = e.nodes.get(n)) == null ? void 0 : o.get("type")) !== "folder" ? !1 : (e.doc.transact(() => {
|
|
339
|
+
e.nodes.set(t.id, F({ ...t, parentId: n, type: "document" }));
|
|
340
|
+
const s = new g.Text();
|
|
341
|
+
t.markdown && s.insert(0, t.markdown), e.documents.set(t.id, s);
|
|
342
|
+
}, "tabula.document.create"), !0);
|
|
343
|
+
}, st = (e, t) => {
|
|
344
|
+
const n = /* @__PURE__ */ new Set([t]);
|
|
345
|
+
let o = !0;
|
|
346
|
+
for (; o; )
|
|
347
|
+
o = !1, e.nodes.forEach((s, r) => {
|
|
348
|
+
!n.has(r) && n.has(I(s.get("parentId"))) && (n.add(r), o = !0);
|
|
349
|
+
});
|
|
350
|
+
return n;
|
|
351
|
+
}, Ut = (e, t) => {
|
|
352
|
+
if (t === m)
|
|
353
|
+
return;
|
|
354
|
+
const n = st(e, t);
|
|
355
|
+
e.doc.transact(() => {
|
|
356
|
+
for (const o of n)
|
|
357
|
+
e.nodes.delete(o), e.documents.delete(o);
|
|
358
|
+
e.comments.forEach((o, s) => {
|
|
359
|
+
n.has(I(o.get("fileId"))) && e.comments.delete(s);
|
|
360
|
+
});
|
|
361
|
+
}, "tabula.node.delete");
|
|
362
|
+
}, Dt = (e, t, n, o = (/* @__PURE__ */ new Date()).toISOString()) => {
|
|
363
|
+
const s = e.nodes.get(t);
|
|
364
|
+
if (!s)
|
|
365
|
+
return !1;
|
|
366
|
+
const r = s.get("type") === "folder" ? "folder" : "document", c = Ie(n, r === "folder" ? "Folder" : "Untitled.md");
|
|
367
|
+
return s.get("title") === c || e.doc.transact(() => {
|
|
368
|
+
s.set("title", c), s.set("updatedAt", o);
|
|
369
|
+
}, "tabula.node.rename"), !0;
|
|
370
|
+
}, rt = (e, t, n) => {
|
|
371
|
+
var r;
|
|
372
|
+
let o = n;
|
|
373
|
+
const s = /* @__PURE__ */ new Set();
|
|
374
|
+
for (; o; ) {
|
|
375
|
+
if (o === t || s.has(o))
|
|
376
|
+
return !0;
|
|
377
|
+
s.add(o);
|
|
378
|
+
const c = (r = e.nodes.get(o)) == null ? void 0 : r.get("parentId");
|
|
379
|
+
o = typeof c == "string" ? c : null;
|
|
380
|
+
}
|
|
381
|
+
return !1;
|
|
382
|
+
}, Lt = (e, t, n, o = (/* @__PURE__ */ new Date()).toISOString()) => {
|
|
383
|
+
const s = e.nodes.get(t), r = e.nodes.get(n);
|
|
384
|
+
return !s || (r == null ? void 0 : r.get("type")) !== "folder" || t === m || rt(e, t, n) ? !1 : (s.get("parentId") === n || e.doc.transact(() => {
|
|
385
|
+
s.set("parentId", n), s.set("updatedAt", o);
|
|
386
|
+
}, "tabula.node.move"), !0);
|
|
387
|
+
}, Wt = (e, t, n, o = (/* @__PURE__ */ new Date()).toISOString()) => {
|
|
388
|
+
const s = e.nodes.get(t);
|
|
389
|
+
return !s || !Number.isFinite(n) ? !1 : (s.get("order") === n || e.doc.transact(() => {
|
|
390
|
+
s.set("order", n), s.set("updatedAt", o);
|
|
391
|
+
}, "tabula.node.order"), !0);
|
|
392
|
+
}, _e = (e) => {
|
|
393
|
+
const t = new g.Map();
|
|
394
|
+
return t.set("id", e.id), t.set("body", e.body.trim()), e.authorId && t.set("authorId", e.authorId), e.authorName && t.set("authorName", e.authorName), e.authorColor && t.set("authorColor", e.authorColor), t.set("createdAt", e.createdAt), t;
|
|
395
|
+
}, ae = (e, t, n) => e && typeof t == "number" ? g.encodeRelativePosition(
|
|
396
|
+
g.createRelativePositionFromTypeIndex(
|
|
397
|
+
e,
|
|
398
|
+
Math.max(0, Math.min(t, e.length)),
|
|
399
|
+
n
|
|
400
|
+
)
|
|
401
|
+
) : void 0, at = (e, t) => {
|
|
402
|
+
var R;
|
|
403
|
+
const n = e.documents.get(t.fileId), o = t.body.trim(), s = t.replies ?? [];
|
|
404
|
+
if (!n || ((R = e.nodes.get(t.fileId)) == null ? void 0 : R.get("type")) !== "document" || !t.id || !o || o.length > U || !e.comments.has(t.id) && e.comments.size >= Le || s.length > ie || s.some((u) => !u.id || !u.body.trim() || u.body.length > U))
|
|
405
|
+
return !1;
|
|
406
|
+
const r = new g.Map();
|
|
407
|
+
r.set("id", t.id), r.set("fileId", t.fileId), r.set("body", o), t.authorId && r.set("authorId", t.authorId), t.authorName && r.set("authorName", t.authorName), t.authorColor && r.set("authorColor", t.authorColor), t.quote && r.set("quote", t.quote.slice(0, U)), t.sourceQuote && r.set("sourceQuote", t.sourceQuote.slice(0, U));
|
|
408
|
+
const c = ae(n, t.selectionStart, 0), d = ae(n, t.selectionEnd, -1);
|
|
409
|
+
c && r.set("anchorStart", c), d && r.set("anchorEnd", d), r.set("resolved", t.resolved), r.set("createdAt", t.createdAt);
|
|
410
|
+
const i = new g.Map();
|
|
411
|
+
for (const u of s)
|
|
412
|
+
i.set(u.id, _e(u));
|
|
413
|
+
return r.set("replies", i), e.comments.set(t.id, r), !0;
|
|
414
|
+
}, Pt = (e, t) => {
|
|
415
|
+
e.comments.delete(t);
|
|
416
|
+
}, Vt = (e, t, n) => {
|
|
417
|
+
var o;
|
|
418
|
+
(o = e.comments.get(t)) == null || o.set("resolved", n);
|
|
419
|
+
}, Bt = (e, t, n) => {
|
|
420
|
+
const o = e.comments.get(t), s = o == null ? void 0 : o.get("replies");
|
|
421
|
+
return !(s instanceof g.Map) || s.size >= ie || !n.id || !n.body.trim() || n.body.length > U ? !1 : (s.set(n.id, _e(n)), !0);
|
|
422
|
+
}, ce = (e, t) => {
|
|
423
|
+
if (t instanceof Uint8Array)
|
|
424
|
+
try {
|
|
425
|
+
const n = g.createAbsolutePositionFromRelativePosition(g.decodeRelativePosition(t), e.doc);
|
|
426
|
+
return n == null ? void 0 : n.index;
|
|
427
|
+
} catch {
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
}, ct = (e) => {
|
|
431
|
+
if (!(e instanceof g.Map))
|
|
432
|
+
return [];
|
|
433
|
+
const t = [];
|
|
434
|
+
return e.forEach((n, o) => {
|
|
435
|
+
if (!(n instanceof g.Map)) return;
|
|
436
|
+
const s = I(n.get("body")).trim();
|
|
437
|
+
s && t.push({
|
|
438
|
+
id: o,
|
|
439
|
+
body: s,
|
|
440
|
+
authorId: S(n.get("authorId")),
|
|
441
|
+
authorName: S(n.get("authorName")),
|
|
442
|
+
authorColor: S(n.get("authorColor")),
|
|
443
|
+
createdAt: I(n.get("createdAt"), (/* @__PURE__ */ new Date(0)).toISOString())
|
|
444
|
+
});
|
|
445
|
+
}), t.sort((n, o) => n.createdAt.localeCompare(o.createdAt) || n.id.localeCompare(o.id));
|
|
446
|
+
}, Se = (e, t, n) => {
|
|
447
|
+
const o = I(n.get("fileId")), s = I(n.get("body")).trim();
|
|
448
|
+
return !o || !s ? null : {
|
|
449
|
+
id: t,
|
|
450
|
+
fileId: o,
|
|
451
|
+
body: s,
|
|
452
|
+
authorId: S(n.get("authorId")),
|
|
453
|
+
authorName: S(n.get("authorName")),
|
|
454
|
+
authorColor: S(n.get("authorColor")),
|
|
455
|
+
quote: S(n.get("quote")),
|
|
456
|
+
sourceQuote: S(n.get("sourceQuote")),
|
|
457
|
+
selectionStart: ce(e, n.get("anchorStart")),
|
|
458
|
+
selectionEnd: ce(e, n.get("anchorEnd")),
|
|
459
|
+
resolved: n.get("resolved") === !0,
|
|
460
|
+
createdAt: I(n.get("createdAt"), (/* @__PURE__ */ new Date(0)).toISOString()),
|
|
461
|
+
replies: ct(n.get("replies"))
|
|
462
|
+
};
|
|
463
|
+
}, Oe = (e) => e.sort((t, n) => t.createdAt.localeCompare(n.createdAt) || t.id.localeCompare(n.id)), vt = (e, t) => {
|
|
464
|
+
var o;
|
|
465
|
+
if (((o = e.nodes.get(t)) == null ? void 0 : o.get("type")) !== "document" || !e.documents.has(t))
|
|
466
|
+
return [];
|
|
467
|
+
const n = [];
|
|
468
|
+
return e.comments.forEach((s, r) => {
|
|
469
|
+
if (s.get("fileId") !== t) return;
|
|
470
|
+
const c = Se(e, r, s);
|
|
471
|
+
c && n.push(c);
|
|
472
|
+
}), Oe(n);
|
|
473
|
+
}, xt = (e) => {
|
|
474
|
+
var o;
|
|
475
|
+
const t = dt(e), n = {};
|
|
476
|
+
for (const s of t.nodes)
|
|
477
|
+
s.type === "document" && (n[s.id] = ((o = e.documents.get(s.id)) == null ? void 0 : o.toString()) ?? "");
|
|
478
|
+
return {
|
|
479
|
+
...t,
|
|
480
|
+
documents: n,
|
|
481
|
+
commentsByFileId: it(e)
|
|
482
|
+
};
|
|
483
|
+
}, dt = (e) => {
|
|
484
|
+
const t = [];
|
|
485
|
+
return e.nodes.forEach((n, o) => {
|
|
486
|
+
const s = Ce(o, n);
|
|
487
|
+
s && t.push(s);
|
|
488
|
+
}), t.sort(ot), {
|
|
489
|
+
roomId: I(e.meta.get("roomId")),
|
|
490
|
+
schemaVersion: T,
|
|
491
|
+
rootId: I(e.meta.get("rootId"), m),
|
|
492
|
+
nodes: t
|
|
493
|
+
};
|
|
494
|
+
}, it = (e) => {
|
|
495
|
+
const t = /* @__PURE__ */ new Set();
|
|
496
|
+
e.nodes.forEach((o, s) => {
|
|
497
|
+
o.get("type") === "document" && e.documents.has(s) && t.add(s);
|
|
498
|
+
});
|
|
499
|
+
const n = {};
|
|
500
|
+
e.comments.forEach((o, s) => {
|
|
501
|
+
const r = Se(e, s, o);
|
|
502
|
+
if (!r || !t.has(r.fileId)) return;
|
|
503
|
+
const { fileId: c } = r;
|
|
504
|
+
(n[c] ?? (n[c] = [])).push(r);
|
|
505
|
+
});
|
|
506
|
+
for (const o of Object.values(n))
|
|
507
|
+
Oe(o);
|
|
508
|
+
return n;
|
|
509
|
+
}, lt = 64, ut = 32 * 1024 * 1024, ft = Math.ceil((D + 2048) * 4 / 3), ht = 3e4, mt = 500, be = Symbol("tabula.remote-sync"), de = Symbol("tabula.remote-awareness"), Ft = (e) => !!(e && typeof e == "object" && e.type === be), zt = ({
|
|
510
|
+
roomId: e,
|
|
511
|
+
doc: t,
|
|
512
|
+
awareness: n,
|
|
513
|
+
adapters: o,
|
|
514
|
+
isClosed: s,
|
|
515
|
+
getIdentityId: r,
|
|
516
|
+
getSenderActor: c,
|
|
517
|
+
onCapacityExceeded: d,
|
|
518
|
+
onInvalidMessage: i,
|
|
519
|
+
onUnsupportedMessage: R
|
|
520
|
+
}) => {
|
|
521
|
+
const u = je(), y = /* @__PURE__ */ new Set(), _ = [];
|
|
522
|
+
let k = null, l = null, Z = 0, z = Promise.resolve("sent"), E = null, H = !1, O, L = 0, K = !1, j = !1, X = !1, W = !1, N = 0, Y = !1, G = !1;
|
|
523
|
+
const C = () => G || s(), P = (a, f = !1) => a.type === "sync.message" && a.payload.byteLength > Be ? (d(), Promise.resolve("discarded")) : (z = z.then(async () => {
|
|
524
|
+
if (C() || !k || !(l != null && l.connected)) return "offline";
|
|
525
|
+
const b = Ke(a, o.clock.createId);
|
|
526
|
+
for (const Q of b) {
|
|
527
|
+
if (C() || !(l != null && l.connected)) return "offline";
|
|
528
|
+
Z += 1;
|
|
529
|
+
const M = await o.crypto.encryptEnvelope(
|
|
530
|
+
k,
|
|
531
|
+
e,
|
|
532
|
+
"room-event",
|
|
533
|
+
Z,
|
|
534
|
+
Q
|
|
535
|
+
);
|
|
536
|
+
if (C() || !(l != null && l.connected)) return "offline";
|
|
537
|
+
f ? l.sendVolatileEnvelope(M) : l.sendEnvelope(M);
|
|
538
|
+
}
|
|
539
|
+
return "sent";
|
|
540
|
+
}).catch(() => (i("A live collaboration update could not be sent."), "failed")), z), ee = () => {
|
|
541
|
+
if (C() || X || !W) return;
|
|
542
|
+
W = !1, X = !0;
|
|
543
|
+
const a = p.createEncoder();
|
|
544
|
+
v.writeSyncStep1(a, t), P({
|
|
545
|
+
type: "sync.message",
|
|
546
|
+
senderId: r(),
|
|
547
|
+
payload: p.toUint8Array(a)
|
|
548
|
+
}).finally(() => {
|
|
549
|
+
X = !1, ee();
|
|
550
|
+
});
|
|
551
|
+
}, te = () => {
|
|
552
|
+
W = !0, ee();
|
|
553
|
+
}, ne = () => {
|
|
554
|
+
if (C() || K || y.size === 0) return;
|
|
555
|
+
const a = [...y], f = !j;
|
|
556
|
+
y.clear(), j = !1, K = !0;
|
|
557
|
+
const h = We(n, a);
|
|
558
|
+
P({
|
|
559
|
+
type: "awareness.updated",
|
|
560
|
+
senderId: r(),
|
|
561
|
+
payload: h
|
|
562
|
+
}, f).finally(() => {
|
|
563
|
+
K = !1, ne();
|
|
564
|
+
});
|
|
565
|
+
}, V = (a = [n.clientID], f = !0) => {
|
|
566
|
+
for (const h of a) y.add(h);
|
|
567
|
+
f || (j = !0), ne();
|
|
568
|
+
}, $ = () => {
|
|
569
|
+
O && (o.clock.clearTimeout(O), O = void 0);
|
|
570
|
+
};
|
|
571
|
+
function we() {
|
|
572
|
+
if (C() || O) return;
|
|
573
|
+
const a = Math.min(
|
|
574
|
+
ht,
|
|
575
|
+
mt * 2 ** L
|
|
576
|
+
);
|
|
577
|
+
L += 1, O = o.clock.setTimeout(() => {
|
|
578
|
+
O = void 0, B();
|
|
579
|
+
}, a);
|
|
580
|
+
}
|
|
581
|
+
function B() {
|
|
582
|
+
if (C() || H || !E || !(l != null && l.connected)) return;
|
|
583
|
+
const a = E;
|
|
584
|
+
E = null, H = !0;
|
|
585
|
+
const f = p.createEncoder();
|
|
586
|
+
v.writeUpdate(f, a), P({
|
|
587
|
+
type: "sync.message",
|
|
588
|
+
senderId: r(),
|
|
589
|
+
payload: p.toUint8Array(f)
|
|
590
|
+
}).then((h) => {
|
|
591
|
+
h !== "sent" && !C() ? (E = E ? g.mergeUpdates([a, E]) : a, h === "failed" && we()) : h === "sent" && (L = 0);
|
|
592
|
+
}).finally(() => {
|
|
593
|
+
H = !1, O || B();
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
const ke = async (a) => {
|
|
597
|
+
const f = A.createDecoder(a.payload), h = A.readVarUint(f), b = c(a.senderId);
|
|
598
|
+
if (h !== v.messageYjsSyncStep1 && (!b || !et(b, "write"))) return;
|
|
599
|
+
const Q = A.createDecoder(a.payload), M = p.createEncoder();
|
|
600
|
+
v.readSyncMessage(Q, M, t, {
|
|
601
|
+
type: be,
|
|
602
|
+
senderId: a.senderId
|
|
603
|
+
}, () => {
|
|
604
|
+
i("A malformed collaboration update was ignored.");
|
|
605
|
+
}), p.length(M) > 0 && await P({
|
|
606
|
+
type: "sync.message",
|
|
607
|
+
senderId: r(),
|
|
608
|
+
payload: p.toUint8Array(M)
|
|
609
|
+
});
|
|
610
|
+
}, oe = async (a) => {
|
|
611
|
+
if (a.senderId !== r()) {
|
|
612
|
+
if (a.type === "awareness.updated") {
|
|
613
|
+
Pe(n, a.payload, de);
|
|
614
|
+
return;
|
|
615
|
+
}
|
|
616
|
+
await ke(a);
|
|
617
|
+
}
|
|
618
|
+
}, Me = async (a) => {
|
|
619
|
+
if (!(C() || !k))
|
|
620
|
+
try {
|
|
621
|
+
const f = await o.crypto.decryptEnvelope(k, a), h = he(f);
|
|
622
|
+
if (!h.ok) {
|
|
623
|
+
h.reason === "unsupported" && R(), i("An unsupported collaboration message was ignored.");
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
if (h.packet.type === "sync.chunk") {
|
|
627
|
+
const b = u.push(h.packet);
|
|
628
|
+
b && await oe(b);
|
|
629
|
+
} else
|
|
630
|
+
await oe(h.packet);
|
|
631
|
+
} catch {
|
|
632
|
+
i("An encrypted collaboration message could not be opened.");
|
|
633
|
+
}
|
|
634
|
+
}, Te = async () => {
|
|
635
|
+
if (!Y) {
|
|
636
|
+
Y = !0;
|
|
637
|
+
try {
|
|
638
|
+
for (; !C() && _.length > 0; ) {
|
|
639
|
+
const a = _.shift();
|
|
640
|
+
N -= a.bufferedChars, await Me(a.envelope);
|
|
641
|
+
}
|
|
642
|
+
} finally {
|
|
643
|
+
Y = !1;
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
}, Ne = (a) => {
|
|
647
|
+
if (C()) return;
|
|
648
|
+
if (!Ve(a) || a.roomId !== e || a.kind !== "room-event") {
|
|
649
|
+
i("A collaboration server message was ignored.");
|
|
650
|
+
return;
|
|
651
|
+
}
|
|
652
|
+
const f = a.ciphertext.length + a.iv.length;
|
|
653
|
+
if (a.ciphertext.length > ft || _.length >= lt || N + f > ut) {
|
|
654
|
+
i("An oversized collaboration message was ignored.");
|
|
655
|
+
return;
|
|
656
|
+
}
|
|
657
|
+
_.push({ envelope: a, bufferedChars: f }), N += f, Te();
|
|
658
|
+
};
|
|
659
|
+
return {
|
|
660
|
+
setRoomKey(a) {
|
|
661
|
+
k = a;
|
|
662
|
+
},
|
|
663
|
+
connect(a, f) {
|
|
664
|
+
l == null || l.disconnect();
|
|
665
|
+
const h = o.createRoomTransport({
|
|
666
|
+
baseUrl: a,
|
|
667
|
+
roomId: e,
|
|
668
|
+
clientId: r(),
|
|
669
|
+
handlers: { ...f, onMessage: Ne }
|
|
670
|
+
});
|
|
671
|
+
l = h, h.connect();
|
|
672
|
+
},
|
|
673
|
+
isConnected: () => !!(l != null && l.connected),
|
|
674
|
+
onJoined() {
|
|
675
|
+
V([n.clientID], !1), te(), $(), L = 0, B();
|
|
676
|
+
},
|
|
677
|
+
onPeerJoined() {
|
|
678
|
+
V([n.clientID], !1), te();
|
|
679
|
+
},
|
|
680
|
+
onTransportDisconnected: $,
|
|
681
|
+
handleLocalUpdate(a) {
|
|
682
|
+
E = E ? g.mergeUpdates([E, a]) : a, B();
|
|
683
|
+
},
|
|
684
|
+
handleAwarenessUpdate(a, f) {
|
|
685
|
+
f !== de && !C() && V([...a.added, ...a.updated, ...a.removed]);
|
|
686
|
+
},
|
|
687
|
+
publishAwareness: V,
|
|
688
|
+
pruneChunks: () => u.prune(),
|
|
689
|
+
getResourceCounts: () => ({
|
|
690
|
+
inboundEnvelopes: _.length,
|
|
691
|
+
inboundBufferedChars: N,
|
|
692
|
+
pendingAwarenessClients: y.size,
|
|
693
|
+
pendingLocalUpdateBytes: (E == null ? void 0 : E.byteLength) ?? 0
|
|
694
|
+
}),
|
|
695
|
+
dispose() {
|
|
696
|
+
G || (G = !0, $(), l == null || l.disconnect(), l = null, k = null, E = null, y.clear(), W = !1, _.length = 0, N = 0, u.clear());
|
|
697
|
+
}
|
|
698
|
+
};
|
|
699
|
+
};
|
|
700
|
+
export {
|
|
701
|
+
Vt as $,
|
|
702
|
+
Ye as A,
|
|
703
|
+
zt as B,
|
|
704
|
+
he as C,
|
|
705
|
+
Qe as D,
|
|
706
|
+
Ot as E,
|
|
707
|
+
Pt as F,
|
|
708
|
+
Ut as G,
|
|
709
|
+
Xe as H,
|
|
710
|
+
se as I,
|
|
711
|
+
Ke as J,
|
|
712
|
+
St as K,
|
|
713
|
+
J as L,
|
|
714
|
+
it as M,
|
|
715
|
+
Mt as N,
|
|
716
|
+
vt as O,
|
|
717
|
+
xt as P,
|
|
718
|
+
dt as Q,
|
|
719
|
+
de as R,
|
|
720
|
+
et as S,
|
|
721
|
+
kt as T,
|
|
722
|
+
Ft as U,
|
|
723
|
+
ye as V,
|
|
724
|
+
Lt as W,
|
|
725
|
+
Et as X,
|
|
726
|
+
Ct as Y,
|
|
727
|
+
Dt as Z,
|
|
728
|
+
at as _,
|
|
729
|
+
Rt as a,
|
|
730
|
+
Wt as a0,
|
|
731
|
+
wt as a1,
|
|
732
|
+
$e as b,
|
|
733
|
+
Ge as c,
|
|
734
|
+
be as d,
|
|
735
|
+
re as e,
|
|
736
|
+
q as f,
|
|
737
|
+
me as g,
|
|
738
|
+
pe as h,
|
|
739
|
+
_t as i,
|
|
740
|
+
D as j,
|
|
741
|
+
x as k,
|
|
742
|
+
xe as l,
|
|
743
|
+
Fe as m,
|
|
744
|
+
ue as n,
|
|
745
|
+
Be as o,
|
|
746
|
+
ve as p,
|
|
747
|
+
w as q,
|
|
748
|
+
le as r,
|
|
749
|
+
Bt as s,
|
|
750
|
+
It as t,
|
|
751
|
+
Re as u,
|
|
752
|
+
tt as v,
|
|
753
|
+
je as w,
|
|
754
|
+
bt as x,
|
|
755
|
+
Nt as y,
|
|
756
|
+
Tt as z
|
|
757
|
+
};
|
|
758
|
+
//# sourceMappingURL=workspaceRoomSync-B3niC7cn.js.map
|