@neocompose/cli 0.84.0 → 0.84.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.
@@ -17587,7 +17587,7 @@ var init_registry = __esm({
17587
17587
  "../packages/manifest/schema-contract/registry.mjs"() {
17588
17588
  "use strict";
17589
17589
  PROJECT_SCHEMA_CONTRACT = Object.freeze({
17590
- cliVersion: "0.84.0",
17590
+ cliVersion: "0.84.2",
17591
17591
  projectFileUploadBatchSize: 32,
17592
17592
  documentRecords: {
17593
17593
  member: {
@@ -21418,7 +21418,8 @@ var init_executable_parser = __esm({
21418
21418
  }
21419
21419
  if (isIdentifier(t) && t.text === NEOSCRIPT_CONSTRUCTOR_KEYWORD) {
21420
21420
  this.next();
21421
- const className = isIdentifier(this.peek()) ? this.next().text : null;
21421
+ const classToken = isIdentifier(this.peek()) ? this.next() : null;
21422
+ const className = classToken?.text ?? null;
21422
21423
  const typeArguments = [];
21423
21424
  if (this.eat("operator", "<")) {
21424
21425
  if (className === null) {
@@ -21452,6 +21453,7 @@ var init_executable_parser = __esm({
21452
21453
  return {
21453
21454
  kind: "new",
21454
21455
  className,
21456
+ ...classToken ? { classNamePos: at(classToken) } : {},
21455
21457
  ...typeArguments.length > 0 ? { typeArguments } : {},
21456
21458
  args,
21457
21459
  ...hasArgumentList ? { hasArgumentList: true } : {},
@@ -22865,9 +22867,14 @@ function indexFirstById(values) {
22865
22867
  }
22866
22868
  return result;
22867
22869
  }
22870
+ function isDerivedNewValueId(valueId, isStored) {
22871
+ return !isPendingId(valueId) && !isUuidV4Id(valueId) && !isStored(valueId);
22872
+ }
22868
22873
  var init_lower_support = __esm({
22869
22874
  "src/project-source/lower-support.ts"() {
22870
22875
  "use strict";
22876
+ init_value_comparison();
22877
+ init_pending_id();
22871
22878
  init_executable_parser();
22872
22879
  }
22873
22880
  });
@@ -31630,6 +31637,22 @@ function neoScriptMemberLookupType(type) {
31630
31637
  }
31631
31638
  return nullable2 && current.nullable !== true ? { ...current, nullable: true } : current;
31632
31639
  }
31640
+ function neoScriptMemberReceiverType(type, memberName, project) {
31641
+ const primary = neoScriptMemberLookupType(type);
31642
+ if (primary.kind !== "named" || primary.narrowedInterfaces === void 0)
31643
+ return primary;
31644
+ const declaration = project.typeById.get(primary.typeId);
31645
+ if (declaration?.kind === "class" && (memberName === NEOSCRIPT_CLASS_ID_MEMBER || memberName === "Clone"))
31646
+ return primary;
31647
+ if (declaration?.members.some((member) => member.name === memberName))
31648
+ return primary;
31649
+ for (const bound of Object.values(primary.narrowedInterfaces)) {
31650
+ if (project.typeById.get(bound.typeId)?.members.some((member) => member.name === memberName)) {
31651
+ return { ...bound, nullable: primary.nullable === true };
31652
+ }
31653
+ }
31654
+ return primary;
31655
+ }
31633
31656
  function isNeoScriptHandleReferenceTarget(target, isValueType) {
31634
31657
  switch (target.kind) {
31635
31658
  case "list":
@@ -31947,6 +31970,20 @@ function isNeoScriptTypeAssignable(source, target, project) {
31947
31970
  if (isUnknownType(source) || isUnknownType(target)) return false;
31948
31971
  if (isNullType(source)) return isNullableType2(target);
31949
31972
  if (isNullableType2(source) && !isNullableType2(target)) return false;
31973
+ if (target.kind === "named" && target.narrowedInterfaces !== void 0) {
31974
+ for (const bound of Object.values(target.narrowedInterfaces)) {
31975
+ if (!isNeoScriptTypeAssignable(source, bound, project)) return false;
31976
+ }
31977
+ }
31978
+ if (source.kind === "named" && source.narrowedInterfaces !== void 0) {
31979
+ const direct = target.kind === "named" ? source.narrowedInterfaces[target.typeId] : void 0;
31980
+ if (direct !== void 0 && isNeoScriptTypeAssignable(direct, target, project))
31981
+ return true;
31982
+ for (const bound of Object.values(source.narrowedInterfaces)) {
31983
+ if (bound !== direct && isNeoScriptTypeAssignable(bound, target, project))
31984
+ return true;
31985
+ }
31986
+ }
31950
31987
  if (source.kind === "primitive" && target.kind === "primitive") {
31951
31988
  if (source.name === target.name) return true;
31952
31989
  return source.name === "int" && (target.name === "float" || target.name === "decimal");
@@ -32031,9 +32068,40 @@ function isNeoScriptTypeAssignable(source, target, project) {
32031
32068
  }
32032
32069
  return false;
32033
32070
  }
32071
+ function withoutNeoScriptInterfaceProofs(type) {
32072
+ if (type.kind !== "named" || type.narrowedInterfaces === void 0)
32073
+ return type;
32074
+ const { narrowedInterfaces: _proofs, ...declared } = type;
32075
+ return declared;
32076
+ }
32034
32077
  function commonNeoScriptAssignableType(left, right, project) {
32035
32078
  if (isNeoScriptTypeAssignable(left, right, project)) return right;
32036
32079
  if (isNeoScriptTypeAssignable(right, left, project)) return left;
32080
+ if (left.kind === "named" && right.kind === "named" && (left.narrowedInterfaces !== void 0 || right.narrowedInterfaces !== void 0)) {
32081
+ const declaredLeft = withoutNeoScriptInterfaceProofs(left);
32082
+ const declaredRight = withoutNeoScriptInterfaceProofs(right);
32083
+ const common = commonNeoScriptAssignableType(
32084
+ declaredLeft,
32085
+ declaredRight,
32086
+ project
32087
+ );
32088
+ if (common?.kind !== "named") return null;
32089
+ const proofs = {};
32090
+ for (const [source, other] of [
32091
+ [left, right],
32092
+ [right, left]
32093
+ ]) {
32094
+ for (const [id2, proof] of Object.entries(
32095
+ source.narrowedInterfaces ?? {}
32096
+ )) {
32097
+ if (proofs[id2] !== void 0) continue;
32098
+ const opposite = other.narrowedInterfaces?.[id2] ?? other;
32099
+ if (isNeoScriptTypeAssignable(opposite, proof, project))
32100
+ proofs[id2] = proof;
32101
+ }
32102
+ }
32103
+ return { ...common, narrowedInterfaces: proofs };
32104
+ }
32037
32105
  return null;
32038
32106
  }
32039
32107
  function isNeoVariantTypeId(typeId, project) {
@@ -34297,17 +34365,22 @@ function mergeFactSets(sets) {
34297
34365
  )
34298
34366
  );
34299
34367
  }
34300
- function mergeNarrowingMaps(maps) {
34368
+ function mergeNarrowingMaps(maps, project) {
34301
34369
  const first = maps[0];
34302
34370
  if (!first) return /* @__PURE__ */ new Map();
34303
34371
  const result = /* @__PURE__ */ new Map();
34304
34372
  for (const [path, narrowed] of first) {
34305
- if (maps.slice(1).every((map) => {
34306
- const candidate = map.get(path);
34307
- return candidate?.rootEntry === narrowed.rootEntry && typeRefsEqual(candidate.type, narrowed.type);
34308
- })) {
34309
- result.set(path, narrowed);
34373
+ let common = narrowed.type;
34374
+ for (let index = 1; index < maps.length; index++) {
34375
+ const candidate = maps[index].get(path);
34376
+ if (candidate?.rootEntry !== narrowed.rootEntry) {
34377
+ common = null;
34378
+ break;
34379
+ }
34380
+ common = commonNeoScriptAssignableType(common, candidate.type, project);
34381
+ if (common === null) break;
34310
34382
  }
34383
+ if (common !== null) result.set(path, { ...narrowed, type: common });
34311
34384
  }
34312
34385
  return result;
34313
34386
  }
@@ -34336,6 +34409,16 @@ function typeRefsEqual(left, right) {
34336
34409
  if (left.kind === "named" && right.kind === "named") {
34337
34410
  const leftArgs = left.typeArguments ?? [];
34338
34411
  const rightArgs = right.typeArguments ?? [];
34412
+ if (left.narrowedInterfaces !== right.narrowedInterfaces) {
34413
+ const leftBounds = Object.entries(left.narrowedInterfaces ?? {});
34414
+ const rightBounds = right.narrowedInterfaces ?? {};
34415
+ if (leftBounds.length !== Object.keys(rightBounds).length) return false;
34416
+ for (const [id2, leftBound] of leftBounds) {
34417
+ const rightBound = rightBounds[id2];
34418
+ if (rightBound === void 0 || !typeRefsEqual(leftBound, rightBound))
34419
+ return false;
34420
+ }
34421
+ }
34339
34422
  return left.typeId === right.typeId && leftArgs.length === rightArgs.length && leftArgs.every((item, index) => {
34340
34423
  const other = rightArgs[index];
34341
34424
  return other !== void 0 && typeRefsEqual(item, other);
@@ -35315,6 +35398,10 @@ function typesOverlap(left, right, project) {
35315
35398
  if (isUnknown(left) || isUnknown(right)) return true;
35316
35399
  if (isNull(left)) return isNullable(right);
35317
35400
  if (isNull(right)) return isNullable(left);
35401
+ left = neoScriptMemberLookupType(left);
35402
+ right = neoScriptMemberLookupType(right);
35403
+ if (left.kind === "typeParameter" || right.kind === "typeParameter")
35404
+ return true;
35318
35405
  if (isNeoScriptTypeAssignable(left, right, project) || isNeoScriptTypeAssignable(right, left, project))
35319
35406
  return true;
35320
35407
  if (left.kind === "named" && right.kind === "named") {
@@ -36684,7 +36771,7 @@ var init_strict_resolver = __esm({
36684
36771
  statement.init.pos
36685
36772
  );
36686
36773
  }
36687
- const localType = declared ?? initial.type;
36774
+ const localType = declared ?? withoutNeoScriptInterfaceProofs(initial.type);
36688
36775
  if (declared) {
36689
36776
  this.requireAssignable(
36690
36777
  initial.type,
@@ -36699,16 +36786,18 @@ var init_strict_resolver = __esm({
36699
36786
  initial.pointer,
36700
36787
  this.project
36701
36788
  );
36702
- scope.define(
36703
- scopeVariable(
36704
- statement.name,
36705
- local,
36706
- localType,
36707
- "local" /* Local */,
36708
- localOwnership(initial),
36709
- this.localWriteTargetRoot(initial, scope)
36710
- )
36789
+ const entry = scopeVariable(
36790
+ statement.name,
36791
+ local,
36792
+ localType,
36793
+ "local" /* Local */,
36794
+ localOwnership(initial),
36795
+ this.localWriteTargetRoot(initial, scope)
36711
36796
  );
36797
+ scope.define(entry);
36798
+ if (inferred && localType !== initial.type) {
36799
+ scope.narrow(statement.name, entry, initial.type);
36800
+ }
36712
36801
  return { type: "variable" /* Variable */, variable: local };
36713
36802
  }
36714
36803
  case "if": {
@@ -36763,7 +36852,8 @@ var init_strict_resolver = __esm({
36763
36852
  mergeBranchInvalidations(scope, branchExitOwnershipScopes);
36764
36853
  if (branchExitNarrowings.length > 0) {
36765
36854
  for (const [path, narrowed] of mergeNarrowingMaps(
36766
- branchExitNarrowings
36855
+ branchExitNarrowings,
36856
+ this.project
36767
36857
  )) {
36768
36858
  const rootEntry = scope.lookup(pathRoot(path));
36769
36859
  if (rootEntry === narrowed.rootEntry) {
@@ -37689,7 +37779,7 @@ var init_strict_resolver = __esm({
37689
37779
  }
37690
37780
  mergeLoopNarrowings(parent, exitPaths) {
37691
37781
  if (exitPaths.length === 0) return;
37692
- const merged = mergeNarrowingMaps(exitPaths);
37782
+ const merged = mergeNarrowingMaps(exitPaths, this.project);
37693
37783
  for (const [path, narrowed] of parent.effectiveNarrowedPaths()) {
37694
37784
  const common = merged.get(path);
37695
37785
  if (parent.containsEntry(narrowed.rootEntry) && (common?.rootEntry !== narrowed.rootEntry || !typeRefsEqual(common.type, narrowed.type))) {
@@ -39442,8 +39532,13 @@ var init_strict_resolver = __esm({
39442
39532
  expression.receiver,
39443
39533
  scope
39444
39534
  );
39445
- if (receiverExpression.type.kind !== "named") return null;
39446
- owner = this.project.typeById.get(receiverExpression.type.typeId);
39535
+ const memberType2 = neoScriptMemberReceiverType(
39536
+ receiverExpression.type,
39537
+ expression.name,
39538
+ this.project
39539
+ );
39540
+ if (memberType2.kind !== "named") return null;
39541
+ owner = this.project.typeById.get(memberType2.typeId);
39447
39542
  symbol = owner?.members.find(
39448
39543
  (candidate) => candidate.name === expression.name && (candidate.kind === "function" || candidate.kind === "method")
39449
39544
  );
@@ -39454,7 +39549,10 @@ var init_strict_resolver = __esm({
39454
39549
  expression.pos
39455
39550
  );
39456
39551
  }
39457
- receiver = { kind: "instance", expression: receiverExpression };
39552
+ receiver = {
39553
+ kind: "instance",
39554
+ expression: { ...receiverExpression, type: memberType2 }
39555
+ };
39458
39556
  }
39459
39557
  } else {
39460
39558
  return null;
@@ -39531,9 +39629,13 @@ var init_strict_resolver = __esm({
39531
39629
  if (symbol === void 0 || symbol.static !== true) return null;
39532
39630
  } else {
39533
39631
  const receiver2 = this.resolveExpression(expression.receiver, scope);
39534
- if (receiver2.type.kind !== "named") return null;
39535
- receiverType = receiver2.type;
39536
- owner = this.project.typeById.get(receiver2.type.typeId);
39632
+ receiverType = neoScriptMemberReceiverType(
39633
+ receiver2.type,
39634
+ expression.name,
39635
+ this.project
39636
+ );
39637
+ if (receiverType.kind !== "named") return null;
39638
+ owner = this.project.typeById.get(receiverType.typeId);
39537
39639
  symbol = owner?.members.find(
39538
39640
  (candidate) => candidate.name === expression.name && (candidate.kind === "function" || candidate.kind === "method")
39539
39641
  );
@@ -39611,6 +39713,7 @@ var init_strict_resolver = __esm({
39611
39713
  pos
39612
39714
  );
39613
39715
  }
39716
+ entryType = withoutNeoScriptInterfaceProofs(entryType);
39614
39717
  for (const item of resolved) {
39615
39718
  const common = commonNeoScriptAssignableType(
39616
39719
  entryType,
@@ -39635,7 +39738,7 @@ var init_strict_resolver = __esm({
39635
39738
  }
39636
39739
  const type = {
39637
39740
  kind: "list",
39638
- elementType: entryType
39741
+ elementType: withoutNeoScriptInterfaceProofs(entryType)
39639
39742
  };
39640
39743
  const wire = toWireType(type, this.project);
39641
39744
  if (wire.type !== 6 /* List */) {
@@ -39701,6 +39804,7 @@ var init_strict_resolver = __esm({
39701
39804
  if (!keyType || !valueType) {
39702
39805
  throw new CompileError("Dictionary literal type inference failed.", pos);
39703
39806
  }
39807
+ valueType = withoutNeoScriptInterfaceProofs(valueType);
39704
39808
  for (const entry of resolved) {
39705
39809
  if (expectedDictionary) {
39706
39810
  this.requireAssignable(
@@ -39727,7 +39831,7 @@ var init_strict_resolver = __esm({
39727
39831
  const type = {
39728
39832
  kind: "dictionary",
39729
39833
  keyType,
39730
- valueType
39834
+ valueType: withoutNeoScriptInterfaceProofs(valueType)
39731
39835
  };
39732
39836
  const wire = toWireType(type, this.project);
39733
39837
  if (wire.type !== 5 /* Dictionary */) {
@@ -39983,8 +40087,19 @@ var init_strict_resolver = __esm({
39983
40087
  const target = this.resolveType(fact.targetType);
39984
40088
  const targetDefinition = target.kind === "named" ? this.project.typeById.get(target.typeId) : void 0;
39985
40089
  const naturalDefinition = natural.type.kind === "named" ? this.project.typeById.get(natural.type.typeId) : void 0;
39986
- const retainConcreteClass = !fact.bindingName && naturalDefinition?.kind === "class" && targetDefinition?.kind === "interface";
39987
- const narrowed = retainConcreteClass ? { ...natural.type, nullable: false } : { ...target, nullable: false };
40090
+ let narrowed = { ...target, nullable: false };
40091
+ if (!fact.bindingName && natural.type.kind === "named" && (naturalDefinition?.kind === "class" || naturalDefinition?.kind === "interface") && target.kind === "named" && targetDefinition?.kind === "interface") {
40092
+ narrowed = { ...natural.type, nullable: false };
40093
+ if (!isNeoScriptTypeAssignable(narrowed, target, this.project)) {
40094
+ narrowed = {
40095
+ ...narrowed,
40096
+ narrowedInterfaces: {
40097
+ ...natural.type.narrowedInterfaces,
40098
+ [target.typeId]: target
40099
+ }
40100
+ };
40101
+ }
40102
+ }
39988
40103
  if (mode === "all" && fact.path !== null && rootEntry !== null && place.type.kind !== "reference") {
39989
40104
  targetScope.narrow(fact.path, rootEntry, narrowed);
39990
40105
  }
@@ -40577,7 +40692,11 @@ var init_strict_resolver = __esm({
40577
40692
  if (receiver.dialogues !== void 0) {
40578
40693
  return this.resolveDialogueGroupRead(receiver, name, pos);
40579
40694
  }
40580
- const memberReceiverType = neoScriptMemberLookupType(receiver.type);
40695
+ const memberReceiverType = neoScriptMemberReceiverType(
40696
+ receiver.type,
40697
+ name,
40698
+ this.project
40699
+ );
40581
40700
  if (memberReceiverType.kind === "named") {
40582
40701
  const type = this.project.typeById.get(memberReceiverType.typeId);
40583
40702
  if (!type) {
@@ -41389,7 +41508,7 @@ var init_strict_resolver = __esm({
41389
41508
  }
41390
41509
  const type = {
41391
41510
  kind: "list",
41392
- elementType: entryType
41511
+ elementType: withoutNeoScriptInterfaceProofs(entryType)
41393
41512
  };
41394
41513
  const wire = toWireType(type, this.project);
41395
41514
  if (wire.type !== 6 /* List */) {
@@ -41630,7 +41749,11 @@ var init_strict_resolver = __esm({
41630
41749
  pos
41631
41750
  );
41632
41751
  }
41633
- const memberReceiverType = neoScriptMemberLookupType(receiver.type);
41752
+ const memberReceiverType = neoScriptMemberReceiverType(
41753
+ receiver.type,
41754
+ callee.name,
41755
+ this.project
41756
+ );
41634
41757
  const namedType2 = memberReceiverType.kind === "named" ? this.project.typeById.get(memberReceiverType.typeId) : void 0;
41635
41758
  const member = namedType2?.members.find(
41636
41759
  (candidate) => (candidate.kind === "function" || candidate.kind === "method") && candidate.name === callee.name
@@ -44055,7 +44178,11 @@ var init_strict_resolver = __esm({
44055
44178
  }
44056
44179
  const receiver = receiverValue();
44057
44180
  if (receiver.dialogues !== void 0) return null;
44058
- const memberReceiverType = neoScriptMemberLookupType(receiver.type);
44181
+ const memberReceiverType = neoScriptMemberReceiverType(
44182
+ receiver.type,
44183
+ memberName,
44184
+ this.project
44185
+ );
44059
44186
  if (memberReceiverType.kind !== "named") return null;
44060
44187
  const type = this.project.typeById.get(memberReceiverType.typeId);
44061
44188
  const symbol = type?.members.find(
@@ -50973,7 +51100,29 @@ function validateExpression(expression, expected, scope, environment, uri, range
50973
51100
  );
50974
51101
  return;
50975
51102
  }
50976
- if (!declaration) return;
51103
+ if (!declaration) {
51104
+ if (expression.className !== null && !environment.projectIndex.typeByName.has(expression.className) && semanticTypeRef(
51105
+ {
51106
+ name: expression.className,
51107
+ ...expression.typeArguments ? { arguments: expression.typeArguments.map(semanticAstType) } : {}
51108
+ },
51109
+ scope,
51110
+ environment
51111
+ ) === void 0) {
51112
+ pushDiagnostic(
51113
+ diagnostics,
51114
+ uri,
51115
+ anchor ? anchorSpan(
51116
+ anchor,
51117
+ expression.classNamePos ?? expression.pos,
51118
+ expression.className.length
51119
+ ) : range2,
51120
+ "unknown-construction-type",
51121
+ `Unknown class '${expression.className}'.`
51122
+ );
51123
+ }
51124
+ return;
51125
+ }
50977
51126
  if (declaration.modifiers.includes("abstract")) {
50978
51127
  pushDiagnostic(
50979
51128
  diagnostics,
@@ -55336,7 +55485,7 @@ function sourceParameter(parameter4, owner, typeIds, id2, functionTypeParameters
55336
55485
  };
55337
55486
  }
55338
55487
  function substituteInheritedSourceMember(member, baseInfo, resolvedBaseType) {
55339
- if (baseInfo.declaration.kind !== "class" || resolvedBaseType.kind !== "named") {
55488
+ if (baseInfo.declaration.kind !== "class" && baseInfo.declaration.kind !== "interface" || resolvedBaseType.kind !== "named") {
55340
55489
  return {
55341
55490
  ...member,
55342
55491
  inheritedFrom: member.inheritedFrom ?? {
@@ -96843,6 +96992,356 @@ var init_stored_value_placement_index = __esm({
96843
96992
  }
96844
96993
  });
96845
96994
 
96995
+ // ../packages/neoscript-runtime/src/values/initializer-identifiers.ts
96996
+ function initializerReferencedIdentifiers(source) {
96997
+ let expression;
96998
+ try {
96999
+ expression = parseExpression(source);
97000
+ } catch {
97001
+ return /* @__PURE__ */ new Set();
97002
+ }
97003
+ const identifiers = /* @__PURE__ */ new Set();
97004
+ const pending = [expression];
97005
+ const visited = /* @__PURE__ */ new Set();
97006
+ while (pending.length > 0) {
97007
+ const value = pending.pop();
97008
+ if (value === null || typeof value !== "object" || visited.has(value)) {
97009
+ continue;
97010
+ }
97011
+ visited.add(value);
97012
+ if (Reflect.get(value, "kind") === "ident") {
97013
+ const name = Reflect.get(value, "name");
97014
+ if (typeof name === "string") identifiers.add(name);
97015
+ }
97016
+ for (const child2 of Object.values(value)) pending.push(child2);
97017
+ }
97018
+ return identifiers;
97019
+ }
97020
+ function initializerReferencesAnyIdentifier(source, names) {
97021
+ const identifiers = initializerReferencedIdentifiers(source);
97022
+ for (const name of names) {
97023
+ if (identifiers.has(name)) return true;
97024
+ }
97025
+ return false;
97026
+ }
97027
+ var init_initializer_identifiers = __esm({
97028
+ "../packages/neoscript-runtime/src/values/initializer-identifiers.ts"() {
97029
+ "use strict";
97030
+ init_executable_parser();
97031
+ }
97032
+ });
97033
+
97034
+ // ../packages/neoscript-runtime/src/initializer-materialization.ts
97035
+ function declarationInitializerContext(document) {
97036
+ const key = initializerEvaluatorCacheKey(document);
97037
+ const revision = initializerEvaluatorCacheRevision(document);
97038
+ const cached = declarationInitializerContextByDocument.get(key);
97039
+ if (cached !== void 0 && (revision === void 0 ? cached.members === document.members && cached.values === document.values : cached.revision === revision)) {
97040
+ return cached.context;
97041
+ }
97042
+ const initializerValueIds = new Set(
97043
+ document.values.filter(isInitValueContent).map((value) => value.id)
97044
+ );
97045
+ const valuesById = new Map(
97046
+ document.values.map((value) => [value.id, value])
97047
+ );
97048
+ const rootOwners = /* @__PURE__ */ new Map();
97049
+ resolveOwnerMembersForValues(
97050
+ document,
97051
+ initializerValueIds,
97052
+ void 0,
97053
+ rootOwners
97054
+ );
97055
+ const created = { valuesById, rootOwners };
97056
+ declarationInitializerContextByDocument.set(key, {
97057
+ members: document.members,
97058
+ values: document.values,
97059
+ revision,
97060
+ context: created
97061
+ });
97062
+ return created;
97063
+ }
97064
+ function evaluateInitializerMaterialization(args) {
97065
+ const createdValues = [];
97066
+ const storageKeyDeclarations = /* @__PURE__ */ new Map();
97067
+ const evaluated = args.evaluateInitializer({
97068
+ genericEnv: args.genericEnv,
97069
+ init: args.init,
97070
+ member: args.member,
97071
+ document: args.document,
97072
+ createdValues,
97073
+ storageKeyDeclarations,
97074
+ ...args.storedConstructionReplay === true ? { storedConstructionReplay: true } : {},
97075
+ ...args.constructionBaselineReplay === true ? { constructionBaselineReplay: true } : {},
97076
+ ...args.argumentValues === void 0 ? {} : { argumentValues: args.argumentValues },
97077
+ sourceValueId: args.sourceValueId ?? null,
97078
+ readTracking: args.readTracking,
97079
+ saveStaticBindings: args.saveStaticBindings,
97080
+ sessionStaticBindings: args.sessionStaticBindings
97081
+ });
97082
+ return { evaluated, createdValues, storageKeyDeclarations };
97083
+ }
97084
+ function materializeInPlaceFields(document, root, createdValues) {
97085
+ const owners = [root, ...createdValues];
97086
+ for (const owner of owners) {
97087
+ const record7 = owner.value;
97088
+ if (typeof owner.classId !== "string") continue;
97089
+ if (typeof record7 !== "object" || record7 === null) continue;
97090
+ if (Array.isArray(record7)) continue;
97091
+ let memberIds;
97092
+ for (const [schemaKey, value] of Object.entries(record7)) {
97093
+ if (typeof value === "string" || value === null) continue;
97094
+ memberIds ??= new Map(
97095
+ resolvedClassSchema(
97096
+ owner.classId,
97097
+ document.classes,
97098
+ document.members
97099
+ ).surface.map((entry) => [entry.schemaKey, entry.memberId])
97100
+ );
97101
+ const memberId = memberIds.get(schemaKey);
97102
+ if (memberId === void 0) {
97103
+ throw new Error(
97104
+ `Class "${owner.classId}" holds "${schemaKey}" in place, which its schema doesn't declare.`
97105
+ );
97106
+ }
97107
+ const row = {
97108
+ id: virtualValueId(owner.id, memberId),
97109
+ projectId: owner.projectId,
97110
+ createdAt: owner.createdAt,
97111
+ updatedAt: owner.updatedAt,
97112
+ value
97113
+ };
97114
+ createdValues.push(row);
97115
+ record7[schemaKey] = row.id;
97116
+ }
97117
+ }
97118
+ }
97119
+ function finalizeMaterializedRoot(args) {
97120
+ materializeInPlaceFields(args.document, args.root, args.createdValues);
97121
+ const allCreated = [args.root, ...args.createdValues];
97122
+ for (const created of allCreated) {
97123
+ if (created === args.root) continue;
97124
+ if (created.classId === void 0) delete created.classId;
97125
+ }
97126
+ stampCreatedValuesMapKey(allCreated, args.mapKey);
97127
+ if (args.supersededRootId !== void 0) {
97128
+ args.storageKeyDeclarations.delete(args.supersededRootId);
97129
+ }
97130
+ args.storageKeyDeclarations.delete(args.root.id);
97131
+ applyDeclaredStorageKeyOverrides({
97132
+ createdValues: allCreated,
97133
+ declarationByValueId: args.storageKeyDeclarations,
97134
+ existingParentContextById: /* @__PURE__ */ new Map([
97135
+ [
97136
+ args.root.id,
97137
+ {
97138
+ mapKey: args.mapKey ?? null,
97139
+ classId: args.root.classId ?? void 0
97140
+ }
97141
+ ]
97142
+ ])
97143
+ });
97144
+ }
97145
+ function materializeInitializerValue(args) {
97146
+ const { evaluated, createdValues, storageKeyDeclarations } = evaluateInitializerMaterialization({
97147
+ evaluateInitializer: args.evaluateInitializer,
97148
+ init: args.row.init,
97149
+ member: args.member,
97150
+ document: args.document,
97151
+ ...args.storedConstructionReplay === true ? { storedConstructionReplay: true } : {},
97152
+ ...args.constructionBaselineReplay === true ? { constructionBaselineReplay: true } : {},
97153
+ ...args.argumentValues === void 0 ? {} : { argumentValues: args.argumentValues },
97154
+ genericEnv: envFromStamp(args.row.genericBindings),
97155
+ sourceValueId: args.row.id,
97156
+ readTracking: args.readTracking,
97157
+ saveStaticBindings: args.saveStaticBindings,
97158
+ sessionStaticBindings: args.sessionStaticBindings
97159
+ });
97160
+ const {
97161
+ init: _init,
97162
+ value: _value,
97163
+ classId: _classId,
97164
+ ...envelope
97165
+ } = args.row;
97166
+ void _init;
97167
+ void _value;
97168
+ void _classId;
97169
+ const root = {
97170
+ ...envelope,
97171
+ value: evaluated.value,
97172
+ ...evaluated.classId === null ? {} : { classId: evaluated.classId },
97173
+ ...evaluated.genericBindings === void 0 ? {} : { genericBindings: { ...evaluated.genericBindings } },
97174
+ ...deepClonePlainData(pickInstanceProvenance(evaluated))
97175
+ };
97176
+ if (evaluated.provisionalRootId !== void 0) {
97177
+ args.document.listenerDefaultCapture?.retarget(
97178
+ evaluated.provisionalRootId,
97179
+ root.id
97180
+ );
97181
+ retargetInitializerRootValueIds(
97182
+ [root, ...createdValues],
97183
+ evaluated.provisionalRootId,
97184
+ root.id
97185
+ );
97186
+ }
97187
+ finalizeMaterializedRoot({
97188
+ document: args.document,
97189
+ root,
97190
+ createdValues,
97191
+ mapKey: args.row.mapKey,
97192
+ storageKeyDeclarations
97193
+ });
97194
+ return {
97195
+ root,
97196
+ createdValues,
97197
+ pinnedRootSchemaKeys: evaluated.pinnedRootSchemaKeys ?? /* @__PURE__ */ new Set(),
97198
+ pinnedSchemaKeysByValueId: evaluated.pinnedSchemaKeysByValueId ?? /* @__PURE__ */ new Map()
97199
+ };
97200
+ }
97201
+ function materializeMemberDefaultValue(args) {
97202
+ const createdValues = [];
97203
+ const storageKeyDeclarations = /* @__PURE__ */ new Map();
97204
+ const declarationArguments = (member, init, sourceValueId) => {
97205
+ const { valuesById, rootOwners } = declarationInitializerContext(
97206
+ args.document
97207
+ );
97208
+ const ownerClass = typeof sourceValueId === "string" ? initializerOwnerContext(
97209
+ args.document,
97210
+ sourceValueId,
97211
+ rootOwners,
97212
+ valuesById,
97213
+ (id2) => args.readTracking?.valueIds.add(id2)
97214
+ ).ownerClass : typeof Reflect.get(member, "id") === "string" && !isStaticMember(member) ? findSchemaPlacement(
97215
+ String(Reflect.get(member, "id")),
97216
+ args.document.classes
97217
+ )?.ownerClass ?? null : null;
97218
+ if (ownerClass === null) return [];
97219
+ const constructorId = ownerClass.requiredConstructorId;
97220
+ if (typeof constructorId !== "string") return [];
97221
+ const constructor2 = args.document.constructors?.find(
97222
+ (candidate) => candidate.id === constructorId
97223
+ );
97224
+ if (constructor2 === void 0) return [];
97225
+ const parameterNames = new Set(
97226
+ constructor2.argumentTypes.map((argument2) => argument2.name)
97227
+ );
97228
+ return declarationInitializerArgumentValues(
97229
+ constructor2.argumentTypes,
97230
+ `Declaration template on '${ownerClass.name}'`,
97231
+ initializerReferencesAnyIdentifier(init.code, parameterNames)
97232
+ );
97233
+ };
97234
+ let lookups;
97235
+ const evaluatorLookups = () => lookups ??= args.initializerEvaluatorLookups(
97236
+ args.document,
97237
+ args.readTracking
97238
+ );
97239
+ const plans = args.readTracking !== void 0 && args.document.databaseVM === void 0 ? void 0 : args.defaultValuePlans(args.document);
97240
+ const database = args.document.databaseVM;
97241
+ const hostPlan = database?.materializationPlan;
97242
+ const built = buildDefaultMemberValue({
97243
+ document: {
97244
+ ...args.document,
97245
+ // The declaration rows a default clones are reads of this
97246
+ // materialization, like any row its initializers read.
97247
+ valueById: (id2) => {
97248
+ args.readTracking?.valueIds.add(id2);
97249
+ const database2 = evaluatorLookups();
97250
+ return database2.defaultValueById !== void 0 ? database2.defaultValueById(id2) : database2.valueById(id2);
97251
+ },
97252
+ unorderedListEntryIds: (containerId) => {
97253
+ args.readTracking?.containerIds.add(containerId);
97254
+ const entryIds = evaluatorLookups().unorderedListEntryIds?.(containerId);
97255
+ if (entryIds === void 0) {
97256
+ throw new Error(
97257
+ `Initializer lookups resolve no unordered-list membership for container "${containerId}".`
97258
+ );
97259
+ }
97260
+ return entryIds;
97261
+ },
97262
+ // Not `resolvedMember`: its id-keyed cache would answer for the
97263
+ // caller's rewritten copy of a member with the stored original.
97264
+ ...plans === void 0 ? {} : {
97265
+ instanceEnv: plans.instanceEnv,
97266
+ storedInstanceMaterializationPlan: hostPlan === void 0 ? plans.storedInstanceMaterializationPlan : (classId, instanceEnv) => hostPlan.call(database, classId, instanceEnv)
97267
+ },
97268
+ recordPlanReads: (reads) => {
97269
+ for (const id2 of reads.valueIds) args.readTracking?.valueIds.add(id2);
97270
+ for (const id2 of reads.containerIds)
97271
+ args.readTracking?.containerIds.add(id2);
97272
+ }
97273
+ },
97274
+ projectId: args.envelope.projectId,
97275
+ member: args.member,
97276
+ createdValues,
97277
+ storageKeyDeclarations,
97278
+ declarationRoot: args.declarationRoot,
97279
+ ...args.genericEnv === void 0 ? {} : { genericEnv: args.genericEnv },
97280
+ // A declaration default may itself be init-backed one level down (P43 §2),
97281
+ // and those nested initializers must evaluate against the same document.
97282
+ initEvaluator: (member, init, sourceValueId, genericEnv) => args.evaluateInitializer({
97283
+ genericEnv,
97284
+ storageKeyDeclarations,
97285
+ init,
97286
+ member,
97287
+ document: args.document,
97288
+ createdValues,
97289
+ storedConstructionReplay: true,
97290
+ argumentValues: declarationArguments(
97291
+ member,
97292
+ init,
97293
+ sourceValueId ?? null
97294
+ ),
97295
+ sourceValueId: sourceValueId ?? null,
97296
+ readTracking: args.readTracking,
97297
+ saveStaticBindings: args.saveStaticBindings,
97298
+ sessionStaticBindings: args.sessionStaticBindings
97299
+ })
97300
+ });
97301
+ const interior = createdValues.filter((created) => created.id !== built.id);
97302
+ const root = {
97303
+ ...args.envelope,
97304
+ value: built.value,
97305
+ ...built.changeListeners === void 0 ? {} : { changeListeners: built.changeListeners },
97306
+ ...built.changeListenerEndpoints === void 0 ? {} : { changeListenerEndpoints: built.changeListenerEndpoints },
97307
+ ...built.classId === void 0 ? {} : { classId: built.classId },
97308
+ ...built.genericBindings == null ? {} : { genericBindings: { ...built.genericBindings } }
97309
+ };
97310
+ args.document.listenerDefaultCapture?.retarget(built.id, root.id);
97311
+ retargetInitializerRootValueIds([root, ...interior], built.id, root.id);
97312
+ finalizeMaterializedRoot({
97313
+ document: args.document,
97314
+ root,
97315
+ createdValues: interior,
97316
+ mapKey: args.envelope.mapKey,
97317
+ storageKeyDeclarations,
97318
+ supersededRootId: built.id
97319
+ });
97320
+ return {
97321
+ root,
97322
+ createdValues: interior,
97323
+ pinnedRootSchemaKeys: /* @__PURE__ */ new Set(),
97324
+ pinnedSchemaKeysByValueId: /* @__PURE__ */ new Map()
97325
+ };
97326
+ }
97327
+ var declarationInitializerContextByDocument;
97328
+ var init_initializer_materialization = __esm({
97329
+ "../packages/neoscript-runtime/src/initializer-materialization.ts"() {
97330
+ "use strict";
97331
+ init_deep_clone_plain_data();
97332
+ init_members();
97333
+ init_inheritance();
97334
+ init_member_value_id();
97335
+ init_instance_provenance();
97336
+ init_generics();
97337
+ init_evaluateNSGetter();
97338
+ init_initializer_context();
97339
+ init_value_row_owner_members();
97340
+ init_initializer_identifiers();
97341
+ declarationInitializerContextByDocument = /* @__PURE__ */ new WeakMap();
97342
+ }
97343
+ });
97344
+
96846
97345
  // ../packages/neoscript-runtime/src/declaration-default-source.ts
96847
97346
  function declarationDefaultSource(id2, stored, resolveGraph) {
96848
97347
  if (stored !== null && !isCollapseStampedInstanceRoot(stored)) return stored;
@@ -96857,6 +97356,37 @@ var init_declaration_default_source = __esm({
96857
97356
  }
96858
97357
  });
96859
97358
 
97359
+ // ../packages/neoscript-runtime/src/virtual-value-identity.ts
97360
+ function claimVirtualIdentity(args) {
97361
+ if (args.fixedVirtualId !== void 0) {
97362
+ args.claimedVirtualIds.set(args.fixedVirtualId, args.pathKey);
97363
+ return {
97364
+ sourceIdentity: args.rawSourceIdentity,
97365
+ virtualId: args.fixedVirtualId
97366
+ };
97367
+ }
97368
+ const valueId = (sourceIdentity4) => derivedVirtualValueId(args.instanceRootId, sourceIdentity4);
97369
+ const derivedId = valueId(args.rawSourceIdentity);
97370
+ const claimedPath = args.claimedVirtualIds.get(derivedId);
97371
+ if (claimedPath === void 0 || claimedPath === args.pathKey) {
97372
+ args.claimedVirtualIds.set(derivedId, args.pathKey);
97373
+ return { sourceIdentity: args.rawSourceIdentity, virtualId: derivedId };
97374
+ }
97375
+ const sourceIdentity3 = `${args.rawSourceIdentity}:${args.pathKey}`;
97376
+ const virtualId = valueId(sourceIdentity3);
97377
+ args.claimedVirtualIds.set(virtualId, args.pathKey);
97378
+ return { sourceIdentity: sourceIdentity3, virtualId };
97379
+ }
97380
+ function derivedVirtualValueId(instanceRootId, sourceIdentity3) {
97381
+ return instanceRootId.startsWith("__pending__:") || hasPendingVirtualSourceIdentity(sourceIdentity3) ? pendingVirtualValueId(instanceRootId, sourceIdentity3) : virtualValueId(instanceRootId, sourceIdentity3);
97382
+ }
97383
+ var init_virtual_value_identity = __esm({
97384
+ "../packages/neoscript-runtime/src/virtual-value-identity.ts"() {
97385
+ "use strict";
97386
+ init_member_value_id();
97387
+ }
97388
+ });
97389
+
96860
97390
  // ../packages/neoscript-runtime/src/listener-endpoint-projection.ts
96861
97391
  function projectListenerEndpoint(args) {
96862
97392
  const { descriptor } = args;
@@ -96886,7 +97416,7 @@ function projectListenerEndpoint(args) {
96886
97416
  var init_listener_endpoint_projection = __esm({
96887
97417
  "../packages/neoscript-runtime/src/listener-endpoint-projection.ts"() {
96888
97418
  "use strict";
96889
- init_virtual_instance_graph();
97419
+ init_virtual_value_identity();
96890
97420
  }
96891
97421
  });
96892
97422
 
@@ -97041,29 +97571,6 @@ function projectNestedListenerEndpoint(id2, descriptor, sourceRoot, targetRoot)
97041
97571
  return derive(targetRoot, positional);
97042
97572
  return void 0;
97043
97573
  }
97044
- function claimVirtualIdentity(args) {
97045
- if (args.fixedVirtualId !== void 0) {
97046
- args.claimedVirtualIds.set(args.fixedVirtualId, args.pathKey);
97047
- return {
97048
- sourceIdentity: args.rawSourceIdentity,
97049
- virtualId: args.fixedVirtualId
97050
- };
97051
- }
97052
- const valueId = (sourceIdentity4) => derivedVirtualValueId(args.instanceRootId, sourceIdentity4);
97053
- const derivedId = valueId(args.rawSourceIdentity);
97054
- const claimedPath = args.claimedVirtualIds.get(derivedId);
97055
- if (claimedPath === void 0 || claimedPath === args.pathKey) {
97056
- args.claimedVirtualIds.set(derivedId, args.pathKey);
97057
- return { sourceIdentity: args.rawSourceIdentity, virtualId: derivedId };
97058
- }
97059
- const sourceIdentity3 = `${args.rawSourceIdentity}:${args.pathKey}`;
97060
- const virtualId = valueId(sourceIdentity3);
97061
- args.claimedVirtualIds.set(virtualId, args.pathKey);
97062
- return { sourceIdentity: sourceIdentity3, virtualId };
97063
- }
97064
- function derivedVirtualValueId(instanceRootId, sourceIdentity3) {
97065
- return instanceRootId.startsWith("__pending__:") || hasPendingVirtualSourceIdentity(sourceIdentity3) ? pendingVirtualValueId(instanceRootId, sourceIdentity3) : virtualValueId(instanceRootId, sourceIdentity3);
97066
- }
97067
97574
  function materializationReadTracking(recorder) {
97068
97575
  if (recorder === void 0)
97069
97576
  return { readTracking: void 0, trackMaterialization: (m) => m() };
@@ -97207,7 +97714,7 @@ function expandStoredInstance(args) {
97207
97714
  code: `virtual-replay:${args.instanceRoot.id}`
97208
97715
  });
97209
97716
  return trackMaterialization(
97210
- () => materializeInitializerValue({
97717
+ () => args.materializeInitializerValue({
97211
97718
  evaluateInitializer: args.evaluateInitializer,
97212
97719
  document: args.document,
97213
97720
  member: replayMember,
@@ -97223,7 +97730,7 @@ function expandStoredInstance(args) {
97223
97730
  const replayDeclaredDefault = () => {
97224
97731
  const stampEnv = instanceRoot.genericBindings == null || Object.keys(instanceRoot.genericBindings).length === 0 ? null : envFromStamp(instanceRoot.genericBindings);
97225
97732
  const built = trackMaterialization(
97226
- () => materializeMemberDefaultValue({
97733
+ () => args.materializeMemberDefaultValue({
97227
97734
  evaluateInitializer: args.evaluateInitializer,
97228
97735
  document: args.document,
97229
97736
  member: replayMember,
@@ -98216,6 +98723,8 @@ function resolveStoredInstanceGraphs(args) {
98216
98723
  if (isMaterializedSpine(resolvedLocations.get(next.root.id))) continue;
98217
98724
  const graph = isClassSlotMember(next.member) ? args.resolveClassGraph?.(next.root, next.member) ?? resolveStoredClassValue({
98218
98725
  evaluateInitializer: args.evaluateInitializer,
98726
+ materializeInitializerValue: args.materializeInitializerValue,
98727
+ materializeMemberDefaultValue: args.materializeMemberDefaultValue,
98219
98728
  document,
98220
98729
  instanceRoot: next.root,
98221
98730
  rootMember: next.member,
@@ -98312,7 +98821,7 @@ function expandStoredClassValue(args) {
98312
98821
  args.readRecorder
98313
98822
  );
98314
98823
  const materialized = trackMaterialization(
98315
- () => materializeMemberDefaultValue({
98824
+ () => args.materializeMemberDefaultValue({
98316
98825
  ...readTracking === void 0 ? {} : { readTracking },
98317
98826
  saveStaticBindings: args.saveStaticBindings,
98318
98827
  sessionStaticBindings: args.sessionStaticBindings,
@@ -100049,6 +100558,8 @@ function resolveVariantInstanceGraphForDocument(args) {
100049
100558
  materializedById.set(args.priorInstanceRoot.id, args.priorInstanceRoot);
100050
100559
  const priorExpanded = expandStoredInstance({
100051
100560
  evaluateInitializer: args.evaluateInitializer,
100561
+ materializeInitializerValue: args.materializeInitializerValue,
100562
+ materializeMemberDefaultValue: args.materializeMemberDefaultValue,
100052
100563
  document,
100053
100564
  instanceRoot: args.priorInstanceRoot,
100054
100565
  rootMember,
@@ -100122,6 +100633,8 @@ function resolveVariantInstanceGraphForDocument(args) {
100122
100633
  materializedById.set(nextInstanceRoot.id, nextInstanceRoot);
100123
100634
  const nextExpanded = expandStoredInstance({
100124
100635
  evaluateInitializer: args.evaluateInitializer,
100636
+ materializeInitializerValue: args.materializeInitializerValue,
100637
+ materializeMemberDefaultValue: args.materializeMemberDefaultValue,
100125
100638
  document,
100126
100639
  instanceRoot: nextInstanceRoot,
100127
100640
  rootMember,
@@ -101248,6 +101761,8 @@ function createHeadlessVirtualInstanceResolver(args) {
101248
101761
  const replayDocument = evidence === null ? resolverDocumentOnce() : frameDocument(evidence);
101249
101762
  const resolution2 = prepareStoredClassValueResolution({
101250
101763
  evaluateInitializer: args.evaluateInitializer,
101764
+ materializeInitializerValue: args.materializeInitializerValue,
101765
+ materializeMemberDefaultValue: args.materializeMemberDefaultValue,
101251
101766
  document: replayDocument,
101252
101767
  instanceRoot,
101253
101768
  rootMember: member,
@@ -101542,7 +102057,8 @@ var init_virtual_instance_graph = __esm({
101542
102057
  init_immutable_json();
101543
102058
  init_members();
101544
102059
  init_instance_provenance();
101545
- init_member_value_id();
102060
+ init_virtual_value_identity();
102061
+ init_virtual_value_identity();
101546
102062
  init_stored_value_placement_index();
101547
102063
  init_unordered_list_membership();
101548
102064
  init_neoscript_types();
@@ -101550,7 +102066,6 @@ var init_virtual_instance_graph = __esm({
101550
102066
  init_project_schema_index();
101551
102067
  init_initializer_context();
101552
102068
  init_strict_ir();
101553
- init_initializer_materialization();
101554
102069
  init_unattributable_reads();
101555
102070
  init_member_body_reads();
101556
102071
  KEPT_ROW_SAMPLE_LIMIT = 12;
@@ -101784,6 +102299,8 @@ function initializerEvaluatorLookups(document, readTracking) {
101784
102299
  const shareFrom = document.evaluatorOverlay === void 0 ? void 0 : sharedHeadlessResolver(document.evaluatorOverlay);
101785
102300
  const headlessVirtualResolver = createHeadlessVirtualInstanceResolver({
101786
102301
  evaluateInitializer: evaluateMemberInitializer,
102302
+ materializeInitializerValue,
102303
+ materializeMemberDefaultValue: materializeMemberDefaultValue2,
101787
102304
  documentMaterializationPlan,
101788
102305
  document,
101789
102306
  resolverLookups: () => lookups,
@@ -101812,6 +102329,8 @@ function initializerEvaluatorLookups(document, readTracking) {
101812
102329
  // nested resolver.
101813
102330
  resolveVariantInstanceGraph: (args) => resolveVariantInstanceGraphForDocument({
101814
102331
  evaluateInitializer: evaluateMemberInitializer,
102332
+ materializeInitializerValue,
102333
+ materializeMemberDefaultValue: materializeMemberDefaultValue2,
101815
102334
  document,
101816
102335
  resolverLookups: lookups,
101817
102336
  readRecorder: headlessVirtualResolver.readRecorder,
@@ -102000,6 +102519,8 @@ function createInitializerMaterializationBatch(authoredDocument, pendingInitiali
102000
102519
  let resolver;
102001
102520
  const virtual = () => resolver ??= createHeadlessVirtualInstanceResolver({
102002
102521
  evaluateInitializer: evaluateMemberInitializer,
102522
+ materializeInitializerValue,
102523
+ materializeMemberDefaultValue: materializeMemberDefaultValue2,
102003
102524
  documentMaterializationPlan,
102004
102525
  document,
102005
102526
  membersById: indexed.membersById,
@@ -102082,6 +102603,8 @@ function createInitializerMaterializationBatch(authoredDocument, pendingInitiali
102082
102603
  virtualInstanceRootIdForValue: (id2) => owningInstanceRootId(virtual().virtualInstanceGraphForValue(id2)),
102083
102604
  resolveVariantInstanceGraph: (args) => resolveVariantInstanceGraphForDocument({
102084
102605
  evaluateInitializer: evaluateMemberInitializer,
102606
+ materializeInitializerValue,
102607
+ materializeMemberDefaultValue: materializeMemberDefaultValue2,
102085
102608
  document,
102086
102609
  resolverLookups: lookups,
102087
102610
  ...args
@@ -102315,10 +102838,18 @@ function storedConstructionReplaySlot(member, sourceRow, document) {
102315
102838
  }
102316
102839
  };
102317
102840
  }
102841
+ function materializeMemberDefaultValue2(args) {
102842
+ return materializeMemberDefaultValue({
102843
+ ...args,
102844
+ initializerEvaluatorLookups,
102845
+ defaultValuePlans
102846
+ });
102847
+ }
102318
102848
  var evaluatorLookupsByDocument, headlessResolversByLookupKey, indexedEvaluatorLookupsByDocument, defaultValuePlansByDocument;
102319
102849
  var init_evaluateInitializer = __esm({
102320
102850
  "../packages/neoscript-runtime/src/neoscript/evaluateInitializer.ts"() {
102321
102851
  "use strict";
102852
+ init_initializer_materialization();
102322
102853
  init_NSGetterRuntimeError();
102323
102854
  init_declaration_default_source();
102324
102855
  init_member_change_listeners();
@@ -102339,354 +102870,6 @@ var init_evaluateInitializer = __esm({
102339
102870
  }
102340
102871
  });
102341
102872
 
102342
- // ../packages/neoscript-runtime/src/values/initializer-identifiers.ts
102343
- function initializerReferencedIdentifiers(source) {
102344
- let expression;
102345
- try {
102346
- expression = parseExpression(source);
102347
- } catch {
102348
- return /* @__PURE__ */ new Set();
102349
- }
102350
- const identifiers = /* @__PURE__ */ new Set();
102351
- const pending = [expression];
102352
- const visited = /* @__PURE__ */ new Set();
102353
- while (pending.length > 0) {
102354
- const value = pending.pop();
102355
- if (value === null || typeof value !== "object" || visited.has(value)) {
102356
- continue;
102357
- }
102358
- visited.add(value);
102359
- if (Reflect.get(value, "kind") === "ident") {
102360
- const name = Reflect.get(value, "name");
102361
- if (typeof name === "string") identifiers.add(name);
102362
- }
102363
- for (const child2 of Object.values(value)) pending.push(child2);
102364
- }
102365
- return identifiers;
102366
- }
102367
- function initializerReferencesAnyIdentifier(source, names) {
102368
- const identifiers = initializerReferencedIdentifiers(source);
102369
- for (const name of names) {
102370
- if (identifiers.has(name)) return true;
102371
- }
102372
- return false;
102373
- }
102374
- var init_initializer_identifiers = __esm({
102375
- "../packages/neoscript-runtime/src/values/initializer-identifiers.ts"() {
102376
- "use strict";
102377
- init_executable_parser();
102378
- }
102379
- });
102380
-
102381
- // ../packages/neoscript-runtime/src/initializer-materialization.ts
102382
- function declarationInitializerContext(document) {
102383
- const key = initializerEvaluatorCacheKey(document);
102384
- const revision = initializerEvaluatorCacheRevision(document);
102385
- const cached = declarationInitializerContextByDocument.get(key);
102386
- if (cached !== void 0 && (revision === void 0 ? cached.members === document.members && cached.values === document.values : cached.revision === revision)) {
102387
- return cached.context;
102388
- }
102389
- const initializerValueIds = new Set(
102390
- document.values.filter(isInitValueContent).map((value) => value.id)
102391
- );
102392
- const valuesById = new Map(
102393
- document.values.map((value) => [value.id, value])
102394
- );
102395
- const rootOwners = /* @__PURE__ */ new Map();
102396
- resolveOwnerMembersForValues(
102397
- document,
102398
- initializerValueIds,
102399
- void 0,
102400
- rootOwners
102401
- );
102402
- const created = { valuesById, rootOwners };
102403
- declarationInitializerContextByDocument.set(key, {
102404
- members: document.members,
102405
- values: document.values,
102406
- revision,
102407
- context: created
102408
- });
102409
- return created;
102410
- }
102411
- function evaluateInitializerMaterialization(args) {
102412
- const createdValues = [];
102413
- const storageKeyDeclarations = /* @__PURE__ */ new Map();
102414
- const evaluated = args.evaluateInitializer({
102415
- genericEnv: args.genericEnv,
102416
- init: args.init,
102417
- member: args.member,
102418
- document: args.document,
102419
- createdValues,
102420
- storageKeyDeclarations,
102421
- ...args.storedConstructionReplay === true ? { storedConstructionReplay: true } : {},
102422
- ...args.constructionBaselineReplay === true ? { constructionBaselineReplay: true } : {},
102423
- ...args.argumentValues === void 0 ? {} : { argumentValues: args.argumentValues },
102424
- sourceValueId: args.sourceValueId ?? null,
102425
- readTracking: args.readTracking,
102426
- saveStaticBindings: args.saveStaticBindings,
102427
- sessionStaticBindings: args.sessionStaticBindings
102428
- });
102429
- return { evaluated, createdValues, storageKeyDeclarations };
102430
- }
102431
- function materializeInPlaceFields(document, root, createdValues) {
102432
- const owners = [root, ...createdValues];
102433
- for (const owner of owners) {
102434
- const record7 = owner.value;
102435
- if (typeof owner.classId !== "string") continue;
102436
- if (typeof record7 !== "object" || record7 === null) continue;
102437
- if (Array.isArray(record7)) continue;
102438
- let memberIds;
102439
- for (const [schemaKey, value] of Object.entries(record7)) {
102440
- if (typeof value === "string" || value === null) continue;
102441
- memberIds ??= new Map(
102442
- resolvedClassSchema(
102443
- owner.classId,
102444
- document.classes,
102445
- document.members
102446
- ).surface.map((entry) => [entry.schemaKey, entry.memberId])
102447
- );
102448
- const memberId = memberIds.get(schemaKey);
102449
- if (memberId === void 0) {
102450
- throw new Error(
102451
- `Class "${owner.classId}" holds "${schemaKey}" in place, which its schema doesn't declare.`
102452
- );
102453
- }
102454
- const row = {
102455
- id: virtualValueId(owner.id, memberId),
102456
- projectId: owner.projectId,
102457
- createdAt: owner.createdAt,
102458
- updatedAt: owner.updatedAt,
102459
- value
102460
- };
102461
- createdValues.push(row);
102462
- record7[schemaKey] = row.id;
102463
- }
102464
- }
102465
- }
102466
- function finalizeMaterializedRoot(args) {
102467
- materializeInPlaceFields(args.document, args.root, args.createdValues);
102468
- const allCreated = [args.root, ...args.createdValues];
102469
- for (const created of allCreated) {
102470
- if (created === args.root) continue;
102471
- if (created.classId === void 0) delete created.classId;
102472
- }
102473
- stampCreatedValuesMapKey(allCreated, args.mapKey);
102474
- if (args.supersededRootId !== void 0) {
102475
- args.storageKeyDeclarations.delete(args.supersededRootId);
102476
- }
102477
- args.storageKeyDeclarations.delete(args.root.id);
102478
- applyDeclaredStorageKeyOverrides({
102479
- createdValues: allCreated,
102480
- declarationByValueId: args.storageKeyDeclarations,
102481
- existingParentContextById: /* @__PURE__ */ new Map([
102482
- [
102483
- args.root.id,
102484
- {
102485
- mapKey: args.mapKey ?? null,
102486
- classId: args.root.classId ?? void 0
102487
- }
102488
- ]
102489
- ])
102490
- });
102491
- }
102492
- function materializeInitializerValue(args) {
102493
- const { evaluated, createdValues, storageKeyDeclarations } = evaluateInitializerMaterialization({
102494
- evaluateInitializer: args.evaluateInitializer,
102495
- init: args.row.init,
102496
- member: args.member,
102497
- document: args.document,
102498
- ...args.storedConstructionReplay === true ? { storedConstructionReplay: true } : {},
102499
- ...args.constructionBaselineReplay === true ? { constructionBaselineReplay: true } : {},
102500
- ...args.argumentValues === void 0 ? {} : { argumentValues: args.argumentValues },
102501
- genericEnv: envFromStamp(args.row.genericBindings),
102502
- sourceValueId: args.row.id,
102503
- readTracking: args.readTracking,
102504
- saveStaticBindings: args.saveStaticBindings,
102505
- sessionStaticBindings: args.sessionStaticBindings
102506
- });
102507
- const {
102508
- init: _init,
102509
- value: _value,
102510
- classId: _classId,
102511
- ...envelope
102512
- } = args.row;
102513
- void _init;
102514
- void _value;
102515
- void _classId;
102516
- const root = {
102517
- ...envelope,
102518
- value: evaluated.value,
102519
- ...evaluated.classId === null ? {} : { classId: evaluated.classId },
102520
- ...evaluated.genericBindings === void 0 ? {} : { genericBindings: { ...evaluated.genericBindings } },
102521
- ...deepClonePlainData(pickInstanceProvenance(evaluated))
102522
- };
102523
- if (evaluated.provisionalRootId !== void 0) {
102524
- args.document.listenerDefaultCapture?.retarget(
102525
- evaluated.provisionalRootId,
102526
- root.id
102527
- );
102528
- retargetInitializerRootValueIds(
102529
- [root, ...createdValues],
102530
- evaluated.provisionalRootId,
102531
- root.id
102532
- );
102533
- }
102534
- finalizeMaterializedRoot({
102535
- document: args.document,
102536
- root,
102537
- createdValues,
102538
- mapKey: args.row.mapKey,
102539
- storageKeyDeclarations
102540
- });
102541
- return {
102542
- root,
102543
- createdValues,
102544
- pinnedRootSchemaKeys: evaluated.pinnedRootSchemaKeys ?? /* @__PURE__ */ new Set(),
102545
- pinnedSchemaKeysByValueId: evaluated.pinnedSchemaKeysByValueId ?? /* @__PURE__ */ new Map()
102546
- };
102547
- }
102548
- function materializeMemberDefaultValue(args) {
102549
- const createdValues = [];
102550
- const storageKeyDeclarations = /* @__PURE__ */ new Map();
102551
- const declarationArguments = (member, init, sourceValueId) => {
102552
- const { valuesById, rootOwners } = declarationInitializerContext(
102553
- args.document
102554
- );
102555
- const ownerClass = typeof sourceValueId === "string" ? initializerOwnerContext(
102556
- args.document,
102557
- sourceValueId,
102558
- rootOwners,
102559
- valuesById,
102560
- (id2) => args.readTracking?.valueIds.add(id2)
102561
- ).ownerClass : typeof Reflect.get(member, "id") === "string" && !isStaticMember(member) ? findSchemaPlacement(
102562
- String(Reflect.get(member, "id")),
102563
- args.document.classes
102564
- )?.ownerClass ?? null : null;
102565
- if (ownerClass === null) return [];
102566
- const constructorId = ownerClass.requiredConstructorId;
102567
- if (typeof constructorId !== "string") return [];
102568
- const constructor2 = args.document.constructors?.find(
102569
- (candidate) => candidate.id === constructorId
102570
- );
102571
- if (constructor2 === void 0) return [];
102572
- const parameterNames = new Set(
102573
- constructor2.argumentTypes.map((argument2) => argument2.name)
102574
- );
102575
- return declarationInitializerArgumentValues(
102576
- constructor2.argumentTypes,
102577
- `Declaration template on '${ownerClass.name}'`,
102578
- initializerReferencesAnyIdentifier(init.code, parameterNames)
102579
- );
102580
- };
102581
- let lookups;
102582
- const evaluatorLookups = () => lookups ??= initializerEvaluatorLookups(args.document, args.readTracking);
102583
- const plans = args.readTracking !== void 0 && args.document.databaseVM === void 0 ? void 0 : defaultValuePlans(args.document);
102584
- const database = args.document.databaseVM;
102585
- const hostPlan = database?.materializationPlan;
102586
- const built = buildDefaultMemberValue({
102587
- document: {
102588
- ...args.document,
102589
- // The declaration rows a default clones are reads of this
102590
- // materialization, like any row its initializers read.
102591
- valueById: (id2) => {
102592
- args.readTracking?.valueIds.add(id2);
102593
- const database2 = evaluatorLookups();
102594
- return database2.defaultValueById !== void 0 ? database2.defaultValueById(id2) : database2.valueById(id2);
102595
- },
102596
- unorderedListEntryIds: (containerId) => {
102597
- args.readTracking?.containerIds.add(containerId);
102598
- const entryIds = evaluatorLookups().unorderedListEntryIds?.(containerId);
102599
- if (entryIds === void 0) {
102600
- throw new Error(
102601
- `Initializer lookups resolve no unordered-list membership for container "${containerId}".`
102602
- );
102603
- }
102604
- return entryIds;
102605
- },
102606
- // Not `resolvedMember`: its id-keyed cache would answer for the
102607
- // caller's rewritten copy of a member with the stored original.
102608
- ...plans === void 0 ? {} : {
102609
- instanceEnv: plans.instanceEnv,
102610
- storedInstanceMaterializationPlan: hostPlan === void 0 ? plans.storedInstanceMaterializationPlan : (classId, instanceEnv) => hostPlan.call(database, classId, instanceEnv)
102611
- },
102612
- recordPlanReads: (reads) => {
102613
- for (const id2 of reads.valueIds) args.readTracking?.valueIds.add(id2);
102614
- for (const id2 of reads.containerIds)
102615
- args.readTracking?.containerIds.add(id2);
102616
- }
102617
- },
102618
- projectId: args.envelope.projectId,
102619
- member: args.member,
102620
- createdValues,
102621
- storageKeyDeclarations,
102622
- declarationRoot: args.declarationRoot,
102623
- ...args.genericEnv === void 0 ? {} : { genericEnv: args.genericEnv },
102624
- // A declaration default may itself be init-backed one level down (P43 §2),
102625
- // and those nested initializers must evaluate against the same document.
102626
- initEvaluator: (member, init, sourceValueId, genericEnv) => args.evaluateInitializer({
102627
- genericEnv,
102628
- storageKeyDeclarations,
102629
- init,
102630
- member,
102631
- document: args.document,
102632
- createdValues,
102633
- storedConstructionReplay: true,
102634
- argumentValues: declarationArguments(
102635
- member,
102636
- init,
102637
- sourceValueId ?? null
102638
- ),
102639
- sourceValueId: sourceValueId ?? null,
102640
- readTracking: args.readTracking,
102641
- saveStaticBindings: args.saveStaticBindings,
102642
- sessionStaticBindings: args.sessionStaticBindings
102643
- })
102644
- });
102645
- const interior = createdValues.filter((created) => created.id !== built.id);
102646
- const root = {
102647
- ...args.envelope,
102648
- value: built.value,
102649
- ...built.changeListeners === void 0 ? {} : { changeListeners: built.changeListeners },
102650
- ...built.changeListenerEndpoints === void 0 ? {} : { changeListenerEndpoints: built.changeListenerEndpoints },
102651
- ...built.classId === void 0 ? {} : { classId: built.classId },
102652
- ...built.genericBindings == null ? {} : { genericBindings: { ...built.genericBindings } }
102653
- };
102654
- args.document.listenerDefaultCapture?.retarget(built.id, root.id);
102655
- retargetInitializerRootValueIds([root, ...interior], built.id, root.id);
102656
- finalizeMaterializedRoot({
102657
- document: args.document,
102658
- root,
102659
- createdValues: interior,
102660
- mapKey: args.envelope.mapKey,
102661
- storageKeyDeclarations,
102662
- supersededRootId: built.id
102663
- });
102664
- return {
102665
- root,
102666
- createdValues: interior,
102667
- pinnedRootSchemaKeys: /* @__PURE__ */ new Set(),
102668
- pinnedSchemaKeysByValueId: /* @__PURE__ */ new Map()
102669
- };
102670
- }
102671
- var declarationInitializerContextByDocument;
102672
- var init_initializer_materialization = __esm({
102673
- "../packages/neoscript-runtime/src/initializer-materialization.ts"() {
102674
- "use strict";
102675
- init_deep_clone_plain_data();
102676
- init_members();
102677
- init_inheritance();
102678
- init_member_value_id();
102679
- init_instance_provenance();
102680
- init_generics();
102681
- init_evaluateInitializer();
102682
- init_evaluateNSGetter();
102683
- init_initializer_context();
102684
- init_value_row_owner_members();
102685
- init_initializer_identifiers();
102686
- declarationInitializerContextByDocument = /* @__PURE__ */ new WeakMap();
102687
- }
102688
- });
102689
-
102690
102873
  // ../packages/neoscript-runtime/src/effective-value-reader.ts
102691
102874
  function rootReadScope(document) {
102692
102875
  const cached = rootReadScopes.get(document);
@@ -103329,7 +103512,7 @@ var init_effective_value_reader = __esm({
103329
103512
  });
103330
103513
  if (slot.kind !== "declaration") continue;
103331
103514
  if (record7 === row.value) record7 = { ...record7 };
103332
- const materialized = materializeMemberDefaultValue({
103515
+ const materialized = materializeMemberDefaultValue2({
103333
103516
  ...this.context,
103334
103517
  evaluateInitializer: evaluateMemberInitializer,
103335
103518
  document: this.declarationDocument,
@@ -103406,6 +103589,8 @@ var init_effective_value_reader = __esm({
103406
103589
  instanceRoot: root,
103407
103590
  rootMember: placement,
103408
103591
  evaluateInitializer: evaluateMemberInitializer,
103592
+ materializeInitializerValue,
103593
+ materializeMemberDefaultValue: materializeMemberDefaultValue2,
103409
103594
  materializedIndex: this.materializedIndex,
103410
103595
  resolveClassGraph: this.context.readTracking === void 0 && this.context.saveStaticBindings === void 0 && this.context.sessionStaticBindings === void 0 ? (root2, member) => initializerStoredClassGraph(this.readDocument, root2.id, member) : void 0,
103411
103596
  onResolvedListenerDefaults: (ownerId, entry) => {
@@ -103450,7 +103635,7 @@ var init_effective_value_reader = __esm({
103450
103635
  const cached = this.defaultRows.get(memberKey)?.get(envKey);
103451
103636
  if (cached !== void 0) return cached;
103452
103637
  let evaluatedInitializer = false;
103453
- const result = materializeMemberDefaultValue({
103638
+ const result = materializeMemberDefaultValue2({
103454
103639
  ...this.context,
103455
103640
  evaluateInitializer: (args) => {
103456
103641
  evaluatedInitializer = true;
@@ -103714,31 +103899,40 @@ var init_neoscript2 = __esm({
103714
103899
  function expandStoredInstance2(args) {
103715
103900
  return expandStoredInstance({
103716
103901
  ...args,
103717
- evaluateInitializer: evaluateMemberInitializer
103902
+ evaluateInitializer: evaluateMemberInitializer,
103903
+ materializeInitializerValue,
103904
+ materializeMemberDefaultValue: materializeMemberDefaultValue2
103718
103905
  });
103719
103906
  }
103720
103907
  function resolveVariantInstanceGraphForDocument2(args) {
103721
103908
  return resolveVariantInstanceGraphForDocument({
103722
103909
  ...args,
103723
- evaluateInitializer: evaluateMemberInitializer
103910
+ evaluateInitializer: evaluateMemberInitializer,
103911
+ materializeInitializerValue,
103912
+ materializeMemberDefaultValue: materializeMemberDefaultValue2
103724
103913
  });
103725
103914
  }
103726
103915
  function createHeadlessVirtualInstanceResolver2(args) {
103727
103916
  return createHeadlessVirtualInstanceResolver({
103728
103917
  ...args,
103729
103918
  evaluateInitializer: evaluateMemberInitializer,
103919
+ materializeInitializerValue,
103920
+ materializeMemberDefaultValue: materializeMemberDefaultValue2,
103730
103921
  documentMaterializationPlan
103731
103922
  });
103732
103923
  }
103733
103924
  function resolveStoredClassValue2(args) {
103734
103925
  return resolveStoredClassValue({
103735
103926
  ...args,
103736
- evaluateInitializer: evaluateMemberInitializer
103927
+ evaluateInitializer: evaluateMemberInitializer,
103928
+ materializeInitializerValue,
103929
+ materializeMemberDefaultValue: materializeMemberDefaultValue2
103737
103930
  });
103738
103931
  }
103739
103932
  var init_virtual_instance_values = __esm({
103740
103933
  "../packages/neoscript-runtime/src/virtual-instance-values.ts"() {
103741
103934
  "use strict";
103935
+ init_initializer_materialization();
103742
103936
  init_evaluateInitializer();
103743
103937
  init_virtual_instance_graph();
103744
103938
  init_virtual_instance_graph();
@@ -126823,11 +127017,10 @@ function appendAuthoredOwnedValueCascadeDeletes(args) {
126823
127017
  for (const rootId of survivingConstructionIds) {
126824
127018
  const instanceRoot = compiledReplayRows.get(rootId) ?? postValuesById.get(rootId);
126825
127019
  const rootMember = postPlacements.get(rootId).member;
126826
- const expanded = expandStoredInstance({
127020
+ const expanded = expandStoredInstance2({
126827
127021
  document: resolverDocument,
126828
127022
  instanceRoot,
126829
- rootMember,
126830
- evaluateInitializer: evaluateMemberInitializer
127023
+ rootMember
126831
127024
  });
126832
127025
  const graph = resolveVirtualInstanceGraph({
126833
127026
  document: resolverDocument,
@@ -139703,6 +139896,10 @@ function verifyProjectSourceCommitAgainstStateV4(args) {
139703
139896
  trustedPendingProjectFiles.set(pendingId2, metadata);
139704
139897
  }
139705
139898
  }
139899
+ const derivedSeedRowIds = derivedCandidateSeedRowIds(
139900
+ args.authoredValueSeeds,
139901
+ args.stateRecords
139902
+ );
139706
139903
  const status = computeWorkspaceStatus(workspace, {
139707
139904
  forceRecompile: args.forceRecompile,
139708
139905
  skipProjectBinaryInspection: true,
@@ -139728,7 +139925,8 @@ ${blockingErrors.map((error) => error.message).join("\n")}` : `Trusted source lo
139728
139925
  auditAuthoredSeedRowIdentities(
139729
139926
  status.authoredValueSeeds,
139730
139927
  args.stateRecords,
139731
- assignments
139928
+ assignments,
139929
+ derivedSeedRowIds
139732
139930
  );
139733
139931
  const usedAssignments = /* @__PURE__ */ new Set();
139734
139932
  const positionless = positionIndependentAssignments(assignments);
@@ -139791,14 +139989,14 @@ function isDerivedOnlyRefresh(change, stateRecords) {
139791
139989
  if (!isObjectRecord(base.data)) return false;
139792
139990
  return canonicalStringify(comparisonData(change.recordKind, change.nextData)) === canonicalStringify(comparisonData(change.recordKind, base.data));
139793
139991
  }
139794
- function auditAuthoredSeedRowIdentities(seeds, stateRecords, assignments) {
139992
+ function auditAuthoredSeedRowIdentities(seeds, stateRecords, assignments, derivedRowIds = /* @__PURE__ */ new Set()) {
139795
139993
  const mintedIds = new Set(assignments.values());
139796
139994
  const authoredCreates = /* @__PURE__ */ new Set();
139797
139995
  for (const [memberId, seed] of seeds) {
139798
139996
  for (const row of seed.values ?? []) {
139799
139997
  if (isPendingId(row.id)) continue;
139800
139998
  if (stateRecords[`value:${row.id}`] !== void 0) continue;
139801
- if (!isUuidV4Id(row.id)) {
139999
+ if (!isUuidV4Id(row.id) && !derivedRowIds.has(row.id)) {
139802
140000
  throw new ProjectSourceCommitVerificationError(
139803
140001
  `Static value seed for member ${memberId} creates row ${row.id}, which is not a UUID v4. A new row's authored identity must wear the same shape a minted one does.`
139804
140002
  );
@@ -139817,6 +140015,19 @@ function auditAuthoredSeedRowIdentities(seeds, stateRecords, assignments) {
139817
140015
  }
139818
140016
  }
139819
140017
  }
140018
+ function derivedCandidateSeedRowIds(seeds, stateRecords) {
140019
+ const derived = /* @__PURE__ */ new Set();
140020
+ for (const seed of seeds) {
140021
+ for (const row of seed.values ?? []) {
140022
+ if (isDerivedNewValueId(
140023
+ row.id,
140024
+ (id2) => stateRecords[`value:${id2}`] !== void 0
140025
+ ))
140026
+ derived.add(row.id);
140027
+ }
140028
+ }
140029
+ return derived;
140030
+ }
139820
140031
  function validateAssignments(value) {
139821
140032
  const assignments = /* @__PURE__ */ new Map();
139822
140033
  const assignedIds = /* @__PURE__ */ new Set();
@@ -142269,6 +142480,9 @@ function emitStoredConstructorExpression(context, member, valueId, visited = /*
142269
142480
  targetTyped
142270
142481
  );
142271
142482
  if (constructor2 !== null) return constructor2;
142483
+ if (hasStoredConstruction && value.instanceConstructorId === null) {
142484
+ return targetTyped ? "new()" : `new ${className}`;
142485
+ }
142272
142486
  if (projection === null || projection.arguments.length === 0 && schemaClass2.requiredConstructorId === void 0) {
142273
142487
  throw new Error(
142274
142488
  `Stored materialized value ${valueId} has no constructor arguments.`
@@ -143416,13 +143630,6 @@ function drainValueReferenceObligationsV4(state, manifest, options) {
143416
143630
  ...composeReferenceSitePosition(move.site, options.sourceTextByUri)
143417
143631
  });
143418
143632
  }
143419
- for (const recorded of options.registry.loweringFailures) {
143420
- failures.push({
143421
- message: recorded.message,
143422
- ...recorded.code === void 0 ? {} : { code: recorded.code },
143423
- ...composeReferenceSitePosition(recorded.site, options.sourceTextByUri)
143424
- });
143425
- }
143426
143633
  for (const obligation of [
143427
143634
  ...collectionValueObligations(manifest),
143428
143635
  ...options.registry.referenceObligations
@@ -143460,7 +143667,17 @@ function drainValueReferenceObligationsV4(state, manifest, options) {
143460
143667
  ...composeReferenceSitePosition(obligation.site, options.sourceTextByUri)
143461
143668
  });
143462
143669
  }
143463
- return failures;
143670
+ const loweringFailures = options.registry.loweringFailures.map(
143671
+ (recorded) => recorded instanceof SchemaSourceError ? recorded : {
143672
+ message: recorded.message,
143673
+ ...recorded.code === void 0 ? {} : { code: recorded.code },
143674
+ ...composeReferenceSitePosition(
143675
+ recorded.site,
143676
+ options.sourceTextByUri
143677
+ )
143678
+ }
143679
+ );
143680
+ return [...loweringFailures, ...failures];
143464
143681
  }
143465
143682
  function withoutDeletedValues(state, deletedValueIds) {
143466
143683
  if (deletedValueIds.size === 0) return state;
@@ -149817,6 +150034,9 @@ function classValueBody(context, member, value, visited, targetTyped, outerEnvir
149817
150034
  }
149818
150035
  continue;
149819
150036
  }
150037
+ const storedBase = context.storedValueBase;
150038
+ if (storedBase !== void 0 && isDerivedNewValueId(childId, (id2) => storedBase.has(id2)))
150039
+ continue;
149820
150040
  const preservesBinding = context.collectionBindingValueIds.has(childId) || context.localValues?.byValueId.has(childId) === true;
149821
150041
  const baseChildBody = context.storedValueBase?.get(childId)?.value;
149822
150042
  const clearedStoredClassOverrides = isObjectRecord(baseChildBody) && Object.keys(baseChildBody).length > 0;
@@ -151989,7 +152209,9 @@ var INFERRED_GENERIC_CLASS_PREFIX, MEMBER_KIND_DICTIONARY2, MEMBER_KIND_LIST2, M
151989
152209
  var init_value_sources = __esm({
151990
152210
  "src/project-source/value-sources.ts"() {
151991
152211
  "use strict";
152212
+ init_source_diagnostics();
151992
152213
  init_immutable_json3();
152214
+ init_lower_support();
151993
152215
  init_record_fields();
151994
152216
  init_source_syntax_cache();
151995
152217
  init_lexer();
@@ -153261,8 +153483,7 @@ function materializeInitializersLocallyV4(args) {
153261
153483
  const sourceRoots = initializerSourceRootIds(
153262
153484
  args.changes,
153263
153485
  args.authoredValueSeeds,
153264
- records3,
153265
- args.workspace.state.records
153486
+ records3
153266
153487
  );
153267
153488
  const written = [...args.changes];
153268
153489
  for (const seed of args.authoredValueSeeds) {
@@ -153660,28 +153881,23 @@ function initializerCode(records3, valueId) {
153660
153881
  }
153661
153882
  return row.init.code;
153662
153883
  }
153663
- function initializerSourceRootIds(changes, seeds, records3, baseRecords) {
153884
+ function initializerSourceRootIds(changes, seeds, records3) {
153664
153885
  const ids = /* @__PURE__ */ new Set();
153665
- const needsFirstMaterialization = (valueId) => {
153666
- const base = baseRecords[`value:${valueId}`]?.data;
153667
- return base === void 0 || isObjectRecord(base) && isObjectRecord(base.init);
153668
- };
153669
153886
  for (const change of changes) {
153670
153887
  if (change.recordKind !== "value") continue;
153671
153888
  if (!isObjectRecord(change.nextData)) continue;
153672
153889
  if (!isObjectRecord(change.nextData.init)) continue;
153673
- if (!needsFirstMaterialization(change.recordId)) continue;
153674
153890
  ids.add(change.recordId);
153675
153891
  }
153676
153892
  for (const seed of seeds) {
153677
153893
  const member = records3.get(`member:${seed.memberId}`)?.data;
153678
153894
  const instanceBinding = isObjectRecord(member) && (member.modifier === 3 || member.valueId === seed.valueId);
153679
153895
  if (!instanceBinding) continue;
153680
- if (seed.nodeType === "initializer" && typeof seed.valueId === "string" && needsFirstMaterialization(seed.valueId)) {
153896
+ if (seed.nodeType === "initializer" && typeof seed.valueId === "string") {
153681
153897
  ids.add(seed.valueId);
153682
153898
  }
153683
153899
  for (const row of seed.values ?? []) {
153684
- if (row.nodeType === "initializer" && needsFirstMaterialization(row.id)) {
153900
+ if (row.nodeType === "initializer") {
153685
153901
  ids.add(row.id);
153686
153902
  }
153687
153903
  }
@@ -157015,6 +157231,13 @@ function walkValueSegments(walk, startId, segments, path, subject, fail2) {
157015
157231
  return null;
157016
157232
  }
157017
157233
  if (!isObjectRecord(body)) {
157234
+ const initializer = pending !== void 0 ? pending.nodeType === "initializer" : isInitValueContent(walk.state[`value:${cursor}`]?.data);
157235
+ if (initializer) {
157236
+ fail2(
157237
+ `${subject} ${path} stops before segment ${segment}: an init block constructs the row it reaches, so a path cannot name its members yet.`
157238
+ );
157239
+ return null;
157240
+ }
157018
157241
  fail2(
157019
157242
  `${subject} ${path} stops before segment ${segment}: the row it reaches stores no single-valued members.`
157020
157243
  );
@@ -157036,6 +157259,10 @@ function walkValueSegments(walk, startId, segments, path, subject, fail2) {
157036
157259
  const resolved = walk.resolveVirtualPath?.(startId, segments);
157037
157260
  if (resolved != null) return resolved;
157038
157261
  } catch (error) {
157262
+ if (error instanceof SchemaSourceError) {
157263
+ walk.registry.loweringFailures.push(error);
157264
+ return null;
157265
+ }
157039
157266
  fail2(
157040
157267
  `${subject} ${path} could not resolve its construction: ${error instanceof Error ? error.message : String(error)}`
157041
157268
  );
@@ -157110,8 +157337,10 @@ var ROOT_PROJECT_FIELDS2, ROOT_PATH_PENDING_PREFIX;
157110
157337
  var init_root_source = __esm({
157111
157338
  "src/project-source/root-source.ts"() {
157112
157339
  "use strict";
157340
+ init_source_diagnostics();
157113
157341
  init_project_root();
157114
157342
  init_value_comparison();
157343
+ init_members();
157115
157344
  init_value_sources();
157116
157345
  init_source_format();
157117
157346
  init_stored_value_placements();
@@ -160286,30 +160515,47 @@ function computeStatus(workspace, options, conflictedFiles, parseErrors, parseWa
160286
160515
  [...staticValues.records, ...memberDefaults.records, ...rootValues.records],
160287
160516
  staticMemberValueIds
160288
160517
  );
160518
+ const sourceTextByUri = new Map(
160519
+ sourceEntries.map((entry) => [entry.relPath, entry.source])
160520
+ );
160289
160521
  let collectionBindings;
160290
160522
  const resolveVirtualPath = (rootId, segments) => {
160291
- if (collectionBindings === void 0) {
160292
- const candidate = /* @__PURE__ */ new Map();
160293
- for (const [key, record7] of Object.entries(rootPathResolutionState)) {
160294
- if (record7.file !== void 0 && isSchemaRecordKindV4(record7.recordKind) && !documentsByKey.has(key))
160295
- continue;
160296
- candidate.set(key, { ...record7, deleted: false });
160297
- }
160298
- for (const row of valueLowerRegistry.pendingValues.values()) {
160299
- candidate.set(`value:${row.id}`, {
160300
- recordKind: "value",
160301
- recordId: row.id,
160302
- contentHash: "",
160303
- deleted: false,
160304
- data: { id: row.id, ...encodeStoredValueRowFields(row) }
160305
- });
160523
+ if (collectionBindings instanceof SchemaSourceError)
160524
+ throw collectionBindings;
160525
+ try {
160526
+ if (collectionBindings === void 0) {
160527
+ const candidate = /* @__PURE__ */ new Map();
160528
+ for (const [key, record7] of Object.entries(rootPathResolutionState)) {
160529
+ if (record7.file !== void 0 && isSchemaRecordKindV4(record7.recordKind) && !documentsByKey.has(key))
160530
+ continue;
160531
+ candidate.set(key, { ...record7, deleted: false });
160532
+ }
160533
+ for (const row of valueLowerRegistry.pendingValues.values()) {
160534
+ candidate.set(`value:${row.id}`, {
160535
+ recordKind: "value",
160536
+ recordId: row.id,
160537
+ contentHash: "",
160538
+ deleted: false,
160539
+ data: { id: row.id, ...encodeStoredValueRowFields(row) }
160540
+ });
160541
+ }
160542
+ const document = readPulledProjectDocumentV4(candidate);
160543
+ compilePulledProjectDocumentForEvaluationV4(document);
160544
+ collectionBindings = new CollectionBindingMaterializer(document);
160306
160545
  }
160307
- const document = readPulledProjectDocumentV4(candidate);
160308
- compilePulledProjectDocumentForEvaluationV4(document);
160309
- collectionBindings = new CollectionBindingMaterializer(document);
160546
+ const resolved = collectionBindings.resolvePath(rootId, segments);
160547
+ return resolved;
160548
+ } catch (error) {
160549
+ const diagnostic = initializerRuntimeDiagnostic(
160550
+ error,
160551
+ valueLowerRegistry.initializerSites,
160552
+ sourceTextByUri,
160553
+ projectAnalysisV4
160554
+ );
160555
+ if (!hasAuthoredSourceFile(diagnostic.file)) throw error;
160556
+ if (collectionBindings === void 0) collectionBindings = diagnostic;
160557
+ throw diagnostic;
160310
160558
  }
160311
- const resolved = collectionBindings.resolvePath(rootId, segments);
160312
- return resolved;
160313
160559
  };
160314
160560
  const resolvedCollectionPaths = resolveRootPathCollectionValuesV4({
160315
160561
  manifest,
@@ -160492,7 +160738,7 @@ function computeStatus(workspace, options, conflictedFiles, parseErrors, parseWa
160492
160738
  unavailableSlots: rootValues.unavailableSlots,
160493
160739
  registry: valueLowerRegistry
160494
160740
  });
160495
- if (collectionBindings !== void 0) {
160741
+ if (collectionBindings !== void 0 && !(collectionBindings instanceof SchemaSourceError)) {
160496
160742
  const bindings = collectionBindings;
160497
160743
  const templateInitializer = (id2) => {
160498
160744
  const sourceValueId = bindings.rowForValue(id2)?.sourceValueId;
@@ -160732,9 +160978,6 @@ function computeStatus(workspace, options, conflictedFiles, parseErrors, parseWa
160732
160978
  changes.push(recordDeleteChange(recordState, recordFile));
160733
160979
  }
160734
160980
  appendCollectionEntryDeletes(workspace, reconstructed3, changes);
160735
- const sourceTextByUri = new Map(
160736
- sourceEntries.map((entry) => [entry.relPath, entry.source])
160737
- );
160738
160981
  const referenceFailures = drainValueReferenceObligationsV4(
160739
160982
  prospectiveState,
160740
160983
  manifest,
@@ -160757,6 +161000,10 @@ function computeStatus(workspace, options, conflictedFiles, parseErrors, parseWa
160757
161000
  }
160758
161001
  );
160759
161002
  for (const failure of referenceFailures) {
161003
+ if (failure instanceof SchemaSourceError) {
161004
+ parseErrors.push(failure);
161005
+ continue;
161006
+ }
160760
161007
  const message = failure.code === void 0 ? failure.message : `${failure.code}: ${failure.message}`;
160761
161008
  parseErrors.push(
160762
161009
  new SchemaSourceError(
@@ -160770,7 +161017,11 @@ function computeStatus(workspace, options, conflictedFiles, parseErrors, parseWa
160770
161017
  }
160771
161018
  reportPhase("record-diff-references", "Checking packed values\u2026");
160772
161019
  if (referenceFailures.length > 0) {
160773
- return refusedStatus(conflictedFiles, parseErrors, parseWarnings);
161020
+ return refusedStatus(
161021
+ conflictedFiles,
161022
+ uniqueSourceErrors(parseErrors),
161023
+ parseWarnings
161024
+ );
160774
161025
  }
160775
161026
  if (valueLowerRegistry.initializerKeyPatches.size > 0) {
160776
161027
  authoredValueSeeds = settleInitializerKeyCode({
@@ -167399,9 +167650,10 @@ function completionItemsForResolution(snapshot, resolved, word) {
167399
167650
  }
167400
167651
  const memberType2 = neoScriptMemberLookupType(resolved.type);
167401
167652
  const owner = memberType2.kind === "named" ? snapshot.project.typeById.get(memberType2.typeId) : void 0;
167402
- return membersForType(snapshot, resolved.type).filter(
167403
- (symbol) => (resolved.symbol?.name !== "base" || isConcreteBaseMember(symbol)) && (owner === void 0 || isMemberCompletionAccessible(snapshot, owner, symbol))
167404
- ).map((symbol) => symbolCompletion(symbol, word, snapshot));
167653
+ return membersForType(snapshot, resolved.type).filter((symbol) => {
167654
+ const declaration = symbol.inheritedFrom === void 0 ? owner : snapshot.project.typeById.get(symbol.inheritedFrom.typeId) ?? owner;
167655
+ return (resolved.symbol?.name !== "base" || isConcreteBaseMember(symbol)) && (declaration === void 0 || isMemberCompletionAccessible(snapshot, declaration, symbol));
167656
+ }).map((symbol) => symbolCompletion(symbol, word, snapshot));
167405
167657
  }
167406
167658
  function isConcreteBaseMember(symbol) {
167407
167659
  return !symbol.id.startsWith("builtin:") && symbol.static !== true && symbol.abstract !== true && (symbol.kind === "function" || symbol.kind === "method" || symbol.computed === true);
@@ -167461,6 +167713,22 @@ function membersForType(snapshot, type) {
167461
167713
  } : {}
167462
167714
  };
167463
167715
  });
167716
+ if (type.narrowedInterfaces) {
167717
+ const names = new Set(members.map((member) => member.name));
167718
+ for (const bound of Object.values(type.narrowedInterfaces)) {
167719
+ for (const member of membersForType(snapshot, bound)) {
167720
+ if (names.has(member.name)) continue;
167721
+ names.add(member.name);
167722
+ const owner = snapshot.project.typeById.get(bound.typeId);
167723
+ members.push(
167724
+ owner === void 0 || member.inheritedFrom !== void 0 ? member : {
167725
+ ...member,
167726
+ inheritedFrom: { typeId: owner.id, typeName: owner.name }
167727
+ }
167728
+ );
167729
+ }
167730
+ }
167731
+ }
167464
167732
  if (named.kind === "class") {
167465
167733
  members = members.filter(
167466
167734
  (member) => member.name !== NEOSCRIPT_CLASS_ID_MEMBER
@@ -197351,12 +197619,36 @@ var init_export = __esm({
197351
197619
 
197352
197620
  // src/project-source/evaluation-workspace.ts
197353
197621
  function workspaceForLocalEvaluation(workspace) {
197622
+ const compiled = compilePendingBodies(
197623
+ Object.entries(workspace.state.records),
197624
+ () => {
197625
+ const records3 = /* @__PURE__ */ new Map();
197626
+ for (const [key, record7] of Object.entries(workspace.state.records))
197627
+ records3.set(key, { ...record7, deleted: false });
197628
+ return records3;
197629
+ }
197630
+ );
197631
+ if (compiled === null) return workspace;
197632
+ const refreshed = { ...workspace.state.records };
197633
+ for (const [key, data] of compiled.bodies)
197634
+ refreshed[key] = { ...refreshed[key], data };
197635
+ return { ...workspace, state: { ...workspace.state, records: refreshed } };
197636
+ }
197637
+ function recordsForLocalEvaluation(records3) {
197638
+ const compiled = compilePendingBodies(records3, () => new Map(records3));
197639
+ if (compiled === null) return records3;
197640
+ for (const [key, data] of compiled.bodies)
197641
+ compiled.records.set(key, { ...records3.get(key), data });
197642
+ return compiled.records;
197643
+ }
197644
+ function compilePendingBodies(entries, copyRecords) {
197354
197645
  const memberIds = /* @__PURE__ */ new Set();
197355
197646
  const constructorIds = /* @__PURE__ */ new Set();
197356
197647
  const pending = /* @__PURE__ */ new Map();
197357
197648
  const scriptSources = /* @__PURE__ */ new Map();
197358
- for (const [key, record7] of Object.entries(workspace.state.records)) {
197649
+ for (const [key, record7] of entries) {
197359
197650
  const kind = record7.recordKind;
197651
+ if (record7.deleted === true) continue;
197360
197652
  if (kind !== "member" && kind !== "constructor") continue;
197361
197653
  const stale = firstRejectedNeoScriptCompiledBody(record7.data, null);
197362
197654
  if (stale !== null) {
@@ -197367,34 +197659,27 @@ function workspaceForLocalEvaluation(workspace) {
197367
197659
  } else if (!hasPendingNeoScriptDerivation(kind, record7.data)) continue;
197368
197660
  (kind === "member" ? memberIds : constructorIds).add(record7.recordId);
197369
197661
  scriptSources.set(key, neoScriptRecordSources(record7.data));
197370
- pending.set(key, {
197371
- ...record7,
197372
- deleted: false,
197373
- data: stripClientDerivedBodies(kind, record7.data)
197374
- });
197662
+ pending.set(key, stripClientDerivedBodies(kind, record7.data));
197375
197663
  }
197376
- if (pending.size === 0) return workspace;
197377
- const records3 = /* @__PURE__ */ new Map();
197378
- for (const [key, record7] of Object.entries(workspace.state.records))
197379
- records3.set(key, pending.get(key) ?? { ...record7, deleted: false });
197380
- const document = readPulledProjectDocumentV4(records3);
197664
+ if (pending.size === 0) return null;
197665
+ const compilable = copyRecords();
197666
+ for (const [key, data] of pending)
197667
+ compilable.set(key, { ...compilable.get(key), data });
197668
+ const document = readPulledProjectDocumentV4(compilable);
197381
197669
  compilePulledProjectDocumentForEvaluationV4(document, void 0, {
197382
197670
  memberIds,
197383
197671
  constructorIds,
197384
197672
  scriptSources
197385
197673
  });
197386
- const refreshed = { ...workspace.state.records };
197674
+ const bodies = /* @__PURE__ */ new Map();
197387
197675
  for (const member of document.members) {
197388
- if (!memberIds.has(member.id)) continue;
197389
- const key = `member:${member.id}`;
197390
- refreshed[key] = { ...refreshed[key], data: member };
197676
+ if (memberIds.has(member.id)) bodies.set(`member:${member.id}`, member);
197391
197677
  }
197392
197678
  for (const constructor2 of document.constructors ?? []) {
197393
- if (!constructorIds.has(constructor2.id)) continue;
197394
- const key = `constructor:${constructor2.id}`;
197395
- refreshed[key] = { ...refreshed[key], data: constructor2 };
197679
+ if (constructorIds.has(constructor2.id))
197680
+ bodies.set(`constructor:${constructor2.id}`, constructor2);
197396
197681
  }
197397
- return { ...workspace, state: { ...workspace.state, records: refreshed } };
197682
+ return { records: compilable, bodies };
197398
197683
  }
197399
197684
  var init_evaluation_workspace = __esm({
197400
197685
  "src/project-source/evaluation-workspace.ts"() {
@@ -198710,11 +198995,7 @@ async function prepareLocalPushArtifactsV4(workspace, status, onPhase = () => vo
198710
198995
  } : void 0;
198711
198996
  onPhase("Hashing project source\u2026");
198712
198997
  const source = projectSourceIdentityForStatus(status);
198713
- const verificationSource = options.fullValidation ? createPendingProjectSourceIdentityV4(
198714
- workspace,
198715
- status,
198716
- status.authoredValueSeeds
198717
- ) : null;
198998
+ const verificationSource = options.fullValidation ? locatedPendingProjectSourceIdentity(workspace, status) : null;
198718
198999
  onPhase("Assigning pending value identities\u2026");
198719
199000
  const pendingAssignment = assignPendingIds(
198720
199001
  status.changes,
@@ -198846,6 +199127,17 @@ function locatePreparationError(error, status, assigned) {
198846
199127
  if (source === void 0) return error;
198847
199128
  return new Error(`${source.file}:${source.line} \u2014 ${error.message}`);
198848
199129
  }
199130
+ function locatedPendingProjectSourceIdentity(workspace, status) {
199131
+ try {
199132
+ return createPendingProjectSourceIdentityV4(
199133
+ workspace,
199134
+ status,
199135
+ status.authoredValueSeeds
199136
+ );
199137
+ } catch (error) {
199138
+ throw locatePreparationError(error, status, /* @__PURE__ */ new Map());
199139
+ }
199140
+ }
198849
199141
  async function prepareLocalCandidateV4(workspace, options = {}) {
198850
199142
  const pushOptions = {
198851
199143
  dryRun: options.dryRun ?? true,
@@ -199210,19 +199502,22 @@ function createPendingProjectSourceIdentityV4(workspace, status, authoredValueSe
199210
199502
  }
199211
199503
  }
199212
199504
  materializePendingSourceLocalization(records3, status);
199213
- const emission = emitProjectDocumentFilesV4(records3, {
199214
- dialogueGroupSymbols: authoredDialogueGroupSymbols(
199215
- status.sourceSnapshot?.analysis
199216
- ),
199217
- storedValueBase: storedValueRowsByIdV4(
199218
- Object.values(workspace.state.records)
199219
- ),
199220
- recordFiles: projectRecordFilesV4(
199221
- Object.values(workspace.state.records),
199222
- status.reconstructed.values()
199223
- ),
199224
- localValues: status.localValues
199225
- });
199505
+ const emission = emitProjectDocumentFilesV4(
199506
+ recordsForLocalEvaluation(records3),
199507
+ {
199508
+ dialogueGroupSymbols: authoredDialogueGroupSymbols(
199509
+ status.sourceSnapshot?.analysis
199510
+ ),
199511
+ storedValueBase: storedValueRowsByIdV4(
199512
+ Object.values(workspace.state.records)
199513
+ ),
199514
+ recordFiles: projectRecordFilesV4(
199515
+ Object.values(workspace.state.records),
199516
+ status.reconstructed.values()
199517
+ ),
199518
+ localValues: status.localValues
199519
+ }
199520
+ );
199226
199521
  const files = emission.files.map((file) => {
199227
199522
  const kind = neoProjectSourceKind(file.path, file.content);
199228
199523
  if (kind === null || !isNeoProjectProductionSourceKind(kind)) {
@@ -202242,7 +202537,7 @@ async function finishFormat4Pull(args) {
202242
202537
  const formatSource = createWorkspaceSourceFormatter(workspace.root);
202243
202538
  const localResult = emitProjectDocumentFilesV4(
202244
202539
  candidateValueRecordsForEmissionV4(
202245
- localRecords,
202540
+ recordsForLocalEvaluation(localRecords),
202246
202541
  workspace.state.records,
202247
202542
  workspace.config.projectId
202248
202543
  ),
@@ -202725,17 +203020,19 @@ function buildEmitRecordSet(document, plans, side) {
202725
203020
  resolvedRecordKind,
202726
203021
  resolvedRecordId,
202727
203022
  data,
202728
- serverRecord
203023
+ // A locally created record's derived fields, such as a new
203024
+ // static field's pending valueId, came from this same lowering.
203025
+ serverRecord ?? (plan.conflicted ? void 0 : { data })
202729
203026
  ) : data
202730
203027
  });
202731
203028
  }
202732
203029
  return records3;
202733
203030
  }
202734
- function composeProspectivePullRecord(recordKind, recordId, data, serverRecord) {
203031
+ function composeProspectivePullRecord(recordKind, recordId, data, base) {
202735
203032
  if (!isSchemaRecordKindV4(recordKind) || !isObjectRecord(data)) return data;
202736
203033
  let baseRecord = null;
202737
- if (serverRecord !== void 0) {
202738
- if (!isObjectRecord(serverRecord.data)) {
203034
+ if (base !== void 0) {
203035
+ if (!isObjectRecord(base.data)) {
202739
203036
  throw new Error(
202740
203037
  `Cannot compose pulled ${recordKind} record ${JSON.stringify(recordId)} because its server payload is not an object.`
202741
203038
  );
@@ -202743,7 +203040,7 @@ function composeProspectivePullRecord(recordKind, recordId, data, serverRecord)
202743
203040
  baseRecord = {
202744
203041
  recordKind,
202745
203042
  recordId,
202746
- data: serverRecord.data
203043
+ data: base.data
202747
203044
  };
202748
203045
  }
202749
203046
  return composeDocumentRecord(
@@ -202784,6 +203081,7 @@ var init_pull = __esm({
202784
203081
  init_static_member_ownership_recovery();
202785
203082
  init_value_base_desync();
202786
203083
  init_packed_value_parity();
203084
+ init_evaluation_workspace();
202787
203085
  init_compiler_metadata();
202788
203086
  }
202789
203087
  });
@@ -215703,7 +216001,7 @@ var releaseWorkspaceLock = () => void 0;
215703
216001
  async function main() {
215704
216002
  const args = parseArgs(process.argv.slice(2));
215705
216003
  if (args.command === "--version") {
215706
- console.log("0.84.0");
216004
+ console.log("0.84.2");
215707
216005
  return;
215708
216006
  }
215709
216007
  if (args.command === null || args.command === "help" || args.command === "--help" || args.command === "-h") {