@neocompose/cli 0.38.2 → 0.38.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/neo.mjs CHANGED
@@ -1008,6 +1008,14 @@ function assertKnownFlags(args) {
1008
1008
  }
1009
1009
  }
1010
1010
  }
1011
+ function assertAllowedFlags(args, allowed) {
1012
+ for (const name of args.flags.keys()) {
1013
+ if (allowed.has(name)) continue;
1014
+ throw new NeoCliUsageError(
1015
+ `Flag "--${name}" is not valid for neo ${args.command ?? "help"}. Run \`neo ${args.command ?? "help"} --help\` for usage.`
1016
+ );
1017
+ }
1018
+ }
1011
1019
  var NeoCliUsageError, BOOLEAN_FLAGS, KNOWN_FLAGS, TEST_ONLY_FLAGS;
1012
1020
  var init_args = __esm({
1013
1021
  "src/args.ts"() {
@@ -9125,19 +9133,6 @@ function bindConstructorArgumentNames(className, declared, argumentNames, pos) {
9125
9133
  return parameter4.name;
9126
9134
  });
9127
9135
  }
9128
- function callMatchesDeclaredOverloadNames(declared, expression) {
9129
- if (declared.length === 0) return false;
9130
- if (callHasPositionalArguments(expression)) return false;
9131
- const names = expression.args.map(
9132
- (_, index) => expression.argumentNames?.[index] ?? ""
9133
- );
9134
- const callKey = neoScriptArgumentNameSetKey(names);
9135
- return declared.some(
9136
- (candidate) => neoScriptArgumentNameSetKey(
9137
- candidate.parameters.map((parameter4) => parameter4.name)
9138
- ) === callKey
9139
- );
9140
- }
9141
9136
  function scopeVariable(name, value, sourceType, writability, ownership, writeRoot, readonlyBinding) {
9142
9137
  return {
9143
9138
  name,
@@ -11819,11 +11814,8 @@ var init_strict_resolver = __esm({
11819
11814
  const declaredTarget = this.project.typeByName.get(className);
11820
11815
  const declared = declaredTarget?.declaredConstructors ?? [];
11821
11816
  const requiredConstructor = neoScriptRequiredConstructor(declaredTarget);
11822
- if (requiredConstructor === null && !callMatchesDeclaredOverloadNames(declared, expression)) {
11823
- this.rejectConstructorProjectionInConstructionBody(expression);
11824
- }
11825
- const projectionCall = requiredConstructor === null && declaredTarget?.constructorSignature !== void 0 && (expression.argumentNames === void 0 && callHasPositionalArguments(expression) || expression.argumentNames !== void 0 && declaredTarget.constructorSignature.namedProjections !== void 0);
11826
- if (declared.length > 0 && !projectionCall) {
11817
+ const generatedPositionalCall = requiredConstructor === null && declaredTarget?.constructorSignature !== void 0 && expression.argumentNames === void 0 && callHasPositionalArguments(expression);
11818
+ if (declared.length > 0 && !generatedPositionalCall) {
11827
11819
  return this.resolveDeclaredConstructor(
11828
11820
  className,
11829
11821
  expression,
@@ -11832,13 +11824,13 @@ var init_strict_resolver = __esm({
11832
11824
  expected
11833
11825
  );
11834
11826
  }
11835
- if (expression.argumentNames && !projectionCall) {
11827
+ if (expression.argumentNames && !generatedPositionalCall) {
11836
11828
  throw new CompileError(
11837
11829
  "Named constructor arguments require a declaration-aware project source context.",
11838
11830
  expression.pos
11839
11831
  );
11840
11832
  }
11841
- if (expression.initializer && expression.initializer.length > 0 && !projectionCall && this.context.storedConstructionReplay !== true) {
11833
+ if (expression.initializer && expression.initializer.length > 0 && !generatedPositionalCall && this.context.storedConstructionReplay !== true) {
11842
11834
  throw new CompileError(
11843
11835
  "Object initializers are available to project source construction and are not executable NeoScript constructors.",
11844
11836
  expression.pos
@@ -14081,26 +14073,11 @@ var init_strict_resolver = __esm({
14081
14073
  )
14082
14074
  }));
14083
14075
  const argumentsList2 = expression.args;
14084
- const namedProjections = signature.namedProjections;
14085
14076
  if (expression.argumentNames !== void 0) {
14086
- if (namedProjections === void 0) {
14087
- throw new CompileError(
14088
- `Class '${className}' exposes no named constructor projection.`,
14089
- pos
14090
- );
14091
- }
14092
- if (argumentsList2.length !== namedProjections.length) {
14093
- throw new CompileError(
14094
- `${className} constructor requires ${namedProjections.length} named argument${namedProjections.length === 1 ? "" : "s"} but got ${argumentsList2.length}.`,
14095
- pos
14096
- );
14097
- }
14098
- if (expression.argumentNames.length !== argumentsList2.length) {
14099
- throw new CompileError(
14100
- `${className} constructor projection requires every argument to be named.`,
14101
- pos
14102
- );
14103
- }
14077
+ throw new CompileError(
14078
+ "Named constructor arguments require a declaration-aware project source context.",
14079
+ pos
14080
+ );
14104
14081
  }
14105
14082
  const requiredCount = signature.parameters.filter(
14106
14083
  (parameter4) => parameter4.required
@@ -14118,30 +14095,10 @@ var init_strict_resolver = __esm({
14118
14095
  );
14119
14096
  }
14120
14097
  const fields = argumentsList2.map((argument2, index) => {
14121
- const projectionName = expression.argumentNames?.[index];
14122
- const projection = projectionName === void 0 ? void 0 : namedProjections?.find(
14123
- (candidate) => candidate.name === projectionName
14124
- );
14125
- if (projectionName !== void 0 && projection === void 0) {
14126
- throw new CompileError(
14127
- `Class '${className}' has no constructor projection named '${projectionName}'.`,
14128
- argument2.pos
14129
- );
14130
- }
14131
- if (projection !== void 0 && expression.argumentNames?.findIndex(
14132
- (candidate) => candidate === projection.name
14133
- ) !== index) {
14134
- throw new CompileError(
14135
- `Constructor argument '${projection.name}' is supplied more than once.`,
14136
- argument2.pos
14137
- );
14138
- }
14139
- const parameter4 = projection === void 0 ? parameters[index] : parameters.find(
14140
- (candidate) => candidate.memberId === projection.memberId
14141
- );
14098
+ const parameter4 = parameters[index];
14142
14099
  if (!parameter4) {
14143
14100
  throw new Error(
14144
- projection === void 0 ? `NeoScript constructor ${className} lost parameter ${index + 1} after argument-count validation.` : `NeoScript constructor ${className} projection '${projection.name}' names missing member '${projection.memberId}'.`
14101
+ `NeoScript constructor ${className} lost parameter ${index + 1} after argument-count validation.`
14145
14102
  );
14146
14103
  }
14147
14104
  const value = this.resolveExpression(
@@ -14161,16 +14118,6 @@ var init_strict_resolver = __esm({
14161
14118
  valuePointer: value.pointer
14162
14119
  };
14163
14120
  });
14164
- if (namedProjections !== void 0 && expression.argumentNames !== void 0) {
14165
- for (const projection of namedProjections) {
14166
- if (!expression.argumentNames.includes(projection.name)) {
14167
- throw new CompileError(
14168
- `${className} constructor is missing named argument '${projection.name}'.`,
14169
- pos
14170
- );
14171
- }
14172
- }
14173
- }
14174
14121
  fields.push(
14175
14122
  ...this.resolveCallSiteInitializerFields(schemaClass2, expression, scope)
14176
14123
  );
@@ -14217,22 +14164,6 @@ var init_strict_resolver = __esm({
14217
14164
  typeId: schemaClass2.id
14218
14165
  };
14219
14166
  }
14220
- /**
14221
- * P43 §7.1. P29's `new T(id: "…")` projection names a class-default row,
14222
- * which is exactly the wrong identity inside a construction body: member
14223
- * initializers have already run, so the body holds its own rows.
14224
- */
14225
- rejectConstructorProjectionInConstructionBody(expression) {
14226
- if (!isNeoScriptConstructionDocumentKind(this.context.kind)) return;
14227
- const idIndex = (expression.argumentNames ?? []).findIndex(
14228
- (name) => name === "id"
14229
- );
14230
- if (idIndex < 0) return;
14231
- throw new CompileError(
14232
- `A constructor projection \`new(id: \u2026)\` names a class-default row, so it cannot be used in a ${this.context.kind} body. Bind the resolved value instead, for example \`Child = iris\`.`,
14233
- expression.pos
14234
- );
14235
- }
14236
14167
  /**
14237
14168
  * P43 §6.1. Construction through the class's author-declared constructors.
14238
14169
  * Arguments are named (§6.1.1 resolves overloads by name set first), and
@@ -19510,7 +19441,7 @@ var init_project_schema_contract_generated = __esm({
19510
19441
  "../packages/neoscript-language/src/project-schema-contract.generated.ts"() {
19511
19442
  "use strict";
19512
19443
  PROJECT_SCHEMA_MANIFEST_FORMAT_VERSION = 3;
19513
- PROJECT_SCHEMA_MANIFEST_CONTRACT_VERSION = "3.14";
19444
+ PROJECT_SCHEMA_MANIFEST_CONTRACT_VERSION = "3.15";
19514
19445
  PROJECT_FILE_UPLOAD_BATCH_SIZE = 32;
19515
19446
  NEO_PROJECT_SOURCE_RECORD_CONTRACT = {
19516
19447
  "recordFields": {
@@ -19580,7 +19511,6 @@ var init_project_schema_contract_generated = __esm({
19580
19511
  "allowedStorageKeys",
19581
19512
  "genericParams",
19582
19513
  "extendsGenericBindings",
19583
- "constructorProjections",
19584
19514
  "constructorIds",
19585
19515
  "requiredConstructorId",
19586
19516
  "targetMemberId"
@@ -22771,7 +22701,7 @@ function resolveInvokedConstructor(declaration, call, diagnostics) {
22771
22701
  return true;
22772
22702
  }
22773
22703
  if (declaration.constructors.length === 0) {
22774
- return call.argumentNames.length > 0;
22704
+ return false;
22775
22705
  }
22776
22706
  if (call.argumentNames.length === 0) {
22777
22707
  return declaration.constructors.some(
@@ -35823,7 +35753,6 @@ var init_document_contracts = __esm({
35823
35753
  "allowedStorageKeys",
35824
35754
  "genericParams",
35825
35755
  "extendsGenericBindings",
35826
- "constructorProjections",
35827
35756
  "constructorIds",
35828
35757
  "requiredConstructorId",
35829
35758
  "targetMemberId"
@@ -35841,7 +35770,6 @@ var init_document_contracts = __esm({
35841
35770
  allowedStorageKeys: "nullIsAbsent",
35842
35771
  genericParams: "nullOrEmptyArrayIsAbsent",
35843
35772
  extendsGenericBindings: "nullOrEmptyObjectIsAbsent",
35844
- constructorProjections: "nullOrEmptyArrayIsAbsent",
35845
35773
  constructorIds: "nullOrEmptyArrayIsAbsent",
35846
35774
  requiredConstructorId: "nullIsAbsent"
35847
35775
  }
@@ -38731,27 +38659,6 @@ function schemaClassFromDocument(record3, context) {
38731
38659
  selectionSpan: source.selectionSpan
38732
38660
  };
38733
38661
  });
38734
- const constructorProjections = optionalArray(data.constructorProjections).map(
38735
- (entry, index) => {
38736
- const projection = requireRecordValue(
38737
- entry,
38738
- record3,
38739
- `constructorProjections[${index}]`
38740
- );
38741
- return {
38742
- parameterName: requiredStringValue(
38743
- projection.parameterName,
38744
- record3,
38745
- `constructorProjections[${index}].parameterName`
38746
- ),
38747
- memberId: requiredStringValue(
38748
- projection.memberId,
38749
- record3,
38750
- `constructorProjections[${index}].memberId`
38751
- )
38752
- };
38753
- }
38754
- );
38755
38662
  const constructorIds = optionalStringArray(data.constructorIds);
38756
38663
  const requiredConstructorId2 = optionalStringOrNull(
38757
38664
  data.requiredConstructorId
@@ -38782,7 +38689,6 @@ function schemaClassFromDocument(record3, context) {
38782
38689
  "extendsGenericBindings"
38783
38690
  ),
38784
38691
  targetMemberId: optionalStringOrNull(data.targetMemberId),
38785
- ...constructorProjections.length === 0 ? {} : { constructorProjections },
38786
38692
  ...constructorIds.length === 0 ? {} : { constructorIds },
38787
38693
  ...requiredConstructorId2 === null ? {} : { requiredConstructorId: requiredConstructorId2 }
38788
38694
  };
@@ -38813,7 +38719,6 @@ function schemaClassToDocument(schemaClass2) {
38813
38719
  ...parameter4.constraint === null ? {} : { constraint: parameter4.constraint }
38814
38720
  })),
38815
38721
  extendsGenericBindings: schemaClass2.extendsGenericBindings,
38816
- constructorProjections: schemaClass2.constructorProjections,
38817
38722
  constructorIds: schemaClass2.constructorIds,
38818
38723
  requiredConstructorId: schemaClass2.requiredConstructorId,
38819
38724
  targetMemberId: schemaClass2.targetMemberId
@@ -40241,7 +40146,6 @@ function assertNeoSchemaClass(value, path) {
40241
40146
  "hiddenInMemberSelector",
40242
40147
  "system",
40243
40148
  "allowedStorage",
40244
- "allowedStorageKeys",
40245
40149
  "genericParameters",
40246
40150
  "extendsGenericBindings",
40247
40151
  "targetMemberId"
@@ -40249,9 +40153,9 @@ function assertNeoSchemaClass(value, path) {
40249
40153
  [
40250
40154
  "docsText",
40251
40155
  "isSealed",
40252
- "constructorProjections",
40253
40156
  "constructorIds",
40254
- "requiredConstructorId"
40157
+ "requiredConstructorId",
40158
+ "allowedStorageKeys"
40255
40159
  ]
40256
40160
  );
40257
40161
  assertIdentity2(type, path, "class");
@@ -40272,7 +40176,9 @@ function assertNeoSchemaClass(value, path) {
40272
40176
  booleanAt(type.hiddenInMemberSelector, `${path}.hiddenInMemberSelector`);
40273
40177
  assertSystem(type.system, `${path}.system`);
40274
40178
  nullableStorage(type.allowedStorage, `${path}.allowedStorage`);
40275
- nullableStringArray(type.allowedStorageKeys, `${path}.allowedStorageKeys`);
40179
+ if (type.allowedStorageKeys !== void 0) {
40180
+ nullableStringArray(type.allowedStorageKeys, `${path}.allowedStorageKeys`);
40181
+ }
40276
40182
  arrayOf(
40277
40183
  type.genericParameters,
40278
40184
  `${path}.genericParameters`,
@@ -40286,18 +40192,6 @@ function assertNeoSchemaClass(value, path) {
40286
40192
  if (type.requiredConstructorId !== void 0) {
40287
40193
  nonEmptyString(type.requiredConstructorId, `${path}.requiredConstructorId`);
40288
40194
  }
40289
- if (type.constructorProjections !== void 0) {
40290
- arrayOf(
40291
- type.constructorProjections,
40292
- `${path}.constructorProjections`,
40293
- assertClassConstructorProjection
40294
- );
40295
- }
40296
- }
40297
- function assertClassConstructorProjection(value, path) {
40298
- const projection = objectAt(value, path, ["parameterName", "memberId"]);
40299
- nonEmptyString(projection.parameterName, `${path}.parameterName`);
40300
- nonEmptyString(projection.memberId, `${path}.memberId`);
40301
40195
  }
40302
40196
  function assertGenericParameter(value, path) {
40303
40197
  const parameter4 = objectAt(value, path, [
@@ -44265,23 +44159,20 @@ function isGenericBindingsRecord(value) {
44265
44159
  if (Array.isArray(value)) return false;
44266
44160
  return Object.values(value).every(isGenericBinding);
44267
44161
  }
44162
+ function hasRetiredConstructorProjectionsTombstone(value) {
44163
+ return value !== null && typeof value === "object" && Object.hasOwn(value, RETIRED_CONSTRUCTOR_PROJECTIONS_FIELD);
44164
+ }
44268
44165
  function isNeoSchemaClassBase(value) {
44166
+ if (hasRetiredConstructorProjectionsTombstone(value)) {
44167
+ return false;
44168
+ }
44269
44169
  const v = value;
44270
44170
  return typeof v?.name === "string" && isValidDocsText(v.docsText) && isClassSchema(v?.schema) && isOptionalSchemaKeyOrder(v?.schemaKeyOrder) && (v.implementsInterfaceIds === void 0 || v.implementsInterfaceIds === null || Array.isArray(v.implementsInterfaceIds) && v.implementsInterfaceIds.every(
44271
44171
  (interfaceId) => typeof interfaceId === "string" && interfaceId.length > 0
44272
- )) && typeof v?.hiddenInMemberSelector === "boolean" && typeof v?.isAbstract === "boolean" && (v.isSealed === void 0 || typeof v.isSealed === "boolean") && (v.allowedStorage === void 0 || v.allowedStorage === null || isEffectiveMemberStorage(v.allowedStorage)) && (v.allowedStorageKeys === void 0 || v.allowedStorageKeys === null || Array.isArray(v.allowedStorageKeys) && v.allowedStorageKeys.every((key) => typeof key === "string")) && (v.genericParams === void 0 || v.genericParams === null || Array.isArray(v.genericParams) && v.genericParams.every(isGenericParamDeclaration)) && (v.extendsGenericBindings === void 0 || v.extendsGenericBindings === null || isGenericBindingsRecord(v.extendsGenericBindings)) && (v.constructorProjections === void 0 || v.constructorProjections === null || Array.isArray(v.constructorProjections) && v.constructorProjections.every(isNeoClassConstructorProjection) && v.system?.kind === SystemProtectionKind.WorldAuthoring) && (v.constructorIds === void 0 || v.constructorIds === null || Array.isArray(v.constructorIds) && v.constructorIds.every(
44172
+ )) && typeof v?.hiddenInMemberSelector === "boolean" && typeof v?.isAbstract === "boolean" && (v.isSealed === void 0 || typeof v.isSealed === "boolean") && (v.allowedStorage === void 0 || v.allowedStorage === null || isEffectiveMemberStorage(v.allowedStorage)) && (v.allowedStorageKeys === void 0 || v.allowedStorageKeys === null || Array.isArray(v.allowedStorageKeys) && v.allowedStorageKeys.every((key) => typeof key === "string")) && (v.genericParams === void 0 || v.genericParams === null || Array.isArray(v.genericParams) && v.genericParams.every(isGenericParamDeclaration)) && (v.extendsGenericBindings === void 0 || v.extendsGenericBindings === null || isGenericBindingsRecord(v.extendsGenericBindings)) && (v.constructorIds === void 0 || v.constructorIds === null || Array.isArray(v.constructorIds) && v.constructorIds.every(
44273
44173
  (constructorId) => typeof constructorId === "string" && constructorId.length > 0
44274
44174
  ) && new Set(v.constructorIds).size === v.constructorIds.length) && (v.requiredConstructorId === void 0 || v.requiredConstructorId === null || typeof v.requiredConstructorId === "string" && v.requiredConstructorId.length > 0 && (v.constructorIds ?? []).length === 0) && (v.targetMemberId === void 0 || v.targetMemberId === null || typeof v.targetMemberId === "string" && v.targetMemberId.length > 0) && (v.system === void 0 || v.system === null || isSystemMetadata(v.system));
44275
44175
  }
44276
- function isNeoClassConstructorProjection(value) {
44277
- if (value === null || typeof value !== "object" || Array.isArray(value)) {
44278
- return false;
44279
- }
44280
- const projection = value;
44281
- return Object.keys(projection).every(
44282
- (key) => key === "parameterName" || key === "memberId"
44283
- ) && typeof projection.parameterName === "string" && projection.parameterName.length > 0 && typeof projection.memberId === "string" && projection.memberId.length > 0;
44284
- }
44285
44176
  function resolveAllowedStorage(classId, classes, draft) {
44286
44177
  const visited = /* @__PURE__ */ new Set();
44287
44178
  const lookup = (id2) => draft && draft.id === id2 ? draft : classes.find((candidate) => candidate.id === id2);
@@ -44350,12 +44241,14 @@ function isNeoSchemaClassProps(value) {
44350
44241
  function isNeoSchemaClass(value) {
44351
44242
  return isNeoSchemaClassProps(value);
44352
44243
  }
44244
+ var RETIRED_CONSTRUCTOR_PROJECTIONS_FIELD;
44353
44245
  var init_classes = __esm({
44354
44246
  "../src/models/classes/classes.ts"() {
44355
44247
  "use strict";
44356
44248
  init_core();
44357
44249
  init_docs_text2();
44358
44250
  init_member_storage();
44251
+ RETIRED_CONSTRUCTOR_PROJECTIONS_FIELD = "constructorProjections";
44359
44252
  }
44360
44253
  });
44361
44254
 
@@ -45755,7 +45648,7 @@ function descendantClassIds(classId, allClasses) {
45755
45648
  }
45756
45649
  return result;
45757
45650
  }
45758
- var CircularInheritanceError, UnresolvedMemberInheritanceError, mergedSchemaEpoch, classIndexes, memberIndexes, instanceSurfaceMemo, storedInstanceMemo, readOnlyMemberMemo, staticMemberMemo, mergeInstanceSchema;
45651
+ var CircularInheritanceError, UnresolvedMemberInheritanceError, mergedSchemaEpoch, classIndexes, memberIndexes, instanceSurfaceMemo, storedInstanceMemo, readOnlyMemberMemo, staticMemberMemo;
45759
45652
  var init_inheritance = __esm({
45760
45653
  "../src/models/classes/inheritance.ts"() {
45761
45654
  "use strict";
@@ -45792,7 +45685,6 @@ var init_inheritance = __esm({
45792
45685
  storedInstanceMemo = createMergeMemo();
45793
45686
  readOnlyMemberMemo = createMergeMemo();
45794
45687
  staticMemberMemo = createMergeMemo();
45795
- mergeInstanceSchema = mergeInstanceSurfaceSchema;
45796
45688
  }
45797
45689
  });
45798
45690
 
@@ -47487,6 +47379,56 @@ var init_world_system_classes_generated = __esm({
47487
47379
  }
47488
47380
  });
47489
47381
 
47382
+ // ../src/models/core/deep-clone-plain-data.ts
47383
+ function deepClonePlainData(value) {
47384
+ return clonePlain(value, "$", /* @__PURE__ */ new Set());
47385
+ }
47386
+ function clonePlain(value, path, visiting) {
47387
+ if (value === null || typeof value !== "object") {
47388
+ if (typeof value === "function") {
47389
+ throw new Error(
47390
+ `Plain-data clone met a function at ${path}; value data never stores callables.`
47391
+ );
47392
+ }
47393
+ if (typeof value === "symbol") {
47394
+ throw new Error(
47395
+ `Plain-data clone met a symbol at ${path}; value data never stores symbols.`
47396
+ );
47397
+ }
47398
+ if (typeof value === "bigint") {
47399
+ throw new Error(
47400
+ `Plain-data clone met a bigint at ${path}; value data stores numbers only.`
47401
+ );
47402
+ }
47403
+ return value;
47404
+ }
47405
+ if (visiting.has(value)) {
47406
+ throw new Error(
47407
+ `Plain-data clone met a cycle at ${path}; value data is acyclic by storage contract.`
47408
+ );
47409
+ }
47410
+ visiting.add(value);
47411
+ try {
47412
+ if (Array.isArray(value)) {
47413
+ return value.map(
47414
+ (entry, index) => clonePlain(entry, `${path}[${index}]`, visiting)
47415
+ );
47416
+ }
47417
+ const clone = {};
47418
+ for (const [key, entry] of Object.entries(value)) {
47419
+ clone[key] = clonePlain(entry, `${path}.${key}`, visiting);
47420
+ }
47421
+ return clone;
47422
+ } finally {
47423
+ visiting.delete(value);
47424
+ }
47425
+ }
47426
+ var init_deep_clone_plain_data = __esm({
47427
+ "../src/models/core/deep-clone-plain-data.ts"() {
47428
+ "use strict";
47429
+ }
47430
+ });
47431
+
47490
47432
  // ../src/models/classes/world-system-classes.ts
47491
47433
  function worldAnimationChildOverrideBindingMemberId(classId) {
47492
47434
  return inSystemRecordNamespaceOf(
@@ -47515,7 +47457,7 @@ function worldAnimationChildOverrideBindingMember(projectId, classId) {
47515
47457
  updatedAt: 0
47516
47458
  };
47517
47459
  }
47518
- var WORLD_ANIMATION_CHILD_OVERRIDE_BINDING_MEMBER_NAME, WORLD_ANIMATION_CHILD_OVERRIDE_BINDING_MEMBER_NAMESPACE, WORLD_SYSTEM_ANIMATION_KIND_MARKER, WORLD_SYSTEM_ANIMATION_KINDS, GENERIC_WORLD_SYSTEM_CLASS_KINDS, WORLD_SYSTEM_ALL_KINDS, WORLD_SYSTEM_CLASS_DEFINITION_BY_KIND, WORLD_SYSTEM_SCHEMA_FIELD_SITES_BY_MEMBER_ID;
47460
+ var WORLD_ANIMATION_CHILD_OVERRIDE_BINDING_MEMBER_NAME, WORLD_ANIMATION_CHILD_OVERRIDE_BINDING_MEMBER_NAMESPACE, WORLD_SYSTEM_CLASS_DEFINITION_BY_KIND, WORLD_SYSTEM_ANIMATION_KIND_MARKER, WORLD_SYSTEM_ANIMATION_KINDS, GENERIC_WORLD_SYSTEM_CLASS_KINDS, WORLD_SYSTEM_ALL_KINDS, WORLD_SYSTEM_SCHEMA_FIELD_SITES_BY_MEMBER_ID;
47519
47461
  var init_world_system_classes = __esm({
47520
47462
  "../src/models/classes/world-system-classes.ts"() {
47521
47463
  "use strict";
@@ -47525,9 +47467,16 @@ var init_world_system_classes = __esm({
47525
47467
  init_dist_node();
47526
47468
  init_system_record_id();
47527
47469
  init_world_system_classes_generated();
47470
+ init_deep_clone_plain_data();
47528
47471
  init_world_system_classes_generated();
47529
47472
  WORLD_ANIMATION_CHILD_OVERRIDE_BINDING_MEMBER_NAME = "NeoAnimationChildBinding";
47530
47473
  WORLD_ANIMATION_CHILD_OVERRIDE_BINDING_MEMBER_NAMESPACE = "2048c3bb-8ae5-51cc-a1dc-15178cc41865";
47474
+ WORLD_SYSTEM_CLASS_DEFINITION_BY_KIND = new Map(
47475
+ WORLD_SYSTEM_CLASS_DEFINITIONS.map((definition2) => [
47476
+ definition2.worldKind,
47477
+ definition2
47478
+ ])
47479
+ );
47531
47480
  WORLD_SYSTEM_ANIMATION_KIND_MARKER = "animation";
47532
47481
  WORLD_SYSTEM_ANIMATION_KINDS = new Set(
47533
47482
  WORLD_SYSTEM_CLASS_DEFINITIONS.map(
@@ -47544,12 +47493,6 @@ var init_world_system_classes = __esm({
47544
47493
  WORLD_SYSTEM_ALL_KINDS = new Set(
47545
47494
  WORLD_SYSTEM_CLASS_DEFINITIONS.map((definition2) => definition2.worldKind)
47546
47495
  );
47547
- WORLD_SYSTEM_CLASS_DEFINITION_BY_KIND = new Map(
47548
- WORLD_SYSTEM_CLASS_DEFINITIONS.map((definition2) => [
47549
- definition2.worldKind,
47550
- definition2
47551
- ])
47552
- );
47553
47496
  WORLD_SYSTEM_SCHEMA_FIELD_SITES_BY_MEMBER_ID = new Map(
47554
47497
  WORLD_SYSTEM_CLASS_DEFINITIONS.flatMap(
47555
47498
  (definition2) => (definition2.schemaFields ?? []).map(
@@ -48302,7 +48245,288 @@ var init_instance_provenance = __esm({
48302
48245
  }
48303
48246
  });
48304
48247
 
48248
+ // ../src/models/members/unordered-list-membership.ts
48249
+ function buildUnorderedListMembershipIndex(values) {
48250
+ const membersByContainerId = /* @__PURE__ */ new Map();
48251
+ for (const candidate of values) {
48252
+ const containerId = candidate.containerId;
48253
+ if (typeof containerId !== "string") continue;
48254
+ const bucket = membersByContainerId.get(containerId);
48255
+ if (bucket === void 0) {
48256
+ membersByContainerId.set(containerId, [candidate.id]);
48257
+ } else {
48258
+ bucket.push(candidate.id);
48259
+ }
48260
+ }
48261
+ for (const bucket of membersByContainerId.values()) {
48262
+ bucket.sort();
48263
+ }
48264
+ return membersByContainerId;
48265
+ }
48266
+ function unorderedListEntryIds(values, listValue2, membershipIndex) {
48267
+ if (!Array.isArray(listValue2.value)) return [];
48268
+ if (membershipIndex !== void 0) {
48269
+ return [...membershipIndex.get(listValue2.id) ?? []];
48270
+ }
48271
+ const ids = [];
48272
+ for (const candidate of values) {
48273
+ if (candidate.containerId === listValue2.id) ids.push(candidate.id);
48274
+ }
48275
+ ids.sort();
48276
+ return ids;
48277
+ }
48278
+ function listEntryIdsForValue(member, listValue2, values) {
48279
+ if (listValue2.value === null) return [];
48280
+ if (listKindOf(member) === "unordered") {
48281
+ return unorderedListEntryIds(values, listValue2);
48282
+ }
48283
+ if (!Array.isArray(listValue2.value)) return [];
48284
+ return listValue2.value.filter(
48285
+ (entry) => typeof entry === "string"
48286
+ );
48287
+ }
48288
+ var init_unordered_list_membership = __esm({
48289
+ "../src/models/members/unordered-list-membership.ts"() {
48290
+ "use strict";
48291
+ init_member_kinds();
48292
+ }
48293
+ });
48294
+
48305
48295
  // ../src/models/members/read-only-members.ts
48296
+ function collectReadOnlyClassValueSites(document, selectedMemberId) {
48297
+ const membersById2 = new Map(
48298
+ document.members.map((member) => [member.id, member])
48299
+ );
48300
+ const valuesById = new Map(document.values.map((value) => [value.id, value]));
48301
+ const unorderedMembership = buildUnorderedListMembershipIndex(
48302
+ document.values
48303
+ );
48304
+ const visited = /* @__PURE__ */ new Set();
48305
+ const siteKeys = /* @__PURE__ */ new Set();
48306
+ const sites = [];
48307
+ const visit = (rawMember, valueId) => {
48308
+ const member = resolveMember2(rawMember, document.members);
48309
+ const memberIdentity = "id" in rawMember && typeof rawMember.id === "string" ? rawMember.id : `class:${isMemberClassBase(member) ? member.classId : member.kind}`;
48310
+ const visitKey = `${memberIdentity}\0${valueId}`;
48311
+ if (visited.has(visitKey)) return;
48312
+ visited.add(visitKey);
48313
+ const value = valuesById.get(valueId);
48314
+ if (value === void 0) return;
48315
+ if (isMemberListBase(member) || isMemberDictionaryBase(member)) {
48316
+ const entry = membersById2.get(member.entryMemberId);
48317
+ if (entry === void 0) return;
48318
+ const childIds = isMemberListBase(member) && listKindOf(member) === "unordered" ? unorderedMembership.get(value.id) ?? [] : Array.isArray(value.value) ? value.value : isStringRecord(value.value) ? Object.values(value.value) : [];
48319
+ for (const childId of childIds) visit(entry, childId);
48320
+ return;
48321
+ }
48322
+ if (!isMemberClassBase(member) || !isStringRecord(value.value)) return;
48323
+ const effectiveClassId = value.classId ?? member.classId;
48324
+ const env = resolveInstanceEnv(
48325
+ effectiveClassId,
48326
+ member.classArguments,
48327
+ document.classes
48328
+ );
48329
+ for (const entry of mergeInstanceSurfaceSchema(
48330
+ effectiveClassId,
48331
+ document.classes,
48332
+ document.members
48333
+ )) {
48334
+ if (entry.memberId === selectedMemberId) {
48335
+ const siteKey = `${value.id}\0${entry.schemaKey}`;
48336
+ if (!siteKeys.has(siteKey)) {
48337
+ siteKeys.add(siteKey);
48338
+ sites.push({
48339
+ value,
48340
+ record: value.value,
48341
+ schemaKey: entry.schemaKey,
48342
+ effectiveClassId
48343
+ });
48344
+ }
48345
+ }
48346
+ const childId = value.value[entry.schemaKey];
48347
+ const childMember = membersById2.get(entry.memberId);
48348
+ if (childMember === void 0 || typeof childId !== "string") continue;
48349
+ visit(substituteMember(childMember, env, document.members), childId);
48350
+ }
48351
+ };
48352
+ for (const member of document.members) {
48353
+ if (typeof member.valueId === "string") visit(member, member.valueId);
48354
+ if (member.defaultValue == null) continue;
48355
+ const synthetic = {
48356
+ id: `__default:${member.id}`,
48357
+ projectId: member.projectId,
48358
+ createdAt: member.createdAt,
48359
+ updatedAt: member.updatedAt,
48360
+ ...member.defaultValue
48361
+ };
48362
+ valuesById.set(synthetic.id, synthetic);
48363
+ visit(member, synthetic.id);
48364
+ }
48365
+ for (const value of document.values) {
48366
+ if (typeof value.classId !== "string") continue;
48367
+ visit(syntheticClassRowMember(value), value.id);
48368
+ }
48369
+ return sites.filter((site) => !site.value.id.startsWith("__default:"));
48370
+ }
48371
+ function collectValuesReachableWithoutReadOnlyBinding(document, excludedMemberId) {
48372
+ const membersById2 = new Map(
48373
+ document.members.map((member) => [member.id, member])
48374
+ );
48375
+ const valuesById = new Map(document.values.map((value) => [value.id, value]));
48376
+ const unorderedMembership = buildUnorderedListMembershipIndex(
48377
+ document.values
48378
+ );
48379
+ const reachable = /* @__PURE__ */ new Set();
48380
+ const visitBody = (rawMember, body, classId, ownerValueId) => {
48381
+ const member = resolveMember2(rawMember, document.members);
48382
+ const visitChild = (childMember, childId) => {
48383
+ if (childMember === void 0 || typeof childId !== "string") return;
48384
+ if (reachable.has(childId)) return;
48385
+ const child = valuesById.get(childId);
48386
+ if (child === void 0) return;
48387
+ reachable.add(childId);
48388
+ visitBody(childMember, child.value, child.classId ?? void 0, child.id);
48389
+ };
48390
+ if (isMemberListBase(member)) {
48391
+ const entry = membersById2.get(member.entryMemberId);
48392
+ if (listKindOf(member) === "unordered" && ownerValueId !== void 0) {
48393
+ for (const childId of unorderedMembership.get(ownerValueId) ?? []) {
48394
+ visitChild(entry, childId);
48395
+ }
48396
+ } else if (Array.isArray(body)) {
48397
+ for (const childId of body) visitChild(entry, childId);
48398
+ }
48399
+ return;
48400
+ }
48401
+ if (isMemberDictionaryBase(member) && isStringRecord(body)) {
48402
+ const entry = membersById2.get(member.entryMemberId);
48403
+ for (const childId of Object.values(body)) visitChild(entry, childId);
48404
+ return;
48405
+ }
48406
+ if (!isMemberClassBase(member) || !isStringRecord(body)) return;
48407
+ const effectiveClassId = classId ?? member.classId;
48408
+ const env = resolveInstanceEnv(
48409
+ effectiveClassId,
48410
+ member.classArguments,
48411
+ document.classes
48412
+ );
48413
+ for (const entry of mergeInstanceSurfaceSchema(
48414
+ effectiveClassId,
48415
+ document.classes,
48416
+ document.members
48417
+ )) {
48418
+ if (entry.memberId === excludedMemberId) continue;
48419
+ const childMember = membersById2.get(entry.memberId);
48420
+ visitChild(
48421
+ childMember === void 0 ? void 0 : substituteMember(childMember, env, document.members),
48422
+ body[entry.schemaKey]
48423
+ );
48424
+ }
48425
+ };
48426
+ for (const member of document.members) {
48427
+ if (member.id !== excludedMemberId && typeof member.valueId === "string") {
48428
+ const value = valuesById.get(member.valueId);
48429
+ if (value !== void 0) {
48430
+ reachable.add(value.id);
48431
+ visitBody(member, value.value, value.classId ?? void 0, value.id);
48432
+ }
48433
+ }
48434
+ if (member.defaultValue != null) {
48435
+ visitBody(
48436
+ member,
48437
+ member.defaultValue.value,
48438
+ member.defaultValue.classId ?? void 0,
48439
+ void 0
48440
+ );
48441
+ }
48442
+ }
48443
+ const referencedValueIds = collectStructurallyReferencedValueIds(
48444
+ document.values
48445
+ );
48446
+ const boundRootIds = new Set(
48447
+ document.members.flatMap(
48448
+ (member) => typeof member.valueId === "string" ? [member.valueId] : []
48449
+ )
48450
+ );
48451
+ for (const value of document.values) {
48452
+ if (typeof value.classId !== "string") continue;
48453
+ if (referencedValueIds.has(value.id) || boundRootIds.has(value.id)) {
48454
+ continue;
48455
+ }
48456
+ reachable.add(value.id);
48457
+ visitBody(
48458
+ syntheticClassRowMember(value),
48459
+ value.value,
48460
+ value.classId,
48461
+ value.id
48462
+ );
48463
+ }
48464
+ return reachable;
48465
+ }
48466
+ function remapReadOnlyConversionValueIds(values, memberId, ownerValueId) {
48467
+ const remapped = /* @__PURE__ */ new Map();
48468
+ values.forEach((value, index) => {
48469
+ remapped.set(
48470
+ value.id,
48471
+ v5_default(
48472
+ `neo-compose:readonly-conversion:${memberId}:${ownerValueId}:${index}`,
48473
+ v5_default.URL
48474
+ )
48475
+ );
48476
+ });
48477
+ const rewrite = (value) => {
48478
+ if (typeof value === "string") return remapped.get(value) ?? value;
48479
+ if (Array.isArray(value)) return value.map(rewrite);
48480
+ if (value === null || typeof value !== "object") return value;
48481
+ return Object.fromEntries(
48482
+ Object.entries(value).map(([key, child]) => [key, rewrite(child)])
48483
+ );
48484
+ };
48485
+ for (const value of values) {
48486
+ value.id = remapped.get(value.id) ?? value.id;
48487
+ value.value = rewrite(value.value);
48488
+ if (typeof value.containerId === "string") {
48489
+ value.containerId = remapped.get(value.containerId) ?? value.containerId;
48490
+ }
48491
+ }
48492
+ }
48493
+ function collectStructurallyReferencedValueIds(values) {
48494
+ const valueIds = new Set(values.map((value) => value.id));
48495
+ const referenced = /* @__PURE__ */ new Set();
48496
+ for (const value of values) {
48497
+ const candidates = Array.isArray(value.value) ? value.value : isStringRecord(value.value) ? Object.values(value.value) : [];
48498
+ for (const candidate of candidates) {
48499
+ if (typeof candidate === "string" && valueIds.has(candidate)) {
48500
+ referenced.add(candidate);
48501
+ }
48502
+ }
48503
+ if (typeof value.containerId === "string") referenced.add(value.id);
48504
+ }
48505
+ return referenced;
48506
+ }
48507
+ function syntheticClassRowMember(value) {
48508
+ const classId = value.classId;
48509
+ if (typeof classId !== "string") {
48510
+ throw new Error(
48511
+ `Partitioned class row "${value.id}" has no effective class id.`
48512
+ );
48513
+ }
48514
+ return {
48515
+ name: "Partitioned class row",
48516
+ kind: 7 /* Class */,
48517
+ classId,
48518
+ locked: false,
48519
+ required: true,
48520
+ isStatic: false,
48521
+ accessModifierKind: "public"
48522
+ };
48523
+ }
48524
+ function isStringRecord(value) {
48525
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
48526
+ return false;
48527
+ }
48528
+ return Object.values(value).every((child) => typeof child === "string");
48529
+ }
48306
48530
  function assertReadOnlyMembersValid(document) {
48307
48531
  const membersById2 = new Map(
48308
48532
  document.members.map((member) => [member.id, member])
@@ -48621,6 +48845,8 @@ var init_read_only_members = __esm({
48621
48845
  init_member_kinds();
48622
48846
  init_instance_provenance();
48623
48847
  init_member_storage();
48848
+ init_unordered_list_membership();
48849
+ init_dist_node();
48624
48850
  VALUELESS_KINDS = /* @__PURE__ */ new Set([
48625
48851
  10 /* NSProperty */,
48626
48852
  13 /* Function */,
@@ -48638,53 +48864,6 @@ var init_member_kinds_db_response = __esm({
48638
48864
  }
48639
48865
  });
48640
48866
 
48641
- // ../src/models/members/unordered-list-membership.ts
48642
- function buildUnorderedListMembershipIndex(values) {
48643
- const membersByContainerId = /* @__PURE__ */ new Map();
48644
- for (const candidate of values) {
48645
- const containerId = candidate.containerId;
48646
- if (typeof containerId !== "string") continue;
48647
- const bucket = membersByContainerId.get(containerId);
48648
- if (bucket === void 0) {
48649
- membersByContainerId.set(containerId, [candidate.id]);
48650
- } else {
48651
- bucket.push(candidate.id);
48652
- }
48653
- }
48654
- for (const bucket of membersByContainerId.values()) {
48655
- bucket.sort();
48656
- }
48657
- return membersByContainerId;
48658
- }
48659
- function unorderedListEntryIds(values, listValue2, membershipIndex) {
48660
- if (!Array.isArray(listValue2.value)) return [];
48661
- if (membershipIndex !== void 0) {
48662
- return [...membershipIndex.get(listValue2.id) ?? []];
48663
- }
48664
- const ids = [];
48665
- for (const candidate of values) {
48666
- if (candidate.containerId === listValue2.id) ids.push(candidate.id);
48667
- }
48668
- ids.sort();
48669
- return ids;
48670
- }
48671
- function listEntryIdsForValue(member, listValue2, values) {
48672
- if (listValue2.value === null) return [];
48673
- if (listKindOf(member) === "unordered") {
48674
- return unorderedListEntryIds(values, listValue2);
48675
- }
48676
- if (!Array.isArray(listValue2.value)) return [];
48677
- return listValue2.value.filter(
48678
- (entry) => typeof entry === "string"
48679
- );
48680
- }
48681
- var init_unordered_list_membership = __esm({
48682
- "../src/models/members/unordered-list-membership.ts"() {
48683
- "use strict";
48684
- init_member_kinds();
48685
- }
48686
- });
48687
-
48688
48867
  // ../src/models/members/member-storage-key.ts
48689
48868
  function normalizeStorageKeyDeclaration(declaration) {
48690
48869
  if (declaration === void 0 || declaration === null) {
@@ -48846,56 +49025,6 @@ var init_storage_partitions = __esm({
48846
49025
  }
48847
49026
  });
48848
49027
 
48849
- // ../src/models/core/deep-clone-plain-data.ts
48850
- function deepClonePlainData(value) {
48851
- return clonePlain(value, "$", /* @__PURE__ */ new Set());
48852
- }
48853
- function clonePlain(value, path, visiting) {
48854
- if (value === null || typeof value !== "object") {
48855
- if (typeof value === "function") {
48856
- throw new Error(
48857
- `Plain-data clone met a function at ${path}; value data never stores callables.`
48858
- );
48859
- }
48860
- if (typeof value === "symbol") {
48861
- throw new Error(
48862
- `Plain-data clone met a symbol at ${path}; value data never stores symbols.`
48863
- );
48864
- }
48865
- if (typeof value === "bigint") {
48866
- throw new Error(
48867
- `Plain-data clone met a bigint at ${path}; value data stores numbers only.`
48868
- );
48869
- }
48870
- return value;
48871
- }
48872
- if (visiting.has(value)) {
48873
- throw new Error(
48874
- `Plain-data clone met a cycle at ${path}; value data is acyclic by storage contract.`
48875
- );
48876
- }
48877
- visiting.add(value);
48878
- try {
48879
- if (Array.isArray(value)) {
48880
- return value.map(
48881
- (entry, index) => clonePlain(entry, `${path}[${index}]`, visiting)
48882
- );
48883
- }
48884
- const clone = {};
48885
- for (const [key, entry] of Object.entries(value)) {
48886
- clone[key] = clonePlain(entry, `${path}.${key}`, visiting);
48887
- }
48888
- return clone;
48889
- } finally {
48890
- visiting.delete(value);
48891
- }
48892
- }
48893
- var init_deep_clone_plain_data = __esm({
48894
- "../src/models/core/deep-clone-plain-data.ts"() {
48895
- "use strict";
48896
- }
48897
- });
48898
-
48899
49028
  // ../src/models/unity/unity-import-settings.ts
48900
49029
  function buildDefaultUnityTexture2DImportSettings() {
48901
49030
  return {
@@ -50022,6 +50151,85 @@ function recordStorageKeyDeclaration(sink, valueId, member) {
50022
50151
  if (declaration === STORAGE_KEY_INHERIT) return;
50023
50152
  sink.set(valueId, declaration);
50024
50153
  }
50154
+ function createDefaultValueResolutionCache() {
50155
+ return {
50156
+ memberByIdIndex: null,
50157
+ instanceEnvironmentByKey: /* @__PURE__ */ new Map(),
50158
+ materializationPlanByClassAndEnvironment: /* @__PURE__ */ new Map(),
50159
+ resolvedMemberById: /* @__PURE__ */ new Map(),
50160
+ storedSchemaByClassId: /* @__PURE__ */ new Map(),
50161
+ validatedInitializerContainers: /* @__PURE__ */ new WeakSet()
50162
+ };
50163
+ }
50164
+ function withIndexedDefaultValueDocument(document, options = {}) {
50165
+ const cache = options.cache ?? createDefaultValueResolutionCache();
50166
+ if (cache.memberByIdIndex === null && options.memberById === void 0 && document.memberById === void 0) {
50167
+ cache.memberByIdIndex = new Map(
50168
+ document.members.map((member) => [member.id, member])
50169
+ );
50170
+ }
50171
+ const indexed = {
50172
+ ...document,
50173
+ memberById: (id2) => options.memberById?.(id2) ?? document.memberById?.(id2) ?? cache.memberByIdIndex?.get(id2) ?? null,
50174
+ resolvedMember: (member) => {
50175
+ const memberId = "id" in member ? member.id : void 0;
50176
+ if (typeof memberId !== "string") {
50177
+ return resolveMember2(member, document.members);
50178
+ }
50179
+ const cached = cache.resolvedMemberById.get(memberId);
50180
+ if (cached !== void 0) return cached;
50181
+ const resolved = resolveMember2(member, document.members);
50182
+ cache.resolvedMemberById.set(memberId, resolved);
50183
+ return resolved;
50184
+ },
50185
+ storedInstanceSchema: (classId) => {
50186
+ const cached = cache.storedSchemaByClassId.get(classId);
50187
+ if (cached !== void 0) return cached;
50188
+ const schema = mergeStoredInstanceSchema(
50189
+ classId,
50190
+ document.classes,
50191
+ document.members
50192
+ );
50193
+ cache.storedSchemaByClassId.set(classId, schema);
50194
+ return schema;
50195
+ },
50196
+ instanceEnv: (classId, classArguments2) => {
50197
+ const key = `${classId}:${JSON.stringify(classArguments2 ?? null)}`;
50198
+ const cached = cache.instanceEnvironmentByKey.get(key);
50199
+ if (cached !== void 0) return cached;
50200
+ const environment = resolveInstanceEnv(
50201
+ classId,
50202
+ classArguments2,
50203
+ document.classes
50204
+ );
50205
+ cache.instanceEnvironmentByKey.set(key, environment);
50206
+ return environment;
50207
+ },
50208
+ isInitValueContent: (value) => {
50209
+ if (typeof value !== "object" || value === null) return false;
50210
+ if (cache.validatedInitializerContainers.has(value)) return true;
50211
+ if (!isInitValueContent(value)) return false;
50212
+ cache.validatedInitializerContainers.add(value);
50213
+ return true;
50214
+ },
50215
+ createValueRow: options.createValueRow ?? document.createValueRow
50216
+ };
50217
+ indexed.storedInstanceMaterializationPlan = (classId, environment) => {
50218
+ let byEnvironment = cache.materializationPlanByClassAndEnvironment.get(classId);
50219
+ const cached = byEnvironment?.get(environment);
50220
+ if (cached !== void 0) return cached;
50221
+ const plan = buildDefaultClassMaterializationPlan(
50222
+ indexed,
50223
+ classId,
50224
+ environment
50225
+ );
50226
+ byEnvironment ??= /* @__PURE__ */ new WeakMap();
50227
+ byEnvironment.set(environment, plan);
50228
+ cache.materializationPlanByClassAndEnvironment.set(classId, byEnvironment);
50229
+ return plan;
50230
+ };
50231
+ return indexed;
50232
+ }
50025
50233
  function documentHasInitValueContent(document, value) {
50026
50234
  return document.isInitValueContent?.(value) ?? isInitValueContent(value);
50027
50235
  }
@@ -50423,7 +50631,7 @@ function buildNewValue(projectId, body, timestamp = Date.now()) {
50423
50631
  updatedAt: timestamp
50424
50632
  };
50425
50633
  if (body.constructorArgs !== void 0 && body.constructorArgs !== null) {
50426
- props.constructorArgs = cloneJsonValue(body.constructorArgs);
50634
+ props.constructorArgs = deepClonePlainData(body.constructorArgs);
50427
50635
  }
50428
50636
  if (body.instanceConstructorId !== void 0) {
50429
50637
  props.instanceConstructorId = body.instanceConstructorId;
@@ -50460,7 +50668,7 @@ function retargetDelegateReceiverValueIds(rows, fromValueId, toValueId) {
50460
50668
  }
50461
50669
  function cloneDefaultClassRecord(args) {
50462
50670
  const sourceValue = args.sourceBody?.value;
50463
- if (!isStringRecord(sourceValue)) return {};
50671
+ if (!isStringRecord2(sourceValue)) return {};
50464
50672
  const record3 = {};
50465
50673
  const entries = getSchemaEntryMap(args.document, args.effectiveClassId);
50466
50674
  for (const [schemaKey, sourceValueId] of Object.entries(sourceValue)) {
@@ -50535,7 +50743,7 @@ function cloneDefaultListRecord(args) {
50535
50743
  }
50536
50744
  function cloneDefaultDictionaryRecord(args) {
50537
50745
  const sourceValue = args.sourceBody?.value;
50538
- if (!isStringRecord(sourceValue)) return { value: {} };
50746
+ if (!isStringRecord2(sourceValue)) return { value: {} };
50539
50747
  const entryMember = findMemberInDocument(
50540
50748
  args.document,
50541
50749
  args.member.entryMemberId
@@ -50711,27 +50919,17 @@ function getSchemaEntryMap(document, classId) {
50711
50919
  }
50712
50920
  function cloneMemberValueBase(body) {
50713
50921
  return {
50714
- value: cloneJsonValue(body.value),
50922
+ value: deepClonePlainData(body.value),
50715
50923
  classId: body.classId,
50716
50924
  ...body.instanceConstructorId === void 0 ? {} : { instanceConstructorId: body.instanceConstructorId },
50717
50925
  ...body.instanceVariantId === void 0 ? {} : { instanceVariantId: body.instanceVariantId },
50718
50926
  ...body.instanceVariantRowValueId === void 0 ? {} : { instanceVariantRowValueId: body.instanceVariantRowValueId },
50719
50927
  ...body.constructorArgs === void 0 || body.constructorArgs === null ? {} : {
50720
- constructorArgs: cloneJsonValue(body.constructorArgs)
50928
+ constructorArgs: deepClonePlainData(body.constructorArgs)
50721
50929
  }
50722
50930
  };
50723
50931
  }
50724
- function cloneJsonValue(value) {
50725
- if (Array.isArray(value)) return value.map((entry) => cloneJsonValue(entry));
50726
- if (value === null) return null;
50727
- if (typeof value !== "object") return value;
50728
- const result = {};
50729
- for (const [key, entry] of Object.entries(value)) {
50730
- result[key] = cloneJsonValue(entry);
50731
- }
50732
- return result;
50733
- }
50734
- function isStringRecord(value) {
50932
+ function isStringRecord2(value) {
50735
50933
  if (value === null) return false;
50736
50934
  if (typeof value !== "object") return false;
50737
50935
  if (Array.isArray(value)) return false;
@@ -51261,7 +51459,7 @@ function validateDocumentListIndexes(ctx) {
51261
51459
  function resolveEffectiveSchemaField(schemaClass2, schemaKey, ctx, entrySlot) {
51262
51460
  let placement;
51263
51461
  try {
51264
- placement = mergeInstanceSchema(
51462
+ placement = mergeInstanceSurfaceSchema(
51265
51463
  schemaClass2.id,
51266
51464
  ctx.classes,
51267
51465
  ctx.members
@@ -51475,7 +51673,7 @@ var init_effective_storage = __esm({
51475
51673
  mergedSchema(classId) {
51476
51674
  const cached = this.mergedSchemaByClassId.get(classId);
51477
51675
  if (cached !== void 0) return cached;
51478
- const merged = mergeInstanceSchema(
51676
+ const merged = mergeInstanceSurfaceSchema(
51479
51677
  classId,
51480
51678
  this.ctx.classes,
51481
51679
  this.ctx.members
@@ -56118,6 +56316,319 @@ var init_dialogue_record_split = __esm({
56118
56316
  }
56119
56317
  });
56120
56318
 
56319
+ // ../src/models/localization/localization-types.ts
56320
+ function memberValueLocalizedTextLink(valueId) {
56321
+ return {
56322
+ kind: "member-value",
56323
+ recordKind: "value",
56324
+ recordId: valueId,
56325
+ fieldPath: "value",
56326
+ valueId
56327
+ };
56328
+ }
56329
+ function memberDefaultLocalizedTextLink(memberId) {
56330
+ return {
56331
+ kind: "member-default-value",
56332
+ recordKind: "member",
56333
+ recordId: memberId,
56334
+ fieldPath: "defaultValue.value"
56335
+ };
56336
+ }
56337
+ function dialogueNodeLocalizedTextLink(nodeId) {
56338
+ return {
56339
+ kind: "dialogue-node-text",
56340
+ recordKind: "dialogue-node",
56341
+ recordId: nodeId,
56342
+ fieldPath: "text",
56343
+ nodeId
56344
+ };
56345
+ }
56346
+ function dialogueChoiceLocalizedTextLink(nodeId, choiceId) {
56347
+ return {
56348
+ kind: "dialogue-choice-text",
56349
+ recordKind: "dialogue-node",
56350
+ recordId: nodeId,
56351
+ fieldPath: `optionSettings.options.${choiceId}.text`,
56352
+ nodeId,
56353
+ choiceId
56354
+ };
56355
+ }
56356
+ function localizedTextLinkIdentity(link) {
56357
+ switch (link.kind) {
56358
+ case "member-value":
56359
+ return JSON.stringify([link.kind, link.valueId]);
56360
+ case "member-default-value":
56361
+ case "dialogue-description":
56362
+ case "dialogue-group-name":
56363
+ case "priority-group-name":
56364
+ return JSON.stringify([link.kind, link.recordId]);
56365
+ case "dialogue-node-text":
56366
+ return JSON.stringify([link.kind, link.nodeId]);
56367
+ case "dialogue-choice-text":
56368
+ return JSON.stringify([link.kind, link.nodeId, link.choiceId]);
56369
+ }
56370
+ }
56371
+ function upsertLocalizedTextLink(links, link) {
56372
+ const identity2 = localizedTextLinkIdentity(link);
56373
+ const existingIndex = links.findIndex(
56374
+ (candidate) => localizedTextLinkIdentity(candidate) === identity2
56375
+ );
56376
+ if (existingIndex === -1) return [...links, link];
56377
+ const next = [...links];
56378
+ next[existingIndex] = { ...next[existingIndex], ...link };
56379
+ return next;
56380
+ }
56381
+ function isProjectLocaleConfig(value) {
56382
+ if (!isObject(value)) return false;
56383
+ const v = value;
56384
+ if (!isLocaleCode(v.locale)) return false;
56385
+ if (!isOptionalNullableString(v.sourceLocale)) return false;
56386
+ if (v.sourceLocale !== void 0 && v.sourceLocale !== null) {
56387
+ if (!isLocaleCode(v.sourceLocale)) return false;
56388
+ }
56389
+ if (!isOptionalNullableString(v.name)) return false;
56390
+ if (!isFiniteNumber(v.sortOrder)) return false;
56391
+ return isOptionalNullableDate(v.archivedAt);
56392
+ }
56393
+ function isProjectLocalizationConfigProps(value) {
56394
+ if (!isWithId(value)) return false;
56395
+ if (!isIWithTimestamps(value)) return false;
56396
+ const v = value;
56397
+ if (v.id !== PROJECT_LOCALIZATION_CONFIG_ID) return false;
56398
+ if (!isString(v.projectId)) return false;
56399
+ if (!isLocaleCode(v.mainLocale)) return false;
56400
+ if (!Array.isArray(v.supportedLocales)) return false;
56401
+ if (!v.supportedLocales.every(isProjectLocaleConfig)) return false;
56402
+ if (!isStringArray2(v.sortedStatusIds)) return false;
56403
+ return isString(v.mainLocaleDefaultStatusId);
56404
+ }
56405
+ function isProjectLocalizationConfig(value) {
56406
+ return isProjectLocalizationConfigProps(value);
56407
+ }
56408
+ function isLocalizationStatusProps(value) {
56409
+ if (!isWithId(value)) return false;
56410
+ if (!isIWithTimestamps(value)) return false;
56411
+ const v = value;
56412
+ if (!isString(v.projectId)) return false;
56413
+ if (!isSlug(v.slug)) return false;
56414
+ if (!isString(v.name)) return false;
56415
+ if (!isOptionalNullableString(v.description)) return false;
56416
+ if (!isOptionalNullableString(v.color)) return false;
56417
+ if (!isOptionalNullableString(v.emoji)) return false;
56418
+ if (!isOptionalNullableDate(v.archivedAt)) return false;
56419
+ if (!isNullableStringArray(v.transitionRules)) return false;
56420
+ if (!isNullableString(v.transitionToStatusIdOnEditText)) return false;
56421
+ if (!isNullableString(v.transitionToWhenSourceBecomesStatusId)) return false;
56422
+ if (v.system !== void 0 && v.system !== null) {
56423
+ return isSystemMetadata(v.system);
56424
+ }
56425
+ return true;
56426
+ }
56427
+ function isLocalizationStatus(value) {
56428
+ return isLocalizationStatusProps(value);
56429
+ }
56430
+ function isLocalizedTextLocaleValue(value) {
56431
+ if (!isObject(value)) return false;
56432
+ const v = value;
56433
+ if (!isNullableString(v.value)) return false;
56434
+ if (!isString(v.statusId)) return false;
56435
+ if (!isOptionalNullableString(v.localeComment)) return false;
56436
+ return isEpochMillis(v.updatedAt);
56437
+ }
56438
+ function isLocalizedTextLinkKind(value) {
56439
+ if (!isString(value)) return false;
56440
+ return LOCALIZED_TEXT_LINK_KINDS.includes(value);
56441
+ }
56442
+ function isLocalizedTextLink(value) {
56443
+ if (!isObject(value)) return false;
56444
+ const v = value;
56445
+ if (!isLocalizedTextLinkKind(v.kind)) return false;
56446
+ if (!isOptionalNullableString(v.recordKind)) return false;
56447
+ if (!isOptionalNullableString(v.recordId)) return false;
56448
+ if (!isOptionalNullableString(v.fieldPath)) return false;
56449
+ if (!isOptionalNullableString(v.valueId)) return false;
56450
+ if (!isOptionalNullableString(v.nodeId)) return false;
56451
+ if (!isOptionalNullableString(v.choiceId)) return false;
56452
+ switch (v.kind) {
56453
+ case "member-value":
56454
+ return isString(v.valueId);
56455
+ case "member-default-value":
56456
+ case "dialogue-description":
56457
+ case "dialogue-group-name":
56458
+ case "priority-group-name":
56459
+ return isString(v.recordId);
56460
+ case "dialogue-node-text":
56461
+ return v.recordKind === "dialogue-node" && isString(v.nodeId);
56462
+ case "dialogue-choice-text":
56463
+ return v.recordKind === "dialogue-node" && isString(v.nodeId) && isString(v.choiceId);
56464
+ }
56465
+ }
56466
+ function isLocalizedTextProps(value) {
56467
+ if (!isWithId(value)) return false;
56468
+ if (!isIWithTimestamps(value)) return false;
56469
+ const v = value;
56470
+ if (!isString(v.projectId)) return false;
56471
+ if (!isOptionalNullableString(v.sourceComment)) return false;
56472
+ if (!Array.isArray(v.links)) return false;
56473
+ if (!v.links.every(isLocalizedTextLink)) return false;
56474
+ if (!isOptionalNullableDate(v.archivedAt)) return false;
56475
+ return isLocaleValueRecord(v.localeValues);
56476
+ }
56477
+ function isLocalizedText(value) {
56478
+ return isLocalizedTextProps(value);
56479
+ }
56480
+ function isLocaleCode(value) {
56481
+ if (!isString(value)) return false;
56482
+ if (value.trim() !== value) return false;
56483
+ if (value.length === 0) return false;
56484
+ return /^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/.test(value);
56485
+ }
56486
+ function isLocaleValueRecord(value) {
56487
+ if (!isObject(value)) return false;
56488
+ for (const [locale, localeValue] of Object.entries(value)) {
56489
+ if (!isLocaleCode(locale)) return false;
56490
+ if (!isLocalizedTextLocaleValue(localeValue)) return false;
56491
+ }
56492
+ return true;
56493
+ }
56494
+ function isOptionalNullableDate(value) {
56495
+ if (value === void 0) return true;
56496
+ if (value === null) return true;
56497
+ return isEpochMillis(value);
56498
+ }
56499
+ function isFiniteNumber(value) {
56500
+ if (typeof value !== "number") return false;
56501
+ return Number.isFinite(value);
56502
+ }
56503
+ function isSlug(value) {
56504
+ if (!isString(value)) return false;
56505
+ return /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(value);
56506
+ }
56507
+ function isNullableString(value) {
56508
+ if (value === null) return true;
56509
+ return isString(value);
56510
+ }
56511
+ function isStringArray2(value) {
56512
+ if (!Array.isArray(value)) return false;
56513
+ return value.every(isString);
56514
+ }
56515
+ function isNullableStringArray(value) {
56516
+ if (value === null) return true;
56517
+ return isStringArray2(value);
56518
+ }
56519
+ var PROJECT_LOCALIZATION_CONFIG_ID, LOCALIZED_TEXT_LINK_KINDS;
56520
+ var init_localization_types = __esm({
56521
+ "../src/models/localization/localization-types.ts"() {
56522
+ "use strict";
56523
+ init_core();
56524
+ PROJECT_LOCALIZATION_CONFIG_ID = "system_b9f80fd7-7ed2-4344-a2b6-625ced732ed0";
56525
+ LOCALIZED_TEXT_LINK_KINDS = [
56526
+ "member-value",
56527
+ "member-default-value",
56528
+ "dialogue-description",
56529
+ "dialogue-node-text",
56530
+ "dialogue-choice-text",
56531
+ "dialogue-group-name",
56532
+ "priority-group-name"
56533
+ ];
56534
+ }
56535
+ });
56536
+
56537
+ // ../src/models/localization/localization-export.ts
56538
+ var init_localization_export = __esm({
56539
+ "../src/models/localization/localization-export.ts"() {
56540
+ "use strict";
56541
+ init_localization_types();
56542
+ }
56543
+ });
56544
+
56545
+ // ../src/models/localization/localization-import.ts
56546
+ var init_localization_import = __esm({
56547
+ "../src/models/localization/localization-import.ts"() {
56548
+ "use strict";
56549
+ }
56550
+ });
56551
+
56552
+ // ../src/models/localization/localized-text-create-envelope.ts
56553
+ function completeLocalizedTextCreateEnvelope(data, config) {
56554
+ const text = asUnknownRecord(data);
56555
+ if (text === null) return data;
56556
+ const localeValues = asUnknownRecord(text.localeValues);
56557
+ const mainLocaleValue = localeValues === null ? null : asUnknownRecord(localeValues[config.mainLocale]);
56558
+ const completedMainLocaleValue = mainLocaleValue === null ? null : {
56559
+ ...mainLocaleValue,
56560
+ ...mainLocaleValue.statusId === void 0 ? { statusId: config.mainLocaleDefaultStatusId } : {},
56561
+ ...mainLocaleValue.updatedAt === void 0 && text.updatedAt !== void 0 ? { updatedAt: text.updatedAt } : {}
56562
+ };
56563
+ return {
56564
+ ...text,
56565
+ ...text.links === void 0 ? { links: [] } : {},
56566
+ ...localeValues === null || completedMainLocaleValue === null ? {} : {
56567
+ localeValues: {
56568
+ ...localeValues,
56569
+ [config.mainLocale]: completedMainLocaleValue
56570
+ }
56571
+ }
56572
+ };
56573
+ }
56574
+ function buildLocalizedTextCreateForLink(args) {
56575
+ const completed = completeLocalizedTextCreateEnvelope(
56576
+ {
56577
+ id: args.id,
56578
+ projectId: args.projectId,
56579
+ sourceComment: null,
56580
+ links: [args.link],
56581
+ localeValues: {
56582
+ [args.config.mainLocale]: {
56583
+ value: args.value,
56584
+ localeComment: null
56585
+ }
56586
+ },
56587
+ createdAt: args.now,
56588
+ updatedAt: args.now
56589
+ },
56590
+ args.config
56591
+ );
56592
+ if (!isLocalizedText(completed)) {
56593
+ throw new Error(
56594
+ `Localized text "${args.id}" could not be completed into a valid create envelope.`
56595
+ );
56596
+ }
56597
+ return completed;
56598
+ }
56599
+ function asUnknownRecord(value) {
56600
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
56601
+ return null;
56602
+ }
56603
+ return value;
56604
+ }
56605
+ var init_localized_text_create_envelope = __esm({
56606
+ "../src/models/localization/localized-text-create-envelope.ts"() {
56607
+ "use strict";
56608
+ init_localization_types();
56609
+ }
56610
+ });
56611
+
56612
+ // ../src/models/localization/index.ts
56613
+ var init_localization2 = __esm({
56614
+ "../src/models/localization/index.ts"() {
56615
+ "use strict";
56616
+ init_localization_types();
56617
+ init_localization_export();
56618
+ init_localization_import();
56619
+ init_localized_text_create_envelope();
56620
+ }
56621
+ });
56622
+
56623
+ // ../src/models/dialogue/dialogue-localized-text-links.ts
56624
+ var init_dialogue_localized_text_links = __esm({
56625
+ "../src/models/dialogue/dialogue-localized-text-links.ts"() {
56626
+ "use strict";
56627
+ init_localization2();
56628
+ init_dialogue_types();
56629
+ }
56630
+ });
56631
+
56121
56632
  // ../src/models/dialogue/priority-types.ts
56122
56633
  function isPriorityTypeBase(value) {
56123
56634
  const v = value;
@@ -56199,6 +56710,7 @@ var init_dialogue_db_response_types = __esm({
56199
56710
  init_dialogue_types();
56200
56711
  init_dialogue_group_types();
56201
56712
  init_priority_types();
56713
+ init_localization_types();
56202
56714
  }
56203
56715
  });
56204
56716
 
@@ -56254,6 +56766,7 @@ var init_dialogue = __esm({
56254
56766
  init_dialogue_lookup_candidates();
56255
56767
  init_dialogue_diagnostics();
56256
56768
  init_dialogue_record_split();
56769
+ init_dialogue_localized_text_links();
56257
56770
  init_dialogue_group_types();
56258
56771
  init_dialogue_db_response_types();
56259
56772
  init_dialogue_triggering();
@@ -57895,10 +58408,23 @@ function neoVariantSystemClass(classes, lookup = false) {
57895
58408
  const declared = classes.find(
57896
58409
  (item) => item.system?.worldKind === (lookup ? NeoWorldSystemClassKind.LookupVariant : NeoWorldSystemClassKind.Variant)
57897
58410
  );
57898
- if (declared === void 0) return null;
58411
+ if (declared === void 0) {
58412
+ throw new Error(
58413
+ `Canonical ${lookup ? "NeoLookupVariant" : "NeoVariant"} system class is missing.`
58414
+ );
58415
+ }
57899
58416
  const targetParamId = declared.genericParams?.[0]?.id;
57900
- if (targetParamId === void 0) return null;
58417
+ if (targetParamId === void 0) {
58418
+ throw new Error(
58419
+ `Canonical ${lookup ? "NeoLookupVariant" : "NeoVariant"} system class "${declared.id}" is missing its target generic parameter.`
58420
+ );
58421
+ }
57901
58422
  const valueParamId = declared.genericParams?.[1]?.id;
58423
+ if (lookup && valueParamId === void 0) {
58424
+ throw new Error(
58425
+ `Canonical NeoLookupVariant system class "${declared.id}" is missing its value generic parameter.`
58426
+ );
58427
+ }
57902
58428
  return {
57903
58429
  classId: declared.id,
57904
58430
  targetParamId,
@@ -59141,9 +59667,6 @@ function lowerClass(context, declaration) {
59141
59667
  hiddenInMemberSelector: hasAnnotation2(declaration.annotations, "hidden"),
59142
59668
  system: systemMetadata(declaration.annotations),
59143
59669
  allowedStorage: storage ? storageValue(storage, "allowed") : null,
59144
- // Class storage keys never exist in source. Retain only the historical
59145
- // null representation while the clean-break record migration completes.
59146
- allowedStorageKeys: null,
59147
59670
  targetMemberId,
59148
59671
  genericParameters,
59149
59672
  extendsGenericBindings: extendsClassId && declaration.baseTypes[0]?.arguments.length ? lowerExtendsBindings(
@@ -59152,7 +59675,6 @@ function lowerClass(context, declaration) {
59152
59675
  extendsClassId,
59153
59676
  declaration.baseTypes[0].arguments
59154
59677
  ) : base?.extendsGenericBindings ?? {},
59155
- ...base?.constructorProjections === void 0 ? {} : { constructorProjections: base.constructorProjections },
59156
59678
  // P43 §6.3/§6.4: declaration order is the only ordering state, and a
59157
59679
  // constructor carries no schema key, so it never enters schemaKeyOrder.
59158
59680
  ...declaration.constructors.length === 0 ? {} : {
@@ -62127,7 +62649,7 @@ function buildStoredValuePlacementIndexV4(records2) {
62127
62649
  } else if (record3.recordKind === "class") {
62128
62650
  classes.push({
62129
62651
  id: record3.recordId,
62130
- ...isStringRecord2(record3.data.schema) ? { schema: record3.data.schema } : {},
62652
+ ...isStringRecord3(record3.data.schema) ? { schema: record3.data.schema } : {},
62131
62653
  ...typeof record3.data.extendsClassId === "string" || record3.data.extendsClassId === null ? { extendsClassId: record3.data.extendsClassId } : {},
62132
62654
  ...typeof record3.data.requiredConstructorId === "string" ? { requiredConstructorId: record3.data.requiredConstructorId } : {},
62133
62655
  ...Array.isArray(record3.data.genericParams) ? {
@@ -62287,7 +62809,7 @@ function memberStoresAggregate(member, parent, membersById2, parentValueId, clas
62287
62809
  }
62288
62810
  return false;
62289
62811
  }
62290
- function isStringRecord2(value) {
62812
+ function isStringRecord3(value) {
62291
62813
  return isObjectRecord2(value) && Object.values(value).every((entry) => typeof entry === "string");
62292
62814
  }
62293
62815
  var init_stored_value_placements = __esm({
@@ -62699,8 +63221,7 @@ function classToLanguageType(schemaClass2, context) {
62699
63221
  }
62700
63222
  function constructorSignature(schemaClass2, members, context, genericEnvironment) {
62701
63223
  if (schemaClass2.isAbstract) return {};
62702
- const projections = inheritedConstructorProjections(schemaClass2, context);
62703
- if (projections.length === 0 && !isClosedClass(schemaClass2.id, context.vm.classes)) {
63224
+ if (!isClosedClass(schemaClass2.id, context.vm.classes)) {
62704
63225
  return {};
62705
63226
  }
62706
63227
  if (resolveAllowedStorage(schemaClass2.id, context.vm.classes) === "immutable" /* Immutable */) {
@@ -62721,9 +63242,7 @@ function constructorSignature(schemaClass2, members, context, genericEnvironment
62721
63242
  defaultValue: "defaultValue" in resolved ? resolved.defaultValue : void 0
62722
63243
  };
62723
63244
  } catch {
62724
- return projections.some(
62725
- (projection) => projection.memberId === memberId
62726
- ) ? { required: true } : null;
63245
+ return null;
62727
63246
  }
62728
63247
  }
62729
63248
  );
@@ -62749,43 +63268,11 @@ function constructorSignature(schemaClass2, members, context, genericEnvironment
62749
63268
  defaultValue: "defaultValue" in resolved ? resolved.defaultValue : void 0
62750
63269
  };
62751
63270
  } catch {
62752
- if (projections.some((projection) => projection.memberId === memberId)) {
62753
- return { required: true };
62754
- }
62755
63271
  return null;
62756
63272
  }
62757
63273
  }
62758
63274
  );
62759
- return {
62760
- constructorSignature: {
62761
- ...signature,
62762
- ...projections.length === 0 ? {} : {
62763
- namedProjections: projections.map((projection) => ({
62764
- name: projection.parameterName,
62765
- memberId: projection.memberId
62766
- }))
62767
- }
62768
- }
62769
- };
62770
- }
62771
- function inheritedConstructorProjections(schemaClass2, context) {
62772
- const classesById2 = new Map(
62773
- context.vm.classes.map((candidate) => [candidate.id, candidate])
62774
- );
62775
- const projections = [];
62776
- const claimed = /* @__PURE__ */ new Set();
62777
- const visited = /* @__PURE__ */ new Set();
62778
- let current = schemaClass2;
62779
- while (current !== void 0 && !visited.has(current.id)) {
62780
- visited.add(current.id);
62781
- for (const projection of current.constructorProjections ?? []) {
62782
- if (claimed.has(projection.parameterName)) continue;
62783
- claimed.add(projection.parameterName);
62784
- projections.push(projection);
62785
- }
62786
- current = current.extendsClassId ? classesById2.get(current.extendsClassId) : void 0;
62787
- }
62788
- return projections;
63275
+ return { constructorSignature: signature };
62789
63276
  }
62790
63277
  function declaredConstructors(schemaClass2, context) {
62791
63278
  const requiredConstructorId2 = schemaClass2.requiredConstructorId;
@@ -63351,7 +63838,6 @@ function memberRuntimeType(record3, context, seen = /* @__PURE__ */ new Set(), g
63351
63838
  context.vm.classes,
63352
63839
  member.valueTypeInfo != null
63353
63840
  );
63354
- if (systemClass === null) return UNKNOWN_TYPE2;
63355
63841
  const target = toLanguageType(
63356
63842
  member.targetTypeInfo,
63357
63843
  context,
@@ -63907,7 +64393,7 @@ var init_neoscript_language_context_adapter = __esm({
63907
64393
  init_project_root_members();
63908
64394
  init_project_file_registry();
63909
64395
  init_analyzer_types();
63910
- NEOSCRIPT_COMPILER_ADAPTER_REVISION = 2;
64396
+ NEOSCRIPT_COMPILER_ADAPTER_REVISION = 3;
63911
64397
  UNKNOWN_TYPE2 = {
63912
64398
  kind: "primitive",
63913
64399
  name: "unknown"
@@ -65372,7 +65858,11 @@ function resolveSemanticOwnerMembersForValues(document, targetValueIds, addition
65372
65858
  }
65373
65859
  return result;
65374
65860
  }
65375
- const graph = new MaterializedValueGraphContext(document);
65861
+ const graph = new MaterializedValueGraphContext(
65862
+ document,
65863
+ new Map(document.values.map((value) => [value.id, value])),
65864
+ new Map((additionalRoots ?? []).map((root) => [root.valueId, root.member]))
65865
+ );
65376
65866
  const allValueIds = new Set(graph.valuesById.keys());
65377
65867
  const semanticRoots = [
65378
65868
  ...additionalRoots ?? []
@@ -65434,7 +65924,7 @@ function resolveSemanticOwnerMembersForValues(document, targetValueIds, addition
65434
65924
  }
65435
65925
  return result;
65436
65926
  }
65437
- function createTypedValueNormalizer(rows, document, childrenByContainerId, parameterTypesForRow, memberById2, memberTypeInfo) {
65927
+ function createTypedValueNormalizer(rows, document, childrenByContainerId, parameterTypesForRow, memberById2, memberTypeInfo, genericEnvironmentForRow) {
65438
65928
  const visiting = /* @__PURE__ */ new Set();
65439
65929
  const normalizeLiteral = (value) => {
65440
65930
  if (Array.isArray(value)) return value.map(normalizeLiteral);
@@ -65473,7 +65963,7 @@ function createTypedValueNormalizer(rows, document, childrenByContainerId, param
65473
65963
  ) : Array.isArray(row.value) ? row.value.map(
65474
65964
  (childId) => typeof childId === "string" ? normalizeTypedRow(childId, typeInfo.entryTypeInfo) : normalizeLiteral(childId)
65475
65965
  ) : normalizeLiteral(row.value);
65476
- } else if (typeInfo.type === 5 /* Dictionary */ && isStringRecord3(row.value)) {
65966
+ } else if (typeInfo.type === 5 /* Dictionary */ && isStringRecord4(row.value)) {
65477
65967
  value = Object.fromEntries(
65478
65968
  Object.entries(row.value).map(([key, childId]) => [
65479
65969
  key,
@@ -65487,7 +65977,7 @@ function createTypedValueNormalizer(rows, document, childrenByContainerId, param
65487
65977
  ...typeof row.classId === "string" ? { classId: row.classId } : {},
65488
65978
  ...row.genericBindings === void 0 ? {} : { genericBindings: row.genericBindings },
65489
65979
  value,
65490
- ...isLiteralValueContent(row) && row.constructorArgs !== void 0 && row.constructorArgs !== null ? {
65980
+ ...carriesSemanticConstructorArguments(row) ? {
65491
65981
  constructorArgs: normalizeConstructorArgs(row.constructorArgs, row)
65492
65982
  } : {}
65493
65983
  };
@@ -65507,18 +65997,24 @@ function createTypedValueNormalizer(rows, document, childrenByContainerId, param
65507
65997
  // the row's payload. Keep those strings literal instead of guessing
65508
65998
  // that UUID-shaped values are further row references.
65509
65999
  value: normalizeLiteral(row.value),
65510
- ...isLiteralValueContent(row) && row.constructorArgs !== void 0 && row.constructorArgs !== null ? {
66000
+ ...carriesSemanticConstructorArguments(row) ? {
65511
66001
  constructorArgs: normalizeConstructorArgs(row.constructorArgs, row)
65512
66002
  } : {}
65513
66003
  };
65514
66004
  visiting.delete(valueId);
65515
66005
  return normalized;
65516
66006
  };
66007
+ function carriesSemanticConstructorArguments(row) {
66008
+ if (!isLiteralValueContent(row)) return false;
66009
+ const constructorArgs = row.constructorArgs;
66010
+ if (constructorArgs === void 0 || constructorArgs === null) return false;
66011
+ return typeof row.instanceConstructorId === "string" || Object.keys(constructorArgs).length > 0;
66012
+ }
65517
66013
  const normalizeClassValue = (row, typeInfo) => {
65518
- if (!isStringRecord3(row.value)) return normalizeLiteral(row.value);
66014
+ if (!isStringRecord4(row.value)) return normalizeLiteral(row.value);
65519
66015
  const effectiveClassId = row.classId ?? (typeInfo.type === 7 /* Class */ ? typeInfo.classId : void 0);
65520
66016
  if (effectiveClassId === void 0) return normalizeLiteral(row.value);
65521
- const env = rowGenericEnvironment(document, row);
66017
+ const env = genericEnvironmentForRow(row);
65522
66018
  const merged = mergeStoredInstanceSchema(
65523
66019
  effectiveClassId,
65524
66020
  document.classes,
@@ -65603,7 +66099,7 @@ function collectSoftOwnedConstructorArgumentValueIds(index, ownerValueId, preser
65603
66099
  collectTypedRow(childId, typeInfo.entryTypeInfo);
65604
66100
  }
65605
66101
  }
65606
- } else if (typeInfo.type === 5 /* Dictionary */ && isStringRecord3(row.value)) {
66102
+ } else if (typeInfo.type === 5 /* Dictionary */ && isStringRecord4(row.value)) {
65607
66103
  for (const childId of Object.values(row.value)) {
65608
66104
  collectTypedRow(childId, typeInfo.entryTypeInfo);
65609
66105
  }
@@ -65625,7 +66121,7 @@ function collectSoftOwnedConstructorArgumentValueIds(index, ownerValueId, preser
65625
66121
  collectNestedConstructorArguments(valueId);
65626
66122
  };
65627
66123
  const collectClassChildren = (row, typeInfo) => {
65628
- if (!isStringRecord3(row.value)) return;
66124
+ if (!isStringRecord4(row.value)) return;
65629
66125
  const effectiveClassId = row.classId ?? (typeInfo.type === 7 /* Class */ ? typeInfo.classId : void 0);
65630
66126
  if (effectiveClassId === void 0) return;
65631
66127
  const env = rowGenericEnvironment(index.document, row);
@@ -65653,8 +66149,12 @@ function collectSoftOwnedConstructorArgumentValueIds(index, ownerValueId, preser
65653
66149
  }
65654
66150
  return collected;
65655
66151
  }
65656
- function rowGenericEnvironment(document, row) {
65657
- const env = typeof row.classId === "string" ? resolveInstanceEnv(row.classId, void 0, document.classes) : /* @__PURE__ */ new Map();
66152
+ function rowGenericEnvironment(document, row, contextualRootMember) {
66153
+ const env = typeof row.classId === "string" ? resolveInstanceEnv(
66154
+ row.classId,
66155
+ contextualRootMember !== void 0 && isMemberClassBase(contextualRootMember) ? contextualRootMember.classArguments : void 0,
66156
+ document.classes
66157
+ ) : /* @__PURE__ */ new Map();
65658
66158
  for (const [paramId, binding] of envFromStamp(row.genericBindings)) {
65659
66159
  env.set(paramId, binding);
65660
66160
  }
@@ -65694,7 +66194,7 @@ function tryMemberTypeInfo(document, rawMember, env) {
65694
66194
  function isAggregateTypeInfo(typeInfo) {
65695
66195
  return typeInfo.type === 7 /* Class */ || typeInfo.type === 22 /* Interface */ || typeInfo.type === 6 /* List */ || typeInfo.type === 5 /* Dictionary */;
65696
66196
  }
65697
- function isStringRecord3(value) {
66197
+ function isStringRecord4(value) {
65698
66198
  if (value === null || typeof value !== "object" || Array.isArray(value)) {
65699
66199
  return false;
65700
66200
  }
@@ -65739,6 +66239,7 @@ var init_constructor_argument_ownership = __esm({
65739
66239
  classesById;
65740
66240
  membersById;
65741
66241
  constructorsById;
66242
+ contextualRootMembersByValueId;
65742
66243
  parameterTypesByValueId = /* @__PURE__ */ new Map();
65743
66244
  settleConstructorParameter;
65744
66245
  aggregateTypeByTargetValueId = /* @__PURE__ */ new Map();
@@ -65746,9 +66247,10 @@ var init_constructor_argument_ownership = __esm({
65746
66247
  ownership;
65747
66248
  constructor(document, rows = new Map(
65748
66249
  document.values.map((value) => [value.id, value])
65749
- )) {
66250
+ ), contextualRootMembersByValueId = /* @__PURE__ */ new Map()) {
65750
66251
  this.valuesById = rows;
65751
66252
  this.document = { ...document, values: [...rows.values()] };
66253
+ this.contextualRootMembersByValueId = contextualRootMembersByValueId;
65752
66254
  this.classesById = new Map(
65753
66255
  document.classes.map((schemaClass2) => [schemaClass2.id, schemaClass2])
65754
66256
  );
@@ -65807,7 +66309,7 @@ var init_constructor_argument_ownership = __esm({
65807
66309
  if (constructor2 === void 0 || constructor2.classId !== root.classId) {
65808
66310
  return result;
65809
66311
  }
65810
- const env = rowGenericEnvironment(this.document, root);
66312
+ const env = this.genericEnvironmentForRow(root);
65811
66313
  for (let index = 0; index < constructor2.argumentTypes.length; index += 1) {
65812
66314
  const parameterId = constructorActionParameterId(constructor2, index);
65813
66315
  const rawTypeInfo = constructor2.argumentTypes[index];
@@ -65867,7 +66369,7 @@ var init_constructor_argument_ownership = __esm({
65867
66369
  ...settled,
65868
66370
  member: substituteMember(
65869
66371
  member,
65870
- rowGenericEnvironment(this.document, owner),
66372
+ this.genericEnvironmentForRow(owner),
65871
66373
  this.document.members
65872
66374
  )
65873
66375
  };
@@ -65927,7 +66429,8 @@ var init_constructor_argument_ownership = __esm({
65927
66429
  return resolved;
65928
66430
  },
65929
66431
  (memberId) => this.membersById.get(memberId),
65930
- (member, env) => this.memberTypeInfo(member, env)
66432
+ (member, env) => this.memberTypeInfo(member, env),
66433
+ (row) => this.genericEnvironmentForRow(row)
65931
66434
  );
65932
66435
  }
65933
66436
  ownerForValue(valueId) {
@@ -66017,7 +66520,8 @@ var init_constructor_argument_ownership = __esm({
66017
66520
  this.childrenByContainerId,
66018
66521
  (row) => this.constructorParameterTypes(row),
66019
66522
  (memberId) => this.membersById.get(memberId),
66020
- (member, env) => this.memberTypeInfo(member, env)
66523
+ (member, env) => this.memberTypeInfo(member, env),
66524
+ (row) => this.genericEnvironmentForRow(row)
66021
66525
  );
66022
66526
  return this.typedNormalizer;
66023
66527
  }
@@ -66039,6 +66543,13 @@ var init_constructor_argument_ownership = __esm({
66039
66543
  }
66040
66544
  return rawTypeInfo;
66041
66545
  }
66546
+ genericEnvironmentForRow(row) {
66547
+ return rowGenericEnvironment(
66548
+ this.document,
66549
+ row,
66550
+ this.contextualRootMembersByValueId.get(row.id)
66551
+ );
66552
+ }
66042
66553
  memberTypeInfo(rawMember, env) {
66043
66554
  try {
66044
66555
  const member = substituteMember(rawMember, env, this.document.members);
@@ -67705,12 +68216,8 @@ function evaluatorResolutionCache(ctx) {
67705
68216
  compiledFunctionByMemberId: /* @__PURE__ */ new Map(),
67706
68217
  compiledGetterByMemberId: /* @__PURE__ */ new Map(),
67707
68218
  compiledSetterByMemberId: /* @__PURE__ */ new Map(),
67708
- resolvedMemberById: /* @__PURE__ */ new Map(),
67709
- storedInstanceSchemaByClassId: /* @__PURE__ */ new Map(),
67710
- instanceEnvByKey: /* @__PURE__ */ new Map(),
68219
+ defaultValueResolutionCache: createDefaultValueResolutionCache(),
67711
68220
  validatedConstructorDescriptorByInfo: /* @__PURE__ */ new WeakMap(),
67712
- validatedInitValueContents: /* @__PURE__ */ new WeakSet(),
67713
- storedInstanceMaterializationPlanByClassAndEnv: /* @__PURE__ */ new Map(),
67714
68221
  effectiveStorageResolver: void 0
67715
68222
  };
67716
68223
  resolutionCacheByMembers.set(members, {
@@ -67723,37 +68230,31 @@ function evaluatorResolutionCache(ctx) {
67723
68230
  return cache;
67724
68231
  }
67725
68232
  function cachedResolvedMember(member, ctx) {
67726
- const memberId = member.id;
67727
- if (typeof memberId !== "string") {
67728
- return resolveMember2(member, ctx.vm.members);
67729
- }
67730
- const cache = evaluatorResolutionCache(ctx).resolvedMemberById;
67731
- const cached = cache.get(memberId);
67732
- if (cached !== void 0) return cached;
67733
- const resolved = resolveMember2(member, ctx.vm.members);
67734
- cache.set(memberId, resolved);
67735
- return resolved;
68233
+ return evaluatorDefaultValueDocument(ctx).resolvedMember(member);
67736
68234
  }
67737
68235
  function cachedStoredInstanceSchema(classId, ctx) {
67738
- const cache = evaluatorResolutionCache(ctx).storedInstanceSchemaByClassId;
67739
- const cached = cache.get(classId);
67740
- if (cached !== void 0) return cached;
67741
- const merged = mergeStoredInstanceSchema(
68236
+ return evaluatorDefaultValueDocument(ctx).storedInstanceSchema(classId);
68237
+ }
68238
+ function cachedStoredInstanceMaterializationPlan(classId, instanceEnv, ctx) {
68239
+ return evaluatorDefaultValueDocument(ctx).storedInstanceMaterializationPlan(
67742
68240
  classId,
67743
- ctx.vm.classes,
67744
- ctx.vm.members
68241
+ instanceEnv
67745
68242
  );
67746
- cache.set(classId, merged);
67747
- return merged;
67748
68243
  }
67749
- function cachedStoredInstanceMaterializationPlan(classId, instanceEnv, ctx) {
67750
- const cache = evaluatorResolutionCache(
67751
- ctx
67752
- ).storedInstanceMaterializationPlanByClassAndEnv;
67753
- let byEnvironment = cache.get(classId);
67754
- const cached = byEnvironment?.get(instanceEnv);
67755
- if (cached !== void 0) return cached;
67756
- const plan = buildDefaultClassMaterializationPlan(
68244
+ function cachedInstanceEnv(classId, classArguments2, ctx) {
68245
+ return evaluatorDefaultValueDocument(ctx).instanceEnv(
68246
+ classId,
68247
+ classArguments2
68248
+ );
68249
+ }
68250
+ function cachedIsInitValueContent(value, ctx) {
68251
+ return evaluatorDefaultValueDocument(ctx).isInitValueContent(value);
68252
+ }
68253
+ function evaluatorDefaultValueDocument(ctx) {
68254
+ if (ctx.__defaultValueDocument !== void 0) {
68255
+ return ctx.__defaultValueDocument;
68256
+ }
68257
+ const document = withIndexedDefaultValueDocument(
67757
68258
  {
67758
68259
  project: ctx.vm.project,
67759
68260
  members: ctx.vm.members,
@@ -67762,37 +68263,13 @@ function cachedStoredInstanceMaterializationPlan(classId, instanceEnv, ctx) {
67762
68263
  values: ctx.vm.values,
67763
68264
  memberById: ctx.vm.databaseVM?.memberById,
67764
68265
  valueById: ctx.vm.databaseVM?.valueById,
67765
- resolvedMember: (member) => cachedResolvedMember(member, ctx),
67766
- storedInstanceSchema: (nestedClassId) => cachedStoredInstanceSchema(nestedClassId, ctx),
67767
- instanceEnv: (nestedClassId, classArguments2) => cachedInstanceEnv(nestedClassId, classArguments2, ctx),
67768
- isInitValueContent: (value) => cachedIsInitValueContent(value, ctx),
67769
68266
  projectFiles: ctx.vm.projectFiles ?? [],
67770
68267
  textureTemplates: ctx.vm.textureTemplates ?? []
67771
68268
  },
67772
- classId,
67773
- instanceEnv
68269
+ { cache: evaluatorResolutionCache(ctx).defaultValueResolutionCache }
67774
68270
  );
67775
- byEnvironment ??= /* @__PURE__ */ new WeakMap();
67776
- byEnvironment.set(instanceEnv, plan);
67777
- cache.set(classId, byEnvironment);
67778
- return plan;
67779
- }
67780
- function cachedInstanceEnv(classId, classArguments2, ctx) {
67781
- const key = `${classId}:${JSON.stringify(classArguments2 ?? null)}`;
67782
- const cache = evaluatorResolutionCache(ctx).instanceEnvByKey;
67783
- const cached = cache.get(key);
67784
- if (cached !== void 0) return cached;
67785
- const resolved = resolveInstanceEnv(classId, classArguments2, ctx.vm.classes);
67786
- cache.set(key, resolved);
67787
- return resolved;
67788
- }
67789
- function cachedIsInitValueContent(value, ctx) {
67790
- if (typeof value !== "object" || value === null) return false;
67791
- const cache = evaluatorResolutionCache(ctx).validatedInitValueContents;
67792
- if (cache.has(value)) return true;
67793
- if (!isInitValueContent(value)) return false;
67794
- cache.add(value);
67795
- return true;
68271
+ ctx.__defaultValueDocument = document;
68272
+ return document;
67796
68273
  }
67797
68274
  function sessionCreationCheckpoint(ctx) {
67798
68275
  if (ctx.__sessionCreationStrategy === "snapshot") {
@@ -71131,7 +71608,7 @@ function evalKeyOf(keyOf, scope, ctx, optional = false, memberId, onReceiver) {
71131
71608
  if (dispatched.kind === "ok") return dispatched.value;
71132
71609
  if (!dispatched.matchedMember && memberId !== void 0) {
71133
71610
  const member = evalMemberById(ctx.vm, memberId);
71134
- const defaultValue = readOnlyDeclarationDefault(member, memberId, ctx);
71611
+ const defaultValue = readOnlyDeclarationDefault(member, ctx);
71135
71612
  if (defaultValue.matched) return defaultValue.value;
71136
71613
  }
71137
71614
  if (Object.prototype.hasOwnProperty.call(receiver, k)) {
@@ -71154,8 +71631,6 @@ function dispatchSchemaMember(receiver, schemaKey, ctx) {
71154
71631
  }
71155
71632
  const member = resolveRuntimeSchemaMember(receiver, schemaKey, ctx);
71156
71633
  if (!member) return { kind: "no-info", matchedMember: false };
71157
- const defaultValue = readOnlyDeclarationDefault(member, member.id, ctx);
71158
- if (defaultValue.matched) return { kind: "ok", value: defaultValue.value };
71159
71634
  if (member.kind === 10 /* NSProperty */) {
71160
71635
  if (!resolveCompiledGetter(member.id, ctx)) {
71161
71636
  return { kind: "no-info", matchedMember: true };
@@ -71165,6 +71640,8 @@ function dispatchSchemaMember(receiver, schemaKey, ctx) {
71165
71640
  value: dispatchNSGetterById(member.id, receiver, ctx)
71166
71641
  };
71167
71642
  }
71643
+ const defaultValue = readOnlyDeclarationDefault(member, ctx);
71644
+ if (defaultValue.matched) return { kind: "ok", value: defaultValue.value };
71168
71645
  if (!Object.prototype.hasOwnProperty.call(receiver, schemaKey)) {
71169
71646
  const expanded = virtualExpandedRecordForReceiver(receiver, ctx);
71170
71647
  if (expanded !== null && Object.prototype.hasOwnProperty.call(expanded, schemaKey)) {
@@ -71196,13 +71673,11 @@ function virtualExpandedRecordForReceiver(receiver, ctx) {
71196
71673
  }
71197
71674
  return record3;
71198
71675
  }
71199
- function readOnlyDeclarationDefault(member, memberId, ctx) {
71676
+ function readOnlyDeclarationDefault(member, ctx) {
71200
71677
  const readOnly = member?.isReadOnly;
71201
71678
  if (readOnly !== true) return { matched: false };
71202
71679
  if (member?.defaultValue === void 0 || member.defaultValue === null) {
71203
- throw new NSGetterRuntimeError(
71204
- `Read-only member '${member?.name ?? memberId}' has no declaration default.`
71205
- );
71680
+ return { matched: false };
71206
71681
  }
71207
71682
  let value = member.defaultValue.value;
71208
71683
  if (isMemberString(member) && member.localizable !== false && typeof value === "string") {
@@ -72571,7 +73046,7 @@ function validateClassConstructorDescriptor(info, ctx, requireEveryRequiredField
72571
73046
  return cacheDescriptor({ schemaClass: schemaClass2, fields, instanceEnv, classArguments: classArguments2 });
72572
73047
  }
72573
73048
  function assertConstructorFieldSlotWritable(args) {
72574
- const surfaceEntry = mergeInstanceSchema(
73049
+ const surfaceEntry = mergeInstanceSurfaceSchema(
72575
73050
  args.settledClassId,
72576
73051
  args.ctx.vm.classes,
72577
73052
  args.ctx.vm.members
@@ -73465,7 +73940,7 @@ function evaluateBaseInitializerFields(args) {
73465
73940
  );
73466
73941
  }
73467
73942
  const baseKeys = new Set(
73468
- mergeInstanceSchema(baseClassId, ctx.vm.classes, ctx.vm.members).map(
73943
+ mergeInstanceSurfaceSchema(baseClassId, ctx.vm.classes, ctx.vm.members).map(
73469
73944
  (entry) => entry.schemaKey
73470
73945
  )
73471
73946
  );
@@ -73551,6 +74026,16 @@ function constructionInitEvaluator(ctx, createdValues, argumentScopes, construct
73551
74026
  return null;
73552
74027
  };
73553
74028
  return (member, init, sourceValueId) => {
74029
+ const memberId = Reflect.get(member, "id");
74030
+ const effectiveMemberId = typeof memberId === "string" ? memberId : null;
74031
+ const scopeMemberId = indexes.initializerScopeMemberIds.get(init) ?? (typeof sourceValueId !== "string" ? void 0 : indexes.initializerScopeMemberIdsByValueId.get(sourceValueId)) ?? effectiveMemberId;
74032
+ const compiled = ensureInitializerCompiled({
74033
+ init,
74034
+ member,
74035
+ initializerCompiler: ctx.vm.initializerCompiler,
74036
+ sourceValueId: sourceValueId ?? null,
74037
+ compileMemberId: scopeMemberId
74038
+ });
73554
74039
  const evaluate = (argumentValues = []) => {
73555
74040
  return withConstructionGenericSlots(
73556
74041
  member,
@@ -73562,19 +74047,15 @@ function constructionInitEvaluator(ctx, createdValues, argumentScopes, construct
73562
74047
  ctx,
73563
74048
  createdValues,
73564
74049
  argumentValues,
73565
- sourceValueId ?? null
74050
+ sourceValueId ?? null,
74051
+ scopeMemberId
73566
74052
  )
73567
74053
  );
73568
74054
  };
73569
- if (init.compiled === void 0) {
73570
- return evaluate();
73571
- }
73572
- const memberId = Reflect.get(member, "id");
73573
- const scopeMemberId = indexes.initializerScopeMemberIds.get(init) ?? (typeof memberId === "string" ? memberId : "");
73574
- const ownerClassId = owningClassId(scopeMemberId);
73575
- const expectedArgumentCount = init.compiled?.parameters.slice(2).length;
74055
+ const ownerClassId = scopeMemberId === null ? null : owningClassId(scopeMemberId);
74056
+ const expectedArgumentCount = compiled.parameters.slice(2).length;
73576
74057
  if (ownerClassId === null) {
73577
- if (expectedArgumentCount !== void 0 && expectedArgumentCount > 0) {
74058
+ if (expectedArgumentCount > 0) {
73578
74059
  throw new NSGetterRuntimeError(
73579
74060
  `Member initializer '${member.name}' has ${expectedArgumentCount} constructor parameter(s), but its declaring class scope could not be resolved.`
73580
74061
  );
@@ -73618,6 +74099,7 @@ function constructorInitializerIndexes(ctx) {
73618
74099
  }
73619
74100
  function buildConstructorInitializerIndexes(vm) {
73620
74101
  const initializerScopeMemberIds = /* @__PURE__ */ new WeakMap();
74102
+ const initializerScopeMemberIdsByValueId = /* @__PURE__ */ new Map();
73621
74103
  const initializerByValueId = /* @__PURE__ */ new Map();
73622
74104
  for (const row of vm.values) {
73623
74105
  const initializer = Reflect.get(row, "init");
@@ -73648,6 +74130,7 @@ function buildConstructorInitializerIndexes(vm) {
73648
74130
  );
73649
74131
  if (typeof rootOwnerId === "string") {
73650
74132
  initializerScopeMemberIds.set(initializer, rootOwnerId);
74133
+ initializerScopeMemberIdsByValueId.set(valueId, rootOwnerId);
73651
74134
  }
73652
74135
  }
73653
74136
  const declaringClassIdsByMemberId = /* @__PURE__ */ new Map();
@@ -73667,6 +74150,7 @@ function buildConstructorInitializerIndexes(vm) {
73667
74150
  }
73668
74151
  return {
73669
74152
  initializerScopeMemberIds,
74153
+ initializerScopeMemberIdsByValueId,
73670
74154
  declaringClassIdsByMemberId,
73671
74155
  memberById: memberById2,
73672
74156
  containerMemberIdByEntryId
@@ -73715,18 +74199,15 @@ function runtimeValueReferencesVariable(value, variableId, visited = /* @__PURE_
73715
74199
  (child) => runtimeValueReferencesVariable(child, variableId, visited)
73716
74200
  );
73717
74201
  }
73718
- function evaluateInitializerInContext(init, member, ctx, createdValues, argumentValues = [], sourceValueId = null) {
74202
+ function evaluateInitializerInContext(init, member, ctx, createdValues, argumentValues = [], sourceValueId = null, compileMemberId) {
73719
74203
  ctx.__constructedArgumentsByValue ??= /* @__PURE__ */ new WeakMap();
73720
- const compiled = init.compiled;
73721
- if (compiled === void 0) {
73722
- const memberId = Reflect.get(member, "id");
73723
- throw new UncompiledInitializerRuntimeError(
73724
- typeof memberId === "string" ? memberId : null,
73725
- member.name,
73726
- init,
73727
- sourceValueId
73728
- );
73729
- }
74204
+ const compiled = ensureInitializerCompiled({
74205
+ init,
74206
+ member,
74207
+ initializerCompiler: ctx.vm.initializerCompiler,
74208
+ sourceValueId,
74209
+ compileMemberId
74210
+ });
73730
74211
  const closeFrame = pushConstructionFrame(ctx, `${member.name} initializer`);
73731
74212
  let result;
73732
74213
  try {
@@ -73783,6 +74264,31 @@ function evaluateInitializerInContext(init, member, ctx, createdValues, argument
73783
74264
  }
73784
74265
  };
73785
74266
  }
74267
+ function ensureInitializerCompiled(args) {
74268
+ let compiled = args.init.compiled;
74269
+ if (compiled === void 0) {
74270
+ const runtimeMemberId = Reflect.get(args.member, "id");
74271
+ let memberId = args.compileMemberId;
74272
+ if (memberId === void 0) {
74273
+ memberId = typeof runtimeMemberId === "string" ? runtimeMemberId : null;
74274
+ }
74275
+ const error = new UncompiledInitializerRuntimeError(
74276
+ memberId,
74277
+ args.member.name,
74278
+ args.init,
74279
+ args.sourceValueId ?? null
74280
+ );
74281
+ args.initializerCompiler?.({
74282
+ init: args.init,
74283
+ memberId,
74284
+ memberName: args.member.name,
74285
+ sourceValueId: args.sourceValueId ?? null
74286
+ });
74287
+ compiled = args.init.compiled;
74288
+ if (compiled === void 0) throw error;
74289
+ }
74290
+ return compiled;
74291
+ }
73786
74292
  function encodeLookupInitializerResult(member, value, created, ctx) {
73787
74293
  const selection2 = encodeLookupInitializerSelection(
73788
74294
  member,
@@ -73872,6 +74378,12 @@ function recordConstructorGroupDependency(valueId, destination, ctx) {
73872
74378
  }
73873
74379
  function encodeRequiredConstructorArgument(args) {
73874
74380
  const trackedId = findKnownRowIdByValueReference(args.value, args.ctx);
74381
+ const replayedAggregateId = trackedId === null && args.ctx.storedConstructionReplay === true && typeof args.value === "string" && evalValueById(
74382
+ args.ctx,
74383
+ args.value,
74384
+ args.ctx.__runtimeSessionValues,
74385
+ args.ctx.__valueOverlay
74386
+ ) !== null ? args.value : null;
73875
74387
  const adoptTracked = (id2, suffix) => {
73876
74388
  if (constructorGroupForRow(id2, args.ctx) !== null) {
73877
74389
  assertOwnedValueAttachable(
@@ -73894,18 +74406,20 @@ function encodeRequiredConstructorArgument(args) {
73894
74406
  }
73895
74407
  if (args.typeInfo.type === 7 /* Class */ || args.typeInfo.type === 22 /* Interface */) {
73896
74408
  if (args.value === null || args.value === void 0) return null;
73897
- if (trackedId === null) {
74409
+ const aggregateId2 = trackedId ?? replayedAggregateId;
74410
+ if (aggregateId2 === null) {
73898
74411
  throw new NSGetterRuntimeError(
73899
74412
  `Constructor aggregate argument '${args.parameterId}' has no backing value row.`
73900
74413
  );
73901
74414
  }
73902
- return adoptTracked(trackedId, "root");
74415
+ return adoptTracked(aggregateId2, "root");
73903
74416
  }
73904
74417
  if (args.typeInfo.type !== 6 /* List */ && args.typeInfo.type !== 5 /* Dictionary */) {
73905
74418
  return cloneConstructorLiteralValue(args.value);
73906
74419
  }
73907
74420
  if (args.value === null || args.value === void 0) return null;
73908
- if (trackedId !== null) return adoptTracked(trackedId, "root");
74421
+ const aggregateId = trackedId ?? replayedAggregateId;
74422
+ if (aggregateId !== null) return adoptTracked(aggregateId, "root");
73909
74423
  const collectionType = args.typeInfo;
73910
74424
  const registerRow = (value, containerId) => {
73911
74425
  const row2 = buildNewValue(args.ctx.vm.project.id, { value });
@@ -74533,10 +75047,10 @@ function evalVariantApply(info, scope, ctx) {
74533
75047
  graph,
74534
75048
  ctx
74535
75049
  );
74536
- const applyValueId = graph.root.Apply;
74537
- if (typeof applyValueId === "string" && applyValueId.length > 0) {
75050
+ const applyValue = graph.root.Apply;
75051
+ if (applyValue !== void 0 && applyValue !== null) {
74538
75052
  invokeVariantClosure({
74539
- closureValueId: applyValueId,
75053
+ closureValueId: applyValue,
74540
75054
  ctx,
74541
75055
  label: `Variant '${graph.name}' Apply`,
74542
75056
  lexicalThis: null,
@@ -76042,7 +76556,7 @@ function buildStoredValuePlacementIndex(args) {
76042
76556
  if (isMemberClassBase(member)) {
76043
76557
  const classId = value.classId ?? member.classId;
76044
76558
  appendPlacement(mutablePlacementsByClassId, classId, placement);
76045
- if (!isLiteralValueContent(value) || !isStringRecord4(value.value)) {
76559
+ if (!isLiteralValueContent(value) || !isStringRecord5(value.value)) {
76046
76560
  continue;
76047
76561
  }
76048
76562
  const settledChildrenBySchemaKey = /* @__PURE__ */ new Map();
@@ -76085,7 +76599,7 @@ function buildStoredValuePlacementIndex(args) {
76085
76599
  const entryMember = membersById2.get(member.entryMemberId);
76086
76600
  if (entryMember === void 0) continue;
76087
76601
  if (isMemberDictionaryBase(member)) {
76088
- if (!isStringRecord4(value.value)) continue;
76602
+ if (!isStringRecord5(value.value)) continue;
76089
76603
  for (const [key, childValueId] of Object.entries(value.value)) {
76090
76604
  queue.push({
76091
76605
  memberId: entryMember.id,
@@ -76133,7 +76647,7 @@ function appendPlacement(index, key, placement) {
76133
76647
  placements.push(placement);
76134
76648
  }
76135
76649
  }
76136
- function isStringRecord4(value) {
76650
+ function isStringRecord5(value) {
76137
76651
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
76138
76652
  return false;
76139
76653
  }
@@ -76151,6 +76665,32 @@ var init_stored_value_placement_index = __esm({
76151
76665
  });
76152
76666
 
76153
76667
  // ../src/database/virtual-instance-values.ts
76668
+ function buildVirtualInstanceMaterializedIndex(args) {
76669
+ const rowsById = new Map(
76670
+ (args.materializedRows ?? args.document.values).map((row) => [row.id, row])
76671
+ );
76672
+ const rows = [...rowsById.values()];
76673
+ return {
76674
+ rows,
76675
+ rowsById,
76676
+ graph: new MaterializedValueGraphContext(
76677
+ { ...args.document, values: rows },
76678
+ rowsById
76679
+ ),
76680
+ unorderedEntryIdsByContainerId: buildUnorderedListMembershipIndex(rows),
76681
+ constructorsById: new Map(
76682
+ (args.document.constructors ?? []).map((constructor2) => [
76683
+ constructor2.id,
76684
+ constructor2
76685
+ ])
76686
+ ),
76687
+ resolveConstructorSettlement: createConstructorSettlementResolver({
76688
+ classes: args.document.classes,
76689
+ constructors: args.document.constructors ?? [],
76690
+ members: args.document.members
76691
+ })
76692
+ };
76693
+ }
76154
76694
  function firstListInParameterType(typeInfo, depth = 0) {
76155
76695
  if (typeof typeInfo !== "object" || typeInfo === null) return null;
76156
76696
  if (depth > CONSTRUCTOR_TYPE_WALK_DEPTH_LIMIT) return "depth-limit";
@@ -76430,21 +76970,26 @@ function resolveVirtualInstanceGraph(args) {
76430
76970
  const unattributable = firstUnattributableExpansionMember(expansion);
76431
76971
  if (unattributable !== null) recorder.recordGlobalRead(unattributable);
76432
76972
  }
76433
- const materializedById = new Map(
76434
- (args.materializedRows ?? args.document.values).map((row) => [row.id, row])
76973
+ const materializedById = args.materializedIndex?.rowsById ?? new Map(
76974
+ (args.materializedRows ?? args.document.values).map((row) => [
76975
+ row.id,
76976
+ row
76977
+ ])
76435
76978
  );
76436
- const materializedRows = [...materializedById.values()];
76437
- const materializedGraph = args.materializedGraph ?? new MaterializedValueGraphContext(
76438
- { ...args.document, values: materializedRows },
76979
+ const materializedRows = args.materializedIndex?.rows ?? [
76980
+ ...materializedById.values()
76981
+ ];
76982
+ const materializedGraph = args.materializedGraph ?? args.materializedIndex?.graph ?? new MaterializedValueGraphContext(
76983
+ { ...args.document, values: [...materializedRows] },
76439
76984
  materializedById
76440
76985
  );
76441
- const constructorsById = new Map(
76986
+ const constructorsById = args.materializedIndex?.constructorsById ?? new Map(
76442
76987
  (args.document.constructors ?? []).map((constructor2) => [
76443
76988
  constructor2.id,
76444
76989
  constructor2
76445
76990
  ])
76446
76991
  );
76447
- const resolveConstructorSettlement = createConstructorSettlementResolver({
76992
+ const resolveConstructorSettlement = args.materializedIndex?.resolveConstructorSettlement ?? createConstructorSettlementResolver({
76448
76993
  classes: args.document.classes,
76449
76994
  constructors: args.document.constructors ?? [],
76450
76995
  members: args.document.members
@@ -76474,7 +77019,7 @@ function resolveVirtualInstanceGraph(args) {
76474
77019
  }
76475
77020
  return result;
76476
77021
  };
76477
- const materializedUnorderedEntryIdsByContainerId = buildUnorderedListMembershipIndex(materializedRows);
77022
+ const materializedUnorderedEntryIdsByContainerId = args.materializedIndex?.unorderedEntryIdsByContainerId ?? buildUnorderedListMembershipIndex(materializedRows);
76478
77023
  const readMaterializedRow = (valueId) => {
76479
77024
  recorder?.recordValueRead(valueId);
76480
77025
  return materializedById.get(valueId) ?? null;
@@ -76760,6 +77305,9 @@ function reportFrameResolutionDisagreement(args) {
76760
77305
  }
76761
77306
  function resolvedStoredInstanceRows(args) {
76762
77307
  const rows = new Map(args.document.values.map((row) => [row.id, row]));
77308
+ const materializedIndex = buildVirtualInstanceMaterializedIndex({
77309
+ document: args.document
77310
+ });
76763
77311
  const queue = [{ root: args.instanceRoot, member: args.rootMember }];
76764
77312
  const resolvedRootIds = /* @__PURE__ */ new Set();
76765
77313
  const resolvedFrameByValueId = /* @__PURE__ */ new Map();
@@ -76778,7 +77326,7 @@ function resolvedStoredInstanceRows(args) {
76778
77326
  rootMember: next.member,
76779
77327
  expandedRoot: expanded.root,
76780
77328
  expandedRows: expanded.rows,
76781
- materializedRows: args.document.values
77329
+ materializedIndex
76782
77330
  });
76783
77331
  for (const [id2, row] of graph.rowsById) {
76784
77332
  const priorFrame = resolvedFrameByValueId.get(id2);
@@ -77352,7 +77900,9 @@ function sparsifyConstructedInstance(args) {
77352
77900
  values: materializedRows
77353
77901
  };
77354
77902
  const materializedGraph = new MaterializedValueGraphContext(
77355
- constructionDocument
77903
+ constructionDocument,
77904
+ new Map(materializedRows.map((row) => [row.id, row])),
77905
+ /* @__PURE__ */ new Map([[args.constructed.root.id, args.rootMember]])
77356
77906
  );
77357
77907
  const graph = resolveVirtualInstanceGraph({
77358
77908
  document: args.document,
@@ -77749,7 +78299,7 @@ function planAtomicCollectionOverrideWrite(args) {
77749
78299
  creates.push(
77750
78300
  createFromVirtual(
77751
78301
  location3,
77752
- location3.pathKey === args.target.pathKey ? args.value : cloneJsonValue2(effective.value)
78302
+ location3.pathKey === args.target.pathKey ? args.value : deepClonePlainData(effective.value)
77753
78303
  )
77754
78304
  );
77755
78305
  }
@@ -78027,14 +78577,7 @@ function stringRecord2(value) {
78027
78577
  );
78028
78578
  }
78029
78579
  function cloneRow(row) {
78030
- return cloneJsonValue2(row);
78031
- }
78032
- function cloneJsonValue2(value) {
78033
- if (Array.isArray(value)) return value.map(cloneJsonValue2);
78034
- if (value === null || typeof value !== "object") return value;
78035
- return Object.fromEntries(
78036
- Object.entries(value).map(([key, entry]) => [key, cloneJsonValue2(entry)])
78037
- );
78580
+ return deepClonePlainData(row);
78038
78581
  }
78039
78582
  function semanticEqual(left, right) {
78040
78583
  return canonicalJson(left) === canonicalJson(right);
@@ -78054,7 +78597,7 @@ function storedArgumentPointer(value, typeInfo) {
78054
78597
  }
78055
78598
  return {
78056
78599
  type: "value" /* value */,
78057
- value: { typeInfo, value: cloneJsonValue2(value) }
78600
+ value: { typeInfo, value: deepClonePlainData(value) }
78058
78601
  };
78059
78602
  }
78060
78603
  function evaluatorEnvelopeParameters() {
@@ -78207,7 +78750,12 @@ function createHeadlessVirtualInstanceResolver(args) {
78207
78750
  values: document.values
78208
78751
  }).placementByValueId;
78209
78752
  const rawById = new Map(document.values.map((row) => [row.id, row]));
78210
- const resolverDocumentOnce = () => composeResolverDocument(document, args.resolverLookups());
78753
+ let resolverDocumentCache = null;
78754
+ const resolverDocumentOnce = () => resolverDocumentCache ??= composeResolverDocument(
78755
+ document,
78756
+ args.resolverLookups()
78757
+ );
78758
+ let materializedIndex = null;
78211
78759
  const graphRowsByRootId = /* @__PURE__ */ new Map();
78212
78760
  const graphByValueId = /* @__PURE__ */ new Map();
78213
78761
  const failedRootIds = /* @__PURE__ */ new Set();
@@ -78232,6 +78780,10 @@ function createHeadlessVirtualInstanceResolver(args) {
78232
78780
  }
78233
78781
  try {
78234
78782
  const resolverDocument = resolverDocumentOnce();
78783
+ materializedIndex ??= buildVirtualInstanceMaterializedIndex({
78784
+ document: resolverDocument,
78785
+ materializedRows: document.values
78786
+ });
78235
78787
  const expanded = expandStoredInstance({
78236
78788
  document: resolverDocument,
78237
78789
  instanceRoot,
@@ -78243,7 +78795,7 @@ function createHeadlessVirtualInstanceResolver(args) {
78243
78795
  rootMember: member,
78244
78796
  expandedRoot: expanded.root,
78245
78797
  expandedRows: expanded.rows,
78246
- materializedRows: document.values
78798
+ materializedIndex
78247
78799
  });
78248
78800
  graphRowsByRootId.set(rootId, graph.rowsById);
78249
78801
  for (const [id2, row] of graph.rowsById) {
@@ -78425,15 +78977,18 @@ function buildInitializerRootValueWithLookups(document, lookups) {
78425
78977
  return rootValue;
78426
78978
  }
78427
78979
  function evaluateMemberInitializer(args) {
78428
- const compiled = args.init.compiled;
78429
- if (compiled === void 0) {
78430
- throw new UncompiledInitializerRuntimeError(
78431
- typeof Reflect.get(args.member, "id") === "string" ? Reflect.get(args.member, "id") : null,
78432
- args.member.name,
78433
- args.init
78434
- );
78435
- }
78436
78980
  const databaseVM = initializerEvaluatorLookups(args.document);
78981
+ const initializerIndexes = databaseVM.constructorInitializerIndexes;
78982
+ const compileMemberId = initializerIndexes?.initializerScopeMemberIds.get(args.init) ?? (args.sourceValueId === null || args.sourceValueId === void 0 ? void 0 : initializerIndexes?.initializerScopeMemberIdsByValueId.get(
78983
+ args.sourceValueId
78984
+ ));
78985
+ const compiled = ensureInitializerCompiled({
78986
+ init: args.init,
78987
+ member: args.member,
78988
+ initializerCompiler: args.document.initializerCompiler,
78989
+ sourceValueId: args.sourceValueId ?? null,
78990
+ compileMemberId
78991
+ });
78437
78992
  const ctx = {
78438
78993
  vm: {
78439
78994
  project: args.document.project,
@@ -78454,7 +79009,8 @@ function evaluateMemberInitializer(args) {
78454
79009
  // initializer evaluator ran (collapse expansion included).
78455
79010
  variants: args.document.variants,
78456
79011
  variantFolders: args.document.variantFolders,
78457
- databaseVM
79012
+ databaseVM,
79013
+ initializerCompiler: args.document.initializerCompiler
78458
79014
  },
78459
79015
  thisValue: null,
78460
79016
  rootValue: buildInitializerRootValueWithLookups(args.document, databaseVM),
@@ -78528,7 +79084,6 @@ var init_evaluateInitializer = __esm({
78528
79084
  init_instance_provenance();
78529
79085
  init_members();
78530
79086
  init_project2();
78531
- init_NSGetterRuntimeError();
78532
79087
  init_evaluateNSGetter();
78533
79088
  init_virtual_instance_values();
78534
79089
  evaluatorLookupsByDocument = /* @__PURE__ */ new WeakMap();
@@ -78577,7 +79132,8 @@ function evaluateInitializerMaterialization(args) {
78577
79132
  storageKeyDeclarations,
78578
79133
  ...args.storedConstructionReplay === true ? { storedConstructionReplay: true } : {},
78579
79134
  ...args.constructionBaselineReplay === true ? { constructionBaselineReplay: true } : {},
78580
- ...args.argumentValues === void 0 ? {} : { argumentValues: args.argumentValues }
79135
+ ...args.argumentValues === void 0 ? {} : { argumentValues: args.argumentValues },
79136
+ sourceValueId: args.sourceValueId ?? null
78581
79137
  });
78582
79138
  return { evaluated, createdValues, storageKeyDeclarations };
78583
79139
  }
@@ -78612,7 +79168,8 @@ function materializeInitializerValue(args) {
78612
79168
  document: args.document,
78613
79169
  ...args.storedConstructionReplay === true ? { storedConstructionReplay: true } : {},
78614
79170
  ...args.constructionBaselineReplay === true ? { constructionBaselineReplay: true } : {},
78615
- ...args.argumentValues === void 0 ? {} : { argumentValues: args.argumentValues }
79171
+ ...args.argumentValues === void 0 ? {} : { argumentValues: args.argumentValues },
79172
+ sourceValueId: args.row.id
78616
79173
  });
78617
79174
  const {
78618
79175
  init: _init,
@@ -78704,7 +79261,8 @@ function materializeMemberDefaultValue(args) {
78704
79261
  member,
78705
79262
  init,
78706
79263
  sourceValueId ?? null
78707
- )
79264
+ ),
79265
+ sourceValueId: sourceValueId ?? null
78708
79266
  })
78709
79267
  });
78710
79268
  const interior = createdValues.filter((created) => created.id !== built.id);
@@ -78740,236 +79298,6 @@ var init_init_backed_value_materialization = __esm({
78740
79298
  }
78741
79299
  });
78742
79300
 
78743
- // ../src/models/localization/localization-types.ts
78744
- function isProjectLocaleConfig(value) {
78745
- if (!isObject(value)) return false;
78746
- const v = value;
78747
- if (!isLocaleCode(v.locale)) return false;
78748
- if (!isOptionalNullableString(v.sourceLocale)) return false;
78749
- if (v.sourceLocale !== void 0 && v.sourceLocale !== null) {
78750
- if (!isLocaleCode(v.sourceLocale)) return false;
78751
- }
78752
- if (!isOptionalNullableString(v.name)) return false;
78753
- if (!isFiniteNumber(v.sortOrder)) return false;
78754
- return isOptionalNullableDate(v.archivedAt);
78755
- }
78756
- function isProjectLocalizationConfigProps(value) {
78757
- if (!isWithId(value)) return false;
78758
- if (!isIWithTimestamps(value)) return false;
78759
- const v = value;
78760
- if (v.id !== PROJECT_LOCALIZATION_CONFIG_ID) return false;
78761
- if (!isString(v.projectId)) return false;
78762
- if (!isLocaleCode(v.mainLocale)) return false;
78763
- if (!Array.isArray(v.supportedLocales)) return false;
78764
- if (!v.supportedLocales.every(isProjectLocaleConfig)) return false;
78765
- if (!isStringArray2(v.sortedStatusIds)) return false;
78766
- return isString(v.mainLocaleDefaultStatusId);
78767
- }
78768
- function isProjectLocalizationConfig(value) {
78769
- return isProjectLocalizationConfigProps(value);
78770
- }
78771
- function isLocalizationStatusProps(value) {
78772
- if (!isWithId(value)) return false;
78773
- if (!isIWithTimestamps(value)) return false;
78774
- const v = value;
78775
- if (!isString(v.projectId)) return false;
78776
- if (!isSlug(v.slug)) return false;
78777
- if (!isString(v.name)) return false;
78778
- if (!isOptionalNullableString(v.description)) return false;
78779
- if (!isOptionalNullableString(v.color)) return false;
78780
- if (!isOptionalNullableString(v.emoji)) return false;
78781
- if (!isOptionalNullableDate(v.archivedAt)) return false;
78782
- if (!isNullableStringArray(v.transitionRules)) return false;
78783
- if (!isNullableString(v.transitionToStatusIdOnEditText)) return false;
78784
- if (!isNullableString(v.transitionToWhenSourceBecomesStatusId)) return false;
78785
- if (v.system !== void 0 && v.system !== null) {
78786
- return isSystemMetadata(v.system);
78787
- }
78788
- return true;
78789
- }
78790
- function isLocalizationStatus(value) {
78791
- return isLocalizationStatusProps(value);
78792
- }
78793
- function isLocalizedTextLocaleValue(value) {
78794
- if (!isObject(value)) return false;
78795
- const v = value;
78796
- if (!isNullableString(v.value)) return false;
78797
- if (!isString(v.statusId)) return false;
78798
- if (!isOptionalNullableString(v.localeComment)) return false;
78799
- return isEpochMillis(v.updatedAt);
78800
- }
78801
- function isLocalizedTextLinkKind(value) {
78802
- if (!isString(value)) return false;
78803
- return LOCALIZED_TEXT_LINK_KINDS.includes(value);
78804
- }
78805
- function isLocalizedTextLink(value) {
78806
- if (!isObject(value)) return false;
78807
- const v = value;
78808
- if (!isLocalizedTextLinkKind(v.kind)) return false;
78809
- if (!isOptionalNullableString(v.recordKind)) return false;
78810
- if (!isOptionalNullableString(v.recordId)) return false;
78811
- if (!isOptionalNullableString(v.fieldPath)) return false;
78812
- if (!isOptionalNullableString(v.valueId)) return false;
78813
- if (!isOptionalNullableString(v.nodeId)) return false;
78814
- return isOptionalNullableString(v.choiceId);
78815
- }
78816
- function isLocalizedTextProps(value) {
78817
- if (!isWithId(value)) return false;
78818
- if (!isIWithTimestamps(value)) return false;
78819
- const v = value;
78820
- if (!isString(v.projectId)) return false;
78821
- if (!isOptionalNullableString(v.sourceComment)) return false;
78822
- if (!Array.isArray(v.links)) return false;
78823
- if (!v.links.every(isLocalizedTextLink)) return false;
78824
- if (!isOptionalNullableDate(v.archivedAt)) return false;
78825
- return isLocaleValueRecord(v.localeValues);
78826
- }
78827
- function isLocalizedText(value) {
78828
- return isLocalizedTextProps(value);
78829
- }
78830
- function isLocaleCode(value) {
78831
- if (!isString(value)) return false;
78832
- if (value.trim() !== value) return false;
78833
- if (value.length === 0) return false;
78834
- return /^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/.test(value);
78835
- }
78836
- function isLocaleValueRecord(value) {
78837
- if (!isObject(value)) return false;
78838
- for (const [locale, localeValue] of Object.entries(value)) {
78839
- if (!isLocaleCode(locale)) return false;
78840
- if (!isLocalizedTextLocaleValue(localeValue)) return false;
78841
- }
78842
- return true;
78843
- }
78844
- function isOptionalNullableDate(value) {
78845
- if (value === void 0) return true;
78846
- if (value === null) return true;
78847
- return isEpochMillis(value);
78848
- }
78849
- function isFiniteNumber(value) {
78850
- if (typeof value !== "number") return false;
78851
- return Number.isFinite(value);
78852
- }
78853
- function isSlug(value) {
78854
- if (!isString(value)) return false;
78855
- return /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(value);
78856
- }
78857
- function isNullableString(value) {
78858
- if (value === null) return true;
78859
- return isString(value);
78860
- }
78861
- function isStringArray2(value) {
78862
- if (!Array.isArray(value)) return false;
78863
- return value.every(isString);
78864
- }
78865
- function isNullableStringArray(value) {
78866
- if (value === null) return true;
78867
- return isStringArray2(value);
78868
- }
78869
- var PROJECT_LOCALIZATION_CONFIG_ID, LOCALIZED_TEXT_LINK_KINDS;
78870
- var init_localization_types = __esm({
78871
- "../src/models/localization/localization-types.ts"() {
78872
- "use strict";
78873
- init_core();
78874
- PROJECT_LOCALIZATION_CONFIG_ID = "system_b9f80fd7-7ed2-4344-a2b6-625ced732ed0";
78875
- LOCALIZED_TEXT_LINK_KINDS = [
78876
- "member-value",
78877
- "member-default-value",
78878
- "dialogue-description",
78879
- "dialogue-node-text",
78880
- "dialogue-choice-text",
78881
- "dialogue-group-name",
78882
- "priority-group-name"
78883
- ];
78884
- }
78885
- });
78886
-
78887
- // ../src/models/localization/localization-export.ts
78888
- var init_localization_export = __esm({
78889
- "../src/models/localization/localization-export.ts"() {
78890
- "use strict";
78891
- init_localization_types();
78892
- }
78893
- });
78894
-
78895
- // ../src/models/localization/localization-import.ts
78896
- var init_localization_import = __esm({
78897
- "../src/models/localization/localization-import.ts"() {
78898
- "use strict";
78899
- }
78900
- });
78901
-
78902
- // ../src/models/localization/localized-text-create-envelope.ts
78903
- function completeLocalizedTextCreateEnvelope(data, config) {
78904
- const text = asUnknownRecord(data);
78905
- if (text === null) return data;
78906
- const localeValues = asUnknownRecord(text.localeValues);
78907
- const mainLocaleValue = localeValues === null ? null : asUnknownRecord(localeValues[config.mainLocale]);
78908
- const completedMainLocaleValue = mainLocaleValue === null ? null : {
78909
- ...mainLocaleValue,
78910
- ...mainLocaleValue.statusId === void 0 ? { statusId: config.mainLocaleDefaultStatusId } : {},
78911
- ...mainLocaleValue.updatedAt === void 0 && text.updatedAt !== void 0 ? { updatedAt: text.updatedAt } : {}
78912
- };
78913
- return {
78914
- ...text,
78915
- ...text.links === void 0 ? { links: [] } : {},
78916
- ...localeValues === null || completedMainLocaleValue === null ? {} : {
78917
- localeValues: {
78918
- ...localeValues,
78919
- [config.mainLocale]: completedMainLocaleValue
78920
- }
78921
- }
78922
- };
78923
- }
78924
- function buildLocalizedTextCreateForLink(args) {
78925
- const completed = completeLocalizedTextCreateEnvelope(
78926
- {
78927
- id: args.id,
78928
- projectId: args.projectId,
78929
- sourceComment: null,
78930
- links: [args.link],
78931
- localeValues: {
78932
- [args.config.mainLocale]: {
78933
- value: args.value,
78934
- localeComment: null
78935
- }
78936
- },
78937
- createdAt: args.now,
78938
- updatedAt: args.now
78939
- },
78940
- args.config
78941
- );
78942
- if (!isLocalizedText(completed)) {
78943
- throw new Error(
78944
- `Localized text "${args.id}" could not be completed into a valid create envelope.`
78945
- );
78946
- }
78947
- return completed;
78948
- }
78949
- function asUnknownRecord(value) {
78950
- if (typeof value !== "object" || value === null || Array.isArray(value)) {
78951
- return null;
78952
- }
78953
- return value;
78954
- }
78955
- var init_localized_text_create_envelope = __esm({
78956
- "../src/models/localization/localized-text-create-envelope.ts"() {
78957
- "use strict";
78958
- init_localization_types();
78959
- }
78960
- });
78961
-
78962
- // ../src/models/localization/index.ts
78963
- var init_localization2 = __esm({
78964
- "../src/models/localization/index.ts"() {
78965
- "use strict";
78966
- init_localization_types();
78967
- init_localization_export();
78968
- init_localization_import();
78969
- init_localized_text_create_envelope();
78970
- }
78971
- });
78972
-
78973
79301
  // ../convex/projectDocumentDialogueMaterialization.ts
78974
79302
  function materializeDialogues(dialogueRecords, dialogueNodes) {
78975
79303
  return dialogueRecords.map((dialogue) => {
@@ -81859,6 +82187,7 @@ function lowerTextNode(context, member, id2, base, common, destination) {
81859
82187
  bindingTypes,
81860
82188
  nullableString3(common.primaryLinkedValueId) ?? context.dialoguePrimaryValueId,
81861
82189
  `node:${id2}`,
82190
+ dialogueNodeLocalizedTextLink(id2),
81862
82191
  member
81863
82192
  );
81864
82193
  const children = member.content?.children.filter((child) => child.graphType === "Option") ?? [];
@@ -81884,6 +82213,7 @@ function lowerTextNode(context, member, id2, base, common, destination) {
81884
82213
  bindingTypes,
81885
82214
  nullableString3(common.primaryLinkedValueId) ?? context.dialoguePrimaryValueId,
81886
82215
  `option:${optionId}`,
82216
+ dialogueChoiceLocalizedTextLink(id2, optionId),
81887
82217
  child
81888
82218
  );
81889
82219
  if (optionText.textRecord) textRecords.push(optionText.textRecord);
@@ -82182,7 +82512,7 @@ function lowerActionLogic(context, prior, fn, fallbackCode, inline, useId, uiRes
82182
82512
  action: isObjectRecord2(prior?.action) ? prior.action : placeholderVoidAction()
82183
82513
  };
82184
82514
  }
82185
- function lowerProse(context, rawProse, baseTextId, baseVariables, baseLinks, bindingTypes, primaryValueId2, owner, source) {
82515
+ function lowerProse(context, rawProse, baseTextId, baseVariables, baseLinks, bindingTypes, primaryValueId2, owner, textLink, source) {
82186
82516
  const textId = baseTextId ?? pendingId("localized-text", source.source.uri, owner, 0, "text");
82187
82517
  const legacyInline = isLegacyInlineText2(context.state, baseTextId);
82188
82518
  const baseText = legacyInline ? {} : baseData2(context.state, "localized-text", textId);
@@ -82315,6 +82645,10 @@ function lowerProse(context, rawProse, baseTextId, baseVariables, baseLinks, bin
82315
82645
  {
82316
82646
  ...baseText,
82317
82647
  id: textId,
82648
+ links: upsertLocalizedTextLink(
82649
+ Array.isArray(baseText.links) ? baseText.links.filter(isLocalizedTextLink) : [],
82650
+ textLink
82651
+ ),
82318
82652
  localeValues: {
82319
82653
  ...localeValues,
82320
82654
  [context.mainLocale]: { ...main2, value }
@@ -83401,6 +83735,7 @@ var init_dialogue_lower = __esm({
83401
83735
  "src/project-source/dialogue-lower.ts"() {
83402
83736
  "use strict";
83403
83737
  init_src();
83738
+ init_localization2();
83404
83739
  init_members();
83405
83740
  init_neoscript();
83406
83741
  init_projection();
@@ -84076,7 +84411,6 @@ function isWorldAnimationStructuralMember(memberId, members) {
84076
84411
  }
84077
84412
  function assertAnimationClipDocumentValid(document) {
84078
84413
  const context = new AnimationValidationContext(document);
84079
- context.validateConstructorProjections();
84080
84414
  context.validateSegments();
84081
84415
  for (const member of document.members) {
84082
84416
  if (!isMemberClass(member)) continue;
@@ -84088,14 +84422,13 @@ function assertAnimationClipDocumentValid(document) {
84088
84422
  function isRecord5(value) {
84089
84423
  return typeof value === "object" && value !== null && !Array.isArray(value);
84090
84424
  }
84091
- var WORLD_RETIRED_TILE_LAYER_LINK_LAYER_MEMBER_ID, WORLD_RETIRED_OBJECT_LAYER_LINK_LAYER_MEMBER_ID, WORLD_ANIMATION_STRUCTURAL_MEMBER_ROOT_IDS, AnimationValidationContext;
84425
+ var WORLD_ANIMATION_STRUCTURAL_MEMBER_ROOT_IDS, AnimationValidationContext;
84092
84426
  var init_animation_clips = __esm({
84093
84427
  "../src/models/animation/animation-clips.ts"() {
84094
84428
  "use strict";
84095
84429
  init_inheritance();
84096
84430
  init_generics();
84097
84431
  init_world_system_classes();
84098
- init_core_types();
84099
84432
  init_member_kinds();
84100
84433
  init_structured_leaf_fields();
84101
84434
  init_effective_storage();
@@ -84103,8 +84436,6 @@ var init_animation_clips = __esm({
84103
84436
  init_neoscript_types();
84104
84437
  init_neoscript_guards();
84105
84438
  init_project_root_members();
84106
- WORLD_RETIRED_TILE_LAYER_LINK_LAYER_MEMBER_ID = "325dba0e-5967-4e18-937e-5c6800b68abc";
84107
- WORLD_RETIRED_OBJECT_LAYER_LINK_LAYER_MEMBER_ID = "9cc0ab67-e138-4d11-8011-fab7d7a75b13";
84108
84439
  WORLD_ANIMATION_STRUCTURAL_MEMBER_ROOT_IDS = /* @__PURE__ */ new Set([
84109
84440
  WORLD_GRID_CHILDREN_MEMBER_ID,
84110
84441
  WORLD_GRID_CHILDREN_ENTRY_MEMBER_ID,
@@ -84113,11 +84444,9 @@ var init_animation_clips = __esm({
84113
84444
  WORLD_OBJECT_PLACEMENT_TILES_MEMBER_ID,
84114
84445
  WORLD_OBJECT_PLACEMENT_TILES_ENTRY_MEMBER_ID,
84115
84446
  WORLD_OBJECT_PLACEMENT_TILE_CELL_MEMBER_ID,
84116
- WORLD_RETIRED_OBJECT_LAYER_LINK_LAYER_MEMBER_ID,
84117
84447
  WORLD_OBJECT_LAYER_LINK_OBJECTS_MEMBER_ID,
84118
84448
  WORLD_OBJECT_LAYER_LINK_OBJECT_ENTRY_MEMBER_ID,
84119
84449
  WORLD_TILE_INSTANCE_CELL_MEMBER_ID,
84120
- WORLD_RETIRED_TILE_LAYER_LINK_LAYER_MEMBER_ID,
84121
84450
  WORLD_TILE_LAYER_LINK_TILES_MEMBER_ID,
84122
84451
  WORLD_TILE_LAYER_LINK_TILE_ENTRY_MEMBER_ID
84123
84452
  ]);
@@ -84142,60 +84471,6 @@ var init_animation_clips = __esm({
84142
84471
  memberById;
84143
84472
  valueById;
84144
84473
  storage;
84145
- validateConstructorProjections() {
84146
- for (const schemaClass2 of this.document.classes) {
84147
- const projections = schemaClass2.constructorProjections ?? [];
84148
- if (projections.length === 0) continue;
84149
- if (schemaClass2.system?.kind !== SystemProtectionKind.WorldAuthoring) {
84150
- throw new Error(
84151
- `Class "${schemaClass2.name}" can declare constructor projections only when it is a locked world system class.`
84152
- );
84153
- }
84154
- const parameterNames = /* @__PURE__ */ new Set();
84155
- const memberIds = /* @__PURE__ */ new Set();
84156
- const effectiveMemberIds = this.effectiveSchemaMemberIds(schemaClass2);
84157
- for (const projection of projections) {
84158
- if (parameterNames.has(projection.parameterName)) {
84159
- throw new Error(
84160
- `Class "${schemaClass2.name}" has duplicate constructor parameter "${projection.parameterName}".`
84161
- );
84162
- }
84163
- if (memberIds.has(projection.memberId)) {
84164
- throw new Error(
84165
- `Class "${schemaClass2.name}" projects multiple constructor parameters onto member "${projection.memberId}".`
84166
- );
84167
- }
84168
- if (!effectiveMemberIds.has(projection.memberId)) {
84169
- throw new Error(
84170
- `Class "${schemaClass2.name}" constructor parameter "${projection.parameterName}" references member "${projection.memberId}", which is neither in its schema nor inherited.`
84171
- );
84172
- }
84173
- parameterNames.add(projection.parameterName);
84174
- memberIds.add(projection.memberId);
84175
- }
84176
- }
84177
- }
84178
- /**
84179
- * Every member id a class resolves under a schema key — its own, then each
84180
- * ancestor's.
84181
- *
84182
- * A projection may name an inherited member: P48 §2.1 moved `Child` onto
84183
- * `NeoAnimationTrackBase`, and `new NeoAnimationChildTrack(id: "…")` still
84184
- * projects onto that one member from a class that no longer declares it.
84185
- */
84186
- effectiveSchemaMemberIds(schemaClass2) {
84187
- const memberIds = /* @__PURE__ */ new Set();
84188
- const visited = /* @__PURE__ */ new Set();
84189
- let current = schemaClass2;
84190
- while (current !== void 0 && !visited.has(current.id)) {
84191
- visited.add(current.id);
84192
- for (const memberId of Object.values(current.schema)) {
84193
- memberIds.add(memberId);
84194
- }
84195
- current = current.extendsClassId === void 0 ? void 0 : this.classById.get(current.extendsClassId);
84196
- }
84197
- return memberIds;
84198
- }
84199
84474
  classHasWorldKind(classId, worldKind) {
84200
84475
  const visited = /* @__PURE__ */ new Set();
84201
84476
  let current = this.classById.get(classId);
@@ -85346,7 +85621,10 @@ function headlessVirtualInstanceLookups(document, options = {}) {
85346
85621
  } : {}
85347
85622
  );
85348
85623
  const virtual = createHeadlessVirtualInstanceResolver({
85349
- document,
85624
+ document: {
85625
+ ...document,
85626
+ ...options.initializerCompiler === void 0 ? {} : { initializerCompiler: options.initializerCompiler }
85627
+ },
85350
85628
  // A thunk: the resolver resolves nested reads through the lookups being
85351
85629
  // built around it.
85352
85630
  resolverLookups: () => lookups
@@ -85382,7 +85660,18 @@ var init_headless_virtual_instance_lookups = __esm({
85382
85660
 
85383
85661
  // src/evaluator-lookups.ts
85384
85662
  function cliEvaluatorLookups(document, options = {}) {
85385
- return headlessVirtualInstanceLookups(document, options);
85663
+ return cliEvaluatorRuntime(document, options).databaseVM;
85664
+ }
85665
+ function cliEvaluatorRuntime(document, options = {}) {
85666
+ const initializerCompiler = isPulledInitializerCompilationDocumentV4(document) ? pulledInitializerCompilerV4(document) : void 0;
85667
+ const databaseVM = headlessVirtualInstanceLookups(document, {
85668
+ ...options,
85669
+ ...initializerCompiler === void 0 ? {} : { initializerCompiler }
85670
+ });
85671
+ return {
85672
+ databaseVM,
85673
+ ...initializerCompiler === void 0 ? {} : { initializerCompiler }
85674
+ };
85386
85675
  }
85387
85676
  function cliEvaluatorReceiverValue(lookups, valueId) {
85388
85677
  if (typeof valueId !== "string") return null;
@@ -85392,6 +85681,7 @@ var init_evaluator_lookups = __esm({
85392
85681
  "src/evaluator-lookups.ts"() {
85393
85682
  "use strict";
85394
85683
  init_headless_virtual_instance_lookups();
85684
+ init_initializer_replay();
85395
85685
  }
85396
85686
  });
85397
85687
 
@@ -85657,17 +85947,26 @@ function syntheticMember(fields) {
85657
85947
  function variantOwnershipRoots(args) {
85658
85948
  const empty = { roots: [], bindingMembers: [] };
85659
85949
  if (args.variants.length === 0) return empty;
85660
- const plainVariantClass = args.classes.find(
85661
- (schemaClass2) => schemaClass2.system?.worldKind === NeoWorldSystemClassKind.Variant
85950
+ const classById = new Map(
85951
+ args.classes.map((schemaClass2) => [schemaClass2.id, schemaClass2])
85952
+ );
85953
+ const classByVariantKind = /* @__PURE__ */ new Map();
85954
+ for (const schemaClass2 of args.classes) {
85955
+ const worldKind = schemaClass2.system?.worldKind;
85956
+ if (worldKind !== NeoWorldSystemClassKind.Variant && worldKind !== NeoWorldSystemClassKind.LookupVariant) {
85957
+ continue;
85958
+ }
85959
+ classByVariantKind.set(worldKind, schemaClass2);
85960
+ }
85961
+ const plainVariantClass = classByVariantKind.get(
85962
+ NeoWorldSystemClassKind.Variant
85662
85963
  );
85663
85964
  if (plainVariantClass === void 0) return empty;
85664
85965
  const valueById = new Map(args.values.map((value) => [value.id, value]));
85665
85966
  const folderById = new Map(
85666
85967
  (args.variantFolders ?? []).map((folder) => [folder.id, folder])
85667
85968
  );
85668
- const memberById2 = new Map(
85669
- (args.members ?? []).map((member) => [member.id, member])
85670
- );
85969
+ let memberById2 = null;
85671
85970
  const roots = [];
85672
85971
  const bindingMembers = [];
85673
85972
  for (const variant of args.variants) {
@@ -85675,11 +85974,9 @@ function variantOwnershipRoots(args) {
85675
85974
  if (root === void 0) continue;
85676
85975
  const lookupFolder = variant.folderId == null ? void 0 : folderById.get(variant.folderId);
85677
85976
  const inferredVariantKind = lookupFolder?.binding == null ? NeoWorldSystemClassKind.Variant : NeoWorldSystemClassKind.LookupVariant;
85678
- const variantClass = args.classes.find(
85679
- (schemaClass2) => schemaClass2.id === root.classId && (schemaClass2.system?.worldKind === NeoWorldSystemClassKind.Variant || schemaClass2.system?.worldKind === NeoWorldSystemClassKind.LookupVariant)
85680
- ) ?? args.classes.find(
85681
- (schemaClass2) => schemaClass2.system?.worldKind === inferredVariantKind
85682
- ) ?? plainVariantClass;
85977
+ const stampedClass = typeof root.classId === "string" ? classById.get(root.classId) : void 0;
85978
+ const stampedKind = stampedClass?.system?.worldKind;
85979
+ const variantClass = (stampedKind === NeoWorldSystemClassKind.Variant || stampedKind === NeoWorldSystemClassKind.LookupVariant ? stampedClass : void 0) ?? classByVariantKind.get(inferredVariantKind) ?? plainVariantClass;
85683
85980
  const parameterId = variantClass.genericParams?.[0]?.id;
85684
85981
  if (parameterId === void 0) continue;
85685
85982
  const stampedTargetMemberId = readStampedTargetMemberId(root, parameterId);
@@ -85706,7 +86003,12 @@ function variantOwnershipRoots(args) {
85706
86003
  })
85707
86004
  );
85708
86005
  const lookupParameterId = variantClass.genericParams?.[1]?.id;
85709
- const lookupCollection = lookupFolder?.binding == null ? void 0 : memberById2.get(lookupFolder.binding.collectionMemberId);
86006
+ if (lookupFolder?.binding != null && memberById2 === null) {
86007
+ memberById2 = new Map(
86008
+ (args.members ?? []).map((member) => [member.id, member])
86009
+ );
86010
+ }
86011
+ const lookupCollection = lookupFolder?.binding == null ? void 0 : memberById2?.get(lookupFolder.binding.collectionMemberId);
85710
86012
  const lookupBinding = lookupParameterId !== void 0 && isMemberListBase(lookupCollection) ? {
85711
86013
  [lookupParameterId]: {
85712
86014
  kind: "member",
@@ -85744,14 +86046,37 @@ function withVariantOwnershipRoots(document, variants) {
85744
86046
  classes: document.classes,
85745
86047
  members: document.members
85746
86048
  });
85747
- if (bindingMembers.length === 0) return { document, roots };
86049
+ const rootMembersByValueId = new Map(
86050
+ roots.map((root) => [root.valueId, root.member])
86051
+ );
86052
+ if (bindingMembers.length === 0) {
86053
+ return { document, roots, rootMembersByValueId };
86054
+ }
85748
86055
  return {
85749
86056
  document: {
85750
86057
  ...document,
85751
86058
  members: [...document.members, ...bindingMembers]
85752
86059
  },
85753
- roots
86060
+ roots,
86061
+ rootMembersByValueId
86062
+ };
86063
+ }
86064
+ function createVariantMaterializedValueGraphContext(document, variants, rows = new Map(
86065
+ document.values.map((value) => [value.id, value])
86066
+ )) {
86067
+ const scopedDocument = {
86068
+ ...document,
86069
+ values: [...rows.values()]
85754
86070
  };
86071
+ const scope = withVariantOwnershipRoots(
86072
+ scopedDocument,
86073
+ variants.filter((variant) => rows.has(variant.valueId))
86074
+ );
86075
+ return new MaterializedValueGraphContext(
86076
+ scope.document,
86077
+ rows,
86078
+ scope.rootMembersByValueId
86079
+ );
85755
86080
  }
85756
86081
  function collectVariantGraphValueIds(args) {
85757
86082
  const collected = /* @__PURE__ */ new Set();
@@ -87606,7 +87931,6 @@ function worldPlacementVariantBindings(args) {
87606
87931
  const valuesById = new Map(args.values.map((value) => [value.id, value]));
87607
87932
  let cachedLookups = null;
87608
87933
  const expansionLookups = () => {
87609
- if (args.expansionDocument === void 0) return null;
87610
87934
  return cachedLookups ??= initializerEvaluatorLookups(
87611
87935
  args.expansionDocument
87612
87936
  );
@@ -87638,10 +87962,6 @@ function worldPlacementVariantBindings(args) {
87638
87962
  }
87639
87963
  function lookupCollectionEntryIds(args) {
87640
87964
  const storedRow = args.valuesById.get(args.collectionValueId);
87641
- if (args.lookups === null) {
87642
- if (storedRow === void 0) return [];
87643
- return listEntryIdsForValue(args.collection, storedRow, args.values);
87644
- }
87645
87965
  const graphRows = args.lookups.virtualInstanceRowsForValue(
87646
87966
  args.collectionValueId
87647
87967
  );
@@ -87661,7 +87981,7 @@ function lookupCollectionEntryIds(args) {
87661
87981
  return listEntryIdsForValue(args.collection, collectionRow, effectiveRows);
87662
87982
  }
87663
87983
  function validateWorldContentSidecars(args) {
87664
- const variants = args.variants ?? [];
87984
+ const variants = args.variants;
87665
87985
  const valuesById = new Map(args.values.map((value) => [value.id, value]));
87666
87986
  const classesById2 = new Map(
87667
87987
  args.classes.map((schemaClass2) => [schemaClass2.id, schemaClass2])
@@ -88587,6 +88907,11 @@ function readMember(value) {
88587
88907
  function readClass(value) {
88588
88908
  if (!isRecord6(value)) throw new Error("Class record is not an object.");
88589
88909
  if (typeof value.id !== "string") throw new Error("Class id is invalid.");
88910
+ if (hasRetiredConstructorProjectionsTombstone(value)) {
88911
+ throw new Error(
88912
+ `Class "${value.id}" cannot declare retired field "constructorProjections".`
88913
+ );
88914
+ }
88590
88915
  if (typeof value.name !== "string") {
88591
88916
  throw new Error(`Class "${value.id}" name is invalid.`);
88592
88917
  }
@@ -90356,26 +90681,6 @@ function assertOpaqueConstructorValid(declaredConstructor) {
90356
90681
  assertOpaqueConstructorBaseClauseValid(declaredConstructor);
90357
90682
  return argumentTypes;
90358
90683
  }
90359
- function assertOpaqueConstructorProjectionsDisjoint(declaredConstructor, owner) {
90360
- const projections = owner.constructorProjections;
90361
- if (projections === void 0 || projections === null) return;
90362
- if (!Array.isArray(projections)) {
90363
- throw new Error(`Class "${owner.id}" constructorProjections are invalid.`);
90364
- }
90365
- const projected = new Set(
90366
- projections.filter(
90367
- (projection) => isRecord6(projection) && typeof projection.parameterName === "string"
90368
- ).map((projection) => projection.parameterName.toLowerCase())
90369
- );
90370
- if (projected.size === 0) return;
90371
- for (const argument2 of declaredConstructor.argumentTypes) {
90372
- if (!isRecord6(argument2) || typeof argument2.name !== "string") continue;
90373
- if (!projected.has(argument2.name.toLowerCase())) continue;
90374
- throw new Error(
90375
- `Constructor "${declaredConstructor.id}" declares parameter "${argument2.name}", which is also a constructor projection argument on class "${owner.id}"; a call site could not tell the two apart.`
90376
- );
90377
- }
90378
- }
90379
90684
  function assertOpaqueRequiredConstructorValid(schemaClass2, constructorsById) {
90380
90685
  const requiredConstructorId2 = schemaClass2.requiredConstructorId;
90381
90686
  if (requiredConstructorId2 === void 0 || requiredConstructorId2 === null) {
@@ -90444,7 +90749,6 @@ function assertOpaqueConstructorsValid(constructors, classesById2) {
90444
90749
  `Class "${owner.id}" names constructor "${declaredConstructor.id}" as its required constructor and also lists it in constructorIds; the required constructor is not a declared member.`
90445
90750
  );
90446
90751
  }
90447
- assertOpaqueConstructorProjectionsDisjoint(declaredConstructor, owner);
90448
90752
  const siblings = constructorsByClassId.get(declaredConstructor.classId) ?? [];
90449
90753
  siblings.push(declaredConstructor);
90450
90754
  constructorsByClassId.set(declaredConstructor.classId, siblings);
@@ -90706,6 +91010,7 @@ var init_projectInterfaceValidation = __esm({
90706
91010
  "use strict";
90707
91011
  init_projectVariantValidation();
90708
91012
  init_src();
91013
+ init_classes();
90709
91014
  NEO_OBJECT_WORLD_KIND = "object";
90710
91015
  READ_ONLY_SYNTHETIC_VALUE_ID_PREFIX2 = "__neo_readonly_default:";
90711
91016
  REJECTED_OPAQUE_CONSTRUCTOR_KEYS = [
@@ -92088,14 +92393,14 @@ function findParentValues(valueId, values) {
92088
92393
  }
92089
92394
  continue;
92090
92395
  }
92091
- if (!isStringRecord5(value.value)) continue;
92396
+ if (!isStringRecord6(value.value)) continue;
92092
92397
  for (const [key, childValueId] of Object.entries(value.value)) {
92093
92398
  if (childValueId === valueId) parents.push({ value, key });
92094
92399
  }
92095
92400
  }
92096
92401
  return parents;
92097
92402
  }
92098
- function isStringRecord5(value) {
92403
+ function isStringRecord6(value) {
92099
92404
  if (typeof value !== "object") return false;
92100
92405
  if (value === null) return false;
92101
92406
  if (Array.isArray(value)) return false;
@@ -92769,7 +93074,6 @@ var init_general_function_call_ir_source_recompile = __esm({
92769
93074
  init_dialogue_logic_compile_pure();
92770
93075
  init_project_migration_runner();
92771
93076
  init_compiler_adapter();
92772
- init_projectDocumentDialogueMaterialization();
92773
93077
  init_neoscript();
92774
93078
  init_dialogue_node_index();
92775
93079
  VOID_ACTION_TYPE_INFO = {
@@ -93113,7 +93417,7 @@ function assertNumberRange(member, value, path) {
93113
93417
  throw new Error(`${path} must be at most ${max}.`);
93114
93418
  }
93115
93419
  }
93116
- function isStringRecord6(value) {
93420
+ function isStringRecord7(value) {
93117
93421
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
93118
93422
  return false;
93119
93423
  }
@@ -93508,7 +93812,7 @@ var init_project_version_static_value_writes = __esm({
93508
93812
  if (!isLiteralValueContent(args.value)) {
93509
93813
  throw new Error(`${args.path} must store a literal Class value.`);
93510
93814
  }
93511
- if (!isStringRecord6(args.value.value)) {
93815
+ if (!isStringRecord7(args.value.value)) {
93512
93816
  throw new Error(`${args.path} must store a Class schema-key map.`);
93513
93817
  }
93514
93818
  const effectiveClassId = args.value.classId ?? args.member.classId;
@@ -93665,7 +93969,7 @@ var init_project_version_static_value_writes = __esm({
93665
93969
  }
93666
93970
  }
93667
93971
  validateDictionary(args) {
93668
- if (!isStringRecord6(args.value.value)) {
93972
+ if (!isStringRecord7(args.value.value)) {
93669
93973
  throw new Error(`${args.path} must store a Dictionary key/value-id map.`);
93670
93974
  }
93671
93975
  const entryRecord = this.memberById.get(args.member.entryMemberId);
@@ -93767,7 +94071,7 @@ var init_project_version_static_value_writes = __esm({
93767
94071
  }
93768
94072
  collectOwnedBody(args) {
93769
94073
  const member = resolveMember2(args.member, this.document.members);
93770
- if (isMemberClassBase(member) && isStringRecord6(args.body)) {
94074
+ if (isMemberClassBase(member) && isStringRecord7(args.body)) {
93771
94075
  const effectiveClassId = args.classId ?? member.classId;
93772
94076
  const env = resolveInstanceEnv(
93773
94077
  effectiveClassId,
@@ -93814,7 +94118,7 @@ var init_project_version_static_value_writes = __esm({
93814
94118
  }
93815
94119
  return;
93816
94120
  }
93817
- if (isMemberDictionaryBase(member) && isStringRecord6(args.body)) {
94121
+ if (isMemberDictionaryBase(member) && isStringRecord7(args.body)) {
93818
94122
  const entryRecord = this.memberById.get(member.entryMemberId);
93819
94123
  if (entryRecord === void 0) return;
93820
94124
  const entryMember = substituteMember(
@@ -93963,12 +94267,7 @@ function materializeLocalizableStringWriteChanges(args) {
93963
94267
  projectId: args.postDocument.project.id,
93964
94268
  config,
93965
94269
  now,
93966
- link: {
93967
- kind: "member-default-value",
93968
- recordKind: "member",
93969
- recordId: change.recordId,
93970
- fieldPath: "defaultValue.value"
93971
- },
94270
+ link: memberDefaultLocalizedTextLink(change.recordId),
93972
94271
  source: "server-localizable-member-default"
93973
94272
  })
93974
94273
  );
@@ -94041,13 +94340,7 @@ function materializeLocalizableStringWriteChanges(args) {
94041
94340
  projectId: args.postDocument.project.id,
94042
94341
  config,
94043
94342
  now,
94044
- link: {
94045
- kind: "member-value",
94046
- recordKind: "value",
94047
- recordId: change.recordId,
94048
- fieldPath: "value",
94049
- valueId: change.recordId
94050
- },
94343
+ link: memberValueLocalizedTextLink(change.recordId),
94051
94344
  source: "server-localizable-member-value"
94052
94345
  })
94053
94346
  );
@@ -94582,7 +94875,10 @@ function attachPreparedValuePlacements(prepared, document) {
94582
94875
  (change) => change.recordKind === "value" && change.operation === "create"
94583
94876
  );
94584
94877
  if (creates.length === 0) return;
94585
- const materializedGraph = new MaterializedValueGraphContext(document);
94878
+ const materializedGraph = createVariantMaterializedValueGraphContext(
94879
+ document,
94880
+ document.variants ?? []
94881
+ );
94586
94882
  const constructorEdges = [];
94587
94883
  for (const edges of materializedGraph.edgesByOwnerValueId.values()) {
94588
94884
  for (const edge of edges) {
@@ -94653,7 +94949,11 @@ function attachPreparedConstructorAggregateEdges(prepared, document) {
94653
94949
  }
94654
94950
  }
94655
94951
  }
94656
- const graph = needsGraph ? new MaterializedValueGraphContext(document, changedValueRows) : null;
94952
+ const graph = !needsGraph ? null : createVariantMaterializedValueGraphContext(
94953
+ document,
94954
+ document.variants ?? [],
94955
+ changedValueRows
94956
+ );
94657
94957
  for (const change of valueChanges) {
94658
94958
  change.constructorAggregateEdges = [
94659
94959
  ...graph?.edgesByOwnerValueId.get(change.recordId) ?? []
@@ -94709,13 +95009,16 @@ function materializePreparedInstanceInitializers(args) {
94709
95009
  const existingValueById = new Map(
94710
95010
  args.document.values.map((value) => [value.id, value])
94711
95011
  );
94712
- let currentGraph = null;
94713
- const requireCurrentGraph = () => currentGraph ??= new MaterializedValueGraphContext(args.document);
94714
95012
  const rootKinds = /* @__PURE__ */ new Map();
94715
95013
  const materializationScope = withVariantOwnershipRoots(
94716
95014
  compiledDocument,
94717
95015
  compiledDocument.variants ?? []
94718
95016
  );
95017
+ let currentGraph = null;
95018
+ const requireCurrentGraph = () => currentGraph ??= createVariantMaterializedValueGraphContext(
95019
+ materializationScope.document,
95020
+ materializationScope.document.variants ?? []
95021
+ );
94719
95022
  const owners = resolveSemanticOwnerMembersForValues(
94720
95023
  materializationScope.document,
94721
95024
  new Set(sites.keys()),
@@ -94749,7 +95052,11 @@ function materializePreparedInstanceInitializers(args) {
94749
95052
  });
94750
95053
  if (existingConstructedRoot) {
94751
95054
  if (!isLiteralValueContent(materialized.root) || existingRoot.classId !== materialized.root.classId || !replayedCreationDataMatches({
94752
- currentDocument: args.document,
95055
+ // The synthetic variant binding members are part of the ownership
95056
+ // scope that compiled and evaluated this initializer. Stored replay
95057
+ // closes its generic slot from the same ephemeral member id, so its
95058
+ // expansion must read that scoped document too.
95059
+ currentDocument: materializationScope.document,
94753
95060
  currentGraph: requireCurrentGraph(),
94754
95061
  currentRoot: existingRoot,
94755
95062
  rootMember: member,
@@ -94896,7 +95203,10 @@ function reconcileInitializerMaterializationTransport(args) {
94896
95203
  allServerIds.add(change.recordId);
94897
95204
  }
94898
95205
  }
94899
- const graph = new MaterializedValueGraphContext(args.document);
95206
+ const graph = createVariantMaterializedValueGraphContext(
95207
+ args.document,
95208
+ args.document.variants ?? []
95209
+ );
94900
95210
  const serverOwners = graph.ownersForValues(allServerIds);
94901
95211
  for (const sourceValueId of serverRootIds) {
94902
95212
  const local = roots.get(sourceValueId);
@@ -94989,12 +95299,14 @@ function constructorArgumentsSemanticallyEqual(args) {
94989
95299
  const replayRows = new Map(args.currentGraph.valuesById);
94990
95300
  replayRows.set(args.replayRoot.id, args.replayRoot);
94991
95301
  for (const row of args.replayCreated) replayRows.set(row.id, row);
94992
- const currentNormalized = new MaterializedValueGraphContext(
95302
+ const currentNormalized = createVariantMaterializedValueGraphContext(
94993
95303
  args.currentDocument,
95304
+ args.currentDocument.variants ?? [],
94994
95305
  currentRows
94995
95306
  ).normalizeConstructorArguments(args.current, args.currentRoot);
94996
- const replayNormalized = new MaterializedValueGraphContext(
95307
+ const replayNormalized = createVariantMaterializedValueGraphContext(
94997
95308
  args.currentDocument,
95309
+ args.currentDocument.variants ?? [],
94998
95310
  replayRows
94999
95311
  ).normalizeConstructorArguments(args.replay, args.replayRoot);
95000
95312
  return canonicallyEqual2(currentNormalized, replayNormalized);
@@ -95299,236 +95611,6 @@ function removeDirectBindingsFromReadOnlySourceTransitions(currentDocument, chan
95299
95611
  delete next.valueId;
95300
95612
  }
95301
95613
  }
95302
- function remapReadOnlyConversionValueIds(values, memberId, ownerValueId) {
95303
- const remapped = /* @__PURE__ */ new Map();
95304
- values.forEach((value, index) => {
95305
- remapped.set(
95306
- value.id,
95307
- v5_default(
95308
- `neo-compose:readonly-conversion:${memberId}:${ownerValueId}:${index}`,
95309
- v5_default.URL
95310
- )
95311
- );
95312
- });
95313
- const rewrite = (value) => {
95314
- if (typeof value === "string") return remapped.get(value) ?? value;
95315
- if (Array.isArray(value)) return value.map(rewrite);
95316
- if (value === null || typeof value !== "object") return value;
95317
- return Object.fromEntries(
95318
- Object.entries(value).map(([key, child]) => [key, rewrite(child)])
95319
- );
95320
- };
95321
- for (const value of values) {
95322
- value.id = remapped.get(value.id) ?? value.id;
95323
- value.value = rewrite(value.value);
95324
- if (typeof value.containerId === "string") {
95325
- value.containerId = remapped.get(value.containerId) ?? value.containerId;
95326
- }
95327
- }
95328
- }
95329
- function collectReadOnlyClassValueSites(document, selectedMemberId) {
95330
- const membersById2 = new Map(
95331
- document.members.map((member) => [member.id, member])
95332
- );
95333
- const valuesById = new Map(document.values.map((value) => [value.id, value]));
95334
- const visited = /* @__PURE__ */ new Set();
95335
- const siteKeys = /* @__PURE__ */ new Set();
95336
- const sites = [];
95337
- const visit = (rawMember, valueId) => {
95338
- const visitKey = `${rawMember.id}\0${valueId}`;
95339
- if (visited.has(visitKey)) return;
95340
- visited.add(visitKey);
95341
- const value = valuesById.get(valueId);
95342
- if (value === void 0) return;
95343
- const member = resolveMember2(rawMember, document.members);
95344
- if (isMemberListBase(member) || isMemberDictionaryBase(member)) {
95345
- const entry = membersById2.get(member.entryMemberId);
95346
- if (entry === void 0) return;
95347
- const childIds = isMemberListBase(member) && listKindOf(member) === "unordered" ? document.values.filter((child) => child.containerId === value.id).map((child) => child.id) : Array.isArray(value.value) ? value.value : isStringValueRecord(value.value) ? Object.values(value.value) : [];
95348
- for (const childId of childIds) visit(entry, childId);
95349
- return;
95350
- }
95351
- if (!isMemberClassBase(member) || !isStringValueRecord(value.value)) {
95352
- return;
95353
- }
95354
- const effectiveClassId = value.classId ?? member.classId;
95355
- const env = resolveInstanceEnv(
95356
- effectiveClassId,
95357
- member.classArguments,
95358
- document.classes
95359
- );
95360
- for (const entry of mergeInstanceSurfaceSchema(
95361
- effectiveClassId,
95362
- document.classes,
95363
- document.members
95364
- )) {
95365
- if (entry.memberId === selectedMemberId) {
95366
- const siteKey = `${value.id}\0${entry.schemaKey}`;
95367
- if (!siteKeys.has(siteKey)) {
95368
- siteKeys.add(siteKey);
95369
- sites.push({
95370
- value,
95371
- record: value.value,
95372
- schemaKey: entry.schemaKey,
95373
- effectiveClassId
95374
- });
95375
- }
95376
- }
95377
- const childId = value.value[entry.schemaKey];
95378
- const childMember = membersById2.get(entry.memberId);
95379
- if (childMember === void 0 || typeof childId !== "string") continue;
95380
- visit(
95381
- substituteMember(childMember, env, document.members),
95382
- childId
95383
- );
95384
- }
95385
- };
95386
- for (const member of document.members) {
95387
- if (typeof member.valueId === "string") visit(member, member.valueId);
95388
- if (member.defaultValue == null) continue;
95389
- const synthetic = {
95390
- id: `__default:${member.id}`,
95391
- projectId: member.projectId,
95392
- createdAt: member.createdAt,
95393
- updatedAt: member.updatedAt,
95394
- ...member.defaultValue
95395
- };
95396
- valuesById.set(synthetic.id, synthetic);
95397
- visit(member, synthetic.id);
95398
- }
95399
- for (const value of document.values) {
95400
- if (typeof value.classId !== "string") continue;
95401
- visit(syntheticClassRowMember(value), value.id);
95402
- }
95403
- return sites.filter((site) => !site.value.id.startsWith("__default:"));
95404
- }
95405
- function collectValuesReachableWithoutReadOnlyBinding(document, excludedMemberId) {
95406
- const membersById2 = new Map(
95407
- document.members.map((member) => [member.id, member])
95408
- );
95409
- const valuesById = new Map(document.values.map((value) => [value.id, value]));
95410
- const reachable = /* @__PURE__ */ new Set();
95411
- const visitBody = (rawMember, body, classId, ownerValueId) => {
95412
- const member = resolveMember2(rawMember, document.members);
95413
- const visitChild = (childMember, childId) => {
95414
- if (childMember === void 0 || typeof childId !== "string") return;
95415
- if (reachable.has(childId)) return;
95416
- const child = valuesById.get(childId);
95417
- if (child === void 0) return;
95418
- reachable.add(childId);
95419
- visitBody(childMember, child.value, child.classId ?? void 0, child.id);
95420
- };
95421
- if (isMemberListBase(member)) {
95422
- const entry = membersById2.get(member.entryMemberId);
95423
- if (listKindOf(member) === "unordered" && ownerValueId !== void 0) {
95424
- for (const child of document.values) {
95425
- if (child.containerId === ownerValueId) visitChild(entry, child.id);
95426
- }
95427
- } else if (Array.isArray(body)) {
95428
- for (const childId of body) visitChild(entry, childId);
95429
- }
95430
- return;
95431
- }
95432
- if (isMemberDictionaryBase(member) && isStringValueRecord(body)) {
95433
- const entry = membersById2.get(member.entryMemberId);
95434
- for (const childId of Object.values(body)) visitChild(entry, childId);
95435
- return;
95436
- }
95437
- if (!isMemberClassBase(member) || !isStringValueRecord(body)) return;
95438
- const effectiveClassId = classId ?? member.classId;
95439
- const env = resolveInstanceEnv(
95440
- effectiveClassId,
95441
- member.classArguments,
95442
- document.classes
95443
- );
95444
- for (const entry of mergeInstanceSurfaceSchema(
95445
- effectiveClassId,
95446
- document.classes,
95447
- document.members
95448
- )) {
95449
- if (entry.memberId === excludedMemberId) continue;
95450
- const childMember = membersById2.get(entry.memberId);
95451
- visitChild(
95452
- childMember === void 0 ? void 0 : substituteMember(
95453
- childMember,
95454
- env,
95455
- document.members
95456
- ),
95457
- body[entry.schemaKey]
95458
- );
95459
- }
95460
- };
95461
- for (const member of document.members) {
95462
- if (member.id !== excludedMemberId && typeof member.valueId === "string") {
95463
- const value = valuesById.get(member.valueId);
95464
- if (value !== void 0) {
95465
- reachable.add(value.id);
95466
- visitBody(member, value.value, value.classId ?? void 0, value.id);
95467
- }
95468
- }
95469
- if (member.defaultValue != null) {
95470
- visitBody(
95471
- member,
95472
- member.defaultValue.value,
95473
- member.defaultValue.classId ?? void 0,
95474
- void 0
95475
- );
95476
- }
95477
- }
95478
- const referencedValueIds = collectStructurallyReferencedValueIds(document);
95479
- const boundRootIds = new Set(
95480
- document.members.flatMap(
95481
- (member) => typeof member.valueId === "string" ? [member.valueId] : []
95482
- )
95483
- );
95484
- for (const value of document.values) {
95485
- if (typeof value.classId !== "string") continue;
95486
- if (referencedValueIds.has(value.id) || boundRootIds.has(value.id))
95487
- continue;
95488
- reachable.add(value.id);
95489
- visitBody(
95490
- syntheticClassRowMember(value),
95491
- value.value,
95492
- value.classId,
95493
- value.id
95494
- );
95495
- }
95496
- return reachable;
95497
- }
95498
- function collectStructurallyReferencedValueIds(document) {
95499
- const valueIds = new Set(document.values.map((value) => value.id));
95500
- const referenced = /* @__PURE__ */ new Set();
95501
- const collect = (body) => {
95502
- const candidates = Array.isArray(body) ? body : isStringValueRecord(body) ? Object.values(body) : [];
95503
- for (const candidate of candidates) {
95504
- if (typeof candidate === "string" && valueIds.has(candidate)) {
95505
- referenced.add(candidate);
95506
- }
95507
- }
95508
- };
95509
- for (const value of document.values) {
95510
- collect(value.value);
95511
- if (typeof value.containerId === "string") {
95512
- referenced.add(value.id);
95513
- }
95514
- }
95515
- return referenced;
95516
- }
95517
- function syntheticClassRowMember(value) {
95518
- return {
95519
- id: `__class-row:${value.id}`,
95520
- projectId: value.projectId,
95521
- name: "Partitioned class row",
95522
- kind: 7 /* Class */,
95523
- classId: value.classId,
95524
- locked: false,
95525
- required: true,
95526
- isStatic: false,
95527
- accessModifierKind: "public",
95528
- createdAt: value.createdAt,
95529
- updatedAt: value.updatedAt
95530
- };
95531
- }
95532
95614
  function collectReadOnlyConversionDeletes(args) {
95533
95615
  if (args.preserved.has(args.valueId) || args.deleted.has(args.valueId))
95534
95616
  return;
@@ -96727,13 +96809,7 @@ function materializeStaticLocalizedTexts(args) {
96727
96809
  id: seed.id,
96728
96810
  projectId: args.document.project.id,
96729
96811
  value: seed.value,
96730
- link: {
96731
- kind: "member-value",
96732
- recordKind: "value",
96733
- recordId: seed.valueId,
96734
- fieldPath: "value",
96735
- valueId: seed.valueId
96736
- },
96812
+ link: memberValueLocalizedTextLink(seed.valueId),
96737
96813
  config,
96738
96814
  now
96739
96815
  });
@@ -97093,7 +97169,13 @@ function isStringValueRecord(value) {
97093
97169
  return value !== null && typeof value === "object" && !Array.isArray(value) && Object.values(value).every((entry) => typeof entry === "string");
97094
97170
  }
97095
97171
  function commitInitEvaluator(document, createdValues) {
97096
- return (member, init) => evaluateMemberInitializer({ init, member, document, createdValues });
97172
+ return (member, init, sourceValueId) => evaluateMemberInitializer({
97173
+ init,
97174
+ member,
97175
+ document,
97176
+ createdValues,
97177
+ sourceValueId: sourceValueId ?? null
97178
+ });
97097
97179
  }
97098
97180
  function hasAuthoredNeoScriptBody(member) {
97099
97181
  if (member.kind === 10 /* NSProperty */) return true;
@@ -98409,7 +98491,6 @@ var init_project_version_schema_commit = __esm({
98409
98491
  init_constructor_argument_ownership();
98410
98492
  init_constructors2();
98411
98493
  init_dialogue_node_index();
98412
- init_dist_node();
98413
98494
  init_member_value_id();
98414
98495
  init_virtual_instance_values();
98415
98496
  init_world_system_classes();
@@ -99003,7 +99084,7 @@ function toWorldReferenceClassRecord(value) {
99003
99084
  return {
99004
99085
  id: id2,
99005
99086
  extendsClassId: nullableStringField(value, "extendsClassId"),
99006
- schema: isStringRecord7(value.schema) ? value.schema : void 0,
99087
+ schema: isStringRecord8(value.schema) ? value.schema : void 0,
99007
99088
  system: isPlainRecord4(value.system) ? value.system : null
99008
99089
  };
99009
99090
  }
@@ -99021,7 +99102,7 @@ function worldReferenceValueClassId(value) {
99021
99102
  if (value === void 0) return null;
99022
99103
  return typeof value.classId === "string" && value.classId.length > 0 ? value.classId : null;
99023
99104
  }
99024
- function isStringRecord7(value) {
99105
+ function isStringRecord8(value) {
99025
99106
  if (!isPlainRecord4(value)) return false;
99026
99107
  return Object.values(value).every((entry) => typeof entry === "string");
99027
99108
  }
@@ -101225,7 +101306,7 @@ function classBelongsToAnimationFamily(classes, classId) {
101225
101306
  function prospectiveAnimationDocumentV4(records2) {
101226
101307
  const candidates = [...records2];
101227
101308
  const hasAnimationSchema = candidates.some(
101228
- (record3) => record3.recordKind === "class" && (Array.isArray(record3.data.constructorProjections) || declaresAnimationWorldKind(record3.data.system))
101309
+ (record3) => record3.recordKind === "class" && declaresAnimationWorldKind(record3.data.system)
101229
101310
  );
101230
101311
  if (!hasAnimationSchema) return null;
101231
101312
  const memberRecords = new Map(
@@ -102557,6 +102638,72 @@ var init_server_preparation_preflight = __esm({
102557
102638
  });
102558
102639
 
102559
102640
  // src/project-source/initializer-replay.ts
102641
+ function isPulledInitializerCompilationDocumentV4(document) {
102642
+ return typeof Reflect.get(document, "project") === "object" && Reflect.get(document, "project") !== null && Array.isArray(Reflect.get(document, "projectFiles")) && Array.isArray(Reflect.get(document, "members")) && Array.isArray(Reflect.get(document, "classes")) && Array.isArray(Reflect.get(document, "enums")) && Array.isArray(Reflect.get(document, "interfaces")) && Array.isArray(Reflect.get(document, "constructors")) && Array.isArray(Reflect.get(document, "values"));
102643
+ }
102644
+ function pulledInitializerCompilerStateV4(document, compilationProject) {
102645
+ const existing = pulledInitializerCompilerStates.get(document);
102646
+ if (existing !== void 0) {
102647
+ if (compilationProject !== void 0) {
102648
+ existing.compilationProject = compilationProject;
102649
+ }
102650
+ return existing;
102651
+ }
102652
+ const created = {
102653
+ compilationProject: compilationProject ?? null
102654
+ };
102655
+ pulledInitializerCompilerStates.set(document, created);
102656
+ return created;
102657
+ }
102658
+ function compilationProjectForPulledDocumentV4(document, state) {
102659
+ state.compilationProject ??= createNeoScriptCompilationProject({
102660
+ project: document.project,
102661
+ projectFiles: document.projectFiles,
102662
+ members: document.members,
102663
+ classes: document.classes,
102664
+ enums: document.enums,
102665
+ interfaces: document.interfaces,
102666
+ constructors: document.constructors ?? []
102667
+ });
102668
+ return state.compilationProject;
102669
+ }
102670
+ function memberCompilationIndexV4(document) {
102671
+ const existing = pulledMemberCompilationIndexes.get(document);
102672
+ if (existing !== void 0) return existing;
102673
+ const created = {
102674
+ membersById: new Map(
102675
+ document.members.map((member) => [member.id, member])
102676
+ ),
102677
+ ownerClassesByMemberId: new Map(
102678
+ document.classes.flatMap(
102679
+ (schemaClass2) => Object.values(schemaClass2.schema).map(
102680
+ (memberId) => [memberId, schemaClass2]
102681
+ )
102682
+ )
102683
+ )
102684
+ };
102685
+ pulledMemberCompilationIndexes.set(document, created);
102686
+ return created;
102687
+ }
102688
+ function pulledInitializerCompilerV4(document, compilationProject) {
102689
+ const state = pulledInitializerCompilerStateV4(document, compilationProject);
102690
+ return (site) => {
102691
+ if (site.sourceValueId !== null) {
102692
+ compilePulledValueInitializerBodyV4(
102693
+ document,
102694
+ site.sourceValueId,
102695
+ compilationProjectForPulledDocumentV4(document, state)
102696
+ );
102697
+ return;
102698
+ }
102699
+ if (site.memberId === null) return;
102700
+ compilePulledMemberInitializerBodyV4(
102701
+ document,
102702
+ site.memberId,
102703
+ compilationProjectForPulledDocumentV4(document, state)
102704
+ );
102705
+ };
102706
+ }
102560
102707
  function describePulledProjectBodyCompileError(error) {
102561
102708
  const fallback = error instanceof Error ? error.message : String(error);
102562
102709
  if (!(error instanceof CompileError)) return fallback;
@@ -102656,42 +102803,22 @@ function replayStoredConstructionV4(args) {
102656
102803
  } : candidate;
102657
102804
  compilePulledUncompiledConstructorsV4(document, compilationProject);
102658
102805
  assertPulledConstructorsCompiled(document);
102659
- const compiledDependencies = /* @__PURE__ */ new Set();
102660
- let materialized;
102661
- for (; ; ) {
102662
- try {
102663
- materialized = materializeInitializerValue({
102806
+ const materialized = materializeInitializerValue({
102807
+ document: {
102808
+ ...document,
102809
+ initializerCompiler: pulledInitializerCompilerV4(
102664
102810
  document,
102665
- // Constructor-only rows have no structural member owner. Use the same
102666
- // explicit typed descriptor for evaluation that compiled the replay.
102667
- member: compileMember,
102668
- row: evaluationRow,
102669
- storedConstructionReplay: true,
102670
- ...args.omitConstructionFields === true ? { constructionBaselineReplay: true } : {},
102671
- ...args.initializerArgumentValues === void 0 ? {} : { argumentValues: args.initializerArgumentValues }
102672
- });
102673
- break;
102674
- } catch (error) {
102675
- const dependencyKey = error instanceof UncompiledInitializerRuntimeError && error.valueId !== null ? error.valueId : error instanceof UncompiledInitializerRuntimeError && error.initializer !== null ? error.initializer : error instanceof UncompiledInitializerRuntimeError ? error.memberId : null;
102676
- if (!(error instanceof UncompiledInitializerRuntimeError) || error.memberId === null || dependencyKey === null || compiledDependencies.has(dependencyKey)) {
102677
- throw error;
102678
- }
102679
- if (error.valueId !== null) {
102680
- compilePulledValueInitializerBodyV4(
102681
- document,
102682
- error.valueId,
102683
- compilationProject
102684
- );
102685
- } else {
102686
- compilePulledMemberInitializerBodyV4(
102687
- document,
102688
- error.memberId,
102689
- compilationProject
102690
- );
102691
- }
102692
- compiledDependencies.add(dependencyKey);
102693
- }
102694
- }
102811
+ compilationProject
102812
+ )
102813
+ },
102814
+ // Constructor-only rows have no structural member owner. Use the same
102815
+ // explicit typed descriptor for evaluation that compiled the replay.
102816
+ member: compileMember,
102817
+ row: evaluationRow,
102818
+ storedConstructionReplay: true,
102819
+ ...args.omitConstructionFields === true ? { constructionBaselineReplay: true } : {},
102820
+ ...args.initializerArgumentValues === void 0 ? {} : { argumentValues: args.initializerArgumentValues }
102821
+ });
102695
102822
  args.onPinnedRootSchemaKeys?.(materialized.pinnedRootSchemaKeys);
102696
102823
  return new Map(
102697
102824
  [materialized.root, ...materialized.createdValues].map((row) => [
@@ -102800,6 +102927,7 @@ function compilePulledProjectDocumentForEvaluationV4(document, compilationProjec
102800
102927
  interfaces: document.interfaces,
102801
102928
  constructors: document.constructors ?? []
102802
102929
  });
102930
+ pulledInitializerCompilerStateV4(document, sharedCompilationProject);
102803
102931
  const compileArgs = {
102804
102932
  project: document.project,
102805
102933
  projectFiles: document.projectFiles,
@@ -102814,19 +102942,13 @@ function compilePulledProjectDocumentForEvaluationV4(document, compilationProjec
102814
102942
  compileConstructorRecord({ ...compileArgs, constructor: constructor2 });
102815
102943
  }
102816
102944
  assertPulledConstructorsCompiled(document);
102817
- const ownerClassByMemberId = new Map(
102818
- compileArgs.classes.flatMap(
102819
- (schemaClass2) => Object.values(schemaClass2.schema).map(
102820
- (memberId) => [memberId, schemaClass2]
102821
- )
102822
- )
102823
- );
102945
+ const memberIndex = memberCompilationIndexV4(document);
102824
102946
  for (const member of compileArgs.members) {
102825
102947
  try {
102826
102948
  compileAuthoredMemberBodies({
102827
102949
  ...compileArgs,
102828
102950
  member,
102829
- thisClass: ownerClassByMemberId.get(member.id) ?? null
102951
+ thisClass: memberIndex.ownerClassesByMemberId.get(member.id) ?? null
102830
102952
  });
102831
102953
  } catch (error) {
102832
102954
  if (error instanceof CompileError) {
@@ -102859,15 +102981,14 @@ function compilePulledMemberInitializerBodyV4(document, memberId, compilationPro
102859
102981
  interfaces: document.interfaces,
102860
102982
  constructors: document.constructors ?? []
102861
102983
  };
102862
- const member = compileArgs.members.find((entry) => entry.id === memberId);
102984
+ const memberIndex = memberCompilationIndexV4(document);
102985
+ const member = memberIndex.membersById.get(memberId);
102863
102986
  if (member === void 0) {
102864
102987
  throw new Error(
102865
102988
  `Cannot compile initializer dependency for missing member "${memberId}".`
102866
102989
  );
102867
102990
  }
102868
- const thisClass = compileArgs.classes.find(
102869
- (schemaClass2) => Object.values(schemaClass2.schema).includes(memberId)
102870
- ) ?? null;
102991
+ const thisClass = memberIndex.ownerClassesByMemberId.get(memberId) ?? null;
102871
102992
  compileMemberInitializerBody({
102872
102993
  ...compileArgs,
102873
102994
  member,
@@ -102988,7 +103109,7 @@ function replayWorkspace(records2) {
102988
103109
  state: { records: stateRecords }
102989
103110
  };
102990
103111
  }
102991
- var pulledBodyCompileSites, pulledValueInitializerCompilationSites;
103112
+ var pulledBodyCompileSites, pulledInitializerCompilerStates, pulledMemberCompilationIndexes, pulledValueInitializerCompilationSites;
102992
103113
  var init_initializer_replay = __esm({
102993
103114
  "src/project-source/initializer-replay.ts"() {
102994
103115
  "use strict";
@@ -103002,9 +103123,10 @@ var init_initializer_replay = __esm({
103002
103123
  init_server_preparation_preflight();
103003
103124
  init_projection();
103004
103125
  init_constructors2();
103005
- init_neoscript_evaluator();
103006
103126
  init_compiler_adapter();
103007
103127
  pulledBodyCompileSites = /* @__PURE__ */ new WeakMap();
103128
+ pulledInitializerCompilerStates = /* @__PURE__ */ new WeakMap();
103129
+ pulledMemberCompilationIndexes = /* @__PURE__ */ new WeakMap();
103008
103130
  pulledValueInitializerCompilationSites = /* @__PURE__ */ new WeakMap();
103009
103131
  }
103010
103132
  });
@@ -103864,6 +103986,9 @@ function lowerVariantGraph(context, binding, created) {
103864
103986
  variantValueRecord(binding, variantRowFields(row), binding.source)
103865
103987
  );
103866
103988
  }
103989
+ for (const text of localizedTexts.values()) {
103990
+ created.push(variantLocalizedTextRecord(context, text, binding.source));
103991
+ }
103867
103992
  }
103868
103993
  function lowerVariantRootRow(context, binding, rootMember, source, rows, localizedTexts) {
103869
103994
  if (rootMember.kind !== "class") {
@@ -104057,6 +104182,27 @@ function variantValueRecord(binding, fileFields, source) {
104057
104182
  }
104058
104183
  };
104059
104184
  }
104185
+ function variantLocalizedTextRecord(context, text, source) {
104186
+ return {
104187
+ recordKind: "localized-text",
104188
+ recordId: text.id,
104189
+ fileFields: {
104190
+ id: text.id,
104191
+ sourceComment: null,
104192
+ links: [memberValueLocalizedTextLink(text.valueId)],
104193
+ localeValues: {
104194
+ [context.mainLocale]: { value: text.value }
104195
+ }
104196
+ },
104197
+ file: source.uri,
104198
+ line: source.range.start.line + 1,
104199
+ sourceSpan: {
104200
+ path: source.uri,
104201
+ start: source.range.start,
104202
+ end: source.range.end
104203
+ }
104204
+ };
104205
+ }
104060
104206
  function variantRootMember(context, binding) {
104061
104207
  const variantClass = context.classesByName.get(binding.variantTypeName);
104062
104208
  if (variantClass === void 0) {
@@ -104807,14 +104953,6 @@ function lowerRowBackedDefault(context, member, backed, baseData3, binding) {
104807
104953
  const assignmentSlices = objectInitializerSlices(binding.initializer);
104808
104954
  for (const assignment of expression.initializer ?? []) {
104809
104955
  const childMember = classMemberByName(context, classId, assignment.name);
104810
- if (inheritedLegacyConstructorProjections(
104811
- context.classes,
104812
- schemaClass2.id
104813
- ).some((projection) => projection.memberId === childMember.id)) {
104814
- throw new Error(
104815
- `Default value ${binding.label}.${assignment.name} is constructor-projected and must be set through its named constructor argument.`
104816
- );
104817
- }
104818
104956
  const childValueMember = recursivePartialMember(member, childMember);
104819
104957
  const childSlice = assignmentSlices.get(assignment.name);
104820
104958
  const existingId = isObjectRecord2(baseBody) ? baseBody[assignment.name] : void 0;
@@ -105454,14 +105592,6 @@ function lowerSeedRow(context, member, sourceExpression, source, valueId, path,
105454
105592
  effectiveClass.id,
105455
105593
  assignment.name
105456
105594
  );
105457
- if (!partial && inheritedLegacyConstructorProjections(
105458
- context.classes,
105459
- effectiveClass.id
105460
- ).some((projection) => projection.memberId === childMember.id)) {
105461
- throw new Error(
105462
- `Class value ${path}.${assignment.name} is constructor-projected and must be set through its named constructor argument.`
105463
- );
105464
- }
105465
105595
  const childPath = `${path}.${assignment.name}`;
105466
105596
  const childId = lowerSeedChild(
105467
105597
  context,
@@ -105547,21 +105677,43 @@ function lowerSeedRow(context, member, sourceExpression, source, valueId, path,
105547
105677
  `String member ${member.name} requires a string literal.`
105548
105678
  );
105549
105679
  }
105550
- const textId = pendingLocalizedTextId(source, path);
105551
- if (localizedTexts.has(textId)) {
105552
- throw new Error(`Localized text construction reuses identity ${textId}.`);
105680
+ const stored = context.state[`value:${valueId}`];
105681
+ if (stored !== void 0) {
105682
+ if (!isObjectRecord2(stored.data)) {
105683
+ throw new Error(
105684
+ `Localizable value ${valueId} has invalid stored data.`
105685
+ );
105686
+ }
105687
+ if (typeof stored.data.value !== "string") {
105688
+ throw new Error(
105689
+ `Localizable value ${valueId} has no existing localized-text link.`
105690
+ );
105691
+ }
105692
+ value = lowerLinkedLocalizedText(
105693
+ context,
105694
+ stored.data.value,
105695
+ expression.value,
105696
+ source
105697
+ );
105698
+ } else {
105699
+ const textId = pendingLocalizedTextId(source, path);
105700
+ if (localizedTexts.has(textId)) {
105701
+ throw new Error(
105702
+ `Localized text construction reuses identity ${textId}.`
105703
+ );
105704
+ }
105705
+ localizedTexts.set(textId, {
105706
+ id: textId,
105707
+ valueId,
105708
+ value: expression.value
105709
+ });
105710
+ context.pendingLocalizedTexts.set(textId, {
105711
+ id: textId,
105712
+ valueId,
105713
+ value: expression.value
105714
+ });
105715
+ value = textId;
105553
105716
  }
105554
- localizedTexts.set(textId, {
105555
- id: textId,
105556
- valueId,
105557
- value: expression.value
105558
- });
105559
- context.pendingLocalizedTexts.set(textId, {
105560
- id: textId,
105561
- valueId,
105562
- value: expression.value
105563
- });
105564
- value = textId;
105565
105717
  } else {
105566
105718
  const lowered = lowerValueBody(
105567
105719
  context,
@@ -106204,14 +106356,6 @@ function lowerClassValue(context, member, expression, base, source, outerEnviron
106204
106356
  }
106205
106357
  for (const assignment of expression.initializer ?? []) {
106206
106358
  const childMember = classMemberByName(context, classId, assignment.name);
106207
- if (!partial && inheritedLegacyConstructorProjections(
106208
- context.classes,
106209
- schemaClass2.id
106210
- ).some((projection) => projection.memberId === childMember.id)) {
106211
- throw new Error(
106212
- `Class value ${String(base.id)}.${assignment.name} is constructor-projected and must be set through its named constructor argument.`
106213
- );
106214
- }
106215
106359
  const childId = baseBody[assignment.name];
106216
106360
  if (typeof childId !== "string") {
106217
106361
  const symbolId2 = sourceValueSymbol(context, assignment.value);
@@ -106277,7 +106421,8 @@ function lowerClassValue(context, member, expression, base, source, outerEnviron
106277
106421
  childId,
106278
106422
  source.source,
106279
106423
  /* @__PURE__ */ new Set(),
106280
- memberById(context, storedMemberIds.get(schemaKey))
106424
+ memberById(context, storedMemberIds.get(schemaKey)),
106425
+ environment
106281
106426
  );
106282
106427
  }
106283
106428
  }
@@ -106309,7 +106454,8 @@ function lowerClassValue(context, member, expression, base, source, outerEnviron
106309
106454
  valueId,
106310
106455
  source.source,
106311
106456
  /* @__PURE__ */ new Set(),
106312
- null
106457
+ null,
106458
+ environment
106313
106459
  );
106314
106460
  }
106315
106461
  }
@@ -106370,7 +106516,7 @@ function storedRowPlacementMember(context, valueId) {
106370
106516
  }
106371
106517
  return null;
106372
106518
  }
106373
- function retainStoredValueSubgraph(context, valueId, source, visited, member) {
106519
+ function retainStoredValueSubgraph(context, valueId, source, visited, member, environment) {
106374
106520
  if (visited.has(valueId)) return;
106375
106521
  visited.add(valueId);
106376
106522
  const state = context.state[`value:${valueId}`];
@@ -106383,7 +106529,28 @@ function retainStoredValueSubgraph(context, valueId, source, visited, member) {
106383
106529
  source,
106384
106530
  { retained: true }
106385
106531
  );
106386
- const owningMember = member ?? storedRowPlacementMember(context, valueId);
106532
+ const rawOwningMember = member ?? storedRowPlacementMember(context, valueId);
106533
+ const owningMember = rawOwningMember === null ? null : resolveGenericSchemaMember(context, rawOwningMember, environment);
106534
+ if (owningMember?.kind === "string" && owningMember.localizable) {
106535
+ const textId = state.data.value;
106536
+ if (typeof textId !== "string") {
106537
+ throw new Error(
106538
+ `Localizable value ${valueId} has no existing localized-text link.`
106539
+ );
106540
+ }
106541
+ const textState = context.state[`localized-text:${textId}`];
106542
+ if (!isObjectRecord2(textState?.data)) {
106543
+ throw new Error(`Localized text ${textId} was not pulled.`);
106544
+ }
106545
+ addReconstructed(
106546
+ context,
106547
+ "localized-text",
106548
+ textId,
106549
+ nonVolatileFields(textState.data),
106550
+ source,
106551
+ { retained: true }
106552
+ );
106553
+ }
106387
106554
  if (owningMember !== null && memberPointsAtForeignRows(owningMember)) return;
106388
106555
  const referenced = /* @__PURE__ */ new Map();
106389
106556
  const add = (id2, childMember) => {
@@ -106405,6 +106572,27 @@ function retainStoredValueSubgraph(context, valueId, source, visited, member) {
106405
106572
  };
106406
106573
  const body = state.data.value;
106407
106574
  const storedClassId = stringOrNull2(state.data.classId);
106575
+ let childEnvironment = environment;
106576
+ if (storedClassId !== null) {
106577
+ if (owningMember?.kind === "class") {
106578
+ childEnvironment = lowerInstanceGenericEnvironment(
106579
+ context,
106580
+ storedClassId,
106581
+ owningMember,
106582
+ environment
106583
+ );
106584
+ } else {
106585
+ const inherited = new Map(environment ?? []);
106586
+ for (const [genericParamId, bindingMemberId] of classGenericEnvironment(
106587
+ context,
106588
+ storedClassId
106589
+ )) {
106590
+ inherited.set(genericParamId, bindingMemberId);
106591
+ }
106592
+ childEnvironment = inherited;
106593
+ }
106594
+ }
106595
+ childEnvironment = valueGenericEnvironment(state.data, childEnvironment);
106408
106596
  if (isObjectRecord2(body) && storedClassId !== null) {
106409
106597
  const storedMemberIds = storedClassSchemaMemberIds(context, storedClassId);
106410
106598
  for (const [schemaKey, child] of Object.entries(body)) {
@@ -106419,7 +106607,14 @@ function retainStoredValueSubgraph(context, valueId, source, visited, member) {
106419
106607
  add(childId, collectionEntryMember(context, owningMember));
106420
106608
  }
106421
106609
  for (const [childId, childMember] of referenced) {
106422
- retainStoredValueSubgraph(context, childId, source, visited, childMember);
106610
+ retainStoredValueSubgraph(
106611
+ context,
106612
+ childId,
106613
+ source,
106614
+ visited,
106615
+ childMember,
106616
+ childEnvironment
106617
+ );
106423
106618
  }
106424
106619
  }
106425
106620
  function lowerConstructorProjections(context, schemaClass2, expression, base, baseBody, body, source, environment, authoredSlice) {
@@ -106486,24 +106681,10 @@ function classInheritanceChain(classes, classId) {
106486
106681
  }
106487
106682
  return chain;
106488
106683
  }
106489
- function inheritedLegacyConstructorProjections(classes, classId) {
106490
- const resolved = [];
106491
- const claimed = /* @__PURE__ */ new Set();
106492
- for (const schemaClass2 of classInheritanceChain(classes, classId)) {
106493
- for (const projection of schemaClass2.constructorProjections ?? []) {
106494
- if (claimed.has(projection.parameterName)) continue;
106495
- claimed.add(projection.parameterName);
106496
- resolved.push(projection);
106497
- }
106498
- }
106499
- return resolved;
106500
- }
106501
106684
  function effectiveConstructorProjections(classes, constructors, members, classId) {
106502
106685
  const schemaClass2 = classes.get(classId);
106503
106686
  const requiredId = schemaClass2?.requiredConstructorId;
106504
- if (schemaClass2 === void 0 || requiredId === void 0) {
106505
- return inheritedLegacyConstructorProjections(classes, classId);
106506
- }
106687
+ if (schemaClass2 === void 0 || requiredId === void 0) return [];
106507
106688
  const required2 = constructors.get(requiredId);
106508
106689
  if (required2 === void 0) return [];
106509
106690
  const projected = requiredConstructorProjectionMap(
@@ -106751,7 +106932,10 @@ function inferAnimationChildOverrideLowerEnvironment(context, schemaClass2, expr
106751
106932
  return inherited;
106752
106933
  }
106753
106934
  const parameter4 = schemaClass2.genericParameters[0];
106754
- const parameterName = schemaClass2.constructorProjections?.[0]?.parameterName ?? requiredConstructorFirstParameterName(context, schemaClass2);
106935
+ const parameterName = requiredConstructorFirstParameterName(
106936
+ context,
106937
+ schemaClass2
106938
+ );
106755
106939
  if (parameter4 === void 0 || parameterName === null) return inherited;
106756
106940
  const argumentIndex = expression.argumentNames?.findIndex(
106757
106941
  (name) => name === parameterName
@@ -107097,10 +107281,6 @@ function lowerStringValue(context, member, expression, base, source) {
107097
107281
  `Localizable value ${String(base.id)} has no existing localized-text link.`
107098
107282
  );
107099
107283
  }
107100
- const textState = context.state[`localized-text:${base.value}`];
107101
- if (!isObjectRecord2(textState?.data)) {
107102
- return expression.value;
107103
- }
107104
107284
  return lowerLinkedLocalizedText(
107105
107285
  context,
107106
107286
  base.value,
@@ -108351,6 +108531,14 @@ function emitValue(context, member, valueId, options) {
108351
108531
  function emitValueBody(context, member, value, visited, targetTyped, environment) {
108352
108532
  const kind = numberField(member, "kind");
108353
108533
  const body = value.value;
108534
+ if (body === null) {
108535
+ if (kind !== 0 /* Null */ && member.required === true) {
108536
+ throw new Error(
108537
+ `Stored required member ${String(member.name ?? member.id)} cannot be null.`
108538
+ );
108539
+ }
108540
+ return "null";
108541
+ }
108354
108542
  if (kind === 0) return "null";
108355
108543
  if (kind === 1 || kind === 2 || kind === 4) return scalar(body);
108356
108544
  if (kind === 3)
@@ -109954,7 +110142,9 @@ function localizedString(context, member, body) {
109954
110142
  return String(body ?? "");
109955
110143
  const localized = context.localizedTexts.get(body);
109956
110144
  if (localized === void 0) {
109957
- return body;
110145
+ throw new Error(
110146
+ `Localizable value references missing localized text "${body}".`
110147
+ );
109958
110148
  }
109959
110149
  context.localizedTextIds.add(body);
109960
110150
  const localeValues = isObjectRecord2(localized?.localeValues) ? localized.localeValues : {};
@@ -110097,6 +110287,7 @@ var init_value_sources = __esm({
110097
110287
  init_member_value_id();
110098
110288
  init_instance_provenance();
110099
110289
  init_members();
110290
+ init_localization2();
110100
110291
  init_compile_ns_property();
110101
110292
  init_compile();
110102
110293
  init_constructor_argument_ownership();
@@ -114135,13 +114326,12 @@ function auditDanglingLocalizedTexts(args) {
114135
114326
  const memberId = placement === void 0 ? memberIdByValueId.get(value.id) : args.memberIdBySchemaKey.get(placement.parent.classId ?? "")?.get(placement.schemaKey);
114136
114327
  if (memberId === void 0) continue;
114137
114328
  if (!localizableMemberIds.has(memberId)) continue;
114138
- if (!isLocalizedTextIdShape(body)) continue;
114139
114329
  const memberName = memberNames.get(memberId) ?? memberId;
114140
114330
  findings.push({
114141
114331
  kind: "dangling-localized-text",
114142
114332
  recordKind: "value",
114143
114333
  recordId: value.id,
114144
- message: `Value "${value.id}" holds localizable string "${memberName}" as localized-text "${body}", which is not in this project. The literal is lost: pull re-emits the id as the text and the next push mints a new one, so the push never converges. Re-author the value, or declare the member \`@settings(localizable: false)\` if it is data rather than display copy.`,
114334
+ message: `Value "${value.id}" holds localizable string "${memberName}" as localized-text "${body}", which is not in this project. Source projection fails closed because no localized text exists for that identity. Re-author the value, or declare the member \`@settings(localizable: false)\` if it is data rather than display copy.`,
114145
114335
  repair: { valueId: value.id, memberId, localizedTextId: body }
114146
114336
  });
114147
114337
  }
@@ -114247,9 +114437,6 @@ function collectRecordIdStrings(data, recordsById2, claim) {
114247
114437
  collectRecordIdStrings(entry, recordsById2, claim);
114248
114438
  }
114249
114439
  }
114250
- function isLocalizedTextIdShape(body) {
114251
- return WHOLE_RECORD_ID.test(body);
114252
- }
114253
114440
  function childStorageKeyDeclaration(args) {
114254
114441
  const { placement } = args;
114255
114442
  if (placement.schemaKey === UNORDERED_MEMBERSHIP_KEY) {
@@ -114378,7 +114565,7 @@ function normalizePartition(mapKey) {
114378
114565
  function describePartition(mapKey) {
114379
114566
  return mapKey === null ? `"${MAIN_STORAGE_PARTITION}"` : `"${mapKey}"`;
114380
114567
  }
114381
- var UNORDERED_MEMBERSHIP_KEY, MEMBER_KIND_STRING, RECORD_ID_PATTERN2, EMBEDDED_RECORD_ID, WHOLE_RECORD_ID;
114568
+ var UNORDERED_MEMBERSHIP_KEY, MEMBER_KIND_STRING, RECORD_ID_PATTERN2, EMBEDDED_RECORD_ID;
114382
114569
  var init_project_integrity = __esm({
114383
114570
  "src/project-source/project-integrity.ts"() {
114384
114571
  "use strict";
@@ -114390,7 +114577,6 @@ var init_project_integrity = __esm({
114390
114577
  MEMBER_KIND_STRING = 3;
114391
114578
  RECORD_ID_PATTERN2 = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
114392
114579
  EMBEDDED_RECORD_ID = new RegExp(RECORD_ID_PATTERN2, "gu");
114393
- WHOLE_RECORD_ID = new RegExp(`^${RECORD_ID_PATTERN2}$`, "u");
114394
114580
  }
114395
114581
  });
114396
114582
 
@@ -115860,7 +116046,8 @@ async function runScript(workspace, command, options, dependencies = {}) {
115860
116046
  saveStaticBindings = readSaveStaticBindings(saveOverlay.staticBindings);
115861
116047
  }
115862
116048
  const overlaidDocument = { ...document, values: evalValues };
115863
- const lookups = cliEvaluatorLookups(overlaidDocument);
116049
+ const runtime = cliEvaluatorRuntime(overlaidDocument);
116050
+ const lookups = runtime.databaseVM;
115864
116051
  const vm = {
115865
116052
  project: document.project,
115866
116053
  members: document.members,
@@ -115874,7 +116061,7 @@ async function runScript(workspace, command, options, dependencies = {}) {
115874
116061
  projectFiles: document.projectFiles,
115875
116062
  localizationConfig: document.localizationConfig,
115876
116063
  localizedTexts: document.localizedTexts,
115877
- databaseVM: lookups
116064
+ ...runtime
115878
116065
  };
115879
116066
  const evaluatorContext2 = {
115880
116067
  vm,
@@ -115954,47 +116141,41 @@ async function runScript(workspace, command, options, dependencies = {}) {
115954
116141
  function buildStoredNeoScriptChecks(document) {
115955
116142
  const checks = [];
115956
116143
  const projectData = document;
115957
- const splitDialogues = document.dialogueRecords.length > 0 || document.dialogueNodes.length > 0;
115958
- const dialogueEntries = splitDialogues ? document.dialogueRecords.map((dialogue) => ({
116144
+ const dialogueEntries = document.dialogueRecords.map((dialogue) => ({
115959
116145
  dialogue,
115960
116146
  nodes: document.dialogueNodes.filter(
115961
116147
  (node) => node.dialogueId === dialogue.id
115962
116148
  )
115963
- })) : document.dialogues.map((dialogue) => ({
115964
- dialogue,
115965
- nodes: aggregateDialogueNodes(dialogue)
115966
116149
  }));
115967
- if (splitDialogues) {
115968
- const dialogueIds = new Set(
115969
- document.dialogueRecords.flatMap(
115970
- (dialogue) => typeof dialogue.id === "string" ? [dialogue.id] : []
115971
- )
115972
- );
115973
- for (const node of document.dialogueNodes) {
115974
- if (typeof node.dialogueId === "string" && dialogueIds.has(node.dialogueId)) {
115975
- continue;
115976
- }
115977
- const nodeId = stableRecordId(node, "(unknown-node)");
115978
- checks.push({
115979
- recordKind: "dialogue-node",
115980
- id: nodeId,
115981
- name: nodeId,
115982
- unit: "condition",
115983
- path: `dialogueNodes.${nodeId}`,
115984
- bodySite: {
115985
- recordKind: "dialogue-node",
115986
- recordId: nodeId,
115987
- recordName: nodeId,
115988
- unit: "getter",
115989
- code: ""
115990
- },
115991
- run: () => {
115992
- throw new Error(
115993
- `Dialogue node "${nodeId}" references missing dialogue "${String(node.dialogueId)}".`
115994
- );
115995
- }
115996
- });
116150
+ const dialogueIds = new Set(
116151
+ document.dialogueRecords.flatMap(
116152
+ (dialogue) => typeof dialogue.id === "string" ? [dialogue.id] : []
116153
+ )
116154
+ );
116155
+ for (const node of document.dialogueNodes) {
116156
+ if (typeof node.dialogueId === "string" && dialogueIds.has(node.dialogueId)) {
116157
+ continue;
115997
116158
  }
116159
+ const nodeId = stableRecordId(node, "(unknown-node)");
116160
+ checks.push({
116161
+ recordKind: "dialogue-node",
116162
+ id: nodeId,
116163
+ name: nodeId,
116164
+ unit: "condition",
116165
+ path: `dialogueNodes.${nodeId}`,
116166
+ bodySite: {
116167
+ recordKind: "dialogue-node",
116168
+ recordId: nodeId,
116169
+ recordName: nodeId,
116170
+ unit: "getter",
116171
+ code: ""
116172
+ },
116173
+ run: () => {
116174
+ throw new Error(
116175
+ `Dialogue node "${nodeId}" references missing dialogue "${String(node.dialogueId)}".`
116176
+ );
116177
+ }
116178
+ });
115998
116179
  }
115999
116180
  for (const { dialogue, nodes } of dialogueEntries) {
116000
116181
  const dialogueId = stableRecordId(dialogue, "(unknown-dialogue)");
@@ -116239,20 +116420,6 @@ function buildStoredNeoScriptChecks(document) {
116239
116420
  }
116240
116421
  return checks;
116241
116422
  }
116242
- function aggregateDialogueNodes(dialogue) {
116243
- const result = [];
116244
- if (isObjectRecord2(dialogue.triggerNode)) {
116245
- result.push(dialogue.triggerNode);
116246
- }
116247
- if (!isObjectRecord2(dialogue.nodes)) return result;
116248
- for (const [nodeKey, nodeValue] of Object.entries(dialogue.nodes)) {
116249
- if (!isObjectRecord2(nodeValue)) continue;
116250
- result.push(
116251
- typeof nodeValue.id === "string" ? nodeValue : { ...nodeValue, id: nodeKey }
116252
- );
116253
- }
116254
- return result;
116255
- }
116256
116423
  function buildScriptDialogueContext(dialogue, nodes) {
116257
116424
  const trigger = nodes.find((node) => node.type === 0 /* Trigger */);
116258
116425
  return {
@@ -120385,8 +120552,8 @@ var init_registry2 = __esm({
120385
120552
  "use strict";
120386
120553
  PROJECT_SCHEMA_CONTRACT = Object.freeze({
120387
120554
  formatVersion: 3,
120388
- contractVersion: "3.14",
120389
- cliVersion: "0.38.2",
120555
+ contractVersion: "3.15",
120556
+ cliVersion: "0.38.4",
120390
120557
  projectFileUploadBatchSize: 32,
120391
120558
  documentRecords: {
120392
120559
  member: {
@@ -120492,7 +120659,6 @@ var init_registry2 = __esm({
120492
120659
  "allowedStorageKeys",
120493
120660
  "genericParams",
120494
120661
  "extendsGenericBindings",
120495
- "constructorProjections",
120496
120662
  "constructorIds",
120497
120663
  "requiredConstructorId",
120498
120664
  "targetMemberId"
@@ -120510,7 +120676,6 @@ var init_registry2 = __esm({
120510
120676
  allowedStorageKeys: "nullIsAbsent",
120511
120677
  genericParams: "nullOrEmptyArrayIsAbsent",
120512
120678
  extendsGenericBindings: "nullOrEmptyObjectIsAbsent",
120513
- constructorProjections: "nullOrEmptyArrayIsAbsent",
120514
120679
  constructorIds: "nullOrEmptyArrayIsAbsent",
120515
120680
  requiredConstructorId: "nullIsAbsent"
120516
120681
  }
@@ -121866,10 +122031,11 @@ function sharedEvaluatorBase(rawDocument) {
121866
122031
  if (cached !== void 0) return cached;
121867
122032
  const document = readDocumentArrays(rawDocument);
121868
122033
  const constructors = Array.isArray(rawDocument.constructors) ? rawDocument.constructors.filter(isRecord10) : [];
121869
- const lookups = cliEvaluatorLookups(
122034
+ const runtime = cliEvaluatorRuntime(
121870
122035
  { ...document, constructors },
121871
122036
  { includeValueGraphIndexes: true }
121872
122037
  );
122038
+ const lookups = runtime.databaseVM;
121873
122039
  const vm = {
121874
122040
  project: document.project,
121875
122041
  members: document.members,
@@ -121883,7 +122049,7 @@ function sharedEvaluatorBase(rawDocument) {
121883
122049
  projectFiles: document.projectFiles,
121884
122050
  localizationConfig: document.localizationConfig,
121885
122051
  localizedTexts: document.localizedTexts,
121886
- databaseVM: lookups
122052
+ ...runtime
121887
122053
  };
121888
122054
  const created = {
121889
122055
  vm,
@@ -124229,7 +124395,8 @@ async function runPendingMigrations(workspace, client, raw, migrations, onlyRef,
124229
124395
  const valueById = new Map(
124230
124396
  document.values.map((value) => [String(value.id), value])
124231
124397
  );
124232
- const lookups = cliEvaluatorLookups(document);
124398
+ const runtime = cliEvaluatorRuntime(document);
124399
+ const lookups = runtime.databaseVM;
124233
124400
  const rootValue = buildRootValue(document, lookups);
124234
124401
  const authoredStaticValueIdByMemberId = new Map(
124235
124402
  document.members.flatMap(
@@ -124314,7 +124481,7 @@ async function runPendingMigrations(workspace, client, raw, migrations, onlyRef,
124314
124481
  projectFiles: document.projectFiles,
124315
124482
  localizationConfig: document.localizationConfig,
124316
124483
  localizedTexts: document.localizedTexts,
124317
- databaseVM: lookups
124484
+ ...runtime
124318
124485
  },
124319
124486
  thisValue: instance === null ? null : instance.value,
124320
124487
  rootValue,
@@ -125907,7 +126074,8 @@ function buildWorld(document, raw) {
125907
126074
  }
125908
126075
  }
125909
126076
  }
125910
- const lookups = cliEvaluatorLookups(document);
126077
+ const runtime = cliEvaluatorRuntime(document);
126078
+ const lookups = runtime.databaseVM;
125911
126079
  return {
125912
126080
  valueById,
125913
126081
  rootValue: buildRootValue(document, lookups),
@@ -125925,7 +126093,7 @@ function buildWorld(document, raw) {
125925
126093
  projectFiles: document.projectFiles,
125926
126094
  localizationConfig: document.localizationConfig,
125927
126095
  localizedTexts: document.localizedTexts,
125928
- databaseVM: lookups
126096
+ ...runtime
125929
126097
  },
125930
126098
  saveOwned,
125931
126099
  sessionOwned,
@@ -126314,6 +126482,7 @@ function cloneDryrunWorld(source) {
126314
126482
  return next;
126315
126483
  };
126316
126484
  const document = { ...source.document, values };
126485
+ const runtime = cliEvaluatorRuntime(document);
126317
126486
  return {
126318
126487
  ...source,
126319
126488
  valueById,
@@ -126322,7 +126491,7 @@ function cloneDryrunWorld(source) {
126322
126491
  vm: {
126323
126492
  ...source.vm,
126324
126493
  values,
126325
- databaseVM: cliEvaluatorLookups(document)
126494
+ ...runtime
126326
126495
  },
126327
126496
  saveOwned: new Set(source.saveOwned),
126328
126497
  sessionOwned: new Set(source.sessionOwned),
@@ -126421,7 +126590,7 @@ function applyEvaluationResult(result, world) {
126421
126590
  const values = [...world.valueById.values()];
126422
126591
  world.document = { ...world.document, values };
126423
126592
  world.vm.values = values;
126424
- world.vm.databaseVM = cliEvaluatorLookups(world.document);
126593
+ Object.assign(world.vm, cliEvaluatorRuntime(world.document));
126425
126594
  }
126426
126595
  function dryrunStoredValueEquals(stored, value, valueId, world) {
126427
126596
  if (valueId !== void 0) return stored === valueId;
@@ -127109,7 +127278,7 @@ There is no --keep-current: preserving current semantic state defines flatten.
127109
127278
  async function main() {
127110
127279
  const args = parseArgs(process.argv.slice(2));
127111
127280
  if (args.command === "--version") {
127112
- console.log("0.38.2");
127281
+ console.log("0.38.4");
127113
127282
  return;
127114
127283
  }
127115
127284
  if (args.command === null || args.command === "help" || args.command === "--help" || args.command === "-h") {
@@ -127180,6 +127349,10 @@ async function main() {
127180
127349
  return;
127181
127350
  }
127182
127351
  case "pull": {
127352
+ assertAllowedFlags(
127353
+ args,
127354
+ /* @__PURE__ */ new Set(["api", "force", "reset", "regenerate-source-names"])
127355
+ );
127183
127356
  const workspace = loadWorkspaceForCommand(args);
127184
127357
  const { runPull: runPull2 } = await Promise.resolve().then(() => (init_pull(), pull_exports));
127185
127358
  await runPull2(workspace, {