lody 0.76.0 → 0.77.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/dist/chunks/{diff-line-counts-Du5QanrM.js → diff-line-counts-bmGB_T-n.js} +1 -2
- package/dist/chunks/diff-worker-task-8tVIjLTu.js +60 -0
- package/dist/chunks/{directory-handle-B50CtQcb.js → directory-handle-BBQKxZ5F.js} +2 -2
- package/dist/chunks/{index-VHXDv9iy.js → index-gHAU1HiK.js} +365 -146
- package/dist/chunks/loro_wasm_bg-BuoLmEH-.js +5398 -0
- package/dist/chunks/{package-C-zjBee4.js → package-qnDHmQq4.js} +2 -2
- package/dist/chunks/review-viewer-DchNTv12.js +154 -0
- package/dist/chunks/{schemas-DAtmu1t9.js → schemas-Du3qLZPS.js} +47 -24
- package/dist/claude-acp.js +582 -100
- package/dist/codex-acp.js +1 -1
- package/dist/diff-worker.js +6 -3
- package/dist/file-index-scan-worker.js +3 -3
- package/dist/index.js +88295 -86755
- package/dist/turn-diff-store-worker.js +1552 -0
- package/package.json +59 -61
- package/dist/chunks/loro_wasm_bg-DLsklGR5.js +0 -5197
- package/dist/chunks/review-viewer-DRumOFSW.js +0 -80
- package/dist/chunks/turn-diff-replay-BUdzlx5r.js +0 -311
- package/dist/turn-diff-replay-worker.js +0 -16
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
|
-
import { readFile, mkdir, writeFile, rename } from "node:fs/promises";
|
|
3
|
-
import os__default from "node:os";
|
|
4
|
-
import path__default from "node:path";
|
|
5
|
-
import process from "node:process";
|
|
6
|
-
const reviewViewerVersion = "0.76.0";
|
|
7
|
-
const reviewViewerSha256 = "1f06e6a56f50a0f2e72ab32443bccf66dc536395d1cdf67dc511161824fcc0b0";
|
|
8
|
-
const reviewViewerFileName = "standalone.html";
|
|
9
|
-
const DEFAULT_CDN_BASES = ["https://cdn.jsdelivr.net/npm", "https://unpkg.com"];
|
|
10
|
-
function cacheDir() {
|
|
11
|
-
return path__default.join(os__default.homedir(), ".lody", "code-review-viewer");
|
|
12
|
-
}
|
|
13
|
-
function cachePath() {
|
|
14
|
-
return path__default.join(cacheDir(), `${reviewViewerVersion}.html`);
|
|
15
|
-
}
|
|
16
|
-
function sha256(buffer) {
|
|
17
|
-
return createHash("sha256").update(buffer).digest("hex");
|
|
18
|
-
}
|
|
19
|
-
function isUrl(source) {
|
|
20
|
-
return /^https?:\/\//i.test(source);
|
|
21
|
-
}
|
|
22
|
-
async function loadSource(source) {
|
|
23
|
-
if (isUrl(source)) {
|
|
24
|
-
const response = await fetch(source, { signal: AbortSignal.timeout(3e4) });
|
|
25
|
-
if (!response.ok) {
|
|
26
|
-
throw new Error(`HTTP ${response.status}`);
|
|
27
|
-
}
|
|
28
|
-
return Buffer.from(await response.arrayBuffer());
|
|
29
|
-
}
|
|
30
|
-
return readFile(path__default.resolve(source));
|
|
31
|
-
}
|
|
32
|
-
async function writeCache(buffer) {
|
|
33
|
-
try {
|
|
34
|
-
await mkdir(cacheDir(), { recursive: true });
|
|
35
|
-
const tmp = `${cachePath()}.tmp-${process.pid}`;
|
|
36
|
-
await writeFile(tmp, buffer);
|
|
37
|
-
await rename(tmp, cachePath());
|
|
38
|
-
} catch {
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
async function resolveReviewViewerTemplate() {
|
|
42
|
-
try {
|
|
43
|
-
const cached = await readFile(cachePath());
|
|
44
|
-
if (sha256(cached) === reviewViewerSha256) {
|
|
45
|
-
return cached.toString("utf8");
|
|
46
|
-
}
|
|
47
|
-
} catch {
|
|
48
|
-
}
|
|
49
|
-
const override = process.env.LODY_REVIEW_VIEWER?.trim();
|
|
50
|
-
const sources = override ? [override] : DEFAULT_CDN_BASES.map(
|
|
51
|
-
(base) => `${base}/lody-code-review-viewer@${reviewViewerVersion}/${reviewViewerFileName}`
|
|
52
|
-
);
|
|
53
|
-
const failures = [];
|
|
54
|
-
for (const source of sources) {
|
|
55
|
-
try {
|
|
56
|
-
const buffer = await loadSource(source);
|
|
57
|
-
const actual = sha256(buffer);
|
|
58
|
-
if (actual !== reviewViewerSha256) {
|
|
59
|
-
failures.push(
|
|
60
|
-
`${source}: sha256 mismatch (expected ${reviewViewerSha256.slice(0, 12)}\u2026, got ${actual.slice(
|
|
61
|
-
0,
|
|
62
|
-
12
|
|
63
|
-
)}\u2026)`
|
|
64
|
-
);
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
await writeCache(buffer);
|
|
68
|
-
return buffer.toString("utf8");
|
|
69
|
-
} catch (error) {
|
|
70
|
-
failures.push(`${source}: ${error instanceof Error ? error.message : String(error)}`);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
throw new Error(
|
|
74
|
-
`Could not obtain the code-review viewer (lody-code-review-viewer@${reviewViewerVersion}).
|
|
75
|
-
` + failures.map((line) => ` - ${line}`).join("\n") + "\nIf you are offline or behind a firewall, download standalone.html for this version and point LODY_REVIEW_VIEWER at it (a file path or URL)."
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
export {
|
|
79
|
-
resolveReviewViewerTemplate
|
|
80
|
-
};
|
|
@@ -1,311 +0,0 @@
|
|
|
1
|
-
import { i as imports, g as __wbg_set_wasm, r as rawWasm, e as LoroDoc, E as EphemeralStoreWasm, U as UndoManager, h as callPendingEvents, __tla as __tla_0 } from "./loro_wasm_bg-DLsklGR5.js";
|
|
2
|
-
let EphemeralStore, isContainerId, isContainer, replayTurnDiffText, turnDiffReplay;
|
|
3
|
-
let __tla = Promise.all([
|
|
4
|
-
(() => {
|
|
5
|
-
try {
|
|
6
|
-
return __tla_0;
|
|
7
|
-
} catch {
|
|
8
|
-
}
|
|
9
|
-
})()
|
|
10
|
-
]).then(async () => {
|
|
11
|
-
const toModuleOrExports = (wasm) => {
|
|
12
|
-
if (!wasm) return wasm;
|
|
13
|
-
if (wasm instanceof WebAssembly.Module) return wasm;
|
|
14
|
-
if (typeof wasm === "object" && "default" in wasm) {
|
|
15
|
-
return wasm.default ?? wasm;
|
|
16
|
-
}
|
|
17
|
-
return wasm;
|
|
18
|
-
};
|
|
19
|
-
const wasmModuleOrExports = toModuleOrExports(rawWasm);
|
|
20
|
-
const finalize = (exports$1) => {
|
|
21
|
-
__wbg_set_wasm(exports$1);
|
|
22
|
-
tryStart(imports);
|
|
23
|
-
};
|
|
24
|
-
function tryStart(imports2) {
|
|
25
|
-
if (typeof imports2.__wbindgen_start === "function") {
|
|
26
|
-
imports2.__wbindgen_start();
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
if (wasmModuleOrExports && wasmModuleOrExports.__wbindgen_start) {
|
|
30
|
-
finalize(wasmModuleOrExports);
|
|
31
|
-
} else if ("Bun" in globalThis) {
|
|
32
|
-
let instance;
|
|
33
|
-
if (wasmModuleOrExports instanceof WebAssembly.Module) {
|
|
34
|
-
({ instance } = await WebAssembly.instantiate(wasmModuleOrExports, {
|
|
35
|
-
"./loro_wasm_bg.js": imports
|
|
36
|
-
}));
|
|
37
|
-
} else {
|
|
38
|
-
const url = Bun.pathToFileURL(wasmModuleOrExports);
|
|
39
|
-
({ instance } = await WebAssembly.instantiateStreaming(fetch(url), {
|
|
40
|
-
"./loro_wasm_bg.js": imports
|
|
41
|
-
}));
|
|
42
|
-
}
|
|
43
|
-
finalize(instance.exports);
|
|
44
|
-
} else {
|
|
45
|
-
const wkmod = wasmModuleOrExports instanceof WebAssembly.Module ? wasmModuleOrExports : await import("./loro_wasm_bg-DLsklGR5.js").then(async (m) => {
|
|
46
|
-
await m.__tla;
|
|
47
|
-
return m;
|
|
48
|
-
}).then((n) => n.r);
|
|
49
|
-
const module = wkmod instanceof WebAssembly.Module ? wkmod : wkmod && wkmod.default || wkmod;
|
|
50
|
-
let instance;
|
|
51
|
-
if (module instanceof WebAssembly.Instance) {
|
|
52
|
-
instance = module;
|
|
53
|
-
} else if (module instanceof WebAssembly.Module) {
|
|
54
|
-
instance = await WebAssembly.instantiate(module, {
|
|
55
|
-
"./loro_wasm_bg.js": imports
|
|
56
|
-
});
|
|
57
|
-
} else if (module instanceof ArrayBuffer || ArrayBuffer.isView(module)) {
|
|
58
|
-
const { instance: inst } = await WebAssembly.instantiate(module, {
|
|
59
|
-
"./loro_wasm_bg.js": imports
|
|
60
|
-
});
|
|
61
|
-
instance = inst;
|
|
62
|
-
} else if (typeof module === "string" || module instanceof URL) {
|
|
63
|
-
const response = await fetch(module);
|
|
64
|
-
const { instance: inst } = await WebAssembly.instantiateStreaming(response, {
|
|
65
|
-
"./loro_wasm_bg.js": imports
|
|
66
|
-
});
|
|
67
|
-
instance = inst;
|
|
68
|
-
} else {
|
|
69
|
-
console.error("Unsupported wasm import type:", module);
|
|
70
|
-
throw new Error("Unsupported wasm import type: " + typeof module);
|
|
71
|
-
}
|
|
72
|
-
finalize(instance.exports ?? instance);
|
|
73
|
-
}
|
|
74
|
-
const CONTAINER_TYPES = [
|
|
75
|
-
"Map",
|
|
76
|
-
"Text",
|
|
77
|
-
"List",
|
|
78
|
-
"Tree",
|
|
79
|
-
"MovableList",
|
|
80
|
-
"Counter"
|
|
81
|
-
];
|
|
82
|
-
isContainerId = function(s) {
|
|
83
|
-
return s.startsWith("cid:");
|
|
84
|
-
};
|
|
85
|
-
isContainer = function(value) {
|
|
86
|
-
if (typeof value !== "object" || value == null) {
|
|
87
|
-
return false;
|
|
88
|
-
}
|
|
89
|
-
const p = Object.getPrototypeOf(value);
|
|
90
|
-
if (p == null || typeof p !== "object" || typeof p["kind"] !== "function") {
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
-
return CONTAINER_TYPES.includes(value.kind());
|
|
94
|
-
};
|
|
95
|
-
EphemeralStore = class {
|
|
96
|
-
constructor(timeout = 3e4) {
|
|
97
|
-
this.inner = new EphemeralStoreWasm(timeout);
|
|
98
|
-
this.timeout = timeout;
|
|
99
|
-
}
|
|
100
|
-
apply(bytes) {
|
|
101
|
-
this.inner.apply(bytes);
|
|
102
|
-
this.startTimerIfNotEmpty();
|
|
103
|
-
}
|
|
104
|
-
set(key, value) {
|
|
105
|
-
this.inner.set(key, value);
|
|
106
|
-
this.startTimerIfNotEmpty();
|
|
107
|
-
}
|
|
108
|
-
delete(key) {
|
|
109
|
-
this.inner.delete(key);
|
|
110
|
-
}
|
|
111
|
-
get(key) {
|
|
112
|
-
return this.inner.get(key);
|
|
113
|
-
}
|
|
114
|
-
getAllStates() {
|
|
115
|
-
return this.inner.getAllStates();
|
|
116
|
-
}
|
|
117
|
-
encode(key) {
|
|
118
|
-
return this.inner.encode(key);
|
|
119
|
-
}
|
|
120
|
-
encodeAll() {
|
|
121
|
-
return this.inner.encodeAll();
|
|
122
|
-
}
|
|
123
|
-
keys() {
|
|
124
|
-
return this.inner.keys();
|
|
125
|
-
}
|
|
126
|
-
destroy() {
|
|
127
|
-
clearInterval(this.timer);
|
|
128
|
-
}
|
|
129
|
-
subscribe(listener) {
|
|
130
|
-
return this.inner.subscribe(listener);
|
|
131
|
-
}
|
|
132
|
-
subscribeLocalUpdates(listener) {
|
|
133
|
-
return this.inner.subscribeLocalUpdates(listener);
|
|
134
|
-
}
|
|
135
|
-
startTimerIfNotEmpty() {
|
|
136
|
-
if (this.inner.isEmpty() || this.timer != null) {
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
this.timer = setInterval(() => {
|
|
140
|
-
this.inner.removeOutdated();
|
|
141
|
-
if (this.inner.isEmpty()) {
|
|
142
|
-
clearInterval(this.timer);
|
|
143
|
-
this.timer = void 0;
|
|
144
|
-
}
|
|
145
|
-
}, this.timeout / 2);
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
LoroDoc.prototype.toJsonWithReplacer = function(replacer) {
|
|
149
|
-
const processed = /* @__PURE__ */ new Set();
|
|
150
|
-
const doc = this;
|
|
151
|
-
const m = (key, value) => {
|
|
152
|
-
if (typeof value === "string") {
|
|
153
|
-
if (isContainerId(value) && !processed.has(value)) {
|
|
154
|
-
processed.add(value);
|
|
155
|
-
const container = doc.getContainerById(value);
|
|
156
|
-
if (container == null) {
|
|
157
|
-
throw new Error(`ContainerID not found: ${value}`);
|
|
158
|
-
}
|
|
159
|
-
const ans2 = replacer(key, container);
|
|
160
|
-
if (ans2 === container) {
|
|
161
|
-
const ans3 = container.getShallowValue();
|
|
162
|
-
if (typeof ans3 === "object") {
|
|
163
|
-
return run(ans3);
|
|
164
|
-
}
|
|
165
|
-
return ans3;
|
|
166
|
-
}
|
|
167
|
-
if (isContainer(ans2)) {
|
|
168
|
-
throw new Error("Using new container is not allowed in toJsonWithReplacer");
|
|
169
|
-
}
|
|
170
|
-
if (typeof ans2 === "object" && ans2 != null) {
|
|
171
|
-
return run(ans2);
|
|
172
|
-
}
|
|
173
|
-
return ans2;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
if (typeof value === "object" && value != null) {
|
|
177
|
-
return run(value);
|
|
178
|
-
}
|
|
179
|
-
const ans = replacer(key, value);
|
|
180
|
-
if (isContainer(ans)) {
|
|
181
|
-
throw new Error("Using new container is not allowed in toJsonWithReplacer");
|
|
182
|
-
}
|
|
183
|
-
return ans;
|
|
184
|
-
};
|
|
185
|
-
const run = (layer2) => {
|
|
186
|
-
if (Array.isArray(layer2)) {
|
|
187
|
-
return layer2.map((item, index) => {
|
|
188
|
-
return m(index, item);
|
|
189
|
-
}).filter((item) => item !== void 0);
|
|
190
|
-
}
|
|
191
|
-
const result = {};
|
|
192
|
-
for (const [key, value] of Object.entries(layer2)) {
|
|
193
|
-
const ans = m(key, value);
|
|
194
|
-
if (ans !== void 0) {
|
|
195
|
-
result[key] = ans;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
return result;
|
|
199
|
-
};
|
|
200
|
-
const layer = doc.getShallowValue();
|
|
201
|
-
return run(layer);
|
|
202
|
-
};
|
|
203
|
-
const CALL_PENDING_EVENTS_WRAPPED = Symbol("loro.callPendingEventsWrapped");
|
|
204
|
-
function decorateMethod(prototype, method) {
|
|
205
|
-
const descriptor = Object.getOwnPropertyDescriptor(prototype, method);
|
|
206
|
-
if (!descriptor || typeof descriptor.value !== "function") {
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
const original = descriptor.value;
|
|
210
|
-
if (original[CALL_PENDING_EVENTS_WRAPPED]) {
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
const wrapped = function(...args) {
|
|
214
|
-
let result;
|
|
215
|
-
try {
|
|
216
|
-
result = original.apply(this, args);
|
|
217
|
-
return result;
|
|
218
|
-
} finally {
|
|
219
|
-
if (result && typeof result.then === "function") {
|
|
220
|
-
result.finally(() => {
|
|
221
|
-
callPendingEvents();
|
|
222
|
-
});
|
|
223
|
-
} else {
|
|
224
|
-
callPendingEvents();
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
};
|
|
228
|
-
wrapped[CALL_PENDING_EVENTS_WRAPPED] = true;
|
|
229
|
-
Object.defineProperty(prototype, method, {
|
|
230
|
-
...descriptor,
|
|
231
|
-
value: wrapped
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
function decorateMethods(prototype, methods) {
|
|
235
|
-
for (const method of methods) {
|
|
236
|
-
decorateMethod(prototype, method);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
decorateMethods(LoroDoc.prototype, [
|
|
240
|
-
"setDetachedEditing",
|
|
241
|
-
"attach",
|
|
242
|
-
"detach",
|
|
243
|
-
"fork",
|
|
244
|
-
"forkAt",
|
|
245
|
-
"checkoutToLatest",
|
|
246
|
-
"checkout",
|
|
247
|
-
"commit",
|
|
248
|
-
"getCursorPos",
|
|
249
|
-
"revertTo",
|
|
250
|
-
"export",
|
|
251
|
-
"exportJsonUpdates",
|
|
252
|
-
"exportJsonInIdSpan",
|
|
253
|
-
"importJsonUpdates",
|
|
254
|
-
"import",
|
|
255
|
-
"importUpdateBatch",
|
|
256
|
-
"importBatch",
|
|
257
|
-
"travelChangeAncestors",
|
|
258
|
-
"getChangedContainersIn",
|
|
259
|
-
"diff",
|
|
260
|
-
"applyDiff",
|
|
261
|
-
"setPeerId"
|
|
262
|
-
]);
|
|
263
|
-
decorateMethods(EphemeralStoreWasm.prototype, [
|
|
264
|
-
"set",
|
|
265
|
-
"delete",
|
|
266
|
-
"apply",
|
|
267
|
-
"removeOutdated"
|
|
268
|
-
]);
|
|
269
|
-
decorateMethods(UndoManager.prototype, [
|
|
270
|
-
"undo",
|
|
271
|
-
"redo"
|
|
272
|
-
]);
|
|
273
|
-
function textAtForkedDoc(doc) {
|
|
274
|
-
const present = doc.getMap("meta").get("present");
|
|
275
|
-
if (present !== true) {
|
|
276
|
-
return null;
|
|
277
|
-
}
|
|
278
|
-
return doc.getText("text").toString();
|
|
279
|
-
}
|
|
280
|
-
replayTurnDiffText = function(input) {
|
|
281
|
-
try {
|
|
282
|
-
const doc = new LoroDoc();
|
|
283
|
-
doc.import(input.snapshot);
|
|
284
|
-
const oldDoc = doc.forkAt(JSON.parse(input.oldFrontiersJson));
|
|
285
|
-
const newDoc = doc.forkAt(JSON.parse(input.newFrontiersJson));
|
|
286
|
-
return {
|
|
287
|
-
status: "ready",
|
|
288
|
-
oldText: textAtForkedDoc(oldDoc),
|
|
289
|
-
newText: textAtForkedDoc(newDoc)
|
|
290
|
-
};
|
|
291
|
-
} catch {
|
|
292
|
-
return {
|
|
293
|
-
status: "unavailable"
|
|
294
|
-
};
|
|
295
|
-
}
|
|
296
|
-
};
|
|
297
|
-
turnDiffReplay = Object.freeze(Object.defineProperty({
|
|
298
|
-
__proto__: null,
|
|
299
|
-
replayTurnDiffText
|
|
300
|
-
}, Symbol.toStringTag, {
|
|
301
|
-
value: "Module"
|
|
302
|
-
}));
|
|
303
|
-
});
|
|
304
|
-
export {
|
|
305
|
-
EphemeralStore as E,
|
|
306
|
-
__tla,
|
|
307
|
-
isContainerId as a,
|
|
308
|
-
isContainer as i,
|
|
309
|
-
replayTurnDiffText as r,
|
|
310
|
-
turnDiffReplay as t
|
|
311
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
let turnDiffReplayWorker;
|
|
2
|
-
let __tla = (async () => {
|
|
3
|
-
let replayFnPromise = null;
|
|
4
|
-
turnDiffReplayWorker = async function(input) {
|
|
5
|
-
replayFnPromise ??= import("./chunks/turn-diff-replay-BUdzlx5r.js").then(async (m) => {
|
|
6
|
-
await m.__tla;
|
|
7
|
-
return m;
|
|
8
|
-
}).then((n) => n.t).then((module) => module.replayTurnDiffText);
|
|
9
|
-
const replayTurnDiffText = await replayFnPromise;
|
|
10
|
-
return replayTurnDiffText(input);
|
|
11
|
-
};
|
|
12
|
-
})();
|
|
13
|
-
export {
|
|
14
|
-
__tla,
|
|
15
|
-
turnDiffReplayWorker as default
|
|
16
|
-
};
|