lody 0.59.0 → 0.60.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.
@@ -6,6 +6,7 @@ import path__default from "node:path";
6
6
  import { execFile } from "node:child_process";
7
7
  import os__default from "node:os";
8
8
  import { watch, existsSync, readFileSync } from "node:fs";
9
+ import { createRequire } from "node:module";
9
10
  import { L as LoroDoc, C as Cursor, __tla as __tla_2 } from "./loro_wasm_bg-BV-n7JyC.js";
10
11
  import "fs";
11
12
  import "path";
@@ -45,7 +46,6 @@ import "assert";
45
46
  import "fs/promises";
46
47
  import "better-sqlite3";
47
48
  import "perf_hooks";
48
- import "node:module";
49
49
  import "node:stream/promises";
50
50
  import "node:string_decoder";
51
51
  import "node:assert";
@@ -53,7 +53,7 @@ import "node:buffer";
53
53
  import "node:async_hooks";
54
54
  import { __tla as __tla_3 } from "../index.js";
55
55
  import { bE, bF, bG, bH, bI, bJ, bK, bL, bM, bN, bO, bP, bQ, bR, bS, bT, bU, bV, bW, bX, bY, bZ, b_, b$, c0, c1, c2, c3, c4, c5, h, c6, c7, c8, r, u, c9, ca, cb, cc, cd, ce, cf, cg, ch, ci, cj, ck, cl, cm, H, cn, co, cp, cq, cr, cs, ct, cu, cv, cw, cx, cy, cz, cA, cB, cC, cD, cE, cF, cG, cH, cI, cJ, cK, cL, cM } from "../index.js";
56
- let CODE_COLLAB_PACKAGE, CodeCollabGuestSession, CodeCollabTextDocumentStore, DEFAULT_TEXT_DOCUMENT_UPDATE_TIMEOUT_MS, GuestRpcClient, WEB_JOIN_LINK_MAX_LENGTH, WEB_JOIN_LINK_WARNING_LENGTH, assertWebJoinLinkWithinBudget, buildCapturedTurnHistoryRecords, classifyHostFileWatchPathEvent, classifyHostLivenessFromPresences, computeHostFileWatcherMaxWaitMs, computeHostLoopSleepMs, computeHostTurnChanges, computeHostTurnChangesEffect, createDiskTokenForPath, createDiskTokenForPathEffect, createHostHydrationContextFromSession, createHostLoopWakeSignal, createHostSaveEchoSuppressorV1, createLoroCursorAnchorV1, createWebJoinLink, createWebJoinLinks, dispatchHostRpcEnvelopeV1, dispatchHostRpcEnvelopeV1Effect, downloadBlobObjectEffect, getHostLivenessStatusV1, getHostLivenessStatusV1Effect, handleHostFileWatcherEventV1, hydrateBlobFile, hydrateBlobFileEffect, hydrateTextFile, hydrateTextFileEffect, initializeTextSaveStateV1, initializeTextSaveStateV1Effect, makeHostLoopTelemetryHandlers, markTextSaveStateDirtyForSnapshotV1, parseHostCommandArgs, prepareHostSession, prepareHostSessionEffect, prepareHostSessionRuntime, prepareHostSessionRuntimeEffect, prepareTextHydrationBaselineV1Effect, processHostRpcBatchEffect$1, processHostRpcBatchV1, publishCursorStateV1, publishCursorStateV1Effect, publishHostCurrentChanges, publishHostCursorV1, publishHostParticipantPresenceV1, publishHostPresenceV1, publishHostPresenceV1Effect, publishHostSelectionV1, publishHostSession, publishHostSessionEffect, publishHostSessionRuntime, publishHostSessionRuntimeEffect, publishParticipantPresenceV1, publishParticipantPresenceV1Effect, publishPreparedHostSessionRuntime, publishPreparedHostSessionRuntimeEffect, publishSelectionStateV1, publishSelectionStateV1Effect, readCursorStateSnapshotV1, readCursorStateSnapshotV1Effect, readHostCursorsV1, readHostParticipantPresenceV1, readHostPresencePeerSnapshotV1, readHostPresencePeerSnapshotV1Effect, readHostPresenceSnapshotV1, readHostPresenceSnapshotV1Effect, readHostSelectionsV1, readParticipantPresenceSnapshotV1, readParticipantPresenceSnapshotV1Effect, readSelectionStateSnapshotV1, readSelectionStateSnapshotV1Effect, reconcileOpenTextDocumentRenamesByContent, reconcileOpenTextDocumentRenamesByContentEffect, recordTextHydrationBaselineV1Effect, reloadTextFileFromDiskIfChangedV1, reloadTextFileFromDiskIfChangedV1Effect, reloadTextFileFromDiskV1, reloadTextFileFromDiskV1Effect, requestPendingMetadataRescanV1, resolveHostLspDefinition, resolveHostLspDefinitionEffect, resolveHostLspReferences, resolveHostLspReferencesEffect, resolveLoroCursorAnchorOffsetV1, resolveSaveConflictV1, resolveSaveConflictV1Effect, runHostEventLoopEffect, runHostEventLoopV1, saveTextFileV1, saveTextFileV1Effect, shouldAutoSaveDirtyTextDocument, snapshotHostTurnHistoryFiles, snapshotHostTurnHistoryFilesEffect, startHostFileWatcher, startHostSession, startHostSessionEffect, startPreparedHostSession, startPreparedHostSessionEffect, takeDuePendingMetadataRescanV1, watchCursorStateV1, watchHostPresencePeerSnapshotV1, watchHostPresenceSnapshotV1, watchParticipantPresenceV1, watchSelectionStateV1;
56
+ let CODE_COLLAB_PACKAGE, CodeCollabGuestSession, CodeCollabTextDocumentStore, DEFAULT_TEXT_DOCUMENT_UPDATE_TIMEOUT_MS, GuestRpcClient, WEB_JOIN_LINK_MAX_LENGTH, WEB_JOIN_LINK_WARNING_LENGTH, assertWebJoinLinkWithinBudget, buildCapturedTurnHistoryRecords, classifyHostFileWatchPathEvent, classifyHostLivenessFromPresences, computeHostFileWatcherMaxWaitMs, computeHostLoopSleepMs, computeHostTurnChanges, computeHostTurnChangesEffect, computeHostTurnFileDiff, computeHostTurnFileDiffEffect, createDiskTokenForPath, createDiskTokenForPathEffect, createHostHydrationContextFromSession, createHostLoopWakeSignal, createHostSaveEchoSuppressorV1, createLoroCursorAnchorV1, createWebJoinLink, createWebJoinLinks, dispatchHostRpcEnvelopeV1, dispatchHostRpcEnvelopeV1Effect, downloadBlobObjectEffect, getHostLivenessStatusV1, getHostLivenessStatusV1Effect, handleHostFileWatcherEventV1, hydrateBlobFile, hydrateBlobFileEffect, hydrateTextFile, hydrateTextFileEffect, initializeTextSaveStateV1, initializeTextSaveStateV1Effect, loadTypeScriptModule, makeHostLoopTelemetryHandlers, markTextSaveStateDirtyForSnapshotV1, parseHostCommandArgs, prepareHostSession, prepareHostSessionEffect, prepareHostSessionRuntime, prepareHostSessionRuntimeEffect, prepareTextHydrationBaselineV1Effect, processHostRpcBatchEffect$1, processHostRpcBatchV1, publishCursorStateV1, publishCursorStateV1Effect, publishHostCurrentChanges, publishHostCursorV1, publishHostParticipantPresenceV1, publishHostPresenceV1, publishHostPresenceV1Effect, publishHostSelectionV1, publishHostSession, publishHostSessionEffect, publishHostSessionRuntime, publishHostSessionRuntimeEffect, publishParticipantPresenceV1, publishParticipantPresenceV1Effect, publishPreparedHostSessionRuntime, publishPreparedHostSessionRuntimeEffect, publishSelectionStateV1, publishSelectionStateV1Effect, readCursorStateSnapshotV1, readCursorStateSnapshotV1Effect, readHostCursorsV1, readHostParticipantPresenceV1, readHostPresencePeerSnapshotV1, readHostPresencePeerSnapshotV1Effect, readHostPresenceSnapshotV1, readHostPresenceSnapshotV1Effect, readHostSelectionsV1, readParticipantPresenceSnapshotV1, readParticipantPresenceSnapshotV1Effect, readSelectionStateSnapshotV1, readSelectionStateSnapshotV1Effect, reconcileOpenTextDocumentRenamesByContent, reconcileOpenTextDocumentRenamesByContentEffect, recordTextHydrationBaselineV1Effect, reloadTextFileFromDiskIfChangedV1, reloadTextFileFromDiskIfChangedV1Effect, reloadTextFileFromDiskV1, reloadTextFileFromDiskV1Effect, requestPendingMetadataRescanV1, resolveHostLspDefinition, resolveHostLspDefinitionEffect, resolveHostLspReferences, resolveHostLspReferencesEffect, resolveLoroCursorAnchorOffsetV1, resolveSaveConflictV1, resolveSaveConflictV1Effect, runHostEventLoopEffect, runHostEventLoopV1, saveTextFileV1, saveTextFileV1Effect, shouldAutoSaveDirtyTextDocument, snapshotHostTurnHistoryFiles, snapshotHostTurnHistoryFilesEffect, startHostFileWatcher, startHostSession, startHostSessionEffect, startPreparedHostSession, startPreparedHostSessionEffect, takeDuePendingMetadataRescanV1, watchCursorStateV1, watchHostPresencePeerSnapshotV1, watchHostPresenceSnapshotV1, watchParticipantPresenceV1, watchSelectionStateV1;
57
57
  let __tla = Promise.all([
58
58
  (() => {
59
59
  try {
@@ -2794,16 +2794,19 @@ let __tla = Promise.all([
2794
2794
  }
2795
2795
  };
2796
2796
  }
2797
- let typeScriptModulePromise;
2798
- function loadTypeScriptModuleEffect() {
2799
- return tryPromiseEffect(async () => {
2800
- typeScriptModulePromise ??= import("typescript").then(async (m) => {
2801
- await m.__tla;
2802
- return m;
2803
- });
2804
- return await typeScriptModulePromise;
2805
- });
2806
- }
2797
+ loadTypeScriptModule = function(workspaceRoot) {
2798
+ const anchors = [
2799
+ path__default.join(path__default.resolve(workspaceRoot), "package.json"),
2800
+ import.meta.url
2801
+ ];
2802
+ for (const anchor of anchors) {
2803
+ try {
2804
+ return createRequire(anchor)("typescript");
2805
+ } catch {
2806
+ }
2807
+ }
2808
+ return void 0;
2809
+ };
2807
2810
  resolveHostLspDefinition = async function(input) {
2808
2811
  return runPromiseEffect(resolveHostLspDefinitionEffect(input));
2809
2812
  };
@@ -2866,7 +2869,10 @@ let __tla = Promise.all([
2866
2869
  if (!isTypeScriptLikePath(entry.path)) {
2867
2870
  return unsupported(`No host language service is configured for ${path__default.extname(entry.path) || "this file"}`);
2868
2871
  }
2869
- const ts = yield* loadTypeScriptModuleEffect();
2872
+ const ts = yield* trySyncEffect(() => loadTypeScriptModule(context.workspaceRoot));
2873
+ if (ts === void 0) {
2874
+ return unsupported("TypeScript is not installed in this workspace; add it to enable code navigation");
2875
+ }
2870
2876
  const liveText = yield* readOptionalLiveTextEffect(context, entry.fileId);
2871
2877
  const project = yield* trySyncEffect(() => createTypeScriptLspProject({
2872
2878
  currentFile: entry,
@@ -6261,6 +6267,9 @@ let __tla = Promise.all([
6261
6267
  computeHostTurnChanges = async function(input) {
6262
6268
  return runPromiseEffect(computeHostTurnChangesEffect(input));
6263
6269
  };
6270
+ computeHostTurnFileDiff = async function(input) {
6271
+ return runPromiseEffect(computeHostTurnFileDiffEffect(input));
6272
+ };
6264
6273
  computeHostTurnChangesEffect = function(input) {
6265
6274
  return gen(function* () {
6266
6275
  const prepared = yield* prepareHostTurnChangesWithoutHistoryEffect(input);
@@ -6272,18 +6281,29 @@ let __tla = Promise.all([
6272
6281
  };
6273
6282
  });
6274
6283
  };
6284
+ computeHostTurnFileDiffEffect = function(input) {
6285
+ return gen(function* () {
6286
+ const turnCapturedFiles = input.capturedTurnBases === void 0 || input.capturedTurnBases.length === 0 ? [] : yield* materializeCapturedTurnFilesEffect(input, input.capturedTurnBases);
6287
+ const turnCapturedRecords = yield* buildCapturedTurnTextRecordsFromFilesEffect(input, turnCapturedFiles);
6288
+ const turnChangedFiles = yield* attachTurnHistoryLineStatsEffect(turnCapturedRecords, input.host.textDocuments, input.host.computeTurnHistoryLineStats, /* @__PURE__ */ new Map());
6289
+ return {
6290
+ turnChangedFiles
6291
+ };
6292
+ });
6293
+ };
6275
6294
  function prepareHostTurnChangesWithoutHistoryEffect(input) {
6276
6295
  return gen(function* () {
6277
- const currentFiles = yield* snapshotHostTurnHistoryFilesEffect(input);
6296
+ const needsSnapshotDiff = input.capturedBases === void 0 && input.baseFiles !== void 0;
6297
+ const currentFiles = needsSnapshotDiff ? yield* snapshotHostTurnHistoryFilesEffect(input) : [];
6278
6298
  const turnCapturedFiles = input.capturedTurnBases === void 0 || input.capturedTurnBases.length === 0 ? [] : yield* materializeCapturedTurnFilesEffect(input, input.capturedTurnBases);
6279
- const snapshotChangedFiles = input.baseFiles === void 0 ? /* @__PURE__ */ new Map() : updateTurnHistoryChangedFiles({
6299
+ const snapshotChangedFiles = !needsSnapshotDiff ? /* @__PURE__ */ new Map() : updateTurnHistoryChangedFiles({
6280
6300
  baseFiles: input.baseFiles,
6281
6301
  currentFiles
6282
6302
  });
6283
6303
  const capturedRecords = yield* buildCapturedRecordsFromBasesEffect(input);
6284
6304
  const turnCapturedRecords = yield* buildCapturedTurnTextRecordsFromFilesEffect(input, turnCapturedFiles);
6285
6305
  const turnChangedFiles = turnCapturedRecords;
6286
- const changedFiles = mergeCapturedChangedFileRecords(snapshotChangedFiles, capturedRecords);
6306
+ const changedFiles = input.capturedBases === void 0 ? snapshotChangedFiles : capturedRecords;
6287
6307
  const lineStatsCache = /* @__PURE__ */ new Map();
6288
6308
  const changedFilesWithStats = yield* attachTurnHistoryLineStatsEffect(changedFiles, input.host.textDocuments, input.host.computeTurnHistoryLineStats, lineStatsCache);
6289
6309
  const turnChangedFilesWithStats = yield* attachTurnHistoryLineStatsEffect(turnChangedFiles, input.host.textDocuments, input.host.computeTurnHistoryLineStats, lineStatsCache);
@@ -6326,14 +6346,6 @@ let __tla = Promise.all([
6326
6346
  contentUnavailable: "missing_text_frontiers"
6327
6347
  }))));
6328
6348
  }
6329
- function mergeCapturedChangedFileRecords(snapshotDerived, captured) {
6330
- if (captured === void 0 || captured.size === 0) return snapshotDerived;
6331
- const merged = new Map(snapshotDerived);
6332
- for (const [fileId, record] of captured) {
6333
- merged.set(fileId, record);
6334
- }
6335
- return merged;
6336
- }
6337
6349
  const MAX_CAPTURED_TURN_TEXT_CHARS = 2e6;
6338
6350
  const CAPTURED_CURRENT_TEXT_READ_CONCURRENCY = 16;
6339
6351
  function normalizeCapturedCurrentText(current) {
@@ -6514,7 +6526,7 @@ let __tla = Promise.all([
6514
6526
  return succeed$1(void 0);
6515
6527
  }
6516
6528
  if (input.textDocuments.getOpenTextDocument(file.fileId) !== void 0) {
6517
- return succeed$1(void 0);
6529
+ return materializeCapturedOpenTextFileRecordEffect(input);
6518
6530
  }
6519
6531
  return gen(function* () {
6520
6532
  const materialization = getCapturedTurnFileTextDocSeed(file);
@@ -6589,9 +6601,15 @@ let __tla = Promise.all([
6589
6601
  return materializeCapturedTextFileRecordEffect(input);
6590
6602
  }
6591
6603
  return gen(function* () {
6592
- const materialized = yield* materializeCapturedTurnTextIntoOpenDocumentEffect(input);
6604
+ return yield* materializeCapturedOpenTextFileRecordEffect(input);
6605
+ });
6606
+ }
6607
+ function materializeCapturedOpenTextFileRecordEffect(input) {
6608
+ const file = input.file;
6609
+ return gen(function* () {
6610
+ const materialized = yield* materializeCapturedTextIntoOpenDocumentEffect(input);
6593
6611
  yield* trySyncEffect(() => {
6594
- logCodeCollabRuntimeDebug("[Code Collab][turn-history] captured turn open-doc materialized", {
6612
+ logCodeCollabRuntimeDebug("[Code Collab][turn-history] captured open-doc materialized", {
6595
6613
  fileId: file.fileId,
6596
6614
  path: file.path,
6597
6615
  baseStatus: file.base.status,
@@ -6620,7 +6638,7 @@ let __tla = Promise.all([
6620
6638
  };
6621
6639
  });
6622
6640
  }
6623
- function materializeCapturedTurnTextIntoOpenDocumentEffect(input) {
6641
+ function materializeCapturedTextIntoOpenDocumentEffect(input) {
6624
6642
  const file = input.file;
6625
6643
  return gen(function* () {
6626
6644
  const liveBefore = yield* input.textDocuments.readCachedLiveTextEffect(file.fileId);
@@ -9922,6 +9940,8 @@ export {
9922
9940
  computeHostLoopSleepMs,
9923
9941
  computeHostTurnChanges,
9924
9942
  computeHostTurnChangesEffect,
9943
+ computeHostTurnFileDiff,
9944
+ computeHostTurnFileDiffEffect,
9925
9945
  c6 as computeTurnHistorySnapshotFileDiffStats,
9926
9946
  computeTurnHistorySnapshotLineStats,
9927
9947
  countTurnHistoryTextLineDiffStats,
@@ -9977,6 +9997,7 @@ export {
9977
9997
  isMissingHostRpcStreamAppendError,
9978
9998
  ci as isRetryableHostRpcStreamReadError,
9979
9999
  cj as isStaleHostRpcStreamReadOffsetError,
10000
+ loadTypeScriptModule,
9980
10001
  logCodeCollabRuntimeDebug,
9981
10002
  ck as makeCodeCollabConfigLayer,
9982
10003
  cl as makeCodeCollabHostTelemetrySink,