markloom 0.3.0 → 0.5.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 +29 -16
- package/ai.md +160 -0
- package/collab.md +68 -0
- package/dist/ai/index.cjs +4 -3
- package/dist/ai/index.d.cts +4 -2
- package/dist/ai/index.d.ts +4 -2
- package/dist/ai/index.js +5 -4
- package/dist/ai/theme.css +63 -63
- package/dist/{chunk-VVFIQLVR.cjs → chunk-4TMHVNL6.cjs} +71 -79
- package/dist/chunk-6DCI7AL3.js +208 -0
- package/dist/chunk-AC5E42NH.cjs +208 -0
- package/dist/chunk-GQ2HHRGI.cjs +16 -0
- package/dist/{chunk-GUPMZI6Q.js → chunk-JMOJU5EU.js} +7 -5
- package/dist/chunk-JS527FDV.cjs +294 -0
- package/dist/chunk-LA5SBCGQ.js +16 -0
- package/dist/{chunk-ITVAR2UM.js → chunk-LEYAQNJA.js} +5 -3
- package/dist/{chunk-J3QWW6CN.js → chunk-MFYF2A6U.js} +5 -13
- package/dist/chunk-RLTHVQNQ.js +294 -0
- package/dist/{chunk-7Q6AXLF2.cjs → chunk-SLRD6FMP.cjs} +30 -28
- package/dist/{chunk-UCNEQGMY.js → chunk-WUHTCCAE.js} +391 -332
- package/dist/{chunk-2X6AF7XH.cjs → chunk-YJAWPRJW.cjs} +722 -663
- package/dist/{chunk-HA6XHJUD.cjs → chunk-YXQDCW4Y.cjs} +22 -20
- package/dist/client-A0ZQJnyR.d.ts +137 -0
- package/dist/client-BNams4wv.d.cts +137 -0
- package/dist/collab/index.cjs +19 -0
- package/dist/collab/index.d.cts +3 -0
- package/dist/collab/index.d.ts +3 -0
- package/dist/collab/index.js +19 -0
- package/dist/comments-DlExS6f-.d.cts +43 -0
- package/dist/comments-PhnR7Gkn.d.ts +43 -0
- package/dist/{controller-Dm4uLD3I.d.ts → controller-BkY1VPzc.d.ts} +24 -8
- package/dist/{controller-cE9iEYp3.d.cts → controller-CVIZI--A.d.cts} +24 -8
- package/dist/index.cjs +21 -243
- package/dist/index.d.cts +5 -7
- package/dist/index.d.ts +5 -7
- package/dist/index.js +22 -244
- package/dist/react/index.cjs +12 -9
- package/dist/react/index.d.cts +7 -5
- package/dist/react/index.d.ts +7 -5
- package/dist/react/index.js +12 -9
- package/dist/rebase-batch-8rL_aXEE.d.ts +38 -0
- package/dist/rebase-batch-bYnBJpRO.d.cts +38 -0
- package/dist/step-BrvHIK7O.d.cts +65 -0
- package/dist/step-BrvHIK7O.d.ts +65 -0
- package/dist/view/index.cjs +11 -8
- package/dist/view/index.d.cts +7 -5
- package/dist/view/index.d.ts +7 -5
- package/dist/view/index.js +9 -6
- package/dist/view/theme.css +507 -507
- package/package.json +10 -3
- package/dist/comments-USjT1wYN.d.cts +0 -105
- package/dist/comments-USjT1wYN.d.ts +0 -105
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import {
|
|
2
|
+
transformRemoteAgainstPending
|
|
3
|
+
} from "./chunk-RLTHVQNQ.js";
|
|
4
|
+
|
|
5
|
+
// src/collab/client.ts
|
|
6
|
+
function toWsUrl(url, room) {
|
|
7
|
+
let u = url.replace(/\/+$/, "");
|
|
8
|
+
if (u.startsWith("https://"))
|
|
9
|
+
u = `wss://${u.slice(8)}`;
|
|
10
|
+
else if (u.startsWith("http://"))
|
|
11
|
+
u = `ws://${u.slice(7)}`;
|
|
12
|
+
return `${u}/room/${encodeURIComponent(room)}`;
|
|
13
|
+
}
|
|
14
|
+
function retryDelay(attempt) {
|
|
15
|
+
const base = Math.min(1e3 * 2 ** Math.min(attempt, 5), 3e4);
|
|
16
|
+
const jitter = base * 0.5 * Math.random();
|
|
17
|
+
return base * 0.75 + jitter;
|
|
18
|
+
}
|
|
19
|
+
var CollabClient = class {
|
|
20
|
+
cfg;
|
|
21
|
+
handlers;
|
|
22
|
+
ws = null;
|
|
23
|
+
closed = false;
|
|
24
|
+
retry = 0;
|
|
25
|
+
reconnectTimer = null;
|
|
26
|
+
siteId = 0;
|
|
27
|
+
version = 0;
|
|
28
|
+
clientSeq = 0;
|
|
29
|
+
pending = [];
|
|
30
|
+
peers = /* @__PURE__ */ new Map();
|
|
31
|
+
joined = false;
|
|
32
|
+
constructor(cfg, handlers) {
|
|
33
|
+
this.cfg = cfg;
|
|
34
|
+
this.handlers = handlers;
|
|
35
|
+
this.connect();
|
|
36
|
+
}
|
|
37
|
+
get peersList() {
|
|
38
|
+
return [...this.peers.values()];
|
|
39
|
+
}
|
|
40
|
+
connect() {
|
|
41
|
+
if (this.closed)
|
|
42
|
+
return;
|
|
43
|
+
this.handlers.onStatus?.("connecting");
|
|
44
|
+
const url = toWsUrl(this.cfg.url, this.cfg.room);
|
|
45
|
+
let ws;
|
|
46
|
+
try {
|
|
47
|
+
ws = new WebSocket(url);
|
|
48
|
+
} catch (e) {
|
|
49
|
+
this.handlers.onError?.(e instanceof Error ? e.message : String(e));
|
|
50
|
+
this.scheduleReconnect();
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
this.ws = ws;
|
|
54
|
+
ws.onopen = () => {
|
|
55
|
+
this.retry = 0;
|
|
56
|
+
this.handlers.onStatus?.("open");
|
|
57
|
+
this.send({
|
|
58
|
+
type: "join",
|
|
59
|
+
room: this.cfg.room,
|
|
60
|
+
name: this.cfg.name,
|
|
61
|
+
color: this.cfg.color,
|
|
62
|
+
seed: this.cfg.seed
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
ws.onclose = () => {
|
|
66
|
+
this.joined = false;
|
|
67
|
+
this.handlers.onStatus?.("closed");
|
|
68
|
+
if (!this.closed)
|
|
69
|
+
this.scheduleReconnect();
|
|
70
|
+
};
|
|
71
|
+
ws.onerror = () => {
|
|
72
|
+
try {
|
|
73
|
+
ws.close();
|
|
74
|
+
} catch {
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
ws.onmessage = (ev) => {
|
|
78
|
+
try {
|
|
79
|
+
const msg = JSON.parse(String(ev.data));
|
|
80
|
+
this.onServer(msg);
|
|
81
|
+
} catch {
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
scheduleReconnect() {
|
|
86
|
+
if (this.reconnectTimer || this.closed)
|
|
87
|
+
return;
|
|
88
|
+
const delay = retryDelay(this.retry++);
|
|
89
|
+
this.reconnectTimer = setTimeout(() => {
|
|
90
|
+
this.reconnectTimer = null;
|
|
91
|
+
this.connect();
|
|
92
|
+
}, delay);
|
|
93
|
+
}
|
|
94
|
+
send(msg) {
|
|
95
|
+
if (this.ws?.readyState === WebSocket.OPEN)
|
|
96
|
+
this.ws.send(JSON.stringify(msg));
|
|
97
|
+
}
|
|
98
|
+
onServer(msg) {
|
|
99
|
+
switch (msg.type) {
|
|
100
|
+
case "welcome": {
|
|
101
|
+
this.siteId = msg.siteId;
|
|
102
|
+
this.version = msg.version;
|
|
103
|
+
this.pending = [];
|
|
104
|
+
this.joined = true;
|
|
105
|
+
this.peers.clear();
|
|
106
|
+
for (const p of msg.peers)
|
|
107
|
+
this.peers.set(p.siteId, p);
|
|
108
|
+
this.handlers.onDoc(msg.doc, msg.version);
|
|
109
|
+
this.handlers.onPeers?.(this.peersList);
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
case "resync": {
|
|
113
|
+
this.version = msg.version;
|
|
114
|
+
this.pending = [];
|
|
115
|
+
this.handlers.onDoc(msg.doc, msg.version);
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
case "op": {
|
|
119
|
+
if (!this.joined)
|
|
120
|
+
return;
|
|
121
|
+
if (msg.siteId === this.siteId) {
|
|
122
|
+
if (msg.clientSeq != null)
|
|
123
|
+
this.pending = this.pending.filter((p) => p.clientSeq > msg.clientSeq);
|
|
124
|
+
this.version = msg.version;
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const pendingAs = this.pending.map((p) => ({ siteId: this.siteId, steps: p.steps }));
|
|
128
|
+
const { remote, pending: nextP } = transformRemoteAgainstPending(
|
|
129
|
+
msg.steps,
|
|
130
|
+
msg.siteId,
|
|
131
|
+
pendingAs,
|
|
132
|
+
this.siteId
|
|
133
|
+
);
|
|
134
|
+
this.pending = this.pending.map((p, i) => ({
|
|
135
|
+
...p,
|
|
136
|
+
steps: nextP[i]?.steps ?? p.steps
|
|
137
|
+
}));
|
|
138
|
+
this.version = msg.version;
|
|
139
|
+
if (remote.length)
|
|
140
|
+
this.handlers.onRemote(remote);
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
case "presence": {
|
|
144
|
+
const cur = this.peers.get(msg.siteId) ?? { siteId: msg.siteId };
|
|
145
|
+
this.peers.set(msg.siteId, {
|
|
146
|
+
...cur,
|
|
147
|
+
name: msg.name ?? cur.name,
|
|
148
|
+
color: msg.color ?? cur.color,
|
|
149
|
+
sel: msg.sel === void 0 ? cur.sel : msg.sel
|
|
150
|
+
});
|
|
151
|
+
this.handlers.onPeers?.(this.peersList);
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
case "peer-join": {
|
|
155
|
+
this.peers.set(msg.siteId, { siteId: msg.siteId, name: msg.name, color: msg.color });
|
|
156
|
+
this.handlers.onPeers?.(this.peersList);
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
case "peer-leave": {
|
|
160
|
+
this.peers.delete(msg.siteId);
|
|
161
|
+
this.handlers.onPeers?.(this.peersList);
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
case "error":
|
|
165
|
+
this.handlers.onError?.(msg.message);
|
|
166
|
+
break;
|
|
167
|
+
case "pong":
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/** 本地已 apply 的 steps 推上服务器 */
|
|
172
|
+
push(steps) {
|
|
173
|
+
if (!steps.length || !this.joined || this.siteId <= 0)
|
|
174
|
+
return;
|
|
175
|
+
const clientSeq = ++this.clientSeq;
|
|
176
|
+
const baseVersion = this.version;
|
|
177
|
+
this.pending.push({ clientSeq, baseVersion, steps });
|
|
178
|
+
this.send({ type: "op", baseVersion, clientSeq, steps });
|
|
179
|
+
}
|
|
180
|
+
presence(sel) {
|
|
181
|
+
if (!this.joined)
|
|
182
|
+
return;
|
|
183
|
+
this.send({
|
|
184
|
+
type: "presence",
|
|
185
|
+
name: this.cfg.name,
|
|
186
|
+
color: this.cfg.color,
|
|
187
|
+
sel
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
close() {
|
|
191
|
+
this.closed = true;
|
|
192
|
+
if (this.reconnectTimer)
|
|
193
|
+
clearTimeout(this.reconnectTimer);
|
|
194
|
+
try {
|
|
195
|
+
this.ws?.close();
|
|
196
|
+
} catch {
|
|
197
|
+
}
|
|
198
|
+
this.ws = null;
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
function connectCollab(cfg, handlers) {
|
|
202
|
+
return new CollabClient(cfg, handlers);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export {
|
|
206
|
+
CollabClient,
|
|
207
|
+
connectCollab
|
|
208
|
+
};
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
|
|
2
|
+
|
|
3
|
+
var _chunkJS527FDVcjs = require('./chunk-JS527FDV.cjs');
|
|
4
|
+
|
|
5
|
+
// src/collab/client.ts
|
|
6
|
+
function toWsUrl(url, room) {
|
|
7
|
+
let u = url.replace(/\/+$/, "");
|
|
8
|
+
if (u.startsWith("https://"))
|
|
9
|
+
u = `wss://${u.slice(8)}`;
|
|
10
|
+
else if (u.startsWith("http://"))
|
|
11
|
+
u = `ws://${u.slice(7)}`;
|
|
12
|
+
return `${u}/room/${encodeURIComponent(room)}`;
|
|
13
|
+
}
|
|
14
|
+
function retryDelay(attempt) {
|
|
15
|
+
const base = Math.min(1e3 * 2 ** Math.min(attempt, 5), 3e4);
|
|
16
|
+
const jitter = base * 0.5 * Math.random();
|
|
17
|
+
return base * 0.75 + jitter;
|
|
18
|
+
}
|
|
19
|
+
var CollabClient = (_class = class {
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
__init() {this.ws = null}
|
|
23
|
+
__init2() {this.closed = false}
|
|
24
|
+
__init3() {this.retry = 0}
|
|
25
|
+
__init4() {this.reconnectTimer = null}
|
|
26
|
+
__init5() {this.siteId = 0}
|
|
27
|
+
__init6() {this.version = 0}
|
|
28
|
+
__init7() {this.clientSeq = 0}
|
|
29
|
+
__init8() {this.pending = []}
|
|
30
|
+
__init9() {this.peers = /* @__PURE__ */ new Map()}
|
|
31
|
+
__init10() {this.joined = false}
|
|
32
|
+
constructor(cfg, handlers) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);_class.prototype.__init6.call(this);_class.prototype.__init7.call(this);_class.prototype.__init8.call(this);_class.prototype.__init9.call(this);_class.prototype.__init10.call(this);
|
|
33
|
+
this.cfg = cfg;
|
|
34
|
+
this.handlers = handlers;
|
|
35
|
+
this.connect();
|
|
36
|
+
}
|
|
37
|
+
get peersList() {
|
|
38
|
+
return [...this.peers.values()];
|
|
39
|
+
}
|
|
40
|
+
connect() {
|
|
41
|
+
if (this.closed)
|
|
42
|
+
return;
|
|
43
|
+
_optionalChain([this, 'access', _ => _.handlers, 'access', _2 => _2.onStatus, 'optionalCall', _3 => _3("connecting")]);
|
|
44
|
+
const url = toWsUrl(this.cfg.url, this.cfg.room);
|
|
45
|
+
let ws;
|
|
46
|
+
try {
|
|
47
|
+
ws = new WebSocket(url);
|
|
48
|
+
} catch (e) {
|
|
49
|
+
_optionalChain([this, 'access', _4 => _4.handlers, 'access', _5 => _5.onError, 'optionalCall', _6 => _6(e instanceof Error ? e.message : String(e))]);
|
|
50
|
+
this.scheduleReconnect();
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
this.ws = ws;
|
|
54
|
+
ws.onopen = () => {
|
|
55
|
+
this.retry = 0;
|
|
56
|
+
_optionalChain([this, 'access', _7 => _7.handlers, 'access', _8 => _8.onStatus, 'optionalCall', _9 => _9("open")]);
|
|
57
|
+
this.send({
|
|
58
|
+
type: "join",
|
|
59
|
+
room: this.cfg.room,
|
|
60
|
+
name: this.cfg.name,
|
|
61
|
+
color: this.cfg.color,
|
|
62
|
+
seed: this.cfg.seed
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
ws.onclose = () => {
|
|
66
|
+
this.joined = false;
|
|
67
|
+
_optionalChain([this, 'access', _10 => _10.handlers, 'access', _11 => _11.onStatus, 'optionalCall', _12 => _12("closed")]);
|
|
68
|
+
if (!this.closed)
|
|
69
|
+
this.scheduleReconnect();
|
|
70
|
+
};
|
|
71
|
+
ws.onerror = () => {
|
|
72
|
+
try {
|
|
73
|
+
ws.close();
|
|
74
|
+
} catch (e2) {
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
ws.onmessage = (ev) => {
|
|
78
|
+
try {
|
|
79
|
+
const msg = JSON.parse(String(ev.data));
|
|
80
|
+
this.onServer(msg);
|
|
81
|
+
} catch (e3) {
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
scheduleReconnect() {
|
|
86
|
+
if (this.reconnectTimer || this.closed)
|
|
87
|
+
return;
|
|
88
|
+
const delay = retryDelay(this.retry++);
|
|
89
|
+
this.reconnectTimer = setTimeout(() => {
|
|
90
|
+
this.reconnectTimer = null;
|
|
91
|
+
this.connect();
|
|
92
|
+
}, delay);
|
|
93
|
+
}
|
|
94
|
+
send(msg) {
|
|
95
|
+
if (_optionalChain([this, 'access', _13 => _13.ws, 'optionalAccess', _14 => _14.readyState]) === WebSocket.OPEN)
|
|
96
|
+
this.ws.send(JSON.stringify(msg));
|
|
97
|
+
}
|
|
98
|
+
onServer(msg) {
|
|
99
|
+
switch (msg.type) {
|
|
100
|
+
case "welcome": {
|
|
101
|
+
this.siteId = msg.siteId;
|
|
102
|
+
this.version = msg.version;
|
|
103
|
+
this.pending = [];
|
|
104
|
+
this.joined = true;
|
|
105
|
+
this.peers.clear();
|
|
106
|
+
for (const p of msg.peers)
|
|
107
|
+
this.peers.set(p.siteId, p);
|
|
108
|
+
this.handlers.onDoc(msg.doc, msg.version);
|
|
109
|
+
_optionalChain([this, 'access', _15 => _15.handlers, 'access', _16 => _16.onPeers, 'optionalCall', _17 => _17(this.peersList)]);
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
case "resync": {
|
|
113
|
+
this.version = msg.version;
|
|
114
|
+
this.pending = [];
|
|
115
|
+
this.handlers.onDoc(msg.doc, msg.version);
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
case "op": {
|
|
119
|
+
if (!this.joined)
|
|
120
|
+
return;
|
|
121
|
+
if (msg.siteId === this.siteId) {
|
|
122
|
+
if (msg.clientSeq != null)
|
|
123
|
+
this.pending = this.pending.filter((p) => p.clientSeq > msg.clientSeq);
|
|
124
|
+
this.version = msg.version;
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const pendingAs = this.pending.map((p) => ({ siteId: this.siteId, steps: p.steps }));
|
|
128
|
+
const { remote, pending: nextP } = _chunkJS527FDVcjs.transformRemoteAgainstPending.call(void 0,
|
|
129
|
+
msg.steps,
|
|
130
|
+
msg.siteId,
|
|
131
|
+
pendingAs,
|
|
132
|
+
this.siteId
|
|
133
|
+
);
|
|
134
|
+
this.pending = this.pending.map((p, i) => ({
|
|
135
|
+
...p,
|
|
136
|
+
steps: _nullishCoalesce(_optionalChain([nextP, 'access', _18 => _18[i], 'optionalAccess', _19 => _19.steps]), () => ( p.steps))
|
|
137
|
+
}));
|
|
138
|
+
this.version = msg.version;
|
|
139
|
+
if (remote.length)
|
|
140
|
+
this.handlers.onRemote(remote);
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
case "presence": {
|
|
144
|
+
const cur = _nullishCoalesce(this.peers.get(msg.siteId), () => ( { siteId: msg.siteId }));
|
|
145
|
+
this.peers.set(msg.siteId, {
|
|
146
|
+
...cur,
|
|
147
|
+
name: _nullishCoalesce(msg.name, () => ( cur.name)),
|
|
148
|
+
color: _nullishCoalesce(msg.color, () => ( cur.color)),
|
|
149
|
+
sel: msg.sel === void 0 ? cur.sel : msg.sel
|
|
150
|
+
});
|
|
151
|
+
_optionalChain([this, 'access', _20 => _20.handlers, 'access', _21 => _21.onPeers, 'optionalCall', _22 => _22(this.peersList)]);
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
case "peer-join": {
|
|
155
|
+
this.peers.set(msg.siteId, { siteId: msg.siteId, name: msg.name, color: msg.color });
|
|
156
|
+
_optionalChain([this, 'access', _23 => _23.handlers, 'access', _24 => _24.onPeers, 'optionalCall', _25 => _25(this.peersList)]);
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
case "peer-leave": {
|
|
160
|
+
this.peers.delete(msg.siteId);
|
|
161
|
+
_optionalChain([this, 'access', _26 => _26.handlers, 'access', _27 => _27.onPeers, 'optionalCall', _28 => _28(this.peersList)]);
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
case "error":
|
|
165
|
+
_optionalChain([this, 'access', _29 => _29.handlers, 'access', _30 => _30.onError, 'optionalCall', _31 => _31(msg.message)]);
|
|
166
|
+
break;
|
|
167
|
+
case "pong":
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/** 本地已 apply 的 steps 推上服务器 */
|
|
172
|
+
push(steps) {
|
|
173
|
+
if (!steps.length || !this.joined || this.siteId <= 0)
|
|
174
|
+
return;
|
|
175
|
+
const clientSeq = ++this.clientSeq;
|
|
176
|
+
const baseVersion = this.version;
|
|
177
|
+
this.pending.push({ clientSeq, baseVersion, steps });
|
|
178
|
+
this.send({ type: "op", baseVersion, clientSeq, steps });
|
|
179
|
+
}
|
|
180
|
+
presence(sel) {
|
|
181
|
+
if (!this.joined)
|
|
182
|
+
return;
|
|
183
|
+
this.send({
|
|
184
|
+
type: "presence",
|
|
185
|
+
name: this.cfg.name,
|
|
186
|
+
color: this.cfg.color,
|
|
187
|
+
sel
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
close() {
|
|
191
|
+
this.closed = true;
|
|
192
|
+
if (this.reconnectTimer)
|
|
193
|
+
clearTimeout(this.reconnectTimer);
|
|
194
|
+
try {
|
|
195
|
+
_optionalChain([this, 'access', _32 => _32.ws, 'optionalAccess', _33 => _33.close, 'call', _34 => _34()]);
|
|
196
|
+
} catch (e4) {
|
|
197
|
+
}
|
|
198
|
+
this.ws = null;
|
|
199
|
+
}
|
|
200
|
+
}, _class);
|
|
201
|
+
function connectCollab(cfg, handlers) {
|
|
202
|
+
return new CollabClient(cfg, handlers);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
exports.CollabClient = CollabClient; exports.connectCollab = connectCollab;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/tree/types.ts
|
|
2
|
+
function isText(n) {
|
|
3
|
+
return "text" in n;
|
|
4
|
+
}
|
|
5
|
+
function isElement(n) {
|
|
6
|
+
return "children" in n;
|
|
7
|
+
}
|
|
8
|
+
function isInlineAtom(n) {
|
|
9
|
+
return isElement(n) && (n.type === "mention" || n.type === "hard_break" || n.type === "math");
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
exports.isText = isText; exports.isElement = isElement; exports.isInlineAtom = isInlineAtom;
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
appendText,
|
|
3
3
|
insertAfter,
|
|
4
|
-
isText,
|
|
5
4
|
mdToDoc,
|
|
6
5
|
normalizeToLeaf,
|
|
7
6
|
pathOfId,
|
|
8
7
|
rewriteNode
|
|
9
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-MFYF2A6U.js";
|
|
9
|
+
import {
|
|
10
|
+
isText
|
|
11
|
+
} from "./chunk-LA5SBCGQ.js";
|
|
10
12
|
|
|
11
13
|
// src/view/selection.ts
|
|
12
14
|
function rootEl(root) {
|
|
13
|
-
return root.querySelector(".
|
|
15
|
+
return root.querySelector(".markloom-doc") ?? root;
|
|
14
16
|
}
|
|
15
17
|
function pointToDom(root, doc, pos) {
|
|
16
18
|
const path = pos.path;
|
|
@@ -337,7 +339,7 @@ function aiInstructionFromQuery(query) {
|
|
|
337
339
|
var newAiId = () => crypto.randomUUID?.() ?? `ai${Math.random().toString(36).slice(2)}`;
|
|
338
340
|
|
|
339
341
|
// src/ai/controller.ts
|
|
340
|
-
var
|
|
342
|
+
var MarkloomAi = class {
|
|
341
343
|
getEditor;
|
|
342
344
|
opts;
|
|
343
345
|
abort = null;
|
|
@@ -1071,6 +1073,6 @@ export {
|
|
|
1071
1073
|
startAiWrite,
|
|
1072
1074
|
precedingPlainText,
|
|
1073
1075
|
aiInstructionFromQuery,
|
|
1074
|
-
|
|
1076
|
+
MarkloomAi,
|
|
1075
1077
|
createAiStream
|
|
1076
1078
|
};
|