@neocompose/cli 0.58.1 → 0.58.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/neo.mjs CHANGED
@@ -86570,6 +86570,54 @@ var init_materialize_values = __esm({
86570
86570
  }
86571
86571
  });
86572
86572
 
86573
+ // ../convex/convexValues.ts
86574
+ function decodeConvexOpaqueJson(value, context) {
86575
+ if (typeof value !== "string") {
86576
+ throw new Error(`${context} must be an encoded JSON string.`);
86577
+ }
86578
+ try {
86579
+ return JSON.parse(value);
86580
+ } catch (error) {
86581
+ const message = error instanceof Error ? error.message : String(error);
86582
+ throw new Error(`${context} could not be parsed as JSON: ${message}`);
86583
+ }
86584
+ }
86585
+ var CONVEX_DOCUMENT_WARNING_BYTES, CONVEX_DOCUMENT_MAX_BYTES;
86586
+ var init_convexValues = __esm({
86587
+ "../convex/convexValues.ts"() {
86588
+ "use strict";
86589
+ CONVEX_DOCUMENT_WARNING_BYTES = 750 * 1024;
86590
+ CONVEX_DOCUMENT_MAX_BYTES = 1024 * 1024;
86591
+ }
86592
+ });
86593
+
86594
+ // ../convex/projectRecordSnapshotStorage.ts
86595
+ function decodeProjectRecordSnapshotData(snapshot, context = `Project record snapshot for ${snapshot.recordKind} "${snapshot.recordId}" dataJson`) {
86596
+ const decoded = decodeConvexOpaqueJson(snapshot.dataJson, context);
86597
+ if (!isPlainRecord(decoded)) return decoded;
86598
+ const hydratedData = { ...decoded };
86599
+ if (snapshot.recordKind === "enum" && !Object.hasOwn(hydratedData, "optionKeyOrder") && isPlainRecord(hydratedData.options)) {
86600
+ hydratedData.optionKeyOrder = Object.keys(hydratedData.options);
86601
+ }
86602
+ hydratedData.id = snapshot.recordId;
86603
+ if (snapshot.recordKind !== "project") {
86604
+ hydratedData.projectId = snapshot.projectId;
86605
+ }
86606
+ if (!Object.hasOwn(hydratedData, "updatedAt")) {
86607
+ hydratedData.updatedAt = snapshot.createdAt;
86608
+ }
86609
+ return hydratedData;
86610
+ }
86611
+ function isPlainRecord(value) {
86612
+ return typeof value === "object" && value !== null && !Array.isArray(value);
86613
+ }
86614
+ var init_projectRecordSnapshotStorage = __esm({
86615
+ "../convex/projectRecordSnapshotStorage.ts"() {
86616
+ "use strict";
86617
+ init_convexValues();
86618
+ }
86619
+ });
86620
+
86573
86621
  // ../src/database/project-read-base.ts
86574
86622
  import { ConvexError } from "convex/values";
86575
86623
  function readProjectReadBase(value) {
@@ -86887,6 +86935,7 @@ var project_document_read_exports = {};
86887
86935
  __export(project_document_read_exports, {
86888
86936
  DOCUMENT_MANIFEST_PAGE_SIZE: () => DOCUMENT_MANIFEST_PAGE_SIZE,
86889
86937
  assembleProjectDocumentRaw: () => assembleProjectDocumentRaw,
86938
+ createDocumentPageReader: () => createDocumentPageReader,
86890
86939
  fetchProjectDocumentPartitionRecords: () => fetchProjectDocumentPartitionRecords,
86891
86940
  fetchProjectDocumentRawChunked: () => fetchProjectDocumentRawChunked,
86892
86941
  fetchProjectDocumentRawChunkedOnce: () => fetchProjectDocumentRawChunkedOnce,
@@ -86944,46 +86993,14 @@ async function fetchProjectDocumentRawChunkedOnce(runner, options = {}) {
86944
86993
  };
86945
86994
  try {
86946
86995
  await rememberRecords(firstPage);
86947
- const fetchRemainingPages = async (mapKey, initialCursor) => {
86948
- let cursor = initialCursor;
86949
- while (cursor !== null) {
86950
- const pageResult = await runner.fetchPage(
86951
- {
86952
- numItems: DOCUMENT_MANIFEST_PAGE_SIZE,
86953
- cursor
86954
- },
86955
- mapKey,
86956
- readBase
86957
- );
86958
- if (pageResult === null) {
86959
- throw new Error(
86960
- "Convex project document manifest returned null for a continuation page."
86961
- );
86962
- }
86963
- const page = readProjectDocumentPage(pageResult);
86964
- assertProjectReadBase(readBase, page.readBase);
86965
- await rememberRecords(page);
86966
- cursor = page.continueCursor;
86967
- }
86968
- };
86969
- await fetchRemainingPages(firstMapKey, firstPage.continueCursor);
86970
- for (const mapKey of mapKeys.slice(1)) {
86971
- const pageResult = await runner.fetchPage(
86972
- { numItems: DOCUMENT_MANIFEST_PAGE_SIZE, cursor: null },
86973
- mapKey,
86974
- readBase,
86975
- "omit"
86976
- );
86977
- if (pageResult === null) {
86978
- throw new Error(
86979
- `Convex project document manifest returned null for partition "${mapKey ?? "all"}".`
86980
- );
86981
- }
86982
- const page = readProjectDocumentPage(pageResult);
86983
- assertProjectReadBase(readBase, page.readBase);
86984
- await rememberRecords(page);
86985
- await fetchRemainingPages(mapKey, page.continueCursor);
86986
- }
86996
+ const pages = createDocumentPageReader(runner, firstPage.readConcurrency);
86997
+ await drainDocumentReads([
86998
+ pages.remaining(firstPage, firstMapKey, readBase, rememberRecords),
86999
+ ...mapKeys.slice(1).map(async (mapKey) => {
87000
+ const page = await pages.first(mapKey, readBase, rememberRecords);
87001
+ await pages.remaining(page, mapKey, readBase, rememberRecords);
87002
+ })
87003
+ ]);
86987
87004
  const snapshotsById = await snapshots.finish();
86988
87005
  if (options.mapKeys !== void 0 && !options.mapKeys.includes("all")) {
86989
87006
  const members = [];
@@ -87043,28 +87060,15 @@ async function fetchProjectDocumentPartitionRecords(runner, mapKey, readBase) {
87043
87060
  (ids) => fetchScopedSnapshotBatch(runner, ids, readBase)
87044
87061
  );
87045
87062
  try {
87046
- let cursor = null;
87047
- do {
87048
- const pageResult = await runner.fetchPage(
87049
- { numItems: DOCUMENT_MANIFEST_PAGE_SIZE, cursor },
87050
- mapKey,
87051
- readBase,
87052
- "omit"
87053
- );
87054
- if (pageResult === null) {
87055
- throw new Error(
87056
- `Convex project document manifest returned null for partition "${mapKey}".`
87057
- );
87058
- }
87059
- const page = readProjectDocumentPage(pageResult);
87060
- assertProjectReadBase(readBase, page.readBase);
87061
- for (const record6 of page.records) {
87063
+ const pages = createDocumentPageReader(runner);
87064
+ const remember = async (page) => {
87065
+ for (const record6 of page.records)
87062
87066
  recordsByKey.set(`${record6.recordKind} ${record6.recordId}`, record6);
87063
- }
87064
87067
  if (page.snapshots !== void 0) snapshots.seed(page.snapshots);
87065
87068
  await snapshots.enqueue(page.records.map((record6) => record6.snapshotId));
87066
- cursor = page.continueCursor;
87067
- } while (cursor !== null);
87069
+ };
87070
+ const first = await pages.first(mapKey, readBase, remember);
87071
+ await pages.remaining(first, mapKey, readBase, remember);
87068
87072
  const snapshotsById = await snapshots.finish();
87069
87073
  await runner.validateReadBase(readBase);
87070
87074
  return [...recordsByKey.values()].map((record6) => {
@@ -87086,6 +87090,84 @@ async function fetchProjectDocumentPartitionRecords(runner, mapKey, readBase) {
87086
87090
  await snapshots.stop();
87087
87091
  }
87088
87092
  }
87093
+ function createDocumentPageReader(runner, concurrency) {
87094
+ let active = 0;
87095
+ let nextWaiter = 0;
87096
+ let waiters = [];
87097
+ let failure;
87098
+ const readPage = async (pagination, mapKey, readBase, remember) => {
87099
+ if (active >= (concurrency ?? 1))
87100
+ await new Promise((resolve5) => waiters.push(resolve5));
87101
+ else active++;
87102
+ try {
87103
+ if (failure !== void 0) throw failure.error;
87104
+ const raw = await runner.fetchPage(pagination, mapKey, readBase, "omit");
87105
+ if (raw === null)
87106
+ throw new Error(
87107
+ `Missing document page for partition "${mapKey ?? "all"}".`
87108
+ );
87109
+ const page = readProjectDocumentPage(raw);
87110
+ assertProjectReadBase(readBase, page.readBase);
87111
+ concurrency ??= page.readConcurrency ?? 1;
87112
+ if (pagination.cursor !== null && page.continueCursor === pagination.cursor)
87113
+ throw new Error("Document continuation made no progress.");
87114
+ if (pagination.endCursor != null && page.continueCursor === null)
87115
+ throw new Error("Document range ended before its endpoint.");
87116
+ await remember(page, pagination.cursor);
87117
+ return page;
87118
+ } catch (error) {
87119
+ failure ??= { error };
87120
+ throw error;
87121
+ } finally {
87122
+ const next = waiters[nextWaiter++];
87123
+ if (next !== void 0) next();
87124
+ else {
87125
+ active--;
87126
+ nextWaiter = 0;
87127
+ waiters = [];
87128
+ }
87129
+ }
87130
+ };
87131
+ return {
87132
+ first(mapKey, readBase, remember) {
87133
+ return readPage(
87134
+ { numItems: DOCUMENT_MANIFEST_PAGE_SIZE, cursor: null },
87135
+ mapKey,
87136
+ readBase,
87137
+ remember
87138
+ );
87139
+ },
87140
+ async remaining(first, mapKey, readBase, remember) {
87141
+ if (first.continueCursor === null) return;
87142
+ const ranges = first.remainingRanges ?? [
87143
+ { cursor: first.continueCursor, endCursor: null }
87144
+ ];
87145
+ await drainDocumentReads(
87146
+ ranges.map(async (range2) => {
87147
+ let cursor = range2.cursor;
87148
+ while (cursor !== null && cursor !== range2.endCursor) {
87149
+ const page = await readPage(
87150
+ {
87151
+ numItems: DOCUMENT_MANIFEST_PAGE_SIZE,
87152
+ cursor,
87153
+ endCursor: range2.endCursor
87154
+ },
87155
+ mapKey,
87156
+ readBase,
87157
+ remember
87158
+ );
87159
+ cursor = page.continueCursor;
87160
+ }
87161
+ })
87162
+ );
87163
+ }
87164
+ };
87165
+ }
87166
+ async function drainDocumentReads(reads) {
87167
+ const results = await Promise.allSettled(reads);
87168
+ for (const result of results)
87169
+ if (result.status === "rejected") throw result.reason;
87170
+ }
87089
87171
  async function fetchProjectDocumentValueRecords(runner, valueIds, readBase) {
87090
87172
  if (runner.fetchValueSnapshotsPage === void 0) {
87091
87173
  throw new Error(
@@ -87151,6 +87233,41 @@ function readProjectDocumentPage(value) {
87151
87233
  "Convex project document manifest page continueCursor must be a string or null."
87152
87234
  );
87153
87235
  }
87236
+ let remainingRanges;
87237
+ if (value.remainingRanges !== void 0) {
87238
+ if (!Array.isArray(value.remainingRanges))
87239
+ throw new Error("Snapshot remaining ranges must be an array.");
87240
+ remainingRanges = [];
87241
+ let expectedCursor = continueCursor;
87242
+ for (const range2 of value.remainingRanges) {
87243
+ if (!isObject4(range2))
87244
+ throw new Error("Snapshot range must be an object.");
87245
+ if (typeof range2.cursor !== "string")
87246
+ throw new Error("Snapshot range cursor must be a string.");
87247
+ if (range2.endCursor !== null && typeof range2.endCursor !== "string")
87248
+ throw new Error("Snapshot range end cursor must be a string or null.");
87249
+ if (range2.cursor !== expectedCursor)
87250
+ throw new Error("Snapshot ranges must form a contiguous continuation.");
87251
+ if (range2.cursor === range2.endCursor)
87252
+ throw new Error("Snapshot range must make progress.");
87253
+ remainingRanges.push({
87254
+ cursor: range2.cursor,
87255
+ endCursor: range2.endCursor
87256
+ });
87257
+ expectedCursor = range2.endCursor;
87258
+ }
87259
+ if (expectedCursor !== null)
87260
+ throw new Error("Snapshot ranges must cover the entire remaining tail.");
87261
+ }
87262
+ const readConcurrency = value.readConcurrency;
87263
+ if (readConcurrency !== void 0) {
87264
+ if (typeof readConcurrency !== "number")
87265
+ throw new Error("Document read concurrency must be a number.");
87266
+ if (!Number.isSafeInteger(readConcurrency))
87267
+ throw new Error("Document read concurrency must be a safe integer.");
87268
+ if (readConcurrency < 1)
87269
+ throw new Error("Document read concurrency must be positive.");
87270
+ }
87154
87271
  const metadata = value.metadata ?? null;
87155
87272
  if (metadata !== null && !isObject4(metadata)) {
87156
87273
  throw new Error(
@@ -87167,6 +87284,8 @@ function readProjectDocumentPage(value) {
87167
87284
  releaseChannels: metadata.releaseChannels,
87168
87285
  documentRevision: metadata.documentRevision
87169
87286
  },
87287
+ ...remainingRanges === void 0 ? {} : { remainingRanges },
87288
+ ...readConcurrency === void 0 ? {} : { readConcurrency },
87170
87289
  ...snapshots === void 0 ? {} : { snapshots },
87171
87290
  records: snapshots === void 0 ? readProjectDocumentManifestRecords(value.records) : snapshots.map((snapshot) => ({
87172
87291
  recordKind: snapshot.recordKind,
@@ -87220,7 +87339,21 @@ function readProjectDocumentManifestPageRecords(value) {
87220
87339
  if (!isObject4(value)) {
87221
87340
  throw new Error("Convex project document manifest page must be an object.");
87222
87341
  }
87223
- return readProjectDocumentPage(value).records;
87342
+ if (value.snapshots === void 0)
87343
+ return readProjectDocumentManifestRecords(value.records);
87344
+ if (!Array.isArray(value.snapshots))
87345
+ throw new Error("Snapshot page snapshots must be an array.");
87346
+ return readProjectDocumentManifestRecords(
87347
+ value.snapshots.map((snapshot) => {
87348
+ if (!isObject4(snapshot))
87349
+ throw new Error("Snapshot page entry must be an object.");
87350
+ return {
87351
+ recordKind: snapshot.recordKind,
87352
+ recordId: snapshot.recordId,
87353
+ snapshotId: snapshot.id
87354
+ };
87355
+ })
87356
+ );
87224
87357
  }
87225
87358
  async function fetchProjectDocumentSnapshots(fetchBatch, snapshotIds) {
87226
87359
  const loader = createProjectDocumentSnapshotLoader(fetchBatch);
@@ -87236,6 +87369,7 @@ function createProjectDocumentSnapshotLoader(fetchBatch) {
87236
87369
  const snapshotsById = /* @__PURE__ */ new Map();
87237
87370
  const active = /* @__PURE__ */ new Set();
87238
87371
  let pending = [];
87372
+ let enqueued = Promise.resolve();
87239
87373
  let stopped = false;
87240
87374
  let failure;
87241
87375
  const checkFailure = () => {
@@ -87272,17 +87406,21 @@ function createProjectDocumentSnapshotLoader(fetchBatch) {
87272
87406
  snapshotsById.set(snapshot.id, snapshot);
87273
87407
  }
87274
87408
  },
87275
- async enqueue(snapshotIds) {
87276
- checkFailure();
87277
- for (const id2 of snapshotIds) {
87278
- if (seen.has(id2)) continue;
87279
- seen.add(id2);
87280
- pending.push(id2);
87281
- if (pending.length === DOCUMENT_SNAPSHOT_FETCH_CHUNK_SIZE)
87282
- await flush();
87283
- }
87409
+ enqueue(snapshotIds) {
87410
+ enqueued = enqueued.then(async () => {
87411
+ checkFailure();
87412
+ for (const id2 of snapshotIds) {
87413
+ if (seen.has(id2)) continue;
87414
+ seen.add(id2);
87415
+ pending.push(id2);
87416
+ if (pending.length === DOCUMENT_SNAPSHOT_FETCH_CHUNK_SIZE)
87417
+ await flush();
87418
+ }
87419
+ });
87420
+ return enqueued;
87284
87421
  },
87285
87422
  async finish() {
87423
+ await enqueued;
87286
87424
  await flush();
87287
87425
  await Promise.all(active);
87288
87426
  checkFailure();
@@ -87290,6 +87428,8 @@ function createProjectDocumentSnapshotLoader(fetchBatch) {
87290
87428
  },
87291
87429
  async stop() {
87292
87430
  stopped = true;
87431
+ await enqueued.catch(() => {
87432
+ });
87293
87433
  await Promise.all(active);
87294
87434
  }
87295
87435
  };
@@ -87361,6 +87501,30 @@ function readProjectDocumentSnapshotBatch(value, requestedIds) {
87361
87501
  `Convex project record snapshot "${snapshot.id}" is missing a content hash.`
87362
87502
  );
87363
87503
  }
87504
+ let data = snapshot.data;
87505
+ if ("dataJson" in snapshot) {
87506
+ if (typeof snapshot.dataJson !== "string")
87507
+ throw new Error(`Snapshot "${snapshot.id}" dataJson must be a string.`);
87508
+ if (typeof snapshot.projectId !== "string")
87509
+ throw new Error(
87510
+ `Snapshot "${snapshot.id}" projectId must be a string.`
87511
+ );
87512
+ if (typeof snapshot.createdAt !== "number")
87513
+ throw new Error(
87514
+ `Snapshot "${snapshot.id}" createdAt must be a number.`
87515
+ );
87516
+ if (!Number.isFinite(snapshot.createdAt))
87517
+ throw new Error(
87518
+ `Snapshot "${snapshot.id}" createdAt must be finite milliseconds.`
87519
+ );
87520
+ data = decodeProjectRecordSnapshotData({
87521
+ projectId: snapshot.projectId,
87522
+ recordKind,
87523
+ recordId: snapshot.recordId,
87524
+ createdAt: snapshot.createdAt,
87525
+ dataJson: snapshot.dataJson
87526
+ });
87527
+ }
87364
87528
  return {
87365
87529
  id: snapshot.id,
87366
87530
  recordKind,
@@ -87371,7 +87535,7 @@ function readProjectDocumentSnapshotBatch(value, requestedIds) {
87371
87535
  data: readCurrentProjectRecordData({
87372
87536
  recordKind,
87373
87537
  dataSchemaVersion: snapshot.dataSchemaVersion,
87374
- data: snapshot.data
87538
+ data
87375
87539
  })
87376
87540
  };
87377
87541
  });
@@ -87693,6 +87857,7 @@ var DOCUMENT_MANIFEST_PAGE_SIZE, DOCUMENT_SNAPSHOT_FETCH_CHUNK_SIZE, DOCUMENT_SN
87693
87857
  var init_project_document_read = __esm({
87694
87858
  "../src/database/project-document-read.ts"() {
87695
87859
  "use strict";
87860
+ init_projectRecordSnapshotStorage();
87696
87861
  init_project_read_base();
87697
87862
  init_project2();
87698
87863
  init_members();
@@ -87711,7 +87876,7 @@ var init_project_document_read = __esm({
87711
87876
  init_projectRecordBuckets();
87712
87877
  init_project_record_migrations();
87713
87878
  init_member_default_reference_ids();
87714
- DOCUMENT_MANIFEST_PAGE_SIZE = 2048;
87879
+ DOCUMENT_MANIFEST_PAGE_SIZE = 8192;
87715
87880
  DOCUMENT_SNAPSHOT_FETCH_CHUNK_SIZE = 128;
87716
87881
  DOCUMENT_SNAPSHOT_FETCH_CONCURRENCY = 4;
87717
87882
  }
@@ -88394,7 +88559,7 @@ var init_commit_preparation_scope_planner = __esm({
88394
88559
 
88395
88560
  // ../src/database/project-record-semantics.ts
88396
88561
  function projectRecordSemanticData(value) {
88397
- if (!isPlainRecord(value)) return value;
88562
+ if (!isPlainRecord2(value)) return value;
88398
88563
  const semantic = {};
88399
88564
  for (const [key, child] of Object.entries(value)) {
88400
88565
  if (SERVER_MANAGED_PROJECT_RECORD_FIELDS.has(key)) continue;
@@ -88431,7 +88596,7 @@ function toCanonicalJsonValue2(value) {
88431
88596
  if (Array.isArray(value)) {
88432
88597
  return value.map((item) => toCanonicalJsonValue2(item) ?? null);
88433
88598
  }
88434
- if (!isPlainRecord(value)) {
88599
+ if (!isPlainRecord2(value)) {
88435
88600
  throw new Error("Cannot canonicalize a non-plain object.");
88436
88601
  }
88437
88602
  const canonical = {};
@@ -88445,7 +88610,7 @@ function toCanonicalJsonValue2(value) {
88445
88610
  }
88446
88611
  return canonical;
88447
88612
  }
88448
- function isPlainRecord(value) {
88613
+ function isPlainRecord2(value) {
88449
88614
  if (value === null || typeof value !== "object") return false;
88450
88615
  const prototype = Object.getPrototypeOf(value);
88451
88616
  return prototype === Object.prototype || prototype === null;
@@ -88479,7 +88644,7 @@ function stagedChangesAffectClassRelations(current, changes) {
88479
88644
  const before2 = classesById.get(change.recordId);
88480
88645
  if (before2 === void 0) return true;
88481
88646
  const after = change.nextData;
88482
- if (!isPlainRecord2(after)) return true;
88647
+ if (!isPlainRecord3(after)) return true;
88483
88648
  if (before2.extendsClassId !== after.extendsClassId) return true;
88484
88649
  continue;
88485
88650
  }
@@ -88498,11 +88663,11 @@ function valueCreateCannotAffectClassRelations(change, before) {
88498
88663
  return before === void 0;
88499
88664
  }
88500
88665
  function relationEndpointClassId(record6) {
88501
- if (!isPlainRecord2(record6)) return void 0;
88666
+ if (!isPlainRecord3(record6)) return void 0;
88502
88667
  if (typeof record6.classId === "string") return record6.classId;
88503
88668
  return void 0;
88504
88669
  }
88505
- function isPlainRecord2(value) {
88670
+ function isPlainRecord3(value) {
88506
88671
  if (value === null || typeof value !== "object") return false;
88507
88672
  return !Array.isArray(value);
88508
88673
  }
@@ -88558,7 +88723,7 @@ function assertWorldFootprintEntryTypes(document, changes) {
88558
88723
  if (change.recordKind !== "value" || change.operation === "delete" || change.deleted)
88559
88724
  continue;
88560
88725
  referencedIds2.add(change.recordId);
88561
- if (isPlainRecord3(change.nextData) && Array.isArray(change.nextData.value)) {
88726
+ if (isPlainRecord4(change.nextData) && Array.isArray(change.nextData.value)) {
88562
88727
  for (const id2 of change.nextData.value)
88563
88728
  if (typeof id2 === "string") referencedIds2.add(id2);
88564
88729
  }
@@ -88595,14 +88760,14 @@ function createdWorldPlacementIds(changes, worldKinds) {
88595
88760
  }
88596
88761
  function hasWorldPlacementBinding(value, worldKinds) {
88597
88762
  if (hasWorldPlacementSidecar(value)) return true;
88598
- if (!isPlainRecord3(value) || typeof value.containerId !== "string")
88763
+ if (!isPlainRecord4(value) || typeof value.containerId !== "string")
88599
88764
  return false;
88600
88765
  if (typeof value.classId !== "string") return false;
88601
88766
  const kind = worldKinds?.get(value.classId);
88602
88767
  return kind === NeoWorldSystemClassKind.Tile;
88603
88768
  }
88604
88769
  function hasWorldPlacementSidecar(value) {
88605
- if (!isPlainRecord3(value) || !isPlainRecord3(value.value)) return false;
88770
+ if (!isPlainRecord4(value) || !isPlainRecord4(value.value)) return false;
88606
88771
  const body = value.value;
88607
88772
  if (typeof body.assetClassId === "string") return true;
88608
88773
  if (typeof body.assetValueId === "string") return true;
@@ -88616,7 +88781,7 @@ function worldPlacementBindingChanged(before, after) {
88616
88781
  );
88617
88782
  }
88618
88783
  function worldPlacementBindingSlice(value) {
88619
- if (!isPlainRecord3(value) || !isPlainRecord3(value.value)) return null;
88784
+ if (!isPlainRecord4(value) || !isPlainRecord4(value.value)) return null;
88620
88785
  return {
88621
88786
  classId: value.classId ?? null,
88622
88787
  containerId: value.containerId ?? null,
@@ -88635,13 +88800,13 @@ function ownedSparseValueBindingChanged(before, after) {
88635
88800
  );
88636
88801
  }
88637
88802
  function ownedSparseValueBindingSlice(value) {
88638
- if (!isPlainRecord3(value)) return null;
88803
+ if (!isPlainRecord4(value)) return null;
88639
88804
  return {
88640
88805
  classId: value.classId ?? null,
88641
88806
  containerId: value.containerId ?? null
88642
88807
  };
88643
88808
  }
88644
- function isPlainRecord3(value) {
88809
+ function isPlainRecord4(value) {
88645
88810
  return typeof value === "object" && value !== null && !Array.isArray(value);
88646
88811
  }
88647
88812
  function stagedChangesRequireWorldLayerBindingValidation(current, changes) {
@@ -88657,14 +88822,14 @@ function stagedChangesRequireWorldLayerBindingValidation(current, changes) {
88657
88822
  continue;
88658
88823
  }
88659
88824
  if (change.recordKind !== "class") continue;
88660
- if (change.operation === "create" && change.deleted !== true && !classesById.has(change.recordId) && isPlainRecord3(change.nextData) && change.nextData.extendsClassId == null && change.nextData.system == null)
88825
+ if (change.operation === "create" && change.deleted !== true && !classesById.has(change.recordId) && isPlainRecord4(change.nextData) && change.nextData.extendsClassId == null && change.nextData.system == null)
88661
88826
  continue;
88662
88827
  if (change.operation !== "update") return true;
88663
88828
  if (change.deleted === true) return true;
88664
88829
  const before = classesById.get(change.recordId);
88665
88830
  if (before === void 0) return true;
88666
88831
  const after = change.nextData;
88667
- if (!isPlainRecord3(after)) return true;
88832
+ if (!isPlainRecord4(after)) return true;
88668
88833
  if (before.extendsClassId !== after.extendsClassId) return true;
88669
88834
  if (isAbstractClass(before) !== isAbstractClass(after)) return true;
88670
88835
  if (!worldClassSystemBlockIsEqual(before.system, after.system)) return true;
@@ -88686,12 +88851,12 @@ function stagedChangesRequireWorldLayerBindingValidation(current, changes) {
88686
88851
  before,
88687
88852
  change.deleted === true || change.operation === "delete" ? null : change.nextData
88688
88853
  ) ? [before, change.nextData] : []) {
88689
- if (!isPlainRecord3(row) || typeof row.containerId !== "string") continue;
88854
+ if (!isPlainRecord4(row) || typeof row.containerId !== "string") continue;
88690
88855
  for (const owner of [
88691
88856
  valuesById.get(row.containerId),
88692
88857
  changedValuesById.get(row.containerId)
88693
88858
  ]) {
88694
- if (isPlainRecord3(owner) && isPlainRecord3(owner.value) && owner.value.assetValueId === change.recordId)
88859
+ if (isPlainRecord4(owner) && isPlainRecord4(owner.value) && owner.value.assetValueId === change.recordId)
88695
88860
  return true;
88696
88861
  }
88697
88862
  }
@@ -88714,9 +88879,9 @@ function worldClassSystemBlockIsEqual(before, after) {
88714
88879
  );
88715
88880
  }
88716
88881
  function hasWorldLayerOverrideMetadata(record6) {
88717
- if (!isPlainRecord3(record6)) return false;
88882
+ if (!isPlainRecord4(record6)) return false;
88718
88883
  const value = record6.value;
88719
- if (!isPlainRecord3(value)) return false;
88884
+ if (!isPlainRecord4(value)) return false;
88720
88885
  return typeof value.layerOverrideValueId === "string";
88721
88886
  }
88722
88887
  var init_project_world_placement_bindings = __esm({
@@ -92493,7 +92658,8 @@ function planCommitPreparationLoadedClosureScope(args) {
92493
92658
  if (rules.has("ancestor-paths") && record6.parentRecordKind !== null && record6.parentRecordKind !== void 0 && record6.parentRecordId !== null && record6.parentRecordId !== void 0) {
92494
92659
  rememberExact(record6.parentRecordKind, record6.parentRecordId);
92495
92660
  }
92496
- const canOwnStoredDescendants = record6.recordKind !== "value" || !isLiteralValueContent(record6.data) || !["string", "number", "boolean"].includes(typeof record6.data.value) || typeof record6.data.classId === "string" || isVirtualInstanceRootShape(record6.data);
92661
+ const memberWithoutStoredChildren = record6.recordKind === "member" && isMemberBase(record6.data) && getOptionalString(record6.data, "valueId") === void 0 && record6.data.defaultValue === void 0;
92662
+ const canOwnStoredDescendants = !memberWithoutStoredChildren && (record6.recordKind !== "value" || !isLiteralValueContent(record6.data) || !["string", "number", "boolean"].includes(typeof record6.data.value) || typeof record6.data.classId === "string" || isVirtualInstanceRootShape(record6.data));
92497
92663
  if (rules.has("descendants") && record6.includeDescendants !== false && canOwnStoredDescendants && (record6.recordKind === "member" || record6.recordKind === "value" || record6.recordKind === "class" || record6.recordKind === "variant")) {
92498
92664
  rememberRange({
92499
92665
  rangeKind: "children",
@@ -106578,7 +106744,7 @@ function systemProtectedWriteInheritedRecordId(write) {
106578
106744
  return null;
106579
106745
  if (write.deleted) return null;
106580
106746
  if (!isSystemBearingRecordKind(write.recordKind)) return null;
106581
- if (!isPlainRecord4(write.nextData)) return null;
106747
+ if (!isPlainRecord5(write.nextData)) return null;
106582
106748
  if (readSystemMetadata(write.nextData) === null) return null;
106583
106749
  const extendsMemberId = write.nextData.extendsMemberId;
106584
106750
  if (typeof extendsMemberId !== "string") return null;
@@ -106598,7 +106764,7 @@ function assertSystemProtectedRecordWriteValid(write) {
106598
106764
  assertSystemMetadataUnchanged(write, base);
106599
106765
  }
106600
106766
  function readBaseRecord(write) {
106601
- if (!isPlainRecord4(write.baseData)) return null;
106767
+ if (!isPlainRecord5(write.baseData)) return null;
106602
106768
  return {
106603
106769
  recordKind: write.recordKind,
106604
106770
  data: write.baseData,
@@ -106611,7 +106777,7 @@ function collectSystemBearingBaseRecords(document) {
106611
106777
  const stored = document[collection];
106612
106778
  if (!Array.isArray(stored)) continue;
106613
106779
  for (const record6 of stored) {
106614
- if (!isPlainRecord4(record6)) continue;
106780
+ if (!isPlainRecord5(record6)) continue;
106615
106781
  const id2 = record6.id;
106616
106782
  if (typeof id2 !== "string") continue;
106617
106783
  records2.set(baseKey(recordKind, id2), {
@@ -106625,7 +106791,7 @@ function collectSystemBearingBaseRecords(document) {
106625
106791
  }
106626
106792
  function assertCreateDeclaresNoSystemMetadata(write) {
106627
106793
  if (!isSystemBearingRecordKind(write.recordKind)) return;
106628
- if (!isPlainRecord4(write.nextData)) return;
106794
+ if (!isPlainRecord5(write.nextData)) return;
106629
106795
  const system = readSystemMetadata(write.nextData);
106630
106796
  if (system === null) return;
106631
106797
  if (inheritsLegacyEmittedSystemMetadata(write, system)) return;
@@ -106651,11 +106817,11 @@ function assertProtectedRecordNotEdited(change, base) {
106651
106817
  )) {
106652
106818
  return;
106653
106819
  }
106654
- if (!isPlainRecord4(change.nextData)) return;
106820
+ if (!isPlainRecord5(change.nextData)) return;
106655
106821
  if (authoredFieldsEqual(change.recordKind, base.data, change.nextData)) {
106656
106822
  return;
106657
106823
  }
106658
- if (isInheritedWorldDefaultEdit(change) && isPlainRecord4(change.inheritedBaseData) && change.inheritedBaseData.id === base.data.extendsMemberId && systemMetadataEqual(
106824
+ if (isInheritedWorldDefaultEdit(change) && isPlainRecord5(change.inheritedBaseData) && change.inheritedBaseData.id === base.data.extendsMemberId && systemMetadataEqual(
106659
106825
  base.system,
106660
106826
  readSystemMetadata(change.inheritedBaseData)
106661
106827
  ))
@@ -106667,7 +106833,7 @@ function assertProtectedRecordNotEdited(change, base) {
106667
106833
  function isInheritedWorldDefaultEdit(write) {
106668
106834
  if (write.recordKind !== "member" || write.recordId.startsWith("system_"))
106669
106835
  return false;
106670
- if (write.deleted || !isPlainRecord4(write.baseData) || !isPlainRecord4(write.nextData))
106836
+ if (write.deleted || !isPlainRecord5(write.baseData) || !isPlainRecord5(write.nextData))
106671
106837
  return false;
106672
106838
  if (readSystemMetadata(write.baseData)?.kind !== SystemProtectionKind.WorldAuthoring)
106673
106839
  return false;
@@ -106683,7 +106849,7 @@ function isInheritedWorldDefaultEdit(write) {
106683
106849
  );
106684
106850
  }
106685
106851
  function assertSystemMetadataUnchanged(change, base) {
106686
- if (!isPlainRecord4(change.nextData)) return;
106852
+ if (!isPlainRecord5(change.nextData)) return;
106687
106853
  const next = readSystemMetadata(change.nextData);
106688
106854
  if (systemMetadataEqual(base.system, next)) return;
106689
106855
  throw new Error(
@@ -106734,10 +106900,10 @@ function repointedChildValueIds(document, change) {
106734
106900
  );
106735
106901
  if (baseValue === void 0) return [];
106736
106902
  const before = baseValue.value;
106737
- if (!isPlainRecord4(before)) return [];
106738
- if (!isPlainRecord4(change.nextData)) return [];
106903
+ if (!isPlainRecord5(before)) return [];
106904
+ if (!isPlainRecord5(change.nextData)) return [];
106739
106905
  const after = change.nextData.value;
106740
- if (!isPlainRecord4(after)) return [];
106906
+ if (!isPlainRecord5(after)) return [];
106741
106907
  return Object.entries(before).flatMap(([schemaKey, childValueId2]) => {
106742
106908
  if (typeof childValueId2 !== "string") return [];
106743
106909
  if (after[schemaKey] === childValueId2) return [];
@@ -106772,7 +106938,7 @@ function isSystemBearingRecordKind(recordKind) {
106772
106938
  );
106773
106939
  }
106774
106940
  function readSystemMetadata(record6) {
106775
- if (!isPlainRecord4(record6)) return null;
106941
+ if (!isPlainRecord5(record6)) return null;
106776
106942
  const system = record6.system;
106777
106943
  if (!isSystemMetadata(system)) return null;
106778
106944
  return system;
@@ -106791,11 +106957,11 @@ function systemReason(system) {
106791
106957
  return SYSTEM_PROTECTION_RULES[system.kind].serverReason;
106792
106958
  }
106793
106959
  function describeChangedRecord(recordKind, recordId, record6) {
106794
- const name = isPlainRecord4(record6) ? record6.name : void 0;
106960
+ const name = isPlainRecord5(record6) ? record6.name : void 0;
106795
106961
  if (typeof name !== "string") return `Record ${recordKind} "${recordId}"`;
106796
106962
  return `Record ${recordKind} "${name}" (${recordId})`;
106797
106963
  }
106798
- function isPlainRecord4(value) {
106964
+ function isPlainRecord5(value) {
106799
106965
  return typeof value === "object" && value !== null && !Array.isArray(value);
106800
106966
  }
106801
106967
  function baseKey(recordKind, recordId) {
@@ -106926,7 +107092,7 @@ function readWorldReferenceList(args) {
106926
107092
  args.keyCandidates
106927
107093
  );
106928
107094
  if (schemaKey === null) return [];
106929
- if (!isPlainRecord5(args.ownerValue.value)) return [];
107095
+ if (!isPlainRecord6(args.ownerValue.value)) return [];
106930
107096
  const listValueId = args.ownerValue.value[schemaKey];
106931
107097
  if (typeof listValueId !== "string") return [];
106932
107098
  const listValue2 = args.graph.valuesById.get(listValueId);
@@ -106992,18 +107158,18 @@ function worldReferenceClassInherits(graph, classId, ancestorClassId) {
106992
107158
  return false;
106993
107159
  }
106994
107160
  function toWorldReferenceClassRecord(value) {
106995
- if (!isPlainRecord5(value)) return null;
107161
+ if (!isPlainRecord6(value)) return null;
106996
107162
  const id2 = stringField2(value, "id");
106997
107163
  if (id2 === null) return null;
106998
107164
  return {
106999
107165
  id: id2,
107000
107166
  extendsClassId: nullableStringField(value, "extendsClassId"),
107001
107167
  schema: isStringRecord8(value.schema) ? value.schema : void 0,
107002
- system: isPlainRecord5(value.system) ? value.system : null
107168
+ system: isPlainRecord6(value.system) ? value.system : null
107003
107169
  };
107004
107170
  }
107005
107171
  function toWorldReferenceValueRecord(value) {
107006
- if (!isPlainRecord5(value)) return null;
107172
+ if (!isPlainRecord6(value)) return null;
107007
107173
  const id2 = stringField2(value, "id");
107008
107174
  if (id2 === null) return null;
107009
107175
  return {
@@ -107017,10 +107183,10 @@ function worldReferenceValueClassId(value) {
107017
107183
  return typeof value.classId === "string" && value.classId.length > 0 ? value.classId : null;
107018
107184
  }
107019
107185
  function isStringRecord8(value) {
107020
- if (!isPlainRecord5(value)) return false;
107186
+ if (!isPlainRecord6(value)) return false;
107021
107187
  return Object.values(value).every((entry) => typeof entry === "string");
107022
107188
  }
107023
- function isPlainRecord5(value) {
107189
+ function isPlainRecord6(value) {
107024
107190
  return typeof value === "object" && value !== null && !Array.isArray(value);
107025
107191
  }
107026
107192
  function stringField2(value, key) {
@@ -107602,7 +107768,7 @@ function stagedAffectedWorldLayerLinkClassIds(args) {
107602
107768
  change.nextData
107603
107769
  ];
107604
107770
  for (const candidate of candidates) {
107605
- if (!isPlainRecord2(candidate)) continue;
107771
+ if (!isPlainRecord3(candidate)) continue;
107606
107772
  const relationKind = candidate.relationKind;
107607
107773
  if (typeof relationKind !== "string") continue;
107608
107774
  if (!isStagedWorldLayerLinkTargetRelationKind(relationKind)) continue;
@@ -107787,7 +107953,7 @@ function candidateActionListenerRowIds(projected, actions) {
107787
107953
  for (const row of projected.values) {
107788
107954
  if (storedRowActionListeners(row).length > 0) candidates.add(row.id);
107789
107955
  if (actionSchemaKeys.size === 0) continue;
107790
- if (!isPlainRecord2(row.value)) continue;
107956
+ if (!isPlainRecord3(row.value)) continue;
107791
107957
  for (const schemaKey of actionSchemaKeys) {
107792
107958
  const childId = row.value[schemaKey];
107793
107959
  if (typeof childId === "string") candidates.add(childId);
@@ -107797,7 +107963,7 @@ function candidateActionListenerRowIds(projected, actions) {
107797
107963
  }
107798
107964
  function storedRowActionListeners(row) {
107799
107965
  const body = row.value;
107800
- if (!isPlainRecord2(body)) return [];
107966
+ if (!isPlainRecord3(body)) return [];
107801
107967
  const listeners = body.listeners;
107802
107968
  return Array.isArray(listeners) ? listeners : [];
107803
107969
  }
@@ -107875,7 +108041,7 @@ function authoredActionListeners(action) {
107875
108041
  if (defaultValue === void 0 || defaultValue === null) return [];
107876
108042
  if (!isLiteralValueContent(defaultValue)) return [];
107877
108043
  const body = defaultValue.value;
107878
- if (!isPlainRecord2(body)) return [];
108044
+ if (!isPlainRecord3(body)) return [];
107879
108045
  const listeners = body.listeners;
107880
108046
  return Array.isArray(listeners) ? listeners : [];
107881
108047
  }
@@ -108237,7 +108403,7 @@ function candidateVariantRowIds(projected, variantMembers) {
108237
108403
  candidates.add(row.id);
108238
108404
  }
108239
108405
  if (schemaKeys.size === 0) continue;
108240
- if (!isPlainRecord2(row.value)) continue;
108406
+ if (!isPlainRecord3(row.value)) continue;
108241
108407
  for (const [schemaKey, childId] of Object.entries(row.value)) {
108242
108408
  if (schemaKeys.has(schemaKey) && typeof childId === "string")
108243
108409
  candidates.add(childId);
@@ -130576,27 +130742,6 @@ var init_convex = __esm({
130576
130742
  }
130577
130743
  });
130578
130744
 
130579
- // ../convex/convexValues.ts
130580
- function decodeConvexOpaqueJson(value, context) {
130581
- if (typeof value !== "string") {
130582
- throw new Error(`${context} must be an encoded JSON string.`);
130583
- }
130584
- try {
130585
- return JSON.parse(value);
130586
- } catch (error) {
130587
- const message = error instanceof Error ? error.message : String(error);
130588
- throw new Error(`${context} could not be parsed as JSON: ${message}`);
130589
- }
130590
- }
130591
- var CONVEX_DOCUMENT_WARNING_BYTES, CONVEX_DOCUMENT_MAX_BYTES;
130592
- var init_convexValues = __esm({
130593
- "../convex/convexValues.ts"() {
130594
- "use strict";
130595
- CONVEX_DOCUMENT_WARNING_BYTES = 750 * 1024;
130596
- CONVEX_DOCUMENT_MAX_BYTES = 1024 * 1024;
130597
- }
130598
- });
130599
-
130600
130745
  // ../src/database/project-version-transaction-result.ts
130601
130746
  function decodeProjectVersionTransactionResultPage(page) {
130602
130747
  const assignments = {};
@@ -131065,6 +131210,35 @@ var init_push_hook = __esm({
131065
131210
  }
131066
131211
  });
131067
131212
 
131213
+ // src/concurrency.ts
131214
+ async function mapWithConcurrency(values, concurrency, run) {
131215
+ let nextIndex = 0;
131216
+ let failure;
131217
+ const results = new Array(values.length);
131218
+ const worker = async () => {
131219
+ while (failure === void 0) {
131220
+ const index = nextIndex;
131221
+ nextIndex += 1;
131222
+ if (index >= values.length) return;
131223
+ try {
131224
+ results[index] = await run(values[index], index);
131225
+ } catch (error) {
131226
+ failure ??= { error };
131227
+ }
131228
+ }
131229
+ };
131230
+ await Promise.all(
131231
+ Array.from({ length: Math.min(concurrency, values.length) }, worker)
131232
+ );
131233
+ if (failure !== void 0) throw failure.error;
131234
+ return results;
131235
+ }
131236
+ var init_concurrency = __esm({
131237
+ "src/concurrency.ts"() {
131238
+ "use strict";
131239
+ }
131240
+ });
131241
+
131068
131242
  // src/project-source/project-file-push.ts
131069
131243
  import { basename as basename2, join as join9 } from "node:path";
131070
131244
  import { readFileSync as readFileSync11 } from "node:fs";
@@ -131493,28 +131667,6 @@ async function waitForRetry(attempt, signal) {
131493
131667
  signal.addEventListener("abort", abort, { once: true });
131494
131668
  });
131495
131669
  }
131496
- async function mapWithConcurrency(values, concurrency, run) {
131497
- let nextIndex = 0;
131498
- let firstError;
131499
- const results = new Array(values.length);
131500
- const worker = async () => {
131501
- while (firstError === void 0) {
131502
- const index = nextIndex;
131503
- nextIndex += 1;
131504
- if (index >= values.length) return;
131505
- try {
131506
- results[index] = await run(values[index]);
131507
- } catch (error) {
131508
- firstError ??= error;
131509
- }
131510
- }
131511
- };
131512
- await Promise.all(
131513
- Array.from({ length: Math.min(concurrency, values.length) }, worker)
131514
- );
131515
- if (firstError !== void 0) throw firstError;
131516
- return results;
131517
- }
131518
131670
  function combineSignals(...signals) {
131519
131671
  const defined = signals.filter(
131520
131672
  (signal) => signal !== void 0
@@ -131545,6 +131697,7 @@ var UPLOAD_CONCURRENCY, PRESIGN_BATCH_SIZE, MULTIPART_PART_CONCURRENCY, PRESIGN_
131545
131697
  var init_project_file_push = __esm({
131546
131698
  "src/project-source/project-file-push.ts"() {
131547
131699
  "use strict";
131700
+ init_concurrency();
131548
131701
  init_project_files();
131549
131702
  init_projection();
131550
131703
  init_src();
@@ -136245,11 +136398,19 @@ var init_reset = __esm({
136245
136398
  });
136246
136399
 
136247
136400
  // src/project-source/project-file-pull.ts
136248
- import { existsSync as existsSync11, rmSync as rmSync7 } from "node:fs";
136401
+ import {
136402
+ existsSync as existsSync11,
136403
+ mkdtempSync,
136404
+ readFileSync as readFileSync15,
136405
+ rmSync as rmSync7,
136406
+ writeFileSync as writeFileSync10
136407
+ } from "node:fs";
136408
+ import { tmpdir } from "node:os";
136249
136409
  import { join as join13 } from "node:path";
136250
136410
  async function pullProjectBinariesV4(args) {
136251
136411
  const resolvePath = createWorkspaceSourcePathResolver(args.workspace.root);
136252
- let client = args.client ?? null;
136412
+ const plans = /* @__PURE__ */ new Map();
136413
+ const downloads = [];
136253
136414
  const localById = new Map(
136254
136415
  (args.localBinaries ?? []).map((binary) => [binary.fileId, binary])
136255
136416
  );
@@ -136263,7 +136424,14 @@ async function pullProjectBinariesV4(args) {
136263
136424
  throw new Error(`project-file:${record6.recordId} must be an object.`);
136264
136425
  }
136265
136426
  if (record6.data.status !== "uploaded") continue;
136266
- client ??= NeoApiClient.forBaseUrl(args.workspace.config.apiBaseUrl);
136427
+ const existing = plans.get(record6.recordId);
136428
+ if (existing !== void 0) {
136429
+ if (existing.contentHash !== record6.contentHash)
136430
+ throw new Error(
136431
+ `Project file ${record6.recordId} appears with conflicting content hashes in the pulled document.`
136432
+ );
136433
+ continue;
136434
+ }
136267
136435
  const key = `project-file:${record6.recordId}`;
136268
136436
  const previous = args.previousRecords[key];
136269
136437
  const localStatus = localById.get(record6.recordId);
@@ -136276,7 +136444,6 @@ async function pullProjectBinariesV4(args) {
136276
136444
  record6.data,
136277
136445
  `project-file:${record6.recordId} metadata`
136278
136446
  );
136279
- let remoteBytes = null;
136280
136447
  let action = planBinaryMergeV4({
136281
136448
  baseDigest,
136282
136449
  localDigest,
@@ -136287,98 +136454,142 @@ async function pullProjectBinariesV4(args) {
136287
136454
  if (args.destructive === true) {
136288
136455
  action = localDigest === remoteDigest ? "unchanged" : "download";
136289
136456
  }
136290
- if (action === "download" || action === "conflict") {
136291
- if (remoteBytes === null) {
136292
- const response = await download(
136293
- record6.data,
136294
- record6.recordId,
136295
- client,
136296
- args.workspace
136297
- );
136298
- remoteBytes = response.bytes;
136299
- if (response.sha256 !== remoteDigest) {
136457
+ const plan = {
136458
+ key,
136459
+ fileId: record6.recordId,
136460
+ contentHash: record6.contentHash,
136461
+ data: record6.data,
136462
+ previous,
136463
+ path,
136464
+ baseDigest,
136465
+ remoteDigest,
136466
+ action
136467
+ };
136468
+ plans.set(record6.recordId, plan);
136469
+ if (action === "download" || action === "conflict") downloads.push(plan);
136470
+ }
136471
+ let stagingDirectory;
136472
+ try {
136473
+ const stagedPaths = /* @__PURE__ */ new Map();
136474
+ if (downloads.length > 0) {
136475
+ stagingDirectory = mkdtempSync(join13(tmpdir(), "neo-pull-files-"));
136476
+ const directory = stagingDirectory;
136477
+ const client = args.client ?? NeoApiClient.forBaseUrl(args.workspace.config.apiBaseUrl);
136478
+ await mapWithConcurrency(
136479
+ downloads,
136480
+ DOWNLOAD_CONCURRENCY,
136481
+ async (plan, index) => {
136482
+ const response = await download(
136483
+ plan.data,
136484
+ plan.fileId,
136485
+ client,
136486
+ args.workspace
136487
+ );
136488
+ if (response.sha256 !== plan.remoteDigest) {
136489
+ throw new Error(
136490
+ `Project file ${plan.fileId} content changed while pull was in progress (${plan.remoteDigest} -> ${response.sha256}). Pull again against a stable version head.`
136491
+ );
136492
+ }
136493
+ const stagedPath = join13(directory, String(index));
136494
+ writeFileSync10(stagedPath, response.bytes);
136495
+ stagedPaths.set(plan.fileId, stagedPath);
136496
+ }
136497
+ );
136498
+ }
136499
+ for (const plan of plans.values()) {
136500
+ const {
136501
+ key,
136502
+ fileId,
136503
+ data,
136504
+ previous,
136505
+ path,
136506
+ baseDigest,
136507
+ remoteDigest,
136508
+ action
136509
+ } = plan;
136510
+ const absolute = resolvePath(path);
136511
+ const stagedPath = stagedPaths.get(fileId);
136512
+ const remoteBytes = stagedPath === void 0 ? null : readFileSync15(stagedPath);
136513
+ if (action === "download") {
136514
+ if (remoteBytes === null) {
136300
136515
  throw new Error(
136301
- `Project file ${record6.recordId} content changed while pull was in progress (${remoteDigest} -> ${response.sha256}). Pull again against a stable version head.`
136516
+ `Project file ${fileId} download plan has no verified remote bytes.`
136302
136517
  );
136303
136518
  }
136519
+ writeVerifiedBinaryDownloadV4(absolute, remoteBytes, remoteDigest);
136520
+ downloaded += 1;
136521
+ states.set(key, binaryState(path, remoteDigest, data));
136522
+ continue;
136304
136523
  }
136305
- }
136306
- if (action === "download") {
136307
- if (remoteBytes === null) {
136308
- throw new Error(
136309
- `Project file ${record6.recordId} download plan has no verified remote bytes.`
136310
- );
136524
+ if (action === "conflict") {
136525
+ if (remoteBytes === null) {
136526
+ throw new Error(
136527
+ `Project file ${fileId} conflict plan has no verified remote bytes.`
136528
+ );
136529
+ }
136530
+ const artifactPath = writeBinaryConflictArtifactV4(
136531
+ args.workspace.root,
136532
+ fileId,
136533
+ fileName(data),
136534
+ remoteBytes,
136535
+ remoteDigest
136536
+ );
136537
+ const state = binaryState(path, baseDigest, data);
136538
+ states.set(key, {
136539
+ ...state,
136540
+ conflict: {
136541
+ action: "conflict",
136542
+ remoteSha256: remoteDigest,
136543
+ artifactPath
136544
+ }
136545
+ });
136546
+ conflicts.push(path);
136547
+ conflicted += 1;
136548
+ continue;
136311
136549
  }
136312
- writeVerifiedBinaryDownloadV4(absolute, remoteBytes, remoteDigest);
136313
- downloaded += 1;
136314
- states.set(key, binaryState(path, remoteDigest, record6.data));
136315
- continue;
136316
- }
136317
- if (action === "conflict") {
136318
- if (remoteBytes === null) {
136319
- throw new Error(
136320
- `Project file ${record6.recordId} conflict plan has no verified remote bytes.`
136321
- );
136550
+ if (action === "converged" || action === "unchanged") {
136551
+ states.set(key, binaryState(path, remoteDigest, data));
136552
+ removePreviousConflict(args.workspace.root, previous?.projectBinary);
136553
+ continue;
136322
136554
  }
136323
- const artifactPath = writeBinaryConflictArtifactV4(
136324
- args.workspace.root,
136325
- record6.recordId,
136326
- fileName(record6.data),
136327
- remoteBytes,
136328
- remoteDigest
136329
- );
136330
- const state = binaryState(path, baseDigest, record6.data);
136331
- states.set(key, {
136332
- ...state,
136333
- conflict: {
136334
- action: "conflict",
136335
- remoteSha256: remoteDigest,
136336
- artifactPath
136337
- }
136555
+ states.set(key, binaryState(path, baseDigest, data));
136556
+ }
136557
+ for (const [key, previous] of Object.entries(args.previousRecords)) {
136558
+ if (previous.recordKind !== "project-file") continue;
136559
+ if (args.document.records.has(key)) continue;
136560
+ const localStatus = localById.get(previous.recordId);
136561
+ const path = localStatus?.path ?? previous.projectBinary?.path ?? canonicalProjectBinaryPathV42(previous.data);
136562
+ const absolute = resolvePath(path);
136563
+ const localDigest = existsSync11(absolute) ? sha256File(absolute) : null;
136564
+ const baseDigest = previous.projectBinary?.sha256 ?? readSha256(previous.data) ?? null;
136565
+ const action = planBinaryMergeV4({
136566
+ baseDigest,
136567
+ localDigest,
136568
+ remoteDigest: null,
136569
+ declarationPresent: localStatus !== void 0,
136570
+ hadLocalBytes: previous.projectBinary !== void 0
136338
136571
  });
136339
- conflicts.push(path);
136340
- conflicted += 1;
136341
- continue;
136342
- }
136343
- if (action === "converged" || action === "unchanged") {
136344
- states.set(key, binaryState(path, remoteDigest, record6.data));
136345
- removePreviousConflict(args.workspace.root, previous?.projectBinary);
136346
- continue;
136347
- }
136348
- states.set(key, binaryState(path, baseDigest, record6.data));
136349
- }
136350
- for (const [key, previous] of Object.entries(args.previousRecords)) {
136351
- if (previous.recordKind !== "project-file") continue;
136352
- if (args.document.records.has(key)) continue;
136353
- const localStatus = localById.get(previous.recordId);
136354
- const path = localStatus?.path ?? previous.projectBinary?.path ?? canonicalProjectBinaryPathV42(previous.data);
136355
- const absolute = resolvePath(path);
136356
- const localDigest = existsSync11(absolute) ? sha256File(absolute) : null;
136357
- const baseDigest = previous.projectBinary?.sha256 ?? readSha256(previous.data) ?? null;
136358
- const action = planBinaryMergeV4({
136359
- baseDigest,
136360
- localDigest,
136361
- remoteDigest: null,
136362
- declarationPresent: localStatus !== void 0,
136363
- hadLocalBytes: previous.projectBinary !== void 0
136364
- });
136365
- if (action === "delete-modify") {
136366
- const data = isObjectRecord2(previous.data) ? previous.data : {};
136367
- states.set(key, {
136368
- ...binaryState(path, baseDigest, data),
136369
- conflict: {
136370
- action: "delete-modify",
136371
- remoteSha256: null
136372
- }
136373
- });
136374
- conflicts.push(path);
136375
- conflicted += 1;
136376
- continue;
136572
+ if (action === "delete-modify") {
136573
+ const data = isObjectRecord2(previous.data) ? previous.data : {};
136574
+ states.set(key, {
136575
+ ...binaryState(path, baseDigest, data),
136576
+ conflict: {
136577
+ action: "delete-modify",
136578
+ remoteSha256: null
136579
+ }
136580
+ });
136581
+ conflicts.push(path);
136582
+ conflicted += 1;
136583
+ continue;
136584
+ }
136585
+ rmSync7(absolute, { force: true });
136586
+ removePreviousConflict(args.workspace.root, previous.projectBinary);
136377
136587
  }
136378
- rmSync7(absolute, { force: true });
136379
- removePreviousConflict(args.workspace.root, previous.projectBinary);
136588
+ return { states, downloaded, conflicted, conflicts };
136589
+ } finally {
136590
+ if (stagingDirectory !== void 0)
136591
+ rmSync7(stagingDirectory, { recursive: true, force: true });
136380
136592
  }
136381
- return { states, downloaded, conflicted, conflicts };
136382
136593
  }
136383
136594
  async function download(data, fileId, client, workspace) {
136384
136595
  const version = typeof data.storageETag === "string" ? `?v=${encodeURIComponent(data.storageETag)}` : "";
@@ -136447,13 +136658,16 @@ function removePreviousConflict(root, state) {
136447
136658
  if (state?.conflict?.artifactPath === void 0) return;
136448
136659
  rmSync7(join13(root, state.conflict.artifactPath), { force: true });
136449
136660
  }
136661
+ var DOWNLOAD_CONCURRENCY;
136450
136662
  var init_project_file_pull = __esm({
136451
136663
  "src/project-source/project-file-pull.ts"() {
136452
136664
  "use strict";
136453
136665
  init_workspace_source_path();
136666
+ init_concurrency();
136454
136667
  init_http();
136455
136668
  init_projection();
136456
136669
  init_project_files();
136670
+ DOWNLOAD_CONCURRENCY = 8;
136457
136671
  }
136458
136672
  });
136459
136673
 
@@ -136578,10 +136792,10 @@ __export(pull_exports, {
136578
136792
  });
136579
136793
  import {
136580
136794
  mkdirSync as mkdirSync10,
136581
- writeFileSync as writeFileSync10,
136795
+ writeFileSync as writeFileSync11,
136582
136796
  rmSync as rmSync8,
136583
136797
  existsSync as existsSync12,
136584
- readFileSync as readFileSync15
136798
+ readFileSync as readFileSync16
136585
136799
  } from "node:fs";
136586
136800
  import { dirname as dirname9 } from "node:path";
136587
136801
  async function runPull(workspace, options, progress = spinner("Checking local workspace\u2026")) {
@@ -137048,7 +137262,7 @@ async function finishFormat4Pull(args) {
137048
137262
  let written = 0;
137049
137263
  for (const path of emittedPaths) {
137050
137264
  const absolute = resolveSourcePath(path);
137051
- const existing = existsSync12(absolute) ? readFileSync15(absolute, "utf8") : null;
137265
+ const existing = existsSync12(absolute) ? readFileSync16(absolute, "utf8") : null;
137052
137266
  const unprojectedConflictKeys = authoredLocalConflictKeysByPath.get(path) ?? [];
137053
137267
  if (unprojectedConflictKeys.length > 0 && existing === null) {
137054
137268
  throw new Error(
@@ -137070,7 +137284,7 @@ async function finishFormat4Pull(args) {
137070
137284
  mkdirSync10(dirname9(absolute), { recursive: true });
137071
137285
  if (existing !== null && !marked && !rewritePaths.has(path)) continue;
137072
137286
  if (existing !== content) {
137073
- writeFileSync10(absolute, content, "utf8");
137287
+ writeFileSync11(absolute, content, "utf8");
137074
137288
  written += 1;
137075
137289
  }
137076
137290
  }
@@ -137504,7 +137718,7 @@ var init_exports = {};
137504
137718
  __export(init_exports, {
137505
137719
  runInit: () => runInit
137506
137720
  });
137507
- import { existsSync as existsSync13, mkdirSync as mkdirSync11, readFileSync as readFileSync16, writeFileSync as writeFileSync11 } from "node:fs";
137721
+ import { existsSync as existsSync13, mkdirSync as mkdirSync11, readFileSync as readFileSync17, writeFileSync as writeFileSync12 } from "node:fs";
137508
137722
  import { join as join14, resolve as resolve3 } from "node:path";
137509
137723
  async function runInit(options) {
137510
137724
  let projectId = options.projectId;
@@ -137629,13 +137843,13 @@ async function runInit(options) {
137629
137843
  }
137630
137844
  function ensurePrivateStateIgnored(root) {
137631
137845
  const path = join14(root, ".gitignore");
137632
- const existing = existsSync13(path) ? readFileSync16(path, "utf8") : "";
137846
+ const existing = existsSync13(path) ? readFileSync17(path, "utf8") : "";
137633
137847
  if (existing.split(/\r?\n/u).some((line) => line.trim() === ".neo/" || line.trim() === ".neo")) {
137634
137848
  return;
137635
137849
  }
137636
137850
  const prefix = existing.length === 0 || existing.endsWith("\n") ? existing : `${existing}
137637
137851
  `;
137638
- writeFileSync11(path, `${prefix}.neo/
137852
+ writeFileSync12(path, `${prefix}.neo/
137639
137853
  `, "utf8");
137640
137854
  }
137641
137855
  var init_init = __esm({
@@ -139039,7 +139253,7 @@ __export(script_exports, {
139039
139253
  readDocumentArrays: () => readDocumentArrays,
139040
139254
  runScript: () => runScript
139041
139255
  });
139042
- import { readFileSync as readFileSync17 } from "node:fs";
139256
+ import { readFileSync as readFileSync18 } from "node:fs";
139043
139257
  function readDocumentArrays(raw) {
139044
139258
  const arrayOf2 = (field) => {
139045
139259
  const value = raw[field];
@@ -139559,9 +139773,9 @@ function buildRootValue(document, lookups) {
139559
139773
  }
139560
139774
  function readSource(options, fallback) {
139561
139775
  if (options.source !== null) return options.source;
139562
- if (options.file !== null) return readFileSync17(options.file, "utf8");
139776
+ if (options.file !== null) return readFileSync18(options.file, "utf8");
139563
139777
  if (fallback !== void 0) return fallback;
139564
- const stdin = readFileSync17(0, "utf8");
139778
+ const stdin = readFileSync18(0, "utf8");
139565
139779
  if (stdin.trim().length === 0) {
139566
139780
  throw new Error(
139567
139781
  "Provide NeoScript source as an argument, --file, or stdin."
@@ -140610,7 +140824,7 @@ var init_registry2 = __esm({
140610
140824
  "schema-contract/registry.mjs"() {
140611
140825
  "use strict";
140612
140826
  PROJECT_SCHEMA_CONTRACT = Object.freeze({
140613
- cliVersion: "0.58.1",
140827
+ cliVersion: "0.58.3",
140614
140828
  projectFileUploadBatchSize: 32,
140615
140829
  documentRecords: {
140616
140830
  member: {
@@ -142038,12 +142252,12 @@ import {
142038
142252
  existsSync as existsSync14,
142039
142253
  mkdirSync as mkdirSync12,
142040
142254
  readdirSync as readdirSync4,
142041
- readFileSync as readFileSync18,
142255
+ readFileSync as readFileSync19,
142042
142256
  realpathSync as realpathSync2,
142043
142257
  renameSync as renameSync7,
142044
142258
  rmSync as rmSync9,
142045
142259
  statSync as statSync2,
142046
- writeFileSync as writeFileSync12
142260
+ writeFileSync as writeFileSync13
142047
142261
  } from "node:fs";
142048
142262
  import {
142049
142263
  basename as basename3,
@@ -142257,7 +142471,7 @@ function preparedHookCandidate(workspace) {
142257
142471
  );
142258
142472
  }
142259
142473
  const parsed = JSON.parse(
142260
- readFileSync18(join15(directory, "candidate.json"), "utf8")
142474
+ readFileSync19(join15(directory, "candidate.json"), "utf8")
142261
142475
  );
142262
142476
  if (!isRecord10(parsed)) {
142263
142477
  throw new NeoTestPreparedCandidateError(
@@ -142327,7 +142541,7 @@ function testCandidateCachePath(workspace, inputFingerprint) {
142327
142541
  function cachedTestCandidate(workspace, inputFingerprint) {
142328
142542
  try {
142329
142543
  const candidatePath = testCandidateCachePath(workspace, inputFingerprint);
142330
- const parsed = JSON.parse(readFileSync18(candidatePath, "utf8"));
142544
+ const parsed = JSON.parse(readFileSync19(candidatePath, "utf8"));
142331
142545
  if (!isRecord10(parsed)) return null;
142332
142546
  if (parsed.version !== 1) return null;
142333
142547
  if (parsed.candidateRevision !== TEST_CANDIDATE_CACHE_REVISION) return null;
@@ -142338,7 +142552,7 @@ function cachedTestCandidate(workspace, inputFingerprint) {
142338
142552
  return null;
142339
142553
  }
142340
142554
  if (typeof parsed.documentSha256 !== "string") return null;
142341
- const documentJson = readFileSync18(
142555
+ const documentJson = readFileSync19(
142342
142556
  join15(dirname10(candidatePath), "document.json"),
142343
142557
  "utf8"
142344
142558
  );
@@ -142378,7 +142592,7 @@ function cacheTestCandidate(workspace, inputFingerprint, candidate) {
142378
142592
  function compileSpec(workspace, document, absolutePath, projectCompilationHash2) {
142379
142593
  const scriptDocument = readDocumentArrays(document);
142380
142594
  const path = relative8(workspace.root, absolutePath).split(sep8).join("/");
142381
- const source = readFileSync18(absolutePath, "utf8");
142595
+ const source = readFileSync19(absolutePath, "utf8");
142382
142596
  const sourceHash = createHash11("sha256").update(source).digest("hex");
142383
142597
  const artifactPath = join15(
142384
142598
  workspace.root,
@@ -142389,7 +142603,7 @@ function compileSpec(workspace, document, absolutePath, projectCompilationHash2)
142389
142603
  `${sourceHash}.json`
142390
142604
  );
142391
142605
  try {
142392
- const cached = JSON.parse(readFileSync18(artifactPath, "utf8"));
142606
+ const cached = JSON.parse(readFileSync19(artifactPath, "utf8"));
142393
142607
  if (isRecord10(cached) && cached.version === 1 && cached.compilerRevision === NEOSCRIPT_COMPILER_REVISION && cached.projectCompilationHash === projectCompilationHash2 && cached.sourceHash === sourceHash && isRecord10(cached.action) && typeof cached.artifactSha256 === "string" && createHash11("sha256").update(JSON.stringify(cached.action)).digest("hex") === cached.artifactSha256 && cached.action.compilerRevision === NEOSCRIPT_COMPILER_REVISION && Array.isArray(cached.action.parameters) && Array.isArray(cached.action.instructions) && isRecord10(cached.action.typeInfo)) {
142394
142608
  return {
142395
142609
  path,
@@ -143206,7 +143420,7 @@ async function executeRegisteredSpec(registered, document, selected, timeoutMs,
143206
143420
  function atomicWrite(path, content) {
143207
143421
  mkdirSync12(dirname10(path), { recursive: true });
143208
143422
  const temporary = `${path}.tmp-${String(process.pid)}-${randomUUID6()}`;
143209
- writeFileSync12(temporary, content, "utf8");
143423
+ writeFileSync13(temporary, content, "utf8");
143210
143424
  renameSync7(temporary, path);
143211
143425
  }
143212
143426
  function testBuildFiles(root) {
@@ -143752,7 +143966,7 @@ import {
143752
143966
  constants as fsConstants,
143753
143967
  accessSync,
143754
143968
  existsSync as existsSync15,
143755
- readFileSync as readFileSync19
143969
+ readFileSync as readFileSync20
143756
143970
  } from "node:fs";
143757
143971
  import { extname as extname2, isAbsolute as isAbsolute4, join as join16, relative as relative9, sep as sep9 } from "node:path";
143758
143972
  function inspectNeoDoctor(workspace) {
@@ -143837,7 +144051,7 @@ function inspectSourceContract(workspace) {
143837
144051
  );
143838
144052
  try {
143839
144053
  const inputs = files.map((file, index) => {
143840
- const text = readFileSync19(file, "utf8");
144054
+ const text = readFileSync20(file, "utf8");
143841
144055
  return {
143842
144056
  uri: relativeFiles[index],
143843
144057
  kind: requiredProjectSourceKindV4(relativeFiles[index], text),
@@ -143885,7 +144099,7 @@ function inspectExtensionContract(root) {
143885
144099
  };
143886
144100
  }
143887
144101
  try {
143888
- const value = JSON.parse(readFileSync19(cachePath, "utf8"));
144102
+ const value = JSON.parse(readFileSync20(cachePath, "utf8"));
143889
144103
  assertProjectSourceAnalysisV4(value);
143890
144104
  return {
143891
144105
  id: NEO_VSCODE_EXTENSION_ID,
@@ -144231,7 +144445,7 @@ __export(migrate_exports, {
144231
144445
  runMigrate: () => runMigrate
144232
144446
  });
144233
144447
  import { randomUUID as randomUUID7 } from "node:crypto";
144234
- import { existsSync as existsSync16, mkdirSync as mkdirSync13, readFileSync as readFileSync20, writeFileSync as writeFileSync13 } from "node:fs";
144448
+ import { existsSync as existsSync16, mkdirSync as mkdirSync13, readFileSync as readFileSync21, writeFileSync as writeFileSync14 } from "node:fs";
144235
144449
  import { join as join17, relative as relative10 } from "node:path";
144236
144450
  async function runMigrate(workspace, subcommand, positional, targetRef, json, dependencies = {}) {
144237
144451
  if (subcommand === "new") {
@@ -144245,7 +144459,7 @@ async function runMigrate(workspace, subcommand, positional, targetRef, json, de
144245
144459
  mkdirSync13(migrationsDir, { recursive: true });
144246
144460
  let nextOrder = 1;
144247
144461
  for (const path of listProjectSourceFilesV4(workspace.root)) {
144248
- const source = readFileSync20(path, "utf8");
144462
+ const source = readFileSync21(path, "utf8");
144249
144463
  if (neoProjectSourceKind(path, source) !== "migration") continue;
144250
144464
  const migration = parseMigrationFile(
144251
144465
  source,
@@ -144268,7 +144482,7 @@ async function runMigrate(workspace, subcommand, positional, targetRef, json, de
144268
144482
  target === "project" ? "// Runs once with root context. Write the NeoScript action below." : `// Runs once per ${target} value; \`this\` is the instance.`,
144269
144483
  ""
144270
144484
  ].join("\n");
144271
- writeFileSync13(absolute, template, "utf8");
144485
+ writeFileSync14(absolute, template, "utf8");
144272
144486
  console.log(`Created ${relPath} \u2014 edit the action body, then "neo push".`);
144273
144487
  console.log("(The id is assigned at push, same as schema creates.)");
144274
144488
  return;
@@ -146431,7 +146645,7 @@ __export(content_exports, {
146431
146645
  makeContentContext: () => makeContentContext,
146432
146646
  runLoc: () => runLoc
146433
146647
  });
146434
- import { readFileSync as readFileSync21 } from "node:fs";
146648
+ import { readFileSync as readFileSync22 } from "node:fs";
146435
146649
  import { randomUUID as randomUUID8 } from "node:crypto";
146436
146650
  function versionPath2(workspace, suffix) {
146437
146651
  return `/api/projects/${workspace.config.projectId}/versions/${workspace.config.versionId}/${suffix}`;
@@ -146439,9 +146653,9 @@ function versionPath2(workspace, suffix) {
146439
146653
  function readBatch(file) {
146440
146654
  let raw = null;
146441
146655
  if (file !== null) {
146442
- raw = readFileSync21(file, "utf8");
146656
+ raw = readFileSync22(file, "utf8");
146443
146657
  } else if (!process.stdin.isTTY) {
146444
- raw = readFileSync21(0, "utf8");
146658
+ raw = readFileSync22(0, "utf8");
146445
146659
  if (raw.trim().length === 0) raw = null;
146446
146660
  }
146447
146661
  if (raw === null) return null;
@@ -147689,9 +147903,9 @@ import { createHash as createHash12 } from "node:crypto";
147689
147903
  import {
147690
147904
  existsSync as existsSync17,
147691
147905
  mkdirSync as mkdirSync14,
147692
- readFileSync as readFileSync22,
147906
+ readFileSync as readFileSync23,
147693
147907
  unlinkSync,
147694
- writeFileSync as writeFileSync14
147908
+ writeFileSync as writeFileSync15
147695
147909
  } from "node:fs";
147696
147910
  import { dirname as dirname11, join as join18 } from "node:path";
147697
147911
  function validatePath(path) {
@@ -147702,7 +147916,7 @@ function validatePath(path) {
147702
147916
  }
147703
147917
  function readManifest(path) {
147704
147918
  if (!existsSync17(path)) return null;
147705
- const data = JSON.parse(readFileSync22(path, "utf8"));
147919
+ const data = JSON.parse(readFileSync23(path, "utf8"));
147706
147920
  if (data === null || typeof data !== "object" || !("schemaVersion" in data) || data.schemaVersion !== 1)
147707
147921
  throw new Error(`Invalid generated-file manifest version: ${path}`);
147708
147922
  if (!("files" in data) || !Array.isArray(data.files) || data.files.length === 0)
@@ -147782,7 +147996,7 @@ function writeUnityGeneratedFiles(directory, projectId, files) {
147782
147996
  const meta = join18(directory, old.path + ".meta");
147783
147997
  operations.push([
147784
147998
  path + ".meta",
147785
- existsSync17(meta) ? readFileSync22(meta, "utf8") : null
147999
+ existsSync17(meta) ? readFileSync23(meta, "utf8") : null
147786
148000
  ]);
147787
148001
  }
147788
148002
  operations.push([path, file.content]);
@@ -147809,7 +148023,7 @@ function writeUnityGeneratedFiles(directory, projectId, files) {
147809
148023
  if (!previous.has(key))
147810
148024
  previous.set(key, {
147811
148025
  path,
147812
- content: existsSync17(path) ? readFileSync22(path, "utf8") : null
148026
+ content: existsSync17(path) ? readFileSync23(path, "utf8") : null
147813
148027
  });
147814
148028
  }
147815
148029
  const write = (path, content) => {
@@ -147817,13 +148031,13 @@ function writeUnityGeneratedFiles(directory, projectId, files) {
147817
148031
  if (existsSync17(path)) unlinkSync(path);
147818
148032
  } else {
147819
148033
  mkdirSync14(dirname11(path), { recursive: true });
147820
- writeFileSync14(path, content);
148034
+ writeFileSync15(path, content);
147821
148035
  }
147822
148036
  };
147823
148037
  const changed = [];
147824
148038
  try {
147825
148039
  for (const [path, content] of operations) {
147826
- const current = existsSync17(path) ? readFileSync22(path, "utf8") : null;
148040
+ const current = existsSync17(path) ? readFileSync23(path, "utf8") : null;
147827
148041
  if (current === content) continue;
147828
148042
  changed.push(path);
147829
148043
  write(path, content);
@@ -147836,7 +148050,7 @@ function writeUnityGeneratedFiles(directory, projectId, files) {
147836
148050
  restored.add(key);
147837
148051
  const original = previous.get(key);
147838
148052
  if (original.path !== path && existsSync17(path)) unlinkSync(path);
147839
- const current = existsSync17(original.path) ? readFileSync22(original.path, "utf8") : null;
148053
+ const current = existsSync17(original.path) ? readFileSync23(original.path, "utf8") : null;
147840
148054
  if (current !== original.content) write(original.path, original.content);
147841
148055
  }
147842
148056
  throw error;
@@ -147853,7 +148067,7 @@ var export_exports = {};
147853
148067
  __export(export_exports, {
147854
148068
  runExportUnity: () => runExportUnity
147855
148069
  });
147856
- import { mkdirSync as mkdirSync15, writeFileSync as writeFileSync15 } from "node:fs";
148070
+ import { mkdirSync as mkdirSync15, writeFileSync as writeFileSync16 } from "node:fs";
147857
148071
  import { join as join19 } from "node:path";
147858
148072
  async function runExportUnity(workspace, outDir) {
147859
148073
  if (outDir === null) {
@@ -147876,9 +148090,9 @@ async function runExportUnity(workspace, outDir) {
147876
148090
  response.projectId,
147877
148091
  response.generatedFiles
147878
148092
  );
147879
- writeFileSync15(join19(resourcesDir, "project.json"), response.projectJson);
148093
+ writeFileSync16(join19(resourcesDir, "project.json"), response.projectJson);
147880
148094
  for (const file of response.localizationFiles ?? []) {
147881
- writeFileSync15(join19(localizationDir, file.fileName), file.content);
148095
+ writeFileSync16(join19(localizationDir, file.fileName), file.content);
147882
148096
  }
147883
148097
  console.log(`wrote ${join19(resourcesDir, "project.json")}`);
147884
148098
  console.log(`synchronized generated files in ${scriptsDir}`);
@@ -148077,7 +148291,7 @@ __export(resolve_exports, {
148077
148291
  resolveMarkers: () => resolveMarkers,
148078
148292
  runResolve: () => runResolve
148079
148293
  });
148080
- import { readFileSync as readFileSync23, rmSync as rmSync10, writeFileSync as writeFileSync16 } from "node:fs";
148294
+ import { readFileSync as readFileSync24, rmSync as rmSync10, writeFileSync as writeFileSync17 } from "node:fs";
148081
148295
  import { join as join21, relative as relative11 } from "node:path";
148082
148296
  function runResolve(workspace, side) {
148083
148297
  const marked = readMarkedProjectSourcesV4(workspace.root);
@@ -148088,7 +148302,7 @@ function runResolve(workspace, side) {
148088
148302
  const resolvedRecords = adoptServerConflictBases(workspace);
148089
148303
  let resolvedFiles = 0;
148090
148304
  for (const file of marked) {
148091
- writeFileSync16(file.absolutePath, resolveMarkers(file.source, side), "utf8");
148305
+ writeFileSync17(file.absolutePath, resolveMarkers(file.source, side), "utf8");
148092
148306
  resolvedFiles += 1;
148093
148307
  }
148094
148308
  let resolvedBinaries = 0;
@@ -148101,7 +148315,7 @@ function runResolve(workspace, side) {
148101
148315
  if (conflict2.remoteSha256 !== null && conflict2.artifactPath !== void 0) {
148102
148316
  writeVerifiedBinaryDownloadV4(
148103
148317
  destination,
148104
- readFileSync23(join21(workspace.root, conflict2.artifactPath)),
148318
+ readFileSync24(join21(workspace.root, conflict2.artifactPath)),
148105
148319
  conflict2.remoteSha256
148106
148320
  );
148107
148321
  binary.sha256 = conflict2.remoteSha256;
@@ -148130,7 +148344,7 @@ function runResolve(workspace, side) {
148130
148344
  function readMarkedProjectSourcesV4(root) {
148131
148345
  const files = [];
148132
148346
  for (const absolutePath of listProjectSourceFilesV4(root)) {
148133
- const source = readFileSync23(absolutePath, "utf8");
148347
+ const source = readFileSync24(absolutePath, "utf8");
148134
148348
  if (detectConflictMarkers(source) === null) continue;
148135
148349
  files.push({
148136
148350
  path: normalizeWorkspaceSourcePath(relative11(root, absolutePath)),
@@ -148431,7 +148645,7 @@ There is no --keep-current: preserving current semantic state defines flatten.
148431
148645
  async function main() {
148432
148646
  const args = parseArgs(process.argv.slice(2));
148433
148647
  if (args.command === "--version") {
148434
- console.log("0.58.1");
148648
+ console.log("0.58.3");
148435
148649
  return;
148436
148650
  }
148437
148651
  if (args.command === null || args.command === "help" || args.command === "--help" || args.command === "-h") {