@neocompose/cli 0.46.0 → 0.46.2

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
@@ -539,6 +539,64 @@ var init_token_store = __esm({
539
539
  }
540
540
  });
541
541
 
542
+ // src/spinner-renderer.ts
543
+ import { writeSync } from "node:fs";
544
+ import { Worker } from "node:worker_threads";
545
+ function startSpinnerRenderer(label, frames, colored) {
546
+ const state = new Int32Array(new SharedArrayBuffer(4));
547
+ const open = colored ? "\x1B[36m" : "";
548
+ const close = colored ? "\x1B[39m" : "";
549
+ writeSync(1, `\r\x1B[2K${open}${frames[0]}${close} ${label}`);
550
+ const worker = new Worker(RENDERER, {
551
+ eval: true,
552
+ execArgv: [],
553
+ workerData: { state: state.buffer, frames, label, open, close }
554
+ });
555
+ const stop = () => {
556
+ for (; ; ) {
557
+ const previous = Atomics.compareExchange(state, 0, 0, 2);
558
+ if (previous === 2) return;
559
+ if (previous === 0) break;
560
+ Atomics.wait(state, 0, 1);
561
+ }
562
+ void worker.terminate();
563
+ writeSync(1, "\r\x1B[2K");
564
+ };
565
+ worker.on("error", stop);
566
+ worker.unref();
567
+ return {
568
+ update(next) {
569
+ if (Atomics.load(state, 0) !== 2) worker.postMessage(next);
570
+ },
571
+ stop
572
+ };
573
+ }
574
+ var RENDERER;
575
+ var init_spinner_renderer = __esm({
576
+ "src/spinner-renderer.ts"() {
577
+ "use strict";
578
+ RENDERER = `
579
+ const { workerData, parentPort } = require("node:worker_threads");
580
+ const { writeSync } = require("node:fs");
581
+ const state = new Int32Array(workerData.state);
582
+ let label = workerData.label;
583
+ let frame = 1;
584
+ function render() {
585
+ if (Atomics.compareExchange(state, 0, 0, 1) !== 0) return;
586
+ try {
587
+ const glyph = workerData.frames[frame++ % workerData.frames.length];
588
+ writeSync(1, "\\r\\u001b[2K" + workerData.open + glyph + workerData.close + " " + label);
589
+ } finally {
590
+ Atomics.store(state, 0, 0);
591
+ Atomics.notify(state, 0);
592
+ }
593
+ }
594
+ parentPort.on("message", (next) => { label = next; render(); });
595
+ setInterval(render, 80);
596
+ `;
597
+ }
598
+ });
599
+
542
600
  // src/ui.ts
543
601
  function paint(open, close) {
544
602
  if (!colorEnabled) return (text) => text;
@@ -564,42 +622,45 @@ function paintChangeKind(kind) {
564
622
  return painter === void 0 ? kind : painter(kind);
565
623
  }
566
624
  function spinner(text) {
567
- if (!colorEnabled) {
625
+ if (process.stdout.isTTY !== true || process.env.TERM === "dumb") {
568
626
  console.log(text);
627
+ let stopped2 = false;
569
628
  return {
570
629
  update: () => void 0,
571
- succeed: (done) => console.log(done),
572
- fail: (done) => console.error(done),
573
- stop: () => void 0
630
+ succeed(done) {
631
+ if (!stopped2) console.log(done);
632
+ stopped2 = true;
633
+ },
634
+ fail(done) {
635
+ if (!stopped2) console.error(done);
636
+ stopped2 = true;
637
+ },
638
+ stop() {
639
+ stopped2 = true;
640
+ }
574
641
  };
575
642
  }
576
- let frame = 0;
577
- let label = text;
578
- const render = () => {
579
- process.stdout.write(
580
- `\r\x1B[2K${color.cyan(SPINNER_FRAMES[frame % SPINNER_FRAMES.length])} ${label}`
581
- );
582
- frame += 1;
583
- };
584
- render();
585
- const timer = setInterval(render, 80);
643
+ const renderer = startSpinnerRenderer(text, SPINNER_FRAMES, colorEnabled);
644
+ let stopped = false;
586
645
  const clear = () => {
587
- clearInterval(timer);
588
- process.stdout.write("\r\x1B[2K");
646
+ if (stopped) return false;
647
+ stopped = true;
648
+ renderer.stop();
649
+ return true;
589
650
  };
590
651
  return {
591
652
  update(next) {
592
- label = next;
653
+ if (!stopped) renderer.update(next);
593
654
  },
594
655
  succeed(done) {
595
- clear();
596
- console.log(`${sym.ok} ${done}`);
656
+ if (clear()) console.log(`${sym.ok} ${done}`);
597
657
  },
598
658
  fail(done) {
599
- clear();
600
- console.error(`${sym.fail} ${done}`);
659
+ if (clear()) console.error(`${sym.fail} ${done}`);
601
660
  },
602
- stop: clear
661
+ stop() {
662
+ clear();
663
+ }
603
664
  };
604
665
  }
605
666
  async function promptSelect(args) {
@@ -643,6 +704,7 @@ var colorEnabled, color, sym, CHANGE_KIND_COLOR, SPINNER_FRAMES;
643
704
  var init_ui = __esm({
644
705
  "src/ui.ts"() {
645
706
  "use strict";
707
+ init_spinner_renderer();
646
708
  colorEnabled = process.stdout.isTTY === true && process.env.NO_COLOR === void 0 && process.env.TERM !== "dumb";
647
709
  color = {
648
710
  bold: paint(1, 22),
@@ -46679,12 +46741,24 @@ function projectSchemaIndexFor(source, revision = EMPTY_REVISION) {
46679
46741
  byMembers = /* @__PURE__ */ new WeakMap();
46680
46742
  projectSchemaIndexes.set(source.classes, byMembers);
46681
46743
  }
46682
- const cached = byMembers.get(source.members);
46744
+ let byEnums = byMembers.get(source.members);
46745
+ if (byEnums === void 0) {
46746
+ byEnums = /* @__PURE__ */ new WeakMap();
46747
+ byMembers.set(source.members, byEnums);
46748
+ }
46749
+ const enumKey = source.enums ?? ABSENT_COLLECTION;
46750
+ let byConstructors = byEnums.get(enumKey);
46751
+ if (byConstructors === void 0) {
46752
+ byConstructors = /* @__PURE__ */ new WeakMap();
46753
+ byEnums.set(enumKey, byConstructors);
46754
+ }
46755
+ const constructorKey = source.constructors ?? ABSENT_COLLECTION;
46756
+ const cached = byConstructors.get(constructorKey);
46683
46757
  if (cached !== void 0 && isCurrent(cached, source, revision)) {
46684
46758
  return cached.index;
46685
46759
  }
46686
46760
  const index = new ProjectSchemaIndex(source);
46687
- byMembers.set(source.members, {
46761
+ byConstructors.set(constructorKey, {
46688
46762
  classCount: source.classes.length,
46689
46763
  memberCount: source.members.length,
46690
46764
  enums: source.enums,
@@ -46697,7 +46771,7 @@ function projectSchemaIndexFor(source, revision = EMPTY_REVISION) {
46697
46771
  });
46698
46772
  return index;
46699
46773
  }
46700
- var CircularInheritanceError, ProjectSchemaIndex, EMPTY_STRING_SET, EMPTY_REVISION, projectSchemaIndexEpoch, projectSchemaIndexes;
46774
+ var CircularInheritanceError, ProjectSchemaIndex, EMPTY_STRING_SET, EMPTY_REVISION, projectSchemaIndexEpoch, projectSchemaIndexes, ABSENT_COLLECTION;
46701
46775
  var init_project_schema_index = __esm({
46702
46776
  "../src/models/project/project-schema-index.ts"() {
46703
46777
  "use strict";
@@ -46859,6 +46933,7 @@ var init_project_schema_index = __esm({
46859
46933
  EMPTY_REVISION = [];
46860
46934
  projectSchemaIndexEpoch = 0;
46861
46935
  projectSchemaIndexes = /* @__PURE__ */ new WeakMap();
46936
+ ABSENT_COLLECTION = {};
46862
46937
  }
46863
46938
  });
46864
46939
 
@@ -65284,7 +65359,7 @@ var init_project_root_members = __esm({
65284
65359
  }
65285
65360
  });
65286
65361
 
65287
- // ../src/components/projects/member-code/analyzer-types.ts
65362
+ // ../src/runtime/neoscript/analyzer-types.ts
65288
65363
  function createAnalyzerSchemaIndex(context) {
65289
65364
  return projectSchemaIndexFor({
65290
65365
  classes: context.vm.classes,
@@ -65313,7 +65388,7 @@ function analyzerMemberById(context, id2) {
65313
65388
  }
65314
65389
  var AnalyzerRootClassId, AnalyzerDialogueContextClassId, activeSchemaIndexByContext;
65315
65390
  var init_analyzer_types = __esm({
65316
- "../src/components/projects/member-code/analyzer-types.ts"() {
65391
+ "../src/runtime/neoscript/analyzer-types.ts"() {
65317
65392
  "use strict";
65318
65393
  init_project_schema_index();
65319
65394
  AnalyzerRootClassId = "__root__";
@@ -65322,7 +65397,7 @@ var init_analyzer_types = __esm({
65322
65397
  }
65323
65398
  });
65324
65399
 
65325
- // ../src/components/projects/member-code/neoscript-language-context-adapter.ts
65400
+ // ../src/runtime/neoscript/neoscript-language-context-adapter.ts
65326
65401
  function createNeoScriptDocumentContext(context, projectOverride) {
65327
65402
  return withAnalyzerSchemaIndex(
65328
65403
  context,
@@ -66713,7 +66788,7 @@ function virtualRootMemberLine(name, memberId) {
66713
66788
  }
66714
66789
  var NEOSCRIPT_COMPILER_ADAPTER_REVISION, UNKNOWN_TYPE2, storageResolverByContext;
66715
66790
  var init_neoscript_language_context_adapter = __esm({
66716
- "../src/components/projects/member-code/neoscript-language-context-adapter.ts"() {
66791
+ "../src/runtime/neoscript/neoscript-language-context-adapter.ts"() {
66717
66792
  "use strict";
66718
66793
  init_src();
66719
66794
  init_members();
@@ -69170,392 +69245,34 @@ var init_constructor_argument_ownership = __esm({
69170
69245
  }
69171
69246
  });
69172
69247
 
69173
- // ../src/view-models/neoscript-evaluator/NSGetterRuntimeError.ts
69174
- var NSGetterRuntimeError, UncompiledInitializerRuntimeError;
69175
- var init_NSGetterRuntimeError = __esm({
69176
- "../src/view-models/neoscript-evaluator/NSGetterRuntimeError.ts"() {
69177
- "use strict";
69178
- NSGetterRuntimeError = class extends Error {
69179
- constructor(message) {
69180
- super(message);
69181
- this.name = "NSGetterRuntimeError";
69182
- }
69183
- };
69184
- UncompiledInitializerRuntimeError = class extends NSGetterRuntimeError {
69185
- constructor(memberId, memberName, initializer = null, valueId = null) {
69186
- super(
69187
- `Initializer for '${memberName}' has no compiled body; push the project so the server compiles it.`
69188
- );
69189
- this.memberId = memberId;
69190
- this.initializer = initializer;
69191
- this.valueId = valueId;
69192
- this.name = "UncompiledInitializerRuntimeError";
69193
- }
69194
- memberId;
69195
- initializer;
69196
- valueId;
69197
- };
69198
- }
69199
- });
69200
-
69201
- // ../src/view-models/neoscript-evaluator/NeoScriptScope.ts
69202
- var NeoScriptScope;
69203
- var init_NeoScriptScope = __esm({
69204
- "../src/view-models/neoscript-evaluator/NeoScriptScope.ts"() {
69205
- "use strict";
69206
- NeoScriptScope = class {
69207
- constructor(parent = null, initialBindings) {
69208
- this.parent = parent;
69209
- this.#bindings = new Map(initialBindings);
69210
- }
69211
- parent;
69212
- #bindings;
69213
- #readonlyBindingErrors = /* @__PURE__ */ new Map();
69214
- get localBindingCount() {
69215
- return this.#bindings.size;
69216
- }
69217
- get(bindingId) {
69218
- if (this.#bindings.has(bindingId)) return this.#bindings.get(bindingId);
69219
- return this.parent?.get(bindingId);
69220
- }
69221
- has(bindingId) {
69222
- return this.#bindings.has(bindingId) || this.parent?.has(bindingId) === true;
69223
- }
69224
- containsLocal(bindingId) {
69225
- return this.#bindings.has(bindingId);
69226
- }
69227
- setLocal(bindingId, value) {
69228
- this.#bindings.set(bindingId, value);
69229
- }
69230
- bindInvocationEntry(bindingId, value) {
69231
- this.#bindings.set(bindingId, value);
69232
- }
69233
- bindInvocationKeyAndEntry(keyBindingId, key, entryBindingId, entry) {
69234
- this.#bindings.set(keyBindingId, key);
69235
- this.#bindings.set(entryBindingId, entry);
69236
- }
69237
- resetInvocationLocals(parameterCount) {
69238
- if (this.#bindings.size > parameterCount) this.#bindings.clear();
69239
- if (this.#readonlyBindingErrors.size > 0) {
69240
- this.#readonlyBindingErrors.clear();
69241
- }
69242
- }
69243
- *keys() {
69244
- const inherited = /* @__PURE__ */ new Set();
69245
- if (this.parent !== null) {
69246
- for (const bindingId of this.parent.keys()) {
69247
- inherited.add(bindingId);
69248
- yield bindingId;
69249
- }
69250
- }
69251
- for (const bindingId of this.#bindings.keys()) {
69252
- if (!inherited.has(bindingId)) yield bindingId;
69253
- }
69254
- }
69255
- markReadonly(bindingId, errorMessage4) {
69256
- const errors = this.#readonlyBindingErrors.get(bindingId);
69257
- if (errors === void 0) {
69258
- this.#readonlyBindingErrors.set(bindingId, [errorMessage4]);
69259
- return;
69260
- }
69261
- errors.push(errorMessage4);
69262
- }
69263
- unmarkReadonly(bindingId) {
69264
- const errors = this.#readonlyBindingErrors.get(bindingId);
69265
- if (errors === void 0) return;
69266
- errors.pop();
69267
- if (errors.length === 0) this.#readonlyBindingErrors.delete(bindingId);
69268
- }
69269
- readonlyError(bindingId) {
69270
- const errors = this.#readonlyBindingErrors.get(bindingId);
69271
- if (errors !== void 0 && errors.length > 0) {
69272
- return errors[errors.length - 1];
69273
- }
69274
- return this.parent?.readonlyError(bindingId);
69275
- }
69276
- };
69277
- }
69278
- });
69279
-
69280
- // ../src/models/decimal/decimal-math.ts
69281
- function pow10(exponent) {
69282
- return TEN ** BigInt(exponent);
69283
- }
69284
- function assertCanonicalInput(value, argName) {
69285
- const violation = getDecimalStringViolation(value);
69286
- if (violation !== null) {
69287
- throw new Error(
69288
- `Decimal argument "${argName}" (${JSON.stringify(value)}) ${violation}.`
69289
- );
69290
- }
69291
- }
69292
- function parseDecimalArg(value, argName) {
69293
- assertCanonicalInput(value, argName);
69294
- const negative = value.startsWith("-");
69295
- const unsigned = negative ? value.slice(1) : value;
69296
- const pointIndex = unsigned.indexOf(".");
69297
- const digits = pointIndex === -1 ? unsigned : unsigned.slice(0, pointIndex) + unsigned.slice(pointIndex + 1);
69298
- const scale = pointIndex === -1 ? 0 : unsigned.length - pointIndex - 1;
69299
- const magnitude = BigInt(digits);
69300
- return { coefficient: negative ? -magnitude : magnitude, scale };
69301
- }
69302
- function formatDecimalParts(parts) {
69303
- const negative = parts.coefficient < 0n;
69304
- const digits = (negative ? -parts.coefficient : parts.coefficient).toString();
69305
- let unsigned;
69306
- if (parts.scale === 0) {
69307
- unsigned = digits;
69308
- } else {
69309
- const padded = digits.padStart(parts.scale + 1, "0");
69310
- const pointIndex = padded.length - parts.scale;
69311
- unsigned = `${padded.slice(0, pointIndex)}.${padded.slice(pointIndex)}`;
69312
- }
69313
- if (parts.coefficient === 0n) return unsigned;
69314
- return negative ? `-${unsigned}` : unsigned;
69315
- }
69316
- function significantDigitCount(coefficient) {
69317
- const magnitude = coefficient < 0n ? -coefficient : coefficient;
69318
- return magnitude.toString().length;
69319
- }
69320
- function assertWithinEnvelope(parts, operation) {
69321
- if (significantDigitCount(parts.coefficient) > DECIMAL_MAX_SIGNIFICANT_DIGITS) {
69322
- throw new DecimalOverflowError(
69323
- `Decimal overflow in ${operation}: the exact result exceeds ${DECIMAL_MAX_SIGNIFICANT_DIGITS} significant digits. Round explicitly (Round/Divide) to reduce precision.`
69324
- );
69325
- }
69326
- if (parts.scale > DECIMAL_MAX_SCALE) {
69327
- throw new DecimalOverflowError(
69328
- `Decimal overflow in ${operation}: the exact result exceeds scale ${DECIMAL_MAX_SCALE}. Round explicitly (Round/Divide) to reduce precision.`
69329
- );
69330
- }
69331
- return parts;
69332
- }
69333
- function alignScales(a, b) {
69334
- const scale = Math.max(a.scale, b.scale);
69335
- return {
69336
- a: a.coefficient * pow10(scale - a.scale),
69337
- b: b.coefficient * pow10(scale - b.scale),
69338
- scale
69339
- };
69340
- }
69341
- function compareDecimalStrings(a, b) {
69342
- const aligned = alignScales(parseDecimalArg(a, "a"), parseDecimalArg(b, "b"));
69343
- if (aligned.a < aligned.b) return -1;
69344
- if (aligned.a > aligned.b) return 1;
69345
- return 0;
69346
- }
69347
- function minDecimalStrings(a, b) {
69348
- return compareDecimalStrings(a, b) <= 0 ? a : b;
69349
- }
69350
- function maxDecimalStrings(a, b) {
69351
- return compareDecimalStrings(a, b) >= 0 ? a : b;
69352
- }
69353
- function clampDecimalStrings(value, min, max) {
69354
- if (compareDecimalStrings(min, max) > 0) {
69355
- throw new DecimalClampRangeError(MATH_CLAMP_RANGE_MESSAGE);
69356
- }
69357
- if (compareDecimalStrings(value, min) < 0) return min;
69358
- if (compareDecimalStrings(value, max) > 0) return max;
69359
- return value;
69360
- }
69361
- function absDecimalString(value) {
69362
- const parts = parseDecimalArg(value, "value");
69363
- const magnitude = parts.coefficient < 0n ? -parts.coefficient : parts.coefficient;
69364
- return formatDecimalParts({ coefficient: magnitude, scale: parts.scale });
69365
- }
69366
- function addDecimalStrings(a, b) {
69367
- const aligned = alignScales(parseDecimalArg(a, "a"), parseDecimalArg(b, "b"));
69368
- return formatDecimalParts(
69369
- assertWithinEnvelope(
69370
- { coefficient: aligned.a + aligned.b, scale: aligned.scale },
69371
- "addition"
69372
- )
69373
- );
69374
- }
69375
- function subtractDecimalStrings(a, b) {
69376
- const aligned = alignScales(parseDecimalArg(a, "a"), parseDecimalArg(b, "b"));
69377
- return formatDecimalParts(
69378
- assertWithinEnvelope(
69379
- { coefficient: aligned.a - aligned.b, scale: aligned.scale },
69380
- "subtraction"
69381
- )
69382
- );
69383
- }
69384
- function multiplyDecimalStrings(a, b) {
69385
- const left = parseDecimalArg(a, "a");
69386
- const right = parseDecimalArg(b, "b");
69387
- return formatDecimalParts(
69388
- assertWithinEnvelope(
69389
- {
69390
- coefficient: left.coefficient * right.coefficient,
69391
- scale: left.scale + right.scale
69392
- },
69393
- "multiplication"
69394
- )
69395
- );
69396
- }
69397
- function assertDigitsInRange(digits, operation) {
69398
- if (!Number.isInteger(digits)) {
69399
- throw new DecimalDigitsRangeError(
69400
- `Decimal ${operation} digits must be an integer (received ${digits}).`
69401
- );
69402
- }
69403
- if (digits < 0 || digits > DECIMAL_MAX_SCALE) {
69404
- throw new DecimalDigitsRangeError(
69405
- `Decimal ${operation} digits must be between 0 and ${DECIMAL_MAX_SCALE} (received ${digits}).`
69406
- );
69407
- }
69408
- }
69409
- function roundParts(parts, digits) {
69410
- if (digits >= parts.scale) return parts;
69411
- const drop = parts.scale - digits;
69412
- const divisor = pow10(drop);
69413
- const negative = parts.coefficient < 0n;
69414
- const magnitude = negative ? -parts.coefficient : parts.coefficient;
69415
- let quotient = magnitude / divisor;
69416
- const remainder = magnitude % divisor;
69417
- const doubled = remainder * 2n;
69418
- if (doubled > divisor || doubled === divisor && quotient % 2n === 1n) {
69419
- quotient += 1n;
69420
- }
69421
- return { coefficient: negative ? -quotient : quotient, scale: digits };
69422
- }
69423
- function roundDecimalString(value, digits) {
69424
- assertDigitsInRange(digits, "round");
69425
- const rounded = roundParts(parseDecimalArg(value, "value"), digits);
69426
- return formatDecimalParts(assertWithinEnvelope(rounded, "round"));
69427
- }
69428
- function toIntegralParts(parts, direction) {
69429
- if (parts.scale === 0) return parts;
69430
- const divisor = pow10(parts.scale);
69431
- const quotient = parts.coefficient / divisor;
69432
- const remainder = parts.coefficient % divisor;
69433
- if (remainder === 0n) return { coefficient: quotient, scale: 0 };
69434
- if (direction === "floor" && remainder < 0n) {
69435
- return { coefficient: quotient - 1n, scale: 0 };
69436
- }
69437
- if (direction === "ceiling" && remainder > 0n) {
69438
- return { coefficient: quotient + 1n, scale: 0 };
69439
- }
69440
- return { coefficient: quotient, scale: 0 };
69441
- }
69442
- function floorDecimalString(value) {
69443
- const parts = toIntegralParts(parseDecimalArg(value, "value"), "floor");
69444
- return formatDecimalParts(assertWithinEnvelope(parts, "floor"));
69445
- }
69446
- function ceilingDecimalString(value) {
69447
- const parts = toIntegralParts(parseDecimalArg(value, "value"), "ceiling");
69448
- return formatDecimalParts(assertWithinEnvelope(parts, "ceiling"));
69449
- }
69450
- function truncateDecimalString(value) {
69451
- const parts = toIntegralParts(parseDecimalArg(value, "value"), "truncate");
69452
- return formatDecimalParts(assertWithinEnvelope(parts, "truncate"));
69453
- }
69454
- function divideDecimalStrings(a, b, digits) {
69455
- assertDigitsInRange(digits, "divide");
69456
- const dividend = parseDecimalArg(a, "a");
69457
- const divisor = parseDecimalArg(b, "b");
69458
- if (divisor.coefficient === 0n) {
69459
- throw new DecimalDivisionByZeroError(
69460
- `Decimal division by zero: ${JSON.stringify(a)} / ${JSON.stringify(b)}.`
69461
- );
69462
- }
69463
- const exponent = divisor.scale - dividend.scale + digits;
69464
- let numerator = dividend.coefficient;
69465
- let denominator = divisor.coefficient;
69466
- if (exponent >= 0) {
69467
- numerator *= pow10(exponent);
69468
- } else {
69469
- denominator *= pow10(-exponent);
69470
- }
69471
- const negative = numerator < 0n !== denominator < 0n;
69472
- const absNumerator = numerator < 0n ? -numerator : numerator;
69473
- const absDenominator = denominator < 0n ? -denominator : denominator;
69474
- let quotient = absNumerator / absDenominator;
69475
- const remainder = absNumerator % absDenominator;
69476
- const doubled = remainder * 2n;
69477
- if (doubled > absDenominator || doubled === absDenominator && quotient % 2n === 1n) {
69478
- quotient += 1n;
69479
- }
69480
- const parts = {
69481
- coefficient: negative ? -quotient : quotient,
69482
- scale: digits
69483
- };
69484
- return formatDecimalParts(assertWithinEnvelope(parts, "division"));
69485
- }
69486
- function decimalStringFromFloat(value, digits) {
69487
- assertDigitsInRange(digits, "float conversion");
69488
- if (Number.isNaN(value)) {
69489
- throw new DecimalNonFiniteError("Cannot convert NaN to a decimal.");
69490
- }
69491
- if (!Number.isFinite(value)) {
69492
- throw new DecimalNonFiniteError(
69493
- `Cannot convert ${value > 0 ? "Infinity" : "-Infinity"} to a decimal.`
69494
- );
69495
- }
69496
- const view = new DataView(new ArrayBuffer(8));
69497
- view.setFloat64(0, value);
69498
- const bits = view.getBigUint64(0);
69499
- const negative = bits >> 63n === 1n;
69500
- const exponentBits = Number(bits >> 52n & 0x7ffn);
69501
- const mantissaBits = bits & 0xfffffffffffffn;
69502
- let mantissa;
69503
- let exponent;
69504
- if (exponentBits === 0) {
69505
- mantissa = mantissaBits;
69506
- exponent = -1074;
69507
- } else {
69508
- mantissa = mantissaBits | 1n << 52n;
69509
- exponent = exponentBits - 1075;
69510
- }
69511
- if (mantissa === 0n) {
69512
- return "0";
69513
- }
69514
- if (negative) mantissa = -mantissa;
69515
- let parts;
69516
- if (exponent >= 0) {
69517
- parts = { coefficient: mantissa * (1n << BigInt(exponent)), scale: 0 };
69518
- } else {
69519
- parts = {
69520
- coefficient: mantissa * 5n ** BigInt(-exponent),
69521
- scale: -exponent
69522
- };
69523
- }
69524
- while (parts.scale > 0 && parts.coefficient % TEN === 0n) {
69525
- parts = { coefficient: parts.coefficient / TEN, scale: parts.scale - 1 };
69526
- }
69527
- const rounded = roundParts(parts, digits);
69528
- return formatDecimalParts(assertWithinEnvelope(rounded, "float conversion"));
69248
+ // ../src/runtime/neoscript/initializer-context.ts
69249
+ function initializerEvaluatorCacheKey(document) {
69250
+ return document.evaluatorCache?.key ?? document;
69529
69251
  }
69530
- function floatFromDecimalString(value) {
69531
- assertCanonicalInput(value, "value");
69532
- return Number(value);
69252
+ function initializerEvaluatorCacheRevision(document) {
69253
+ return document.evaluatorCache?.revision;
69533
69254
  }
69534
- var DecimalOverflowError, DecimalDivisionByZeroError, DecimalDigitsRangeError, DecimalNonFiniteError, DecimalClampRangeError, MATH_CLAMP_RANGE_MESSAGE, TEN;
69535
- var init_decimal_math = __esm({
69536
- "../src/models/decimal/decimal-math.ts"() {
69255
+ var InitializerReadSet;
69256
+ var init_initializer_context = __esm({
69257
+ "../src/runtime/neoscript/initializer-context.ts"() {
69537
69258
  "use strict";
69538
- init_members();
69539
- DecimalOverflowError = class extends Error {
69540
- };
69541
- DecimalDivisionByZeroError = class extends Error {
69542
- };
69543
- DecimalDigitsRangeError = class extends Error {
69544
- };
69545
- DecimalNonFiniteError = class extends Error {
69546
- };
69547
- DecimalClampRangeError = class extends Error {
69259
+ init_collections();
69260
+ InitializerReadSet = class {
69261
+ valueIds = /* @__PURE__ */ new Set();
69262
+ localizedTextIds = /* @__PURE__ */ new Set();
69263
+ variantIds = /* @__PURE__ */ new Set();
69264
+ containerIds = /* @__PURE__ */ new Set();
69265
+ staticMemberIds = /* @__PURE__ */ new Set();
69266
+ hasValuePlacementRead = false;
69267
+ hasUnattributableValueRead = false;
69268
+ recordUnattributableValueRead = (_reason) => {
69269
+ void _reason;
69270
+ this.hasUnattributableValueRead = true;
69271
+ };
69272
+ recordValuePlacementRead = () => {
69273
+ this.hasValuePlacementRead = true;
69274
+ };
69548
69275
  };
69549
- MATH_CLAMP_RANGE_MESSAGE = "Math.Clamp requires min <= max.";
69550
- TEN = 10n;
69551
- }
69552
- });
69553
-
69554
- // ../src/models/decimal/index.ts
69555
- var init_decimal = __esm({
69556
- "../src/models/decimal/index.ts"() {
69557
- "use strict";
69558
- init_decimal_math();
69559
69276
  }
69560
69277
  });
69561
69278
 
@@ -70347,7 +70064,396 @@ var init_project2 = __esm({
70347
70064
  }
70348
70065
  });
70349
70066
 
70350
- // ../src/view-models/neoscript-evaluator/evaluateNSGetter.ts
70067
+ // ../src/runtime/neoscript/NeoScriptScope.ts
70068
+ var NeoScriptScope;
70069
+ var init_NeoScriptScope = __esm({
70070
+ "../src/runtime/neoscript/NeoScriptScope.ts"() {
70071
+ "use strict";
70072
+ NeoScriptScope = class {
70073
+ constructor(parent = null, initialBindings) {
70074
+ this.parent = parent;
70075
+ this.#bindings = new Map(initialBindings);
70076
+ }
70077
+ parent;
70078
+ #bindings;
70079
+ #readonlyBindingErrors = /* @__PURE__ */ new Map();
70080
+ get localBindingCount() {
70081
+ return this.#bindings.size;
70082
+ }
70083
+ get(bindingId) {
70084
+ if (this.#bindings.has(bindingId)) return this.#bindings.get(bindingId);
70085
+ return this.parent?.get(bindingId);
70086
+ }
70087
+ has(bindingId) {
70088
+ return this.#bindings.has(bindingId) || this.parent?.has(bindingId) === true;
70089
+ }
70090
+ containsLocal(bindingId) {
70091
+ return this.#bindings.has(bindingId);
70092
+ }
70093
+ setLocal(bindingId, value) {
70094
+ this.#bindings.set(bindingId, value);
70095
+ }
70096
+ bindInvocationEntry(bindingId, value) {
70097
+ this.#bindings.set(bindingId, value);
70098
+ }
70099
+ bindInvocationKeyAndEntry(keyBindingId, key, entryBindingId, entry) {
70100
+ this.#bindings.set(keyBindingId, key);
70101
+ this.#bindings.set(entryBindingId, entry);
70102
+ }
70103
+ resetInvocationLocals(parameterCount) {
70104
+ if (this.#bindings.size > parameterCount) this.#bindings.clear();
70105
+ if (this.#readonlyBindingErrors.size > 0) {
70106
+ this.#readonlyBindingErrors.clear();
70107
+ }
70108
+ }
70109
+ *keys() {
70110
+ const inherited = /* @__PURE__ */ new Set();
70111
+ if (this.parent !== null) {
70112
+ for (const bindingId of this.parent.keys()) {
70113
+ inherited.add(bindingId);
70114
+ yield bindingId;
70115
+ }
70116
+ }
70117
+ for (const bindingId of this.#bindings.keys()) {
70118
+ if (!inherited.has(bindingId)) yield bindingId;
70119
+ }
70120
+ }
70121
+ markReadonly(bindingId, errorMessage4) {
70122
+ const errors = this.#readonlyBindingErrors.get(bindingId);
70123
+ if (errors === void 0) {
70124
+ this.#readonlyBindingErrors.set(bindingId, [errorMessage4]);
70125
+ return;
70126
+ }
70127
+ errors.push(errorMessage4);
70128
+ }
70129
+ unmarkReadonly(bindingId) {
70130
+ const errors = this.#readonlyBindingErrors.get(bindingId);
70131
+ if (errors === void 0) return;
70132
+ errors.pop();
70133
+ if (errors.length === 0) this.#readonlyBindingErrors.delete(bindingId);
70134
+ }
70135
+ readonlyError(bindingId) {
70136
+ const errors = this.#readonlyBindingErrors.get(bindingId);
70137
+ if (errors !== void 0 && errors.length > 0) {
70138
+ return errors[errors.length - 1];
70139
+ }
70140
+ return this.parent?.readonlyError(bindingId);
70141
+ }
70142
+ };
70143
+ }
70144
+ });
70145
+
70146
+ // ../src/runtime/neoscript/NSGetterRuntimeError.ts
70147
+ var NSGetterRuntimeError, UncompiledInitializerRuntimeError;
70148
+ var init_NSGetterRuntimeError = __esm({
70149
+ "../src/runtime/neoscript/NSGetterRuntimeError.ts"() {
70150
+ "use strict";
70151
+ NSGetterRuntimeError = class extends Error {
70152
+ constructor(message) {
70153
+ super(message);
70154
+ this.name = "NSGetterRuntimeError";
70155
+ }
70156
+ };
70157
+ UncompiledInitializerRuntimeError = class extends NSGetterRuntimeError {
70158
+ constructor(memberId, memberName, initializer = null, valueId = null) {
70159
+ super(
70160
+ `Initializer for '${memberName}' has no compiled body; push the project so the server compiles it.`
70161
+ );
70162
+ this.memberId = memberId;
70163
+ this.initializer = initializer;
70164
+ this.valueId = valueId;
70165
+ this.name = "UncompiledInitializerRuntimeError";
70166
+ }
70167
+ memberId;
70168
+ initializer;
70169
+ valueId;
70170
+ };
70171
+ }
70172
+ });
70173
+
70174
+ // ../src/models/decimal/decimal-math.ts
70175
+ function pow10(exponent) {
70176
+ return TEN ** BigInt(exponent);
70177
+ }
70178
+ function assertCanonicalInput(value, argName) {
70179
+ const violation = getDecimalStringViolation(value);
70180
+ if (violation !== null) {
70181
+ throw new Error(
70182
+ `Decimal argument "${argName}" (${JSON.stringify(value)}) ${violation}.`
70183
+ );
70184
+ }
70185
+ }
70186
+ function parseDecimalArg(value, argName) {
70187
+ assertCanonicalInput(value, argName);
70188
+ const negative = value.startsWith("-");
70189
+ const unsigned = negative ? value.slice(1) : value;
70190
+ const pointIndex = unsigned.indexOf(".");
70191
+ const digits = pointIndex === -1 ? unsigned : unsigned.slice(0, pointIndex) + unsigned.slice(pointIndex + 1);
70192
+ const scale = pointIndex === -1 ? 0 : unsigned.length - pointIndex - 1;
70193
+ const magnitude = BigInt(digits);
70194
+ return { coefficient: negative ? -magnitude : magnitude, scale };
70195
+ }
70196
+ function formatDecimalParts(parts) {
70197
+ const negative = parts.coefficient < 0n;
70198
+ const digits = (negative ? -parts.coefficient : parts.coefficient).toString();
70199
+ let unsigned;
70200
+ if (parts.scale === 0) {
70201
+ unsigned = digits;
70202
+ } else {
70203
+ const padded = digits.padStart(parts.scale + 1, "0");
70204
+ const pointIndex = padded.length - parts.scale;
70205
+ unsigned = `${padded.slice(0, pointIndex)}.${padded.slice(pointIndex)}`;
70206
+ }
70207
+ if (parts.coefficient === 0n) return unsigned;
70208
+ return negative ? `-${unsigned}` : unsigned;
70209
+ }
70210
+ function significantDigitCount(coefficient) {
70211
+ const magnitude = coefficient < 0n ? -coefficient : coefficient;
70212
+ return magnitude.toString().length;
70213
+ }
70214
+ function assertWithinEnvelope(parts, operation) {
70215
+ if (significantDigitCount(parts.coefficient) > DECIMAL_MAX_SIGNIFICANT_DIGITS) {
70216
+ throw new DecimalOverflowError(
70217
+ `Decimal overflow in ${operation}: the exact result exceeds ${DECIMAL_MAX_SIGNIFICANT_DIGITS} significant digits. Round explicitly (Round/Divide) to reduce precision.`
70218
+ );
70219
+ }
70220
+ if (parts.scale > DECIMAL_MAX_SCALE) {
70221
+ throw new DecimalOverflowError(
70222
+ `Decimal overflow in ${operation}: the exact result exceeds scale ${DECIMAL_MAX_SCALE}. Round explicitly (Round/Divide) to reduce precision.`
70223
+ );
70224
+ }
70225
+ return parts;
70226
+ }
70227
+ function alignScales(a, b) {
70228
+ const scale = Math.max(a.scale, b.scale);
70229
+ return {
70230
+ a: a.coefficient * pow10(scale - a.scale),
70231
+ b: b.coefficient * pow10(scale - b.scale),
70232
+ scale
70233
+ };
70234
+ }
70235
+ function compareDecimalStrings(a, b) {
70236
+ const aligned = alignScales(parseDecimalArg(a, "a"), parseDecimalArg(b, "b"));
70237
+ if (aligned.a < aligned.b) return -1;
70238
+ if (aligned.a > aligned.b) return 1;
70239
+ return 0;
70240
+ }
70241
+ function minDecimalStrings(a, b) {
70242
+ return compareDecimalStrings(a, b) <= 0 ? a : b;
70243
+ }
70244
+ function maxDecimalStrings(a, b) {
70245
+ return compareDecimalStrings(a, b) >= 0 ? a : b;
70246
+ }
70247
+ function clampDecimalStrings(value, min, max) {
70248
+ if (compareDecimalStrings(min, max) > 0) {
70249
+ throw new DecimalClampRangeError(MATH_CLAMP_RANGE_MESSAGE);
70250
+ }
70251
+ if (compareDecimalStrings(value, min) < 0) return min;
70252
+ if (compareDecimalStrings(value, max) > 0) return max;
70253
+ return value;
70254
+ }
70255
+ function absDecimalString(value) {
70256
+ const parts = parseDecimalArg(value, "value");
70257
+ const magnitude = parts.coefficient < 0n ? -parts.coefficient : parts.coefficient;
70258
+ return formatDecimalParts({ coefficient: magnitude, scale: parts.scale });
70259
+ }
70260
+ function addDecimalStrings(a, b) {
70261
+ const aligned = alignScales(parseDecimalArg(a, "a"), parseDecimalArg(b, "b"));
70262
+ return formatDecimalParts(
70263
+ assertWithinEnvelope(
70264
+ { coefficient: aligned.a + aligned.b, scale: aligned.scale },
70265
+ "addition"
70266
+ )
70267
+ );
70268
+ }
70269
+ function subtractDecimalStrings(a, b) {
70270
+ const aligned = alignScales(parseDecimalArg(a, "a"), parseDecimalArg(b, "b"));
70271
+ return formatDecimalParts(
70272
+ assertWithinEnvelope(
70273
+ { coefficient: aligned.a - aligned.b, scale: aligned.scale },
70274
+ "subtraction"
70275
+ )
70276
+ );
70277
+ }
70278
+ function multiplyDecimalStrings(a, b) {
70279
+ const left = parseDecimalArg(a, "a");
70280
+ const right = parseDecimalArg(b, "b");
70281
+ return formatDecimalParts(
70282
+ assertWithinEnvelope(
70283
+ {
70284
+ coefficient: left.coefficient * right.coefficient,
70285
+ scale: left.scale + right.scale
70286
+ },
70287
+ "multiplication"
70288
+ )
70289
+ );
70290
+ }
70291
+ function assertDigitsInRange(digits, operation) {
70292
+ if (!Number.isInteger(digits)) {
70293
+ throw new DecimalDigitsRangeError(
70294
+ `Decimal ${operation} digits must be an integer (received ${digits}).`
70295
+ );
70296
+ }
70297
+ if (digits < 0 || digits > DECIMAL_MAX_SCALE) {
70298
+ throw new DecimalDigitsRangeError(
70299
+ `Decimal ${operation} digits must be between 0 and ${DECIMAL_MAX_SCALE} (received ${digits}).`
70300
+ );
70301
+ }
70302
+ }
70303
+ function roundParts(parts, digits) {
70304
+ if (digits >= parts.scale) return parts;
70305
+ const drop = parts.scale - digits;
70306
+ const divisor = pow10(drop);
70307
+ const negative = parts.coefficient < 0n;
70308
+ const magnitude = negative ? -parts.coefficient : parts.coefficient;
70309
+ let quotient = magnitude / divisor;
70310
+ const remainder = magnitude % divisor;
70311
+ const doubled = remainder * 2n;
70312
+ if (doubled > divisor || doubled === divisor && quotient % 2n === 1n) {
70313
+ quotient += 1n;
70314
+ }
70315
+ return { coefficient: negative ? -quotient : quotient, scale: digits };
70316
+ }
70317
+ function roundDecimalString(value, digits) {
70318
+ assertDigitsInRange(digits, "round");
70319
+ const rounded = roundParts(parseDecimalArg(value, "value"), digits);
70320
+ return formatDecimalParts(assertWithinEnvelope(rounded, "round"));
70321
+ }
70322
+ function toIntegralParts(parts, direction) {
70323
+ if (parts.scale === 0) return parts;
70324
+ const divisor = pow10(parts.scale);
70325
+ const quotient = parts.coefficient / divisor;
70326
+ const remainder = parts.coefficient % divisor;
70327
+ if (remainder === 0n) return { coefficient: quotient, scale: 0 };
70328
+ if (direction === "floor" && remainder < 0n) {
70329
+ return { coefficient: quotient - 1n, scale: 0 };
70330
+ }
70331
+ if (direction === "ceiling" && remainder > 0n) {
70332
+ return { coefficient: quotient + 1n, scale: 0 };
70333
+ }
70334
+ return { coefficient: quotient, scale: 0 };
70335
+ }
70336
+ function floorDecimalString(value) {
70337
+ const parts = toIntegralParts(parseDecimalArg(value, "value"), "floor");
70338
+ return formatDecimalParts(assertWithinEnvelope(parts, "floor"));
70339
+ }
70340
+ function ceilingDecimalString(value) {
70341
+ const parts = toIntegralParts(parseDecimalArg(value, "value"), "ceiling");
70342
+ return formatDecimalParts(assertWithinEnvelope(parts, "ceiling"));
70343
+ }
70344
+ function truncateDecimalString(value) {
70345
+ const parts = toIntegralParts(parseDecimalArg(value, "value"), "truncate");
70346
+ return formatDecimalParts(assertWithinEnvelope(parts, "truncate"));
70347
+ }
70348
+ function divideDecimalStrings(a, b, digits) {
70349
+ assertDigitsInRange(digits, "divide");
70350
+ const dividend = parseDecimalArg(a, "a");
70351
+ const divisor = parseDecimalArg(b, "b");
70352
+ if (divisor.coefficient === 0n) {
70353
+ throw new DecimalDivisionByZeroError(
70354
+ `Decimal division by zero: ${JSON.stringify(a)} / ${JSON.stringify(b)}.`
70355
+ );
70356
+ }
70357
+ const exponent = divisor.scale - dividend.scale + digits;
70358
+ let numerator = dividend.coefficient;
70359
+ let denominator = divisor.coefficient;
70360
+ if (exponent >= 0) {
70361
+ numerator *= pow10(exponent);
70362
+ } else {
70363
+ denominator *= pow10(-exponent);
70364
+ }
70365
+ const negative = numerator < 0n !== denominator < 0n;
70366
+ const absNumerator = numerator < 0n ? -numerator : numerator;
70367
+ const absDenominator = denominator < 0n ? -denominator : denominator;
70368
+ let quotient = absNumerator / absDenominator;
70369
+ const remainder = absNumerator % absDenominator;
70370
+ const doubled = remainder * 2n;
70371
+ if (doubled > absDenominator || doubled === absDenominator && quotient % 2n === 1n) {
70372
+ quotient += 1n;
70373
+ }
70374
+ const parts = {
70375
+ coefficient: negative ? -quotient : quotient,
70376
+ scale: digits
70377
+ };
70378
+ return formatDecimalParts(assertWithinEnvelope(parts, "division"));
70379
+ }
70380
+ function decimalStringFromFloat(value, digits) {
70381
+ assertDigitsInRange(digits, "float conversion");
70382
+ if (Number.isNaN(value)) {
70383
+ throw new DecimalNonFiniteError("Cannot convert NaN to a decimal.");
70384
+ }
70385
+ if (!Number.isFinite(value)) {
70386
+ throw new DecimalNonFiniteError(
70387
+ `Cannot convert ${value > 0 ? "Infinity" : "-Infinity"} to a decimal.`
70388
+ );
70389
+ }
70390
+ const view = new DataView(new ArrayBuffer(8));
70391
+ view.setFloat64(0, value);
70392
+ const bits = view.getBigUint64(0);
70393
+ const negative = bits >> 63n === 1n;
70394
+ const exponentBits = Number(bits >> 52n & 0x7ffn);
70395
+ const mantissaBits = bits & 0xfffffffffffffn;
70396
+ let mantissa;
70397
+ let exponent;
70398
+ if (exponentBits === 0) {
70399
+ mantissa = mantissaBits;
70400
+ exponent = -1074;
70401
+ } else {
70402
+ mantissa = mantissaBits | 1n << 52n;
70403
+ exponent = exponentBits - 1075;
70404
+ }
70405
+ if (mantissa === 0n) {
70406
+ return "0";
70407
+ }
70408
+ if (negative) mantissa = -mantissa;
70409
+ let parts;
70410
+ if (exponent >= 0) {
70411
+ parts = { coefficient: mantissa * (1n << BigInt(exponent)), scale: 0 };
70412
+ } else {
70413
+ parts = {
70414
+ coefficient: mantissa * 5n ** BigInt(-exponent),
70415
+ scale: -exponent
70416
+ };
70417
+ }
70418
+ while (parts.scale > 0 && parts.coefficient % TEN === 0n) {
70419
+ parts = { coefficient: parts.coefficient / TEN, scale: parts.scale - 1 };
70420
+ }
70421
+ const rounded = roundParts(parts, digits);
70422
+ return formatDecimalParts(assertWithinEnvelope(rounded, "float conversion"));
70423
+ }
70424
+ function floatFromDecimalString(value) {
70425
+ assertCanonicalInput(value, "value");
70426
+ return Number(value);
70427
+ }
70428
+ var DecimalOverflowError, DecimalDivisionByZeroError, DecimalDigitsRangeError, DecimalNonFiniteError, DecimalClampRangeError, MATH_CLAMP_RANGE_MESSAGE, TEN;
70429
+ var init_decimal_math = __esm({
70430
+ "../src/models/decimal/decimal-math.ts"() {
70431
+ "use strict";
70432
+ init_members();
70433
+ DecimalOverflowError = class extends Error {
70434
+ };
70435
+ DecimalDivisionByZeroError = class extends Error {
70436
+ };
70437
+ DecimalDigitsRangeError = class extends Error {
70438
+ };
70439
+ DecimalNonFiniteError = class extends Error {
70440
+ };
70441
+ DecimalClampRangeError = class extends Error {
70442
+ };
70443
+ MATH_CLAMP_RANGE_MESSAGE = "Math.Clamp requires min <= max.";
70444
+ TEN = 10n;
70445
+ }
70446
+ });
70447
+
70448
+ // ../src/models/decimal/index.ts
70449
+ var init_decimal = __esm({
70450
+ "../src/models/decimal/index.ts"() {
70451
+ "use strict";
70452
+ init_decimal_math();
70453
+ }
70454
+ });
70455
+
70456
+ // ../src/runtime/neoscript/evaluateNSGetter.ts
70351
70457
  function isCatchableNeoScriptRuntimeError(error) {
70352
70458
  return error instanceof NSGetterRuntimeError && !(error instanceof UncompiledInitializerRuntimeError) && !(error instanceof NonCatchableNSGetterRuntimeError);
70353
70459
  }
@@ -70831,9 +70937,9 @@ function evaluatorOwnershipDistances(rowId, indexes) {
70831
70937
  if (cached !== void 0) return cached;
70832
70938
  const distances = /* @__PURE__ */ new Map([[rowId, 0]]);
70833
70939
  const pending = [rowId];
70834
- while (pending.length > 0) {
70835
- const currentId = pending.shift();
70836
- if (currentId === void 0) break;
70940
+ for (let cursor = 0; cursor < pending.length; cursor += 1) {
70941
+ const currentId = pending[cursor];
70942
+ if (currentId === void 0) continue;
70837
70943
  const currentDistance = distances.get(currentId);
70838
70944
  if (currentDistance === void 0) continue;
70839
70945
  for (const parent of evaluatorParentLinks(indexes, currentId)) {
@@ -71451,6 +71557,19 @@ function finalizeConstructorAllocations(ctx, returnValue, ownsInvocationState, r
71451
71557
  }
71452
71558
  const escapedRoots = /* @__PURE__ */ new Set();
71453
71559
  const scannedRows = /* @__PURE__ */ new Set();
71560
+ let rowsByContainerId;
71561
+ const containerEntryIds = (containerId) => {
71562
+ if (rowsByContainerId === void 0) {
71563
+ rowsByContainerId = /* @__PURE__ */ new Map();
71564
+ for (const candidate of evaluatorValues(ctx)) {
71565
+ if (typeof candidate.containerId !== "string") continue;
71566
+ const entries = rowsByContainerId.get(candidate.containerId) ?? [];
71567
+ entries.push(candidate.id);
71568
+ rowsByContainerId.set(candidate.containerId, entries);
71569
+ }
71570
+ }
71571
+ return rowsByContainerId.get(containerId) ?? [];
71572
+ };
71454
71573
  const markConstructorGroupEscaped = (rootId) => {
71455
71574
  if (escapedRoots.has(rootId)) return;
71456
71575
  escapedRoots.add(rootId);
@@ -71500,13 +71619,11 @@ function finalizeConstructorAllocations(ctx, returnValue, ownsInvocationState, r
71500
71619
  ctx.onUnattributableValueRead?.(
71501
71620
  `constructor-argument-list:${argumentId}`
71502
71621
  );
71503
- for (const candidate of evaluatorValues(ctx)) {
71504
- if (candidate.containerId === argumentId) {
71505
- scanCreationDataRow({
71506
- id: candidate.id,
71507
- typeInfo: typeInfo.entryTypeInfo
71508
- });
71509
- }
71622
+ for (const childId of containerEntryIds(argumentId)) {
71623
+ scanCreationDataRow({
71624
+ id: childId,
71625
+ typeInfo: typeInfo.entryTypeInfo
71626
+ });
71510
71627
  }
71511
71628
  return;
71512
71629
  }
@@ -71526,9 +71643,11 @@ function finalizeConstructorAllocations(ctx, returnValue, ownsInvocationState, r
71526
71643
  }
71527
71644
  const rawMember = hintedMember ?? activeStaticBindingRoot(valueId, ctx)?.member ?? memberForValueRow(row, ctx);
71528
71645
  let member = rawMember;
71646
+ let resolvedMemberForSubstitution;
71529
71647
  if (rawMember !== null) {
71530
71648
  try {
71531
- member = resolveMember2(rawMember, ctx.vm.members);
71649
+ member = cachedResolvedMember(rawMember, ctx);
71650
+ resolvedMemberForSubstitution = member;
71532
71651
  } catch {
71533
71652
  member = rawMember;
71534
71653
  }
@@ -71538,7 +71657,8 @@ function finalizeConstructorAllocations(ctx, returnValue, ownsInvocationState, r
71538
71657
  member = substituteMember(
71539
71658
  member,
71540
71659
  envFromStamp(row.genericBindings),
71541
- ctx.vm.members
71660
+ ctx.vm.members,
71661
+ resolvedMemberForSubstitution
71542
71662
  );
71543
71663
  } catch {
71544
71664
  }
@@ -71558,10 +71678,8 @@ function finalizeConstructorAllocations(ctx, returnValue, ownsInvocationState, r
71558
71678
  const entryMember = evalMemberById(ctx.vm, member.entryMemberId);
71559
71679
  if (listKindOf(member) === 1 /* Unordered */) {
71560
71680
  ctx.onUnattributableValueRead?.(`constructed-unordered-list:${row.id}`);
71561
- for (const candidate of evaluatorValues(ctx)) {
71562
- if (candidate.containerId === row.id) {
71563
- scanOwnedRow(candidate.id, entryMember);
71564
- }
71681
+ for (const childId of containerEntryIds(row.id)) {
71682
+ scanOwnedRow(childId, entryMember);
71565
71683
  }
71566
71684
  return;
71567
71685
  }
@@ -79196,7 +79314,7 @@ function iterateCollection(c, ctx, callback) {
79196
79314
  }
79197
79315
  var DELEGATE_LEXICAL_THIS, DELEGATE_LEXICAL_ROOT, NonCatchableNSGetterRuntimeError, NativeFunctionDelegateUnavailableError, CorruptNeoScriptIRError, NeoScriptResourceLimitError, NeoScriptWallClockTimeoutError, DEFAULT_NEO_SCRIPT_EXECUTION_BUDGET_LIMITS, liveListIndexesByProject, evaluatorOwnershipCachesByBase, MAX_CONSTRUCTION_DEPTH, MAX_LOOP_ITERATIONS, resolutionCacheByMembers, NO_SCHEMA_REVISION, LazyValueOverlay, READONLY_FOREACH_BINDING_ERROR, READONLY_CATCH_BINDING_ERROR, NS_MATH_OP_NAMES, DOUBLE_INTEGRAL_MAGNITUDE, EMPTY_SUPPLIED_CONSTRUCTOR_FIELDS;
79198
79316
  var init_evaluateNSGetter = __esm({
79199
- "../src/view-models/neoscript-evaluator/evaluateNSGetter.ts"() {
79317
+ "../src/runtime/neoscript/evaluateNSGetter.ts"() {
79200
79318
  "use strict";
79201
79319
  init_deep_clone_plain_data();
79202
79320
  init_instance_provenance();
@@ -79575,7 +79693,229 @@ var init_stored_value_placement_index = __esm({
79575
79693
  }
79576
79694
  });
79577
79695
 
79578
- // ../src/database/virtual-instance-values.ts
79696
+ // ../src/runtime/initializer-materialization.ts
79697
+ function declarationInitializerContext(document) {
79698
+ const key = initializerEvaluatorCacheKey(document);
79699
+ const revision = initializerEvaluatorCacheRevision(document);
79700
+ const cached = declarationInitializerContextByDocument.get(key);
79701
+ if (cached !== void 0 && (revision === void 0 ? cached.members === document.members && cached.values === document.values : cached.revision === revision)) {
79702
+ return cached.context;
79703
+ }
79704
+ const initializerValueIds = new Set(
79705
+ document.values.filter(isInitValueContent).map((value) => value.id)
79706
+ );
79707
+ const valuesById = new Map(
79708
+ document.values.map((value) => [value.id, value])
79709
+ );
79710
+ const rootOwners = /* @__PURE__ */ new Map();
79711
+ resolveOwnerMembersForValues(
79712
+ document,
79713
+ initializerValueIds,
79714
+ void 0,
79715
+ rootOwners
79716
+ );
79717
+ const created = { valuesById, rootOwners };
79718
+ declarationInitializerContextByDocument.set(key, {
79719
+ members: document.members,
79720
+ values: document.values,
79721
+ revision,
79722
+ context: created
79723
+ });
79724
+ return created;
79725
+ }
79726
+ function evaluateInitializerMaterialization(args) {
79727
+ const createdValues = [];
79728
+ const storageKeyDeclarations = /* @__PURE__ */ new Map();
79729
+ const evaluated = args.evaluateInitializer({
79730
+ init: args.init,
79731
+ member: args.member,
79732
+ document: args.document,
79733
+ createdValues,
79734
+ storageKeyDeclarations,
79735
+ ...args.storedConstructionReplay === true ? { storedConstructionReplay: true } : {},
79736
+ ...args.constructionBaselineReplay === true ? { constructionBaselineReplay: true } : {},
79737
+ ...args.argumentValues === void 0 ? {} : { argumentValues: args.argumentValues },
79738
+ sourceValueId: args.sourceValueId ?? null,
79739
+ readTracking: args.readTracking,
79740
+ saveStaticBindings: args.saveStaticBindings,
79741
+ sessionStaticBindings: args.sessionStaticBindings
79742
+ });
79743
+ return { evaluated, createdValues, storageKeyDeclarations };
79744
+ }
79745
+ function finalizeMaterializedRoot(args) {
79746
+ for (const created of args.allCreated) {
79747
+ if (created === args.root) continue;
79748
+ if (created.classId === void 0) delete created.classId;
79749
+ }
79750
+ stampCreatedValuesMapKey(args.allCreated, args.mapKey);
79751
+ if (args.supersededRootId !== void 0) {
79752
+ args.storageKeyDeclarations.delete(args.supersededRootId);
79753
+ }
79754
+ args.storageKeyDeclarations.delete(args.root.id);
79755
+ applyDeclaredStorageKeyOverrides({
79756
+ createdValues: args.allCreated,
79757
+ declarationByValueId: args.storageKeyDeclarations,
79758
+ existingParentContextById: /* @__PURE__ */ new Map([
79759
+ [
79760
+ args.root.id,
79761
+ {
79762
+ mapKey: args.mapKey ?? null,
79763
+ classId: args.root.classId ?? void 0
79764
+ }
79765
+ ]
79766
+ ])
79767
+ });
79768
+ }
79769
+ function materializeInitializerValue(args) {
79770
+ const { evaluated, createdValues, storageKeyDeclarations } = evaluateInitializerMaterialization({
79771
+ evaluateInitializer: args.evaluateInitializer,
79772
+ init: args.row.init,
79773
+ member: args.member,
79774
+ document: args.document,
79775
+ ...args.storedConstructionReplay === true ? { storedConstructionReplay: true } : {},
79776
+ ...args.constructionBaselineReplay === true ? { constructionBaselineReplay: true } : {},
79777
+ ...args.argumentValues === void 0 ? {} : { argumentValues: args.argumentValues },
79778
+ sourceValueId: args.row.id,
79779
+ readTracking: args.readTracking,
79780
+ saveStaticBindings: args.saveStaticBindings,
79781
+ sessionStaticBindings: args.sessionStaticBindings
79782
+ });
79783
+ const {
79784
+ init: _init,
79785
+ value: _value,
79786
+ classId: _classId,
79787
+ ...envelope
79788
+ } = args.row;
79789
+ void _init;
79790
+ void _value;
79791
+ void _classId;
79792
+ const root = {
79793
+ ...envelope,
79794
+ value: evaluated.value,
79795
+ ...evaluated.classId === null ? {} : { classId: evaluated.classId },
79796
+ ...evaluated.genericBindings === void 0 ? {} : { genericBindings: { ...evaluated.genericBindings } },
79797
+ ...evaluated.constructorArgs === void 0 ? {} : { constructorArgs: deepClonePlainData(evaluated.constructorArgs) },
79798
+ ...evaluated.instanceConstructorId === void 0 ? {} : { instanceConstructorId: evaluated.instanceConstructorId },
79799
+ ...evaluated.instanceVariantId === void 0 ? {} : { instanceVariantId: evaluated.instanceVariantId },
79800
+ ...evaluated.instanceVariantRowValueId === void 0 ? {} : {
79801
+ instanceVariantRowValueId: evaluated.instanceVariantRowValueId
79802
+ }
79803
+ };
79804
+ const allCreated = [root, ...createdValues];
79805
+ if (evaluated.provisionalRootId !== void 0) {
79806
+ retargetDelegateReceiverValueIds(
79807
+ allCreated,
79808
+ evaluated.provisionalRootId,
79809
+ root.id
79810
+ );
79811
+ }
79812
+ finalizeMaterializedRoot({
79813
+ root,
79814
+ allCreated,
79815
+ mapKey: args.row.mapKey,
79816
+ storageKeyDeclarations
79817
+ });
79818
+ return {
79819
+ root,
79820
+ createdValues,
79821
+ pinnedRootSchemaKeys: evaluated.pinnedRootSchemaKeys ?? /* @__PURE__ */ new Set()
79822
+ };
79823
+ }
79824
+ function materializeMemberDefaultValue(args) {
79825
+ const createdValues = [];
79826
+ const storageKeyDeclarations = /* @__PURE__ */ new Map();
79827
+ args.readTracking?.recordUnattributableValueRead(
79828
+ `declaration-owner-resolution:${args.envelope.id}`
79829
+ );
79830
+ const { valuesById, rootOwners } = declarationInitializerContext(
79831
+ args.document
79832
+ );
79833
+ const declarationArguments = (member, init, sourceValueId) => {
79834
+ const ownerClass = typeof sourceValueId === "string" ? initializerOwnerContext(
79835
+ args.document,
79836
+ sourceValueId,
79837
+ rootOwners,
79838
+ valuesById
79839
+ ).ownerClass : typeof Reflect.get(member, "id") === "string" ? findSchemaPlacement(
79840
+ String(Reflect.get(member, "id")),
79841
+ args.document.classes
79842
+ )?.ownerClass ?? null : null;
79843
+ if (ownerClass === null) return [];
79844
+ const constructorId = ownerClass.requiredConstructorId;
79845
+ if (typeof constructorId !== "string") return [];
79846
+ const constructor2 = args.document.constructors?.find(
79847
+ (candidate) => candidate.id === constructorId
79848
+ );
79849
+ if (constructor2 === void 0) return [];
79850
+ const parameterNames = new Set(
79851
+ constructor2.argumentTypes.map((argument2) => argument2.name)
79852
+ );
79853
+ return declarationInitializerArgumentValues(
79854
+ constructor2.argumentTypes,
79855
+ `Declaration template on '${ownerClass.name}'`,
79856
+ initializerReferencesAnyIdentifier(init.code, parameterNames)
79857
+ );
79858
+ };
79859
+ const built = buildDefaultMemberValue({
79860
+ document: args.document,
79861
+ projectId: args.envelope.projectId,
79862
+ member: args.member,
79863
+ createdValues,
79864
+ storageKeyDeclarations,
79865
+ ...args.genericEnv === void 0 ? {} : { genericEnv: args.genericEnv },
79866
+ // A declaration default may itself be init-backed one level down (P43 §2),
79867
+ // and those nested initializers must evaluate against the same document.
79868
+ initEvaluator: (member, init, sourceValueId) => args.evaluateInitializer({
79869
+ init,
79870
+ member,
79871
+ document: args.document,
79872
+ createdValues,
79873
+ storedConstructionReplay: true,
79874
+ argumentValues: declarationArguments(
79875
+ member,
79876
+ init,
79877
+ sourceValueId ?? null
79878
+ ),
79879
+ sourceValueId: sourceValueId ?? null,
79880
+ readTracking: args.readTracking,
79881
+ saveStaticBindings: args.saveStaticBindings,
79882
+ sessionStaticBindings: args.sessionStaticBindings
79883
+ })
79884
+ });
79885
+ const interior = createdValues.filter((created) => created.id !== built.id);
79886
+ const root = {
79887
+ ...args.envelope,
79888
+ value: built.value,
79889
+ ...built.classId === void 0 ? {} : { classId: built.classId },
79890
+ ...built.genericBindings == null ? {} : { genericBindings: { ...built.genericBindings } }
79891
+ };
79892
+ const allCreated = [root, ...interior];
79893
+ retargetDelegateReceiverValueIds(allCreated, built.id, root.id);
79894
+ finalizeMaterializedRoot({
79895
+ root,
79896
+ allCreated,
79897
+ mapKey: args.envelope.mapKey,
79898
+ storageKeyDeclarations,
79899
+ supersededRootId: built.id
79900
+ });
79901
+ return { root, createdValues: interior, pinnedRootSchemaKeys: /* @__PURE__ */ new Set() };
79902
+ }
79903
+ var declarationInitializerContextByDocument;
79904
+ var init_initializer_materialization = __esm({
79905
+ "../src/runtime/initializer-materialization.ts"() {
79906
+ "use strict";
79907
+ init_deep_clone_plain_data();
79908
+ init_members();
79909
+ init_inheritance();
79910
+ init_evaluateNSGetter();
79911
+ init_initializer_context();
79912
+ init_value_row_owner_members();
79913
+ init_compile_ns_property();
79914
+ declarationInitializerContextByDocument = /* @__PURE__ */ new WeakMap();
79915
+ }
79916
+ });
79917
+
79918
+ // ../src/runtime/virtual-instance-graph.ts
79579
79919
  function buildVirtualInstanceMaterializedIndex(args) {
79580
79920
  const rowsById = new Map(
79581
79921
  (args.materializedRows ?? args.document.values).map((row) => [row.id, row])
@@ -79821,6 +80161,7 @@ function expandStoredInstance(args) {
79821
80161
  };
79822
80162
  return trackMaterialization(
79823
80163
  () => materializeInitializerValue({
80164
+ evaluateInitializer: args.evaluateInitializer,
79824
80165
  document: args.document,
79825
80166
  member: replayMember,
79826
80167
  row: { ...envelope, init },
@@ -79836,6 +80177,7 @@ function expandStoredInstance(args) {
79836
80177
  const stampEnv = instanceRoot.genericBindings == null || Object.keys(instanceRoot.genericBindings).length === 0 ? null : envFromStamp(instanceRoot.genericBindings);
79837
80178
  const built = trackMaterialization(
79838
80179
  () => materializeMemberDefaultValue({
80180
+ evaluateInitializer: args.evaluateInitializer,
79839
80181
  document: args.document,
79840
80182
  member: replayMember,
79841
80183
  envelope,
@@ -80213,6 +80555,7 @@ function resolvedStoredInstanceRows(args) {
80213
80555
  if (next === void 0 || resolvedRootIds.has(next.root.id)) continue;
80214
80556
  resolvedRootIds.add(next.root.id);
80215
80557
  const expanded = expandStoredInstance({
80558
+ evaluateInitializer: args.evaluateInitializer,
80216
80559
  document,
80217
80560
  instanceRoot: next.root,
80218
80561
  rootMember: next.member
@@ -81558,6 +81901,7 @@ function resolveVariantInstanceGraphForDocument(args) {
81558
81901
  for (const row of args.localRows) materializedById.set(row.id, row);
81559
81902
  materializedById.set(args.priorInstanceRoot.id, args.priorInstanceRoot);
81560
81903
  const priorExpanded = expandStoredInstance({
81904
+ evaluateInitializer: args.evaluateInitializer,
81561
81905
  document,
81562
81906
  instanceRoot: args.priorInstanceRoot,
81563
81907
  rootMember,
@@ -81596,6 +81940,7 @@ function resolveVariantInstanceGraphForDocument(args) {
81596
81940
  }
81597
81941
  materializedById.set(args.nextInstanceRoot.id, args.nextInstanceRoot);
81598
81942
  const nextExpanded = expandStoredInstance({
81943
+ evaluateInitializer: args.evaluateInitializer,
81599
81944
  document,
81600
81945
  instanceRoot: args.nextInstanceRoot,
81601
81946
  rootMember,
@@ -81681,6 +82026,7 @@ function createHeadlessVirtualInstanceResolver(args) {
81681
82026
  materializedRows: document.values
81682
82027
  });
81683
82028
  const expanded = expandStoredInstance({
82029
+ evaluateInitializer: args.evaluateInitializer,
81684
82030
  document: resolverDocument,
81685
82031
  instanceRoot,
81686
82032
  rootMember: member,
@@ -81740,8 +82086,8 @@ function createHeadlessVirtualInstanceResolver(args) {
81740
82086
  };
81741
82087
  }
81742
82088
  var KEPT_ROW_SAMPLE_LIMIT, CORPUS_SCANNING_MEMBER_KINDS, VirtualExpansionUnsupportedError, ROOT_PATH, SYNTHETIC_LINEAGE_PREFIXES, resolverDocumentsByDocument;
81743
- var init_virtual_instance_values = __esm({
81744
- "../src/database/virtual-instance-values.ts"() {
82089
+ var init_virtual_instance_graph = __esm({
82090
+ "../src/runtime/virtual-instance-graph.ts"() {
81745
82091
  "use strict";
81746
82092
  init_deep_clone_plain_data();
81747
82093
  init_inheritance();
@@ -81755,8 +82101,8 @@ var init_virtual_instance_values = __esm({
81755
82101
  init_instance_provenance();
81756
82102
  init_unordered_list_membership();
81757
82103
  init_neoscript();
81758
- init_evaluateInitializer();
81759
- init_init_backed_value_materialization();
82104
+ init_initializer_context();
82105
+ init_initializer_materialization();
81760
82106
  init_constructor_argument_ownership();
81761
82107
  init_constructors2();
81762
82108
  init_src();
@@ -81777,13 +82123,7 @@ var init_virtual_instance_values = __esm({
81777
82123
  }
81778
82124
  });
81779
82125
 
81780
- // ../src/view-models/neoscript-evaluator/evaluateInitializer.ts
81781
- function initializerEvaluatorCacheKey(document) {
81782
- return document.evaluatorCache?.key ?? document;
81783
- }
81784
- function initializerEvaluatorCacheRevision(document) {
81785
- return document.evaluatorCache?.revision;
81786
- }
82126
+ // ../src/runtime/neoscript/evaluateInitializer.ts
81787
82127
  function initializerEvaluatorLookups(document, readTracking) {
81788
82128
  const trackedHeadless = readTracking !== void 0 && document.databaseVM === void 0;
81789
82129
  const indexKey = initializerEvaluatorCacheKey(document);
@@ -81843,6 +82183,7 @@ function initializerEvaluatorLookups(document, readTracking) {
81843
82183
  revision
81844
82184
  );
81845
82185
  const headlessVirtualResolver = document.databaseVM === void 0 ? createHeadlessVirtualInstanceResolver({
82186
+ evaluateInitializer: evaluateMemberInitializer,
81846
82187
  document,
81847
82188
  resolverLookups: () => lookups,
81848
82189
  ...readTracking === void 0 ? {} : { readRecorder: virtualReadRecorder(readTracking) }
@@ -81861,6 +82202,7 @@ function initializerEvaluatorLookups(document, readTracking) {
81861
82202
  // resolves against the plain document, with these lookups as the
81862
82203
  // nested resolver.
81863
82204
  resolveVariantInstanceGraph: (args) => resolveVariantInstanceGraphForDocument({
82205
+ evaluateInitializer: evaluateMemberInitializer,
81864
82206
  document,
81865
82207
  resolverLookups: lookups,
81866
82208
  ...readTracking === void 0 ? {} : { readRecorder: virtualReadRecorder(readTracking) },
@@ -82094,279 +82436,86 @@ function evaluateMemberInitializer(args) {
82094
82436
  }
82095
82437
  };
82096
82438
  }
82097
- var evaluatorLookupsByDocument, indexedEvaluatorLookupsByDocument, InitializerReadSet;
82439
+ var evaluatorLookupsByDocument, indexedEvaluatorLookupsByDocument;
82098
82440
  var init_evaluateInitializer = __esm({
82099
- "../src/view-models/neoscript-evaluator/evaluateInitializer.ts"() {
82441
+ "../src/runtime/neoscript/evaluateInitializer.ts"() {
82100
82442
  "use strict";
82443
+ init_initializer_context();
82101
82444
  init_deep_clone_plain_data();
82102
- init_collections();
82103
82445
  init_instance_provenance();
82104
82446
  init_members();
82105
82447
  init_project2();
82106
82448
  init_evaluateNSGetter();
82107
- init_virtual_instance_values();
82449
+ init_virtual_instance_graph();
82108
82450
  evaluatorLookupsByDocument = /* @__PURE__ */ new WeakMap();
82109
82451
  indexedEvaluatorLookupsByDocument = /* @__PURE__ */ new WeakMap();
82110
- InitializerReadSet = class {
82111
- valueIds = /* @__PURE__ */ new Set();
82112
- localizedTextIds = /* @__PURE__ */ new Set();
82113
- variantIds = /* @__PURE__ */ new Set();
82114
- containerIds = /* @__PURE__ */ new Set();
82115
- staticMemberIds = /* @__PURE__ */ new Set();
82116
- hasValuePlacementRead = false;
82117
- hasUnattributableValueRead = false;
82118
- recordUnattributableValueRead = (_reason) => {
82119
- void _reason;
82120
- this.hasUnattributableValueRead = true;
82121
- };
82122
- recordValuePlacementRead = () => {
82123
- this.hasValuePlacementRead = true;
82124
- };
82125
- };
82126
82452
  }
82127
82453
  });
82128
82454
 
82129
- // ../src/view-models/neoscript-evaluator/index.ts
82130
- var init_neoscript_evaluator = __esm({
82131
- "../src/view-models/neoscript-evaluator/index.ts"() {
82455
+ // ../src/runtime/materialize-values.ts
82456
+ function materializeInitializerValue2(args) {
82457
+ return materializeInitializerValue({
82458
+ ...args,
82459
+ evaluateInitializer: evaluateMemberInitializer
82460
+ });
82461
+ }
82462
+ var init_materialize_values = __esm({
82463
+ "../src/runtime/materialize-values.ts"() {
82132
82464
  "use strict";
82133
- init_NSGetterRuntimeError();
82134
- init_evaluateNSGetter();
82135
82465
  init_evaluateInitializer();
82466
+ init_initializer_materialization();
82136
82467
  }
82137
82468
  });
82138
82469
 
82139
- // ../src/database/init-backed-value-materialization.ts
82140
- function declarationInitializerContext(document) {
82141
- const key = initializerEvaluatorCacheKey(document);
82142
- const revision = initializerEvaluatorCacheRevision(document);
82143
- const cached = declarationInitializerContextByDocument.get(key);
82144
- if (cached !== void 0 && (revision === void 0 ? cached.members === document.members && cached.values === document.values : cached.revision === revision)) {
82145
- return cached.context;
82146
- }
82147
- const initializerValueIds = new Set(
82148
- document.values.filter(isInitValueContent).map((value) => value.id)
82149
- );
82150
- const valuesById = new Map(
82151
- document.values.map((value) => [value.id, value])
82152
- );
82153
- const rootOwners = /* @__PURE__ */ new Map();
82154
- resolveOwnerMembersForValues(
82155
- document,
82156
- initializerValueIds,
82157
- void 0,
82158
- rootOwners
82159
- );
82160
- const created = { valuesById, rootOwners };
82161
- declarationInitializerContextByDocument.set(key, {
82162
- members: document.members,
82163
- values: document.values,
82164
- revision,
82165
- context: created
82166
- });
82167
- return created;
82168
- }
82169
- function evaluateInitializerMaterialization(args) {
82170
- const createdValues = [];
82171
- const storageKeyDeclarations = /* @__PURE__ */ new Map();
82172
- const evaluated = evaluateMemberInitializer({
82173
- init: args.init,
82174
- member: args.member,
82175
- document: args.document,
82176
- createdValues,
82177
- storageKeyDeclarations,
82178
- ...args.storedConstructionReplay === true ? { storedConstructionReplay: true } : {},
82179
- ...args.constructionBaselineReplay === true ? { constructionBaselineReplay: true } : {},
82180
- ...args.argumentValues === void 0 ? {} : { argumentValues: args.argumentValues },
82181
- sourceValueId: args.sourceValueId ?? null,
82182
- readTracking: args.readTracking,
82183
- saveStaticBindings: args.saveStaticBindings,
82184
- sessionStaticBindings: args.sessionStaticBindings
82470
+ // ../src/runtime/virtual-instance-values.ts
82471
+ function expandStoredInstance2(args) {
82472
+ return expandStoredInstance({
82473
+ ...args,
82474
+ evaluateInitializer: evaluateMemberInitializer
82185
82475
  });
82186
- return { evaluated, createdValues, storageKeyDeclarations };
82187
82476
  }
82188
- function finalizeMaterializedRoot(args) {
82189
- for (const created of args.allCreated) {
82190
- if (created === args.root) continue;
82191
- if (created.classId === void 0) delete created.classId;
82192
- }
82193
- stampCreatedValuesMapKey(args.allCreated, args.mapKey);
82194
- if (args.supersededRootId !== void 0) {
82195
- args.storageKeyDeclarations.delete(args.supersededRootId);
82196
- }
82197
- args.storageKeyDeclarations.delete(args.root.id);
82198
- applyDeclaredStorageKeyOverrides({
82199
- createdValues: args.allCreated,
82200
- declarationByValueId: args.storageKeyDeclarations,
82201
- existingParentContextById: /* @__PURE__ */ new Map([
82202
- [
82203
- args.root.id,
82204
- {
82205
- mapKey: args.mapKey ?? null,
82206
- classId: args.root.classId ?? void 0
82207
- }
82208
- ]
82209
- ])
82477
+ function resolvedStoredInstanceRows2(args) {
82478
+ return resolvedStoredInstanceRows({
82479
+ ...args,
82480
+ evaluateInitializer: evaluateMemberInitializer
82210
82481
  });
82211
82482
  }
82212
- function materializeInitializerValue(args) {
82213
- const { evaluated, createdValues, storageKeyDeclarations } = evaluateInitializerMaterialization({
82214
- init: args.row.init,
82215
- member: args.member,
82216
- document: args.document,
82217
- ...args.storedConstructionReplay === true ? { storedConstructionReplay: true } : {},
82218
- ...args.constructionBaselineReplay === true ? { constructionBaselineReplay: true } : {},
82219
- ...args.argumentValues === void 0 ? {} : { argumentValues: args.argumentValues },
82220
- sourceValueId: args.row.id,
82221
- readTracking: args.readTracking,
82222
- saveStaticBindings: args.saveStaticBindings,
82223
- sessionStaticBindings: args.sessionStaticBindings
82224
- });
82225
- const {
82226
- init: _init,
82227
- value: _value,
82228
- classId: _classId,
82229
- ...envelope
82230
- } = args.row;
82231
- void _init;
82232
- void _value;
82233
- void _classId;
82234
- const root = {
82235
- ...envelope,
82236
- value: evaluated.value,
82237
- ...evaluated.classId === null ? {} : { classId: evaluated.classId },
82238
- ...evaluated.genericBindings === void 0 ? {} : { genericBindings: { ...evaluated.genericBindings } },
82239
- ...evaluated.constructorArgs === void 0 ? {} : { constructorArgs: deepClonePlainData(evaluated.constructorArgs) },
82240
- ...evaluated.instanceConstructorId === void 0 ? {} : { instanceConstructorId: evaluated.instanceConstructorId },
82241
- ...evaluated.instanceVariantId === void 0 ? {} : { instanceVariantId: evaluated.instanceVariantId },
82242
- ...evaluated.instanceVariantRowValueId === void 0 ? {} : {
82243
- instanceVariantRowValueId: evaluated.instanceVariantRowValueId
82244
- }
82245
- };
82246
- const allCreated = [root, ...createdValues];
82247
- if (evaluated.provisionalRootId !== void 0) {
82248
- retargetDelegateReceiverValueIds(
82249
- allCreated,
82250
- evaluated.provisionalRootId,
82251
- root.id
82252
- );
82253
- }
82254
- finalizeMaterializedRoot({
82255
- root,
82256
- allCreated,
82257
- mapKey: args.row.mapKey,
82258
- storageKeyDeclarations
82483
+ function resolveVariantInstanceGraphForDocument2(args) {
82484
+ return resolveVariantInstanceGraphForDocument({
82485
+ ...args,
82486
+ evaluateInitializer: evaluateMemberInitializer
82259
82487
  });
82260
- return {
82261
- root,
82262
- createdValues,
82263
- pinnedRootSchemaKeys: evaluated.pinnedRootSchemaKeys ?? /* @__PURE__ */ new Set()
82264
- };
82265
82488
  }
82266
- function materializeMemberDefaultValue(args) {
82267
- const createdValues = [];
82268
- const storageKeyDeclarations = /* @__PURE__ */ new Map();
82269
- args.readTracking?.recordUnattributableValueRead(
82270
- `declaration-owner-resolution:${args.envelope.id}`
82271
- );
82272
- const { valuesById, rootOwners } = declarationInitializerContext(
82273
- args.document
82274
- );
82275
- const declarationArguments = (member, init, sourceValueId) => {
82276
- const ownerClass = typeof sourceValueId === "string" ? initializerOwnerContext(
82277
- args.document,
82278
- sourceValueId,
82279
- rootOwners,
82280
- valuesById
82281
- ).ownerClass : typeof Reflect.get(member, "id") === "string" ? findSchemaPlacement(
82282
- String(Reflect.get(member, "id")),
82283
- args.document.classes
82284
- )?.ownerClass ?? null : null;
82285
- if (ownerClass === null) return [];
82286
- const constructorId = ownerClass.requiredConstructorId;
82287
- if (typeof constructorId !== "string") return [];
82288
- const constructor2 = args.document.constructors?.find(
82289
- (candidate) => candidate.id === constructorId
82290
- );
82291
- if (constructor2 === void 0) return [];
82292
- const parameterNames = new Set(
82293
- constructor2.argumentTypes.map((argument2) => argument2.name)
82294
- );
82295
- return declarationInitializerArgumentValues(
82296
- constructor2.argumentTypes,
82297
- `Declaration template on '${ownerClass.name}'`,
82298
- initializerReferencesAnyIdentifier(init.code, parameterNames)
82299
- );
82300
- };
82301
- const built = buildDefaultMemberValue({
82302
- document: args.document,
82303
- projectId: args.envelope.projectId,
82304
- member: args.member,
82305
- createdValues,
82306
- storageKeyDeclarations,
82307
- ...args.genericEnv === void 0 ? {} : { genericEnv: args.genericEnv },
82308
- // A declaration default may itself be init-backed one level down (P43 §2),
82309
- // and those nested initializers must evaluate against the same document.
82310
- initEvaluator: (member, init, sourceValueId) => evaluateMemberInitializer({
82311
- init,
82312
- member,
82313
- document: args.document,
82314
- createdValues,
82315
- storedConstructionReplay: true,
82316
- argumentValues: declarationArguments(
82317
- member,
82318
- init,
82319
- sourceValueId ?? null
82320
- ),
82321
- sourceValueId: sourceValueId ?? null,
82322
- readTracking: args.readTracking,
82323
- saveStaticBindings: args.saveStaticBindings,
82324
- sessionStaticBindings: args.sessionStaticBindings
82325
- })
82326
- });
82327
- const interior = createdValues.filter((created) => created.id !== built.id);
82328
- const root = {
82329
- ...args.envelope,
82330
- value: built.value,
82331
- ...built.classId === void 0 ? {} : { classId: built.classId },
82332
- ...built.genericBindings == null ? {} : { genericBindings: { ...built.genericBindings } }
82333
- };
82334
- const allCreated = [root, ...interior];
82335
- retargetDelegateReceiverValueIds(allCreated, built.id, root.id);
82336
- finalizeMaterializedRoot({
82337
- root,
82338
- allCreated,
82339
- mapKey: args.envelope.mapKey,
82340
- storageKeyDeclarations,
82341
- supersededRootId: built.id
82489
+ function createHeadlessVirtualInstanceResolver2(args) {
82490
+ return createHeadlessVirtualInstanceResolver({
82491
+ ...args,
82492
+ evaluateInitializer: evaluateMemberInitializer
82342
82493
  });
82343
- return { root, createdValues: interior, pinnedRootSchemaKeys: /* @__PURE__ */ new Set() };
82344
82494
  }
82345
- var declarationInitializerContextByDocument;
82346
- var init_init_backed_value_materialization = __esm({
82347
- "../src/database/init-backed-value-materialization.ts"() {
82495
+ var init_virtual_instance_values = __esm({
82496
+ "../src/runtime/virtual-instance-values.ts"() {
82348
82497
  "use strict";
82349
- init_deep_clone_plain_data();
82350
- init_members();
82351
- init_inheritance();
82352
- init_neoscript_evaluator();
82353
- init_evaluateNSGetter();
82354
82498
  init_evaluateInitializer();
82355
- init_value_row_owner_members();
82356
- init_compile_ns_property();
82357
- declarationInitializerContextByDocument = /* @__PURE__ */ new WeakMap();
82499
+ init_virtual_instance_graph();
82500
+ init_virtual_instance_graph();
82358
82501
  }
82359
82502
  });
82360
82503
 
82361
82504
  // ../convex/projectDocumentDialogueMaterialization.ts
82362
82505
  function materializeDialogues(dialogueRecords, dialogueNodes) {
82506
+ const nodesByDialogue = /* @__PURE__ */ new Map();
82507
+ for (const node of dialogueNodes) {
82508
+ const dialogueId = getDialogueNodeDialogueId(node);
82509
+ if (dialogueId === null) continue;
82510
+ const nodes = nodesByDialogue.get(dialogueId) ?? [];
82511
+ nodes.push(node);
82512
+ nodesByDialogue.set(dialogueId, nodes);
82513
+ }
82363
82514
  return dialogueRecords.map((dialogue) => {
82364
82515
  if (!isRecordWithStringId(dialogue)) return dialogue;
82365
82516
  const { triggerNodeId: _triggerNodeId, ...dialoguePayload } = dialogue;
82366
82517
  void _triggerNodeId;
82367
- const nodes = dialogueNodes.filter(
82368
- (node) => getDialogueNodeDialogueId(node) === dialogue.id
82369
- );
82518
+ const nodes = nodesByDialogue.get(dialogue.id) ?? [];
82370
82519
  const triggerNode = findDialogueTriggerNode(dialogue, nodes);
82371
82520
  const bodyNodes = Object.fromEntries(
82372
82521
  nodes.flatMap((node) => {
@@ -82540,7 +82689,6 @@ __export(project_document_read_exports, {
82540
82689
  readProjectDocumentContentHashHeads: () => readProjectDocumentContentHashHeads,
82541
82690
  readProjectDocumentManifestPage: () => readProjectDocumentManifestPage,
82542
82691
  readProjectDocumentManifestPageRecords: () => readProjectDocumentManifestPageRecords,
82543
- readProjectDocumentManifestRecords: () => readProjectDocumentManifestRecords,
82544
82692
  readProjectDocumentRevisionMarker: () => readProjectDocumentRevisionMarker,
82545
82693
  withStoredValueBase: () => withStoredValueBase
82546
82694
  });
@@ -82781,7 +82929,10 @@ async function fetchProjectDocumentSnapshots(fetchBatch, snapshotIds) {
82781
82929
  }
82782
82930
  }
82783
82931
  });
82784
- await Promise.all(workers);
82932
+ const outcomes = await Promise.allSettled(workers);
82933
+ for (const outcome of outcomes) {
82934
+ if (outcome.status === "rejected") throw outcome.reason;
82935
+ }
82785
82936
  return snapshotsById;
82786
82937
  }
82787
82938
  function readProjectDocumentSnapshotBatch(value, requestedIds) {
@@ -89476,6 +89627,17 @@ var init_packed_value_parity = __esm({
89476
89627
  }
89477
89628
  });
89478
89629
 
89630
+ // ../src/runtime/neoscript/index.ts
89631
+ var init_neoscript2 = __esm({
89632
+ "../src/runtime/neoscript/index.ts"() {
89633
+ "use strict";
89634
+ init_NSGetterRuntimeError();
89635
+ init_evaluateNSGetter();
89636
+ init_evaluateInitializer();
89637
+ init_initializer_context();
89638
+ }
89639
+ });
89640
+
89479
89641
  // ../src/database/headless-virtual-instance-lookups.ts
89480
89642
  function headlessVirtualInstanceLookups(document, options = {}) {
89481
89643
  const members = document.members;
@@ -89493,7 +89655,7 @@ function headlessVirtualInstanceLookups(document, options = {}) {
89493
89655
  }
89494
89656
  } : {}
89495
89657
  );
89496
- const virtual = createHeadlessVirtualInstanceResolver({
89658
+ const virtual = createHeadlessVirtualInstanceResolver2({
89497
89659
  document: {
89498
89660
  ...expandedDocument,
89499
89661
  ...options.initializerCompiler === void 0 ? {} : { initializerCompiler: options.initializerCompiler }
@@ -89511,7 +89673,7 @@ function headlessVirtualInstanceLookups(document, options = {}) {
89511
89673
  virtualInstanceRowsForValue: (receiverValueId) => virtual.virtualInstanceRowsForValue(receiverValueId),
89512
89674
  // Stored-construction replay evaluates `ToVariant`, and production's
89513
89675
  // variant-constructed placements collapse through exactly this path.
89514
- resolveVariantInstanceGraph: (args) => resolveVariantInstanceGraphForDocument({
89676
+ resolveVariantInstanceGraph: (args) => resolveVariantInstanceGraphForDocument2({
89515
89677
  document,
89516
89678
  resolverLookups: lookups,
89517
89679
  ...args
@@ -89528,7 +89690,7 @@ var init_headless_virtual_instance_lookups = __esm({
89528
89690
  "use strict";
89529
89691
  init_virtual_instance_values();
89530
89692
  init_packed_value_encoding();
89531
- init_neoscript_evaluator();
89693
+ init_neoscript2();
89532
89694
  }
89533
89695
  });
89534
89696
 
@@ -90884,7 +91046,7 @@ function materializedInitializerReconciliationFailuresV4(args) {
90884
91046
  let effectiveCurrentRows = currentRows;
90885
91047
  if (currentRoot !== void 0) {
90886
91048
  try {
90887
- effectiveCurrentRows = resolvedStoredInstanceRows({
91049
+ effectiveCurrentRows = resolvedStoredInstanceRows2({
90888
91050
  // The replay immediately above compiled the constructor records
90889
91051
  // that turn this pulled document into an evaluator document.
90890
91052
  document,
@@ -96104,7 +96266,7 @@ var init_project_migration_runner = __esm({
96104
96266
  "../src/database/project-migration-runner.ts"() {
96105
96267
  "use strict";
96106
96268
  init_compiler_adapter();
96107
- init_neoscript_evaluator();
96269
+ init_neoscript2();
96108
96270
  init_members();
96109
96271
  init_packed_value_encoding();
96110
96272
  init_project_root_members();
@@ -97921,7 +98083,7 @@ function provenVirtualValueIds(args) {
97921
98083
  return /* @__PURE__ */ new Set();
97922
98084
  }
97923
98085
  const document = args.merged.document;
97924
- const expanded = expandStoredInstance({
98086
+ const expanded = expandStoredInstance2({
97925
98087
  document,
97926
98088
  instanceRoot: root,
97927
98089
  rootMember
@@ -99345,7 +99507,7 @@ function materializePreparedInstanceInitializers(args) {
99345
99507
  `Value "${valueId}" carries an initializer but no ownership path resolves its declared member.`
99346
99508
  );
99347
99509
  }
99348
- const materialized = materializeInitializerValue({
99510
+ const materialized = materializeInitializerValue2({
99349
99511
  // Every site that survives the declaration-default guard is source for
99350
99512
  // a persisted instance construction. The trusted replay mode both
99351
99513
  // admits Immutable storage and installs the concrete generic slot; the
@@ -99376,7 +99538,7 @@ function materializePreparedInstanceInitializers(args) {
99376
99538
  replayOnlyIndexes.push(site.index);
99377
99539
  continue;
99378
99540
  }
99379
- const baseline = materializeInitializerValue({
99541
+ const baseline = materializeInitializerValue2({
99380
99542
  document: materializationScope.document,
99381
99543
  member,
99382
99544
  row: {
@@ -99597,7 +99759,7 @@ function reconcileInitializerMaterializationTransport(args) {
99597
99759
  }
99598
99760
  }
99599
99761
  function constructorArgumentsSemanticallyEqual(args) {
99600
- const currentRows = resolvedStoredInstanceRows({
99762
+ const currentRows = resolvedStoredInstanceRows2({
99601
99763
  document: args.currentDocument,
99602
99764
  instanceRoot: args.currentRoot,
99603
99765
  rootMember: args.rootMember
@@ -102789,7 +102951,7 @@ var init_project_version_schema_commit = __esm({
102789
102951
  init_compiler_adapter();
102790
102952
  init_project_fingerprint();
102791
102953
  init_project_migration_runner();
102792
- init_neoscript_evaluator();
102954
+ init_neoscript2();
102793
102955
  init_project_version_intents();
102794
102956
  init_general_function_call_ir_source_recompile();
102795
102957
  init_projectDocumentDialogueMaterialization();
@@ -102798,7 +102960,7 @@ var init_project_version_schema_commit = __esm({
102798
102960
  init_project_version_static_value_writes();
102799
102961
  init_localizable_member_value_writes();
102800
102962
  init_value_row_owner_members();
102801
- init_init_backed_value_materialization();
102963
+ init_materialize_values();
102802
102964
  init_packed_value_write_fold();
102803
102965
  init_constructor_argument_ownership();
102804
102966
  init_constructors2();
@@ -103638,7 +103800,7 @@ function materializeDeclarationInitializersForAnimationValidation(document) {
103638
103800
  delete deferredMember.valueId;
103639
103801
  return deferredMember;
103640
103802
  }
103641
- const materialized = materializeInitializerValue({
103803
+ const materialized = materializeInitializerValue2({
103642
103804
  document: { ...document, members, values: [...valuesById.values()] },
103643
103805
  member,
103644
103806
  row: {
@@ -103672,7 +103834,7 @@ function materializeDeclarationInitializersForAnimationValidation(document) {
103672
103834
  deferred.add(row.id);
103673
103835
  continue;
103674
103836
  }
103675
- const materialized = materializeInitializerValue({
103837
+ const materialized = materializeInitializerValue2({
103676
103838
  document: { ...document, members, values: [...valuesById.values()] },
103677
103839
  member,
103678
103840
  row
@@ -104549,7 +104711,7 @@ var init_project_version_whole_graph_validation = __esm({
104549
104711
  init_inheritance();
104550
104712
  init_neoscript();
104551
104713
  init_constructor_argument_ownership();
104552
- init_init_backed_value_materialization();
104714
+ init_materialize_values();
104553
104715
  init_world_system_classes();
104554
104716
  init_project_world_reference_graph();
104555
104717
  init_project_record_semantics();
@@ -104671,10 +104833,12 @@ function compareWorkspacePaths(left, right) {
104671
104833
  }
104672
104834
  function computeWorkspaceStatus(workspace, options) {
104673
104835
  let phaseStarted = performance.now();
104674
- const reportPhase = (phase) => {
104836
+ options.onPhase?.("Reading project schema\u2026");
104837
+ const reportPhase = (phase, nextLabel) => {
104675
104838
  const finished = performance.now();
104676
104839
  options.reportPhase?.(phase, finished - phaseStarted);
104677
104840
  phaseStarted = finished;
104841
+ if (nextLabel !== void 0) options.onPhase?.(nextLabel);
104678
104842
  };
104679
104843
  const conflictedFiles = [];
104680
104844
  const parseErrors = [];
@@ -104837,7 +105001,7 @@ function computeWorkspaceStatus(workspace, options) {
104837
105001
  analysis,
104838
105002
  compilationSources
104839
105003
  );
104840
- reportPhase("analysis-schema-defaults");
105004
+ reportPhase("analysis-schema-defaults", "Reading stored values\u2026");
104841
105005
  } catch (error) {
104842
105006
  parseErrors.push(
104843
105007
  error instanceof SchemaSourceError ? error : new SchemaSourceError(
@@ -104912,7 +105076,7 @@ function computeWorkspaceStatus(workspace, options) {
104912
105076
  manifest,
104913
105077
  { registry: valueLowerRegistry }
104914
105078
  );
104915
- reportPhase("documents-static-root");
105079
+ reportPhase("documents-static-root", "Reading variants and dialogues\u2026");
104916
105080
  authoredValueSeeds = new Map([...authoredValueSeeds, ...rootValues.seeds]);
104917
105081
  const rootPathResolutionState = overlayProspectiveSourceRecords(
104918
105082
  loweringRecords,
@@ -105070,7 +105234,7 @@ function computeWorkspaceStatus(workspace, options) {
105070
105234
  prospectiveState,
105071
105235
  projectAnalysisV4
105072
105236
  );
105073
- reportPhase("supplemental-dialogue");
105237
+ reportPhase("supplemental-dialogue", "Comparing records\u2026");
105074
105238
  records2.push(
105075
105239
  ...staticValues.records,
105076
105240
  ...memberDefaults.records,
@@ -105193,7 +105357,7 @@ function computeWorkspaceStatus(workspace, options) {
105193
105357
  )
105194
105358
  );
105195
105359
  }
105196
- reportPhase("record-diff-references");
105360
+ reportPhase("record-diff-references", "Checking packed values\u2026");
105197
105361
  if (referenceFailures.length > 0) {
105198
105362
  return {
105199
105363
  changes: [],
@@ -105274,7 +105438,7 @@ function computeWorkspaceStatus(workspace, options) {
105274
105438
  reconstructed: reconstructed3,
105275
105439
  changes
105276
105440
  });
105277
- reportPhase("packed-value-fold");
105441
+ reportPhase("packed-value-fold", "Checking initializers\u2026");
105278
105442
  for (const change of changes) {
105279
105443
  if (change.recordKind !== "value" || change.kind !== "update") continue;
105280
105444
  const refusal = valueDematerializationRefusal({
@@ -105318,7 +105482,7 @@ function computeWorkspaceStatus(workspace, options) {
105318
105482
  )
105319
105483
  );
105320
105484
  }
105321
- reportPhase("initializer-reconciliation");
105485
+ reportPhase("initializer-reconciliation", "Checking project files\u2026");
105322
105486
  for (const fileId of options.trustedPendingProjectFiles?.keys() ?? []) {
105323
105487
  const key = `project-file:${fileId}`;
105324
105488
  const base = workspace.state.records[key];
@@ -105355,7 +105519,7 @@ function computeWorkspaceStatus(workspace, options) {
105355
105519
  binaryChanges = binaryFiles.filter(
105356
105520
  (binary) => binary.action !== "unchanged" && binary.action !== "converged"
105357
105521
  );
105358
- reportPhase("binary-inspection");
105522
+ reportPhase("binary-inspection", "Validating animation changes\u2026");
105359
105523
  const invalidatedFileIds = /* @__PURE__ */ new Set();
105360
105524
  for (const binary of binaryFiles) {
105361
105525
  if (binary.action === "create" || binary.action === "upload") {
@@ -105404,7 +105568,7 @@ function computeWorkspaceStatus(workspace, options) {
105404
105568
  );
105405
105569
  }
105406
105570
  }
105407
- reportPhase("animation-clip-validation");
105571
+ reportPhase("animation-clip-validation", "Preparing new values\u2026");
105408
105572
  for (const binary of binaryChanges) {
105409
105573
  if (binary.action !== "missing-local") continue;
105410
105574
  parseErrors.push(
@@ -105541,7 +105705,7 @@ function replayAnimationDeclarationInitializersV4(records2, document, fallbackDo
105541
105705
  if (owner === void 0) continue;
105542
105706
  const declaredClassId = typeof row.classId === "string" ? row.classId : Reflect.get(owner, "classId");
105543
105707
  if (typeof declaredClassId !== "string") continue;
105544
- if (!classBelongsToAnimationFamily(document.classes, declaredClassId)) {
105708
+ if (!classBelongsToAnimationFamily(document.classesById, declaredClassId)) {
105545
105709
  continue;
105546
105710
  }
105547
105711
  const fallback = fallbackValues.get(row.id);
@@ -105620,10 +105784,7 @@ function animationRecordsFromState(records2) {
105620
105784
  return isObjectRecord2(data) ? [{ recordKind: record4.recordKind, data }] : [];
105621
105785
  });
105622
105786
  }
105623
- function classBelongsToAnimationFamily(classes, classId) {
105624
- const classesById = new Map(
105625
- classes.map((schemaClass2) => [schemaClass2.id, schemaClass2])
105626
- );
105787
+ function classBelongsToAnimationFamily(classesById, classId) {
105627
105788
  const visited = /* @__PURE__ */ new Set();
105628
105789
  let currentId = classId;
105629
105790
  while (currentId !== null && !visited.has(currentId)) {
@@ -105689,6 +105850,9 @@ function prospectiveAnimationDocumentV4(records2) {
105689
105850
  }
105690
105851
  }
105691
105852
  if (project === void 0) return null;
105853
+ const classesById = new Map(
105854
+ classes.map((schemaClass2) => [schemaClass2.id, schemaClass2])
105855
+ );
105692
105856
  const classIdByName = new Map(classes.map((value) => [value.name, value.id]));
105693
105857
  const validationValues = expandPackedValueRows(values).map((value) => {
105694
105858
  if (typeof value.classId === "string") return value;
@@ -105713,10 +105877,12 @@ function prospectiveAnimationDocumentV4(records2) {
105713
105877
  return {
105714
105878
  project,
105715
105879
  classes,
105880
+ classesById,
105716
105881
  members,
105717
105882
  values: expandProspectiveAnimationInstances({
105718
105883
  project,
105719
105884
  classes,
105885
+ classesById,
105720
105886
  constructors,
105721
105887
  members,
105722
105888
  values: validationValues
@@ -105725,7 +105891,7 @@ function prospectiveAnimationDocumentV4(records2) {
105725
105891
  }
105726
105892
  function expandProspectiveAnimationInstances(document) {
105727
105893
  const animationRoots = document.values.filter(
105728
- (row) => isLiteralValueContent(row) && isVirtualInstanceRootShape(row) && typeof row.classId === "string" && classBelongsToAnimationFamily(document.classes, row.classId)
105894
+ (row) => isLiteralValueContent(row) && isVirtualInstanceRootShape(row) && typeof row.classId === "string" && classBelongsToAnimationFamily(document.classesById, row.classId)
105729
105895
  );
105730
105896
  if (animationRoots.length === 0) return [...document.values];
105731
105897
  const lookups = cliEvaluatorLookups({
@@ -107119,8 +107285,7 @@ var init_commit_preparation_scope_planner = __esm({
107119
107285
  "source-only-rows",
107120
107286
  "whole-graph-validation-members",
107121
107287
  "world-value-ranges"
107122
- ],
107123
- mutatesDocument: []
107288
+ ]
107124
107289
  },
107125
107290
  "authored-value-seeds": {
107126
107291
  order: 2,
@@ -107142,10 +107307,7 @@ var init_commit_preparation_scope_planner = __esm({
107142
107307
  "every-variant-root",
107143
107308
  "localizable-reference-candidates",
107144
107309
  "world-value-ranges"
107145
- ],
107146
- // `materializeStaticSeedBindingMembers` pushes the binding member it mints
107147
- // into the document the rest of this pass reads, not only into `prepared`.
107148
- mutatesDocument: ["members"]
107310
+ ]
107149
107311
  },
107150
107312
  "variant-child-override-binding-members": {
107151
107313
  order: 3,
@@ -107161,10 +107323,7 @@ var init_commit_preparation_scope_planner = __esm({
107161
107323
  "every-variant-root",
107162
107324
  "stamp-edge-candidates",
107163
107325
  "world-value-ranges"
107164
- ],
107165
- // The minted binding member is pushed straight into the document the
107166
- // later passes read, not only into `prepared`.
107167
- mutatesDocument: ["members"]
107326
+ ]
107168
107327
  },
107169
107328
  "prepared-instance-initializers": {
107170
107329
  order: 4,
@@ -107177,8 +107336,7 @@ var init_commit_preparation_scope_planner = __esm({
107177
107336
  "full-content-dimension",
107178
107337
  "member-default-value-closure",
107179
107338
  "world-value-ranges"
107180
- ],
107181
- mutatesDocument: []
107339
+ ]
107182
107340
  },
107183
107341
  "delegate-value-bodies": {
107184
107342
  order: 5,
@@ -107194,8 +107352,7 @@ var init_commit_preparation_scope_planner = __esm({
107194
107352
  "every-variant-root",
107195
107353
  "source-only-rows",
107196
107354
  "world-value-ranges"
107197
- ],
107198
- mutatesDocument: []
107355
+ ]
107199
107356
  },
107200
107357
  "variant-constructor-args": {
107201
107358
  order: 6,
@@ -107208,8 +107365,7 @@ var init_commit_preparation_scope_planner = __esm({
107208
107365
  "touched-variant-schema-key-children",
107209
107366
  "member-default-value-closure",
107210
107367
  "world-value-ranges"
107211
- ],
107212
- mutatesDocument: []
107368
+ ]
107213
107369
  }
107214
107370
  };
107215
107371
  }
@@ -108922,6 +109078,12 @@ var init_server_preparation_preflight = __esm({
108922
109078
  function isPulledInitializerCompilationDocumentV4(document) {
108923
109079
  return typeof Reflect.get(document, "project") === "object" && Reflect.get(document, "project") !== null && Array.isArray(Reflect.get(document, "projectFiles")) && Array.isArray(Reflect.get(document, "members")) && Array.isArray(Reflect.get(document, "classes")) && Array.isArray(Reflect.get(document, "enums")) && Array.isArray(Reflect.get(document, "interfaces")) && Array.isArray(Reflect.get(document, "constructors")) && Array.isArray(Reflect.get(document, "values"));
108924
109080
  }
109081
+ function createPulledConstructionReplayContext(args) {
109082
+ return {
109083
+ document: args.document,
109084
+ constructorsValidated: false
109085
+ };
109086
+ }
108925
109087
  function pulledInitializerCompilerStateV4(document, compilationProject) {
108926
109088
  const existing = pulledInitializerCompilerStates.get(document);
108927
109089
  if (existing !== void 0) {
@@ -108997,6 +109159,14 @@ function describePulledProjectBodyCompileError(error) {
108997
109159
  }
108998
109160
  function replayStoredConstructionV4(args) {
108999
109161
  const document = args.document ?? readPulledProjectDocumentV4(args.records);
109162
+ if (args.replayContext !== void 0 && args.replayContext.document !== document) {
109163
+ throw new Error(
109164
+ "Construction replay context belongs to a different document."
109165
+ );
109166
+ }
109167
+ if (args.compileDocumentBodies === true && args.replayContext !== void 0) {
109168
+ args.replayContext.constructorsValidated = false;
109169
+ }
109000
109170
  const compilationProject = args.compilationProject ?? (args.compileDocumentBodies === true ? createNeoScriptCompilationProject({
109001
109171
  project: document.project,
109002
109172
  projectFiles: document.projectFiles,
@@ -109081,9 +109251,13 @@ function replayStoredConstructionV4(args) {
109081
109251
  ...candidate,
109082
109252
  init: withoutInitializerConstructionFields(candidate.init)
109083
109253
  } : candidate;
109084
- compilePulledUncompiledConstructorsV4(document, compilationProject);
109085
- assertPulledConstructorsCompiled(document);
109086
- const materialized = materializeInitializerValue({
109254
+ compilePulledUncompiledConstructorsV4(
109255
+ document,
109256
+ compilationProject,
109257
+ args.replayContext
109258
+ );
109259
+ assertPulledConstructorsCompiled(document, args.replayContext);
109260
+ const materialized = materializeInitializerValue2({
109087
109261
  document: {
109088
109262
  ...document,
109089
109263
  // Replays need distinct compiler closures but read one immutable
@@ -109110,11 +109284,15 @@ function replayStoredConstructionV4(args) {
109110
109284
  ])
109111
109285
  );
109112
109286
  }
109113
- function compilePulledUncompiledConstructorsV4(document, compilationProject) {
109287
+ function compilePulledUncompiledConstructorsV4(document, compilationProject, replayContext) {
109288
+ if (replayContext?.constructorsValidated === true) return;
109114
109289
  const uncompiled = (document.constructors ?? []).filter(
109115
109290
  (constructor2) => !isNeoClassConstructor(constructor2)
109116
109291
  );
109117
- if (uncompiled.length === 0) return;
109292
+ if (uncompiled.length === 0) {
109293
+ if (replayContext !== void 0) replayContext.constructorsValidated = true;
109294
+ return;
109295
+ }
109118
109296
  const project = compilationProject ?? createNeoScriptCompilationProject({
109119
109297
  project: document.project,
109120
109298
  projectFiles: document.projectFiles,
@@ -109137,6 +109315,7 @@ function compilePulledUncompiledConstructorsV4(document, compilationProject) {
109137
109315
  for (const constructor2 of uncompiled) {
109138
109316
  compileConstructorRecord({ ...compileArgs, constructor: constructor2 });
109139
109317
  }
109318
+ assertPulledConstructorsCompiled(document, replayContext);
109140
109319
  }
109141
109320
  function valueInitializerCompilationSites(document) {
109142
109321
  const cached = pulledValueInitializerCompilationSites.get(document);
@@ -109244,7 +109423,13 @@ function compilePulledProjectDocumentForEvaluationV4(document, compilationProjec
109244
109423
  }
109245
109424
  }
109246
109425
  }
109247
- function assertPulledConstructorsCompiled(document) {
109426
+ function assertPulledConstructorsCompiled(document, replayContext) {
109427
+ if (replayContext !== void 0 && replayContext.document !== document) {
109428
+ throw new Error(
109429
+ "Constructor validation context belongs to a different document."
109430
+ );
109431
+ }
109432
+ if (replayContext?.constructorsValidated === true) return;
109248
109433
  const uncompiled = (document.constructors ?? []).find(
109249
109434
  (constructor2) => !isNeoClassConstructor(constructor2)
109250
109435
  );
@@ -109253,6 +109438,7 @@ function assertPulledConstructorsCompiled(document) {
109253
109438
  `Constructor "${uncompiled.id}" was read from authored source but was not compiled before evaluation.`
109254
109439
  );
109255
109440
  }
109441
+ if (replayContext !== void 0) replayContext.constructorsValidated = true;
109256
109442
  }
109257
109443
  function compilePulledMemberInitializerBodyV4(document, memberId, compilationProject) {
109258
109444
  const compileArgs = {
@@ -109398,7 +109584,7 @@ var init_initializer_replay = __esm({
109398
109584
  "use strict";
109399
109585
  init_members();
109400
109586
  init_compile_ns_property();
109401
- init_init_backed_value_materialization();
109587
+ init_materialize_values();
109402
109588
  init_virtual_instance_values();
109403
109589
  init_value_row_owner_members();
109404
109590
  init_project_document_read();
@@ -109451,11 +109637,16 @@ function buildValueEmitContext(records2, manifest) {
109451
109637
  const readDocument = () => document ??= readPulledProjectDocumentV4(records2);
109452
109638
  let compilationProject;
109453
109639
  const readCompilationProject = () => compilationProject ??= createNeoScriptCompilationProject(readDocument());
109640
+ let replayContext;
109641
+ const readReplayContext = () => replayContext ??= createPulledConstructionReplayContext({
109642
+ document: readDocument()
109643
+ });
109454
109644
  let materializedGraph;
109455
109645
  return {
109456
109646
  records: records2,
109457
109647
  readDocument,
109458
109648
  readCompilationProject,
109649
+ readReplayContext,
109459
109650
  readMaterializedGraph: () => {
109460
109651
  if (materializedGraph !== void 0) return materializedGraph;
109461
109652
  materializedGraph = new MaterializedValueGraphContext(
@@ -109497,6 +109688,7 @@ function buildValueEmitContext(records2, manifest) {
109497
109688
  fileSymbols: projectFileSymbols(records2),
109498
109689
  localizedTextIds: /* @__PURE__ */ new Set(),
109499
109690
  constructionReplays: /* @__PURE__ */ new Map(),
109691
+ constructorBodySchemaKeys: /* @__PURE__ */ new WeakMap(),
109500
109692
  materializedConstructors: /* @__PURE__ */ new Map(),
109501
109693
  materializedConstructorOverrideKeys: /* @__PURE__ */ new Map()
109502
109694
  };
@@ -110400,6 +110592,9 @@ function variantReconstructedFields(context, row) {
110400
110592
  }
110401
110593
  function mergedOverStoredRow(base, lowered) {
110402
110594
  const merged = { ...valueFileFields(base), ...lowered };
110595
+ if (lowered.classId === null && base.classId === void 0) {
110596
+ delete merged.classId;
110597
+ }
110403
110598
  const storedArgs = isObjectRecord2(base.constructorArgs) ? base.constructorArgs : null;
110404
110599
  const loweredArgs = isObjectRecord2(merged.constructorArgs) ? merged.constructorArgs : null;
110405
110600
  if (storedArgs !== null && loweredArgs !== null) {
@@ -115074,7 +115269,8 @@ function storedConstructionReplayRows(context, valueId, code, member) {
115074
115269
  valueId,
115075
115270
  code,
115076
115271
  member,
115077
- compilationProject: context.readCompilationProject()
115272
+ compilationProject: context.readCompilationProject(),
115273
+ replayContext: context.readReplayContext()
115078
115274
  });
115079
115275
  context.constructionReplays.set(valueId, replay);
115080
115276
  return replay;
@@ -115216,7 +115412,11 @@ function storedConstructorCallSource(context, schemaClass2, value, className, en
115216
115412
  // re-declared that external graph under the construction, and the
115217
115413
  // emitter then refused the whole pull with a containment cycle on the
115218
115414
  // re-declared row's own children.
115219
- constructorArgumentBodySchemaKey(value, constructorArgs[key]) !== void 0
115415
+ constructorArgumentBodySchemaKey(
115416
+ context,
115417
+ value,
115418
+ constructorArgs[key]
115419
+ ) !== void 0
115220
115420
  )}`
115221
115421
  ];
115222
115422
  });
@@ -115228,7 +115428,11 @@ function storedConstructorCallSource(context, schemaClass2, value, className, en
115228
115428
  function settledMemberForConstructorArgument(context, schemaClass2, value, argument2, argumentName) {
115229
115429
  if (typeof argument2 !== "string") return void 0;
115230
115430
  const schema = isObjectRecord2(schemaClass2.schema) ? schemaClass2.schema : {};
115231
- const bodySchemaKey = constructorArgumentBodySchemaKey(value, argument2);
115431
+ const bodySchemaKey = constructorArgumentBodySchemaKey(
115432
+ context,
115433
+ value,
115434
+ argument2
115435
+ );
115232
115436
  if (bodySchemaKey !== void 0) {
115233
115437
  return memberForSchemaKey(context, schema, bodySchemaKey);
115234
115438
  }
@@ -115245,11 +115449,22 @@ function settledMemberForConstructorArgument(context, schemaClass2, value, argum
115245
115449
  const namedSchemaKey = schemaKeyForParameterName(schema, argumentName);
115246
115450
  return namedSchemaKey === void 0 ? void 0 : memberForSchemaKey(context, schema, namedSchemaKey);
115247
115451
  }
115248
- function constructorArgumentBodySchemaKey(value, argument2) {
115452
+ function constructorArgumentBodySchemaKey(context, value, argument2) {
115249
115453
  if (typeof argument2 !== "string") return void 0;
115250
115454
  const body = value.value;
115251
115455
  if (!isObjectRecord2(body)) return void 0;
115252
- return Object.entries(body).find(([, rowId]) => rowId === argument2)?.[0];
115456
+ let keysByArgument = context.constructorBodySchemaKeys.get(value);
115457
+ if (keysByArgument === void 0) {
115458
+ const created = /* @__PURE__ */ new Map();
115459
+ for (const [schemaKey, rowId] of Object.entries(body)) {
115460
+ if (typeof rowId === "string" && !created.has(rowId)) {
115461
+ created.set(rowId, schemaKey);
115462
+ }
115463
+ }
115464
+ keysByArgument = created;
115465
+ context.constructorBodySchemaKeys.set(value, keysByArgument);
115466
+ }
115467
+ return keysByArgument.get(argument2);
115253
115468
  }
115254
115469
  function memberForSchemaKey(context, schema, schemaKey) {
115255
115470
  const memberId = schema[schemaKey];
@@ -117715,6 +117930,7 @@ function listProjectTestFilesV1(root) {
117715
117930
  return listNeoWorkspaceFilesV1(root).specs;
117716
117931
  }
117717
117932
  function computeWorkspaceStatus2(workspace, options = {}) {
117933
+ options.onPhase?.("Reading project sources\u2026");
117718
117934
  const virtualSourceFiles = options.virtualSourceFiles ?? listProjectSourceFilesV4(workspace.root).map((path) => ({
117719
117935
  path: relative3(workspace.root, path).split(sep3).join("/"),
117720
117936
  content: readFileSync7(path, "utf8")
@@ -119333,12 +119549,11 @@ import {
119333
119549
  readFileSync as readFileSync9
119334
119550
  } from "node:fs";
119335
119551
  import { dirname as dirname8 } from "node:path";
119336
- async function runPull(workspace, options) {
119552
+ async function runPull(workspace, options, progress = spinner("Checking local workspace\u2026")) {
119337
119553
  if (options.reset) {
119338
- await runResetPull(workspace);
119554
+ await runResetPull(workspace, progress);
119339
119555
  return;
119340
119556
  }
119341
- const progress = spinner("Checking local workspace\u2026");
119342
119557
  try {
119343
119558
  await runNormalPull(workspace, options, progress);
119344
119559
  } catch (error) {
@@ -119353,32 +119568,6 @@ async function runNormalPull(workspace, options, progress) {
119353
119568
  if (acceptSourceEquivalentConflictBases(workspace, mainLocale) > 0) {
119354
119569
  writeWorkspaceState(workspace.root, workspace.state);
119355
119570
  }
119356
- let localByKey = /* @__PURE__ */ new Map();
119357
- let localStatus = null;
119358
- if (hasBaseline && !destructive) {
119359
- const status = computeWorkspaceStatus2(workspace);
119360
- localStatus = status;
119361
- if (status.conflictedFiles.length > 0) {
119362
- throw new Error(
119363
- `Resolve conflict markers before pulling: ${status.conflictedFiles.join(", ")}`
119364
- );
119365
- }
119366
- const blockingErrors = status.parseErrors.filter(
119367
- isBlockingSchemaSourceError
119368
- );
119369
- if (blockingErrors.length > 0) {
119370
- throw new Error(
119371
- `Fix parse errors before pulling:
119372
- ${blockingErrors.map((error) => ` ${error.message}`).join("\n")}`
119373
- );
119374
- }
119375
- localByKey = new Map(
119376
- [...status.reconstructed.entries()].map(([key, record4]) => [
119377
- key,
119378
- record4.fullData
119379
- ])
119380
- );
119381
- }
119382
119571
  let changedRecordKeys = null;
119383
119572
  let nextCursor = null;
119384
119573
  let observedHeadTransactionHash;
@@ -119433,6 +119622,35 @@ ${blockingErrors.map((error) => ` ${error.message}`).join("\n")}`
119433
119622
  document = await fetchProjectDocument(workspace);
119434
119623
  nextCursor = document.revision === void 0 ? null : cursorFromRevision(document.revision);
119435
119624
  }
119625
+ let localByKey = /* @__PURE__ */ new Map();
119626
+ let localStatus = null;
119627
+ if (hasBaseline && !destructive) {
119628
+ const status = computeWorkspaceStatus2(workspace, {
119629
+ onPhase: (label) => progress.update(label)
119630
+ });
119631
+ localStatus = status;
119632
+ if (status.conflictedFiles.length > 0) {
119633
+ throw new Error(
119634
+ `Resolve conflict markers before pulling: ${status.conflictedFiles.join(", ")}`
119635
+ );
119636
+ }
119637
+ const blockingErrors = status.parseErrors.filter(
119638
+ isBlockingSchemaSourceError
119639
+ );
119640
+ if (blockingErrors.length > 0) {
119641
+ throw new Error(
119642
+ `Fix parse errors before pulling:
119643
+ ${blockingErrors.map((error) => ` ${error.message}`).join("\n")}`
119644
+ );
119645
+ }
119646
+ localByKey = new Map(
119647
+ [...status.reconstructed.entries()].map(([key, record4]) => [
119648
+ key,
119649
+ record4.fullData
119650
+ ])
119651
+ );
119652
+ }
119653
+ progress.update("Merging remote changes\u2026");
119436
119654
  const plans = /* @__PURE__ */ new Map();
119437
119655
  let mergedCount = 0;
119438
119656
  let conflictCount = 0;
@@ -119564,8 +119782,8 @@ ${blockingErrors.map((error) => ` ${error.message}`).join("\n")}`
119564
119782
  progress
119565
119783
  });
119566
119784
  }
119567
- async function runResetPull(workspace) {
119568
- const progress = spinner("Pulling project snapshot\u2026");
119785
+ async function runResetPull(workspace, progress) {
119786
+ progress.update("Pulling project snapshot\u2026");
119569
119787
  try {
119570
119788
  const document = await fetchProjectDocument(workspace);
119571
119789
  progress.update("Downloading project files\u2026");
@@ -123404,7 +123622,7 @@ var init_script = __esm({
123404
123622
  init_game_save_record_read2();
123405
123623
  init_projection();
123406
123624
  init_compiler_adapter();
123407
- init_neoscript_evaluator();
123625
+ init_neoscript2();
123408
123626
  init_evaluator_lookups();
123409
123627
  init_project_root_members();
123410
123628
  init_save_overlay_resolution();
@@ -125033,6 +125251,7 @@ async function downloadProjectVersionTransactionResult(args) {
125033
125251
  async function preparePushStatus(workspace, options, onPhase = () => void 0) {
125034
125252
  onPhase("Analyzing working copy\u2026");
125035
125253
  const status = computeWorkspaceStatus2(workspace, {
125254
+ onPhase,
125036
125255
  forceRecompile: options.forceRecompile
125037
125256
  });
125038
125257
  if (status.conflictedFiles.length > 0) {
@@ -127422,7 +127641,7 @@ var init_registry2 = __esm({
127422
127641
  "schema-contract/registry.mjs"() {
127423
127642
  "use strict";
127424
127643
  PROJECT_SCHEMA_CONTRACT = Object.freeze({
127425
- cliVersion: "0.46.0",
127644
+ cliVersion: "0.46.2",
127426
127645
  projectFileUploadBatchSize: 32,
127427
127646
  documentRecords: {
127428
127647
  member: {
@@ -130478,7 +130697,7 @@ var init_test = __esm({
130478
130697
  "use strict";
130479
130698
  init_src();
130480
130699
  init_members();
130481
- init_neoscript_evaluator();
130700
+ init_neoscript2();
130482
130701
  init_evaluator_lookups();
130483
130702
  init_neoscript_language_adapter();
130484
130703
  init_workspace_status();
@@ -132219,7 +132438,7 @@ var init_migrate = __esm({
132219
132438
  init_source_diagnostics();
132220
132439
  init_compiler_adapter();
132221
132440
  init_push_body_diagnostics();
132222
- init_neoscript_evaluator();
132441
+ init_neoscript2();
132223
132442
  init_evaluator_lookups();
132224
132443
  init_virtual_instance_values();
132225
132444
  init_script();
@@ -133864,7 +134083,7 @@ var init_dialogue_dryrun = __esm({
133864
134083
  "use strict";
133865
134084
  init_document();
133866
134085
  init_projection();
133867
- init_neoscript_evaluator();
134086
+ init_neoscript2();
133868
134087
  init_evaluator_lookups();
133869
134088
  init_project_root_members();
133870
134089
  init_members();
@@ -134241,6 +134460,17 @@ var init_resolve = __esm({
134241
134460
 
134242
134461
  // src/main.ts
134243
134462
  var main_exports = {};
134463
+ function computeCommandWorkspaceStatus(args) {
134464
+ const progress = !boolFlag(args, "json") && process.stdout.isTTY === true ? spinner("Reading local workspace\u2026") : null;
134465
+ try {
134466
+ const workspace = loadWorkspaceForCommand(args);
134467
+ return computeWorkspaceStatus2(workspace, {
134468
+ onPhase: (label) => progress?.update(label)
134469
+ });
134470
+ } finally {
134471
+ progress?.stop();
134472
+ }
134473
+ }
134244
134474
  function profileFlag(args) {
134245
134475
  const value = stringFlag(args, "profile");
134246
134476
  if (value === null) return null;
@@ -134435,7 +134665,7 @@ There is no --keep-current: preserving current semantic state defines flatten.
134435
134665
  async function main() {
134436
134666
  const args = parseArgs(process.argv.slice(2));
134437
134667
  if (args.command === "--version") {
134438
- console.log("0.46.0");
134668
+ console.log("0.46.2");
134439
134669
  return;
134440
134670
  }
134441
134671
  if (args.command === null || args.command === "help" || args.command === "--help" || args.command === "-h") {
@@ -134510,13 +134740,25 @@ async function main() {
134510
134740
  args,
134511
134741
  /* @__PURE__ */ new Set(["api", "force", "reset", "regenerate-source-names"])
134512
134742
  );
134513
- const workspace = loadWorkspaceForCommand(args);
134514
- const { runPull: runPull2 } = await Promise.resolve().then(() => (init_pull(), pull_exports));
134515
- await runPull2(workspace, {
134516
- force: boolFlag(args, "force"),
134517
- reset: boolFlag(args, "reset"),
134518
- regenerateSourceNames: boolFlag(args, "regenerate-source-names")
134519
- });
134743
+ const progress = spinner("Reading local workspace\u2026");
134744
+ try {
134745
+ const workspace = loadWorkspaceForCommand(args);
134746
+ const { runPull: runPull2 } = await Promise.resolve().then(() => (init_pull(), pull_exports));
134747
+ await runPull2(
134748
+ workspace,
134749
+ {
134750
+ force: boolFlag(args, "force"),
134751
+ reset: boolFlag(args, "reset"),
134752
+ regenerateSourceNames: boolFlag(args, "regenerate-source-names")
134753
+ },
134754
+ progress
134755
+ );
134756
+ } catch (error) {
134757
+ progress.fail("Pull failed.");
134758
+ throw error;
134759
+ } finally {
134760
+ progress.stop();
134761
+ }
134520
134762
  return;
134521
134763
  }
134522
134764
  case "doctor": {
@@ -134724,7 +134966,6 @@ async function main() {
134724
134966
  return;
134725
134967
  }
134726
134968
  case "test": {
134727
- const workspace = loadWorkspaceForCommand(args);
134728
134969
  const reporterValue = stringFlag(args, "reporter") ?? "default";
134729
134970
  if (reporterValue !== "default" && reporterValue !== "json") {
134730
134971
  throw new NeoCliUsageError('--reporter must be "default" or "json".');
@@ -134746,8 +134987,9 @@ async function main() {
134746
134987
  "--testTimeout must be a positive number of milliseconds."
134747
134988
  );
134748
134989
  }
134749
- const progress = reporterValue === "default" && process.stdout.isTTY === true ? spinner("Preparing test project\u2026") : null;
134990
+ const progress = reporterValue === "default" && process.stdout.isTTY === true ? spinner("Reading local workspace\u2026") : null;
134750
134991
  try {
134992
+ const workspace = loadWorkspaceForCommand(args);
134751
134993
  const { runTest: runTest2 } = await Promise.resolve().then(() => (init_test(), test_exports));
134752
134994
  await runTest2(
134753
134995
  workspace,
@@ -134764,6 +135006,8 @@ async function main() {
134764
135006
  } catch (error) {
134765
135007
  progress?.fail("Test run failed.");
134766
135008
  throw error;
135009
+ } finally {
135010
+ progress?.stop();
134767
135011
  }
134768
135012
  return;
134769
135013
  }
@@ -134849,8 +135093,7 @@ async function main() {
134849
135093
  return;
134850
135094
  }
134851
135095
  case "status": {
134852
- const workspace = loadWorkspaceForCommand(args);
134853
- const status = computeWorkspaceStatus2(workspace);
135096
+ const status = computeCommandWorkspaceStatus(args);
134854
135097
  if (boolFlag(args, "json")) {
134855
135098
  console.log(
134856
135099
  JSON.stringify(
@@ -134894,8 +135137,7 @@ async function main() {
134894
135137
  return;
134895
135138
  }
134896
135139
  case "diff": {
134897
- const workspace = loadWorkspaceForCommand(args);
134898
- const status = computeWorkspaceStatus2(workspace);
135140
+ const status = computeCommandWorkspaceStatus(args);
134899
135141
  if (boolFlag(args, "json")) {
134900
135142
  console.log(
134901
135143
  JSON.stringify(