@neocompose/cli 0.81.1 → 0.81.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/neo.mjs CHANGED
@@ -1291,6 +1291,15 @@ function neoScriptRegistryEntryType(typeName) {
1291
1291
  }
1292
1292
  return REGISTRY_ENTRY_TYPES[typeName] ?? null;
1293
1293
  }
1294
+ function typeArgumentArityMessage(typeName, expected, provided) {
1295
+ return `Type '${typeName}' expects ${expected} type argument${expected === 1 ? "" : "s"}, but ${provided} ${provided === 1 ? "was" : "were"} provided.`;
1296
+ }
1297
+ function genericParameterArgumentsMessage(name) {
1298
+ return `Generic parameter '${name}' cannot receive type arguments.`;
1299
+ }
1300
+ function delegateArityMessage(provided) {
1301
+ return `Type 'NeoDelegate' expects a return type followed by up to ${NEOSCRIPT_DELEGATE_MAX_PARAMETERS} parameter types, but ${provided} type arguments were provided.`;
1302
+ }
1294
1303
  function neoScriptRegistryReferenceType(entryTypeName) {
1295
1304
  for (const definition2 of Object.values(REGISTRY_ENTRY_TYPES)) {
1296
1305
  if (definition2.entryType === entryTypeName) return definition2.refType;
@@ -1376,7 +1385,7 @@ function vectorTypes() {
1376
1385
  members: structuredLeafFieldProperties(name)
1377
1386
  }));
1378
1387
  }
1379
- var NEO_PROJECT_IGNORED_DIRECTORY_NAMES, NEOSCRIPT_KEYWORDS, NEOSCRIPT_INFERRED_LOCAL_KEYWORD, NEOSCRIPT_CONSTRUCTOR_KEYWORD, NEOSCRIPT_PRIMITIVE_TYPES, NEOSCRIPT_BUILTIN_ANNOTATION_TYPES, NEOSCRIPT_BUILTIN_NAMESPACES, NEOSCRIPT_BUILTIN_TYPES, NEO_VARIANT_TYPE_NAME, NEO_VARIANT_FOLDER_TYPE_NAME, NEO_LOOKUP_VARIANT_TYPE_NAME, NEO_LOOKUP_VARIANT_FOLDER_TYPE_NAME, NEO_VARIANT_SCOPE_NAME, NEO_VARIANT_RESERVED_NAME, NEO_VARIANT_FOLDER_PATH_SEPARATOR, NEOSCRIPT_OPERATORS, STRING_TYPE2, INT_TYPE2, FLOAT_TYPE, DECIMAL_TYPE, BOOL_TYPE2, IMAGE_REF_TYPE, SPRITE_INFO_TYPE, VECTOR2_TYPE, FLOAT_OPTIONAL_TYPE, NEOSCRIPT_STRUCTURED_LEAF_FIELDS, NEOSCRIPT_IMAGE_REGISTRY_TYPE, NEOSCRIPT_AUDIO_CLIP_REGISTRY_TYPE, NEOSCRIPT_PENDING_SYMBOL_ID_PREFIX, REGISTRY_ENTRY_TYPES, NEOSCRIPT_GLOBALS, NEOSCRIPT_SCALAR_METHODS, NEOSCRIPT_CLASS_ID_MEMBER, NEOSCRIPT_ON_CHANGED_MEMBER, NEOSCRIPT_CLASS_ID_SYMBOL, NEOSCRIPT_PRIMITIVE_DERIVED_MEMBERS, NEOSCRIPT_SPRITE_INFO_EMPTY_MEMBER_ID, NEOSCRIPT_SPRITE_INFO_EMPTY_VALUE, NEOSCRIPT_MATH_TYPE_ID, MATH_INFERENCE_RULE, MATH_INTEGRAL_RULE, NEOSCRIPT_LIST_TYPE_NAME, NEOSCRIPT_LIST_TYPE_ID, NEOSCRIPT_LIST_REPEAT_NAME, LIST_ENTRY_TYPE, NEOSCRIPT_BUILTIN_TYPE_SYMBOLS;
1388
+ var NEO_PROJECT_IGNORED_DIRECTORY_NAMES, NEOSCRIPT_KEYWORDS, NEOSCRIPT_INFERRED_LOCAL_KEYWORD, NEOSCRIPT_CONSTRUCTOR_KEYWORD, NEOSCRIPT_PRIMITIVE_TYPES, NEOSCRIPT_BUILTIN_ANNOTATION_TYPES, NEOSCRIPT_BUILTIN_NAMESPACES, NEOSCRIPT_BUILTIN_TYPES, NEO_VARIANT_TYPE_NAME, NEO_VARIANT_FOLDER_TYPE_NAME, NEO_LOOKUP_VARIANT_TYPE_NAME, NEO_LOOKUP_VARIANT_FOLDER_TYPE_NAME, NEO_VARIANT_SCOPE_NAME, NEO_VARIANT_RESERVED_NAME, NEO_VARIANT_FOLDER_PATH_SEPARATOR, NEOSCRIPT_OPERATORS, STRING_TYPE2, INT_TYPE2, FLOAT_TYPE, DECIMAL_TYPE, BOOL_TYPE2, IMAGE_REF_TYPE, SPRITE_INFO_TYPE, VECTOR2_TYPE, FLOAT_OPTIONAL_TYPE, NEOSCRIPT_STRUCTURED_LEAF_FIELDS, NEOSCRIPT_IMAGE_REGISTRY_TYPE, NEOSCRIPT_AUDIO_CLIP_REGISTRY_TYPE, NEOSCRIPT_PENDING_SYMBOL_ID_PREFIX, REGISTRY_ENTRY_TYPES, NEOSCRIPT_DELEGATE_MAX_PARAMETERS, NEOSCRIPT_GLOBALS, NEOSCRIPT_SCALAR_METHODS, NEOSCRIPT_CLASS_ID_MEMBER, NEOSCRIPT_ON_CHANGED_MEMBER, NEOSCRIPT_CLASS_ID_SYMBOL, NEOSCRIPT_PRIMITIVE_DERIVED_MEMBERS, NEOSCRIPT_SPRITE_INFO_EMPTY_MEMBER_ID, NEOSCRIPT_SPRITE_INFO_EMPTY_VALUE, NEOSCRIPT_MATH_TYPE_ID, MATH_INFERENCE_RULE, MATH_INTEGRAL_RULE, NEOSCRIPT_LIST_TYPE_NAME, NEOSCRIPT_LIST_TYPE_ID, NEOSCRIPT_LIST_REPEAT_NAME, LIST_ENTRY_TYPE, NEOSCRIPT_BUILTIN_TYPE_SYMBOLS;
1380
1389
  var init_language_spec = __esm({
1381
1390
  "../packages/neoscript-language/src/language-spec.ts"() {
1382
1391
  "use strict";
@@ -1652,6 +1661,7 @@ var init_language_spec = __esm({
1652
1661
  refType: { kind: "primitive", name: "AudioClipRef" }
1653
1662
  }
1654
1663
  };
1664
+ NEOSCRIPT_DELEGATE_MAX_PARAMETERS = 16;
1655
1665
  NEOSCRIPT_GLOBALS = [
1656
1666
  builtinFunction(
1657
1667
  "VisitCount",
@@ -30982,21 +30992,34 @@ function resolveNeoScriptType(type, context, project) {
30982
30992
  const declaringType = declaringTypeRef?.kind === "named" ? project.typeById.get(declaringTypeRef.typeId) : void 0;
30983
30993
  const byName = (candidate) => candidate.name === type.name;
30984
30994
  const typeParameter2 = context.typeParameters?.find(byName) ?? declaringType?.typeParameters?.find(byName);
30995
+ const written = type.typeArguments?.length ?? 0;
30985
30996
  if (typeParameter2?.type.kind === "typeParameter") {
30997
+ if (written > 0)
30998
+ throw new CompileError(
30999
+ genericParameterArgumentsMessage(type.name),
31000
+ type.pos
31001
+ );
30986
31002
  resolved = typeParameter2.type;
30987
31003
  break;
30988
31004
  }
30989
31005
  const builtin = namedPrimitive(type.name);
31006
+ const registryReference = builtin ? null : neoScriptRegistryReferenceType(type.name);
31007
+ if ((builtin || registryReference) && written > 0)
31008
+ throw new CompileError(
31009
+ typeArgumentArityMessage(type.name, 0, written),
31010
+ type.pos
31011
+ );
30990
31012
  if (builtin) {
30991
31013
  resolved = { kind: "primitive", name: builtin };
30992
31014
  break;
30993
31015
  }
30994
- const registryReference = neoScriptRegistryReferenceType(type.name);
30995
31016
  if (registryReference) {
30996
31017
  resolved = registryReference;
30997
31018
  break;
30998
31019
  }
30999
31020
  if (type.name === "NeoDelegate") {
31021
+ if (written > NEOSCRIPT_DELEGATE_MAX_PARAMETERS + 1)
31022
+ throw new CompileError(delegateArityMessage(written), type.pos);
31000
31023
  const [returnType, ...parameterTypes] = (type.typeArguments ?? []).map(
31001
31024
  (argument2) => resolveNeoScriptType(argument2, context, project)
31002
31025
  );
@@ -31014,6 +31037,7 @@ function resolveNeoScriptType(type, context, project) {
31014
31037
  renamedDialogueTypeMessage(type.name, "value") ?? `Unknown type '${type.name}'`,
31015
31038
  type.pos
31016
31039
  );
31040
+ if (written > 0) assertTypeArgumentCount(named, written, type.pos);
31017
31041
  resolved = {
31018
31042
  kind: "named",
31019
31043
  typeId: named.id,
@@ -31082,6 +31106,14 @@ function assertDirectTypeParameterArguments(target, pos, project) {
31082
31106
  const message = wrappedTypeParameterMessage(target, project);
31083
31107
  if (message !== null) throw new CompileError(message, pos);
31084
31108
  }
31109
+ function assertTypeArgumentCount(declaring, count, pos) {
31110
+ const expected = declaring.typeParameters?.length ?? 0;
31111
+ if (count === expected) return;
31112
+ throw new CompileError(
31113
+ typeArgumentArityMessage(declaring.name, expected, count),
31114
+ pos
31115
+ );
31116
+ }
31085
31117
  function assertTypeArgumentConstraints(declaring, type, pos, project) {
31086
31118
  declaring.typeParameters?.forEach((parameter4, index) => {
31087
31119
  const argument2 = type.typeArguments?.[index];
@@ -36849,13 +36881,12 @@ var init_strict_resolver = __esm({
36849
36881
  const typeArguments = expression.typeArguments?.map(
36850
36882
  (argument2) => this.resolveType(argument2)
36851
36883
  );
36852
- if (typeArguments !== void 0 && typeArguments.length !== (schemaClass2.typeParameters?.length ?? 0)) {
36853
- throw new CompileError(
36854
- `Class '${schemaClass2.name}' expects ${schemaClass2.typeParameters?.length ?? 0} type argument${schemaClass2.typeParameters?.length === 1 ? "" : "s"} but got ${typeArguments.length}.`,
36884
+ if (typeArguments !== void 0) {
36885
+ assertTypeArgumentCount(
36886
+ schemaClass2,
36887
+ typeArguments.length,
36855
36888
  expression.pos
36856
36889
  );
36857
- }
36858
- if (typeArguments !== void 0) {
36859
36890
  const target = {
36860
36891
  kind: "named",
36861
36892
  typeId: schemaClass2.id,
@@ -50946,20 +50977,20 @@ function validateTypeApplication(uri, type, genericParameters, environment, diag
50946
50977
  uri,
50947
50978
  type.range,
50948
50979
  "generic-parameter-arguments",
50949
- `Generic parameter '${type.name}' cannot receive type arguments.`
50980
+ genericParameterArgumentsMessage(type.name)
50950
50981
  );
50951
50982
  }
50952
50983
  return;
50953
50984
  }
50954
50985
  const target = environment.declarations.get(type.name);
50955
50986
  if (type.name === "NeoDelegate") {
50956
- if (type.typeArguments.length < 1 || type.typeArguments.length > 17) {
50987
+ if (type.typeArguments.length < 1 || type.typeArguments.length > NEOSCRIPT_DELEGATE_MAX_PARAMETERS + 1) {
50957
50988
  diagnose(
50958
50989
  diagnostics,
50959
50990
  uri,
50960
50991
  type.range,
50961
50992
  "generic-argument-arity",
50962
- `Type 'NeoDelegate' expects a return type followed by up to 16 parameter types, but ${type.typeArguments.length} type arguments were provided.`
50993
+ delegateArityMessage(type.typeArguments.length)
50963
50994
  );
50964
50995
  }
50965
50996
  return;
@@ -50974,13 +51005,13 @@ function validateTypeApplication(uri, type, genericParameters, environment, diag
50974
51005
  "Type 'NeoAction' cannot use 'void' as a parameter type; spell a zero-argument action as bare 'NeoAction'."
50975
51006
  );
50976
51007
  }
50977
- if (type.typeArguments.length > 16) {
51008
+ if (type.typeArguments.length > NEOSCRIPT_DELEGATE_MAX_PARAMETERS) {
50978
51009
  diagnose(
50979
51010
  diagnostics,
50980
51011
  uri,
50981
51012
  type.range,
50982
51013
  "generic-argument-arity",
50983
- `Type 'NeoAction' expects up to 16 parameter types, but ${type.typeArguments.length} type arguments were provided.`
51014
+ `Type 'NeoAction' expects up to ${NEOSCRIPT_DELEGATE_MAX_PARAMETERS} parameter types, but ${type.typeArguments.length} type arguments were provided.`
50984
51015
  );
50985
51016
  }
50986
51017
  if (type.nullable) {
@@ -51002,7 +51033,7 @@ function validateTypeApplication(uri, type, genericParameters, environment, diag
51002
51033
  uri,
51003
51034
  type.range,
51004
51035
  "generic-argument-arity",
51005
- `Type '${type.name}' expects ${expected} type argument${expected === 1 ? "" : "s"}, but ${type.typeArguments.length} ${type.typeArguments.length === 1 ? "was" : "were"} provided.`,
51036
+ typeArgumentArityMessage(type.name, expected, type.typeArguments.length),
51006
51037
  target ? related(target.location, "The type declaration is here.") : void 0
51007
51038
  );
51008
51039
  return;
@@ -54533,7 +54564,7 @@ var init_registry = __esm({
54533
54564
  "../packages/manifest/schema-contract/registry.mjs"() {
54534
54565
  "use strict";
54535
54566
  PROJECT_SCHEMA_CONTRACT = Object.freeze({
54536
- cliVersion: "0.81.1",
54567
+ cliVersion: "0.81.3",
54537
54568
  projectFileUploadBatchSize: 32,
54538
54569
  documentRecords: {
54539
54570
  member: {
@@ -77377,7 +77408,7 @@ function readNeoScriptRuntimeRow(ctx, valueId) {
77377
77408
  }
77378
77409
  function inspectNeoScriptValueReference(ctx, value, collection, index) {
77379
77410
  let id2 = findKnownRowIdByValueReference(value, ctx);
77380
- if (id2 === null && collection !== void 0 && index !== void 0 && typeof value === "string" && (findKnownRowIdByValueReference(collection, ctx) !== null || Array.isArray(collection) && typeof index === "number" && ctx.__unorderedListProjections?.referenceEntryIndexesByArray.get(collection)?.has(index) || typeof collection === "object" && collection !== null && typeof index === "string" && ctx.__unorderedListProjections?.referenceEntryKeysByRecord.get(collection)?.has(index))) {
77411
+ if (id2 === null && collection !== void 0 && index !== void 0 && typeof value === "string" && isReferenceEntry(collectionReferences(collection, ctx), index)) {
77381
77412
  id2 = value;
77382
77413
  }
77383
77414
  if (id2 === null) return null;
@@ -79038,15 +79069,9 @@ function evalActionListenerInstruction(ins, scope, ctx, options) {
79038
79069
  }
79039
79070
  let destination;
79040
79071
  const target = ins.target.pointer;
79041
- const currentValue = target.type === "keyOf" /* keyOf */ ? evalKeyOf(
79042
- target.keyOf,
79043
- scope,
79044
- ctx,
79045
- target.optional === true,
79046
- (resolved) => {
79047
- destination = resolved;
79048
- }
79049
- ) : evalPointer(target, scope, ctx);
79072
+ const currentValue = target.type === "keyOf" /* keyOf */ ? evalKeyOf(target, scope, ctx, (resolved) => {
79073
+ destination = resolved;
79074
+ }) : evalPointer(target, scope, ctx);
79050
79075
  const current = actionListenersOf(currentValue, () => `'${operator}' target`);
79051
79076
  const identity2 = nsActionListenerIdentity(listener);
79052
79077
  const present = current.some(
@@ -79117,38 +79142,26 @@ function applyOverlayAssignment(target, targetTypeInfo, value, scope, ctx, desti
79117
79142
  );
79118
79143
  }
79119
79144
  receiver[index] = referenceValueId;
79120
- setCollectionReferenceProvenance(receiver, index, true, ctx);
79145
+ recordWrittenEntry(receiver, index, true, ctx);
79121
79146
  invalidateEvaluatorIndexes(ctx, receiver);
79122
79147
  return;
79123
79148
  }
79124
- if (ctx.__unorderedListProjections?.referenceEntryIndexesByArray.has(
79125
- receiver
79126
- ) === true) {
79127
- receiver[index] = value;
79128
- setCollectionReferenceProvenance(receiver, index, false, ctx);
79129
- invalidateEvaluatorIndexes(ctx, receiver);
79149
+ if (collectionReferences(receiver, ctx) === 0 /* RowIds */ && replaceEntryRowValue(
79150
+ receiver,
79151
+ receiver[index],
79152
+ value,
79153
+ targetTypeInfo,
79154
+ ctx
79155
+ ))
79130
79156
  return;
79131
- }
79132
- const existing2 = receiver[index];
79133
- if (typeof existing2 === "string") {
79134
- const row = evalValueById(
79135
- ctx,
79136
- existing2,
79137
- ctx.__runtimeSessionValues,
79138
- ctx.__valueOverlay
79139
- );
79140
- if (row !== null) {
79141
- replaceRowValue(row, value, receiver, ctx);
79142
- updateUnorderedListProjectionAfterAssignment(row, value, ctx);
79143
- return;
79144
- }
79145
- }
79146
79157
  receiver[index] = value;
79158
+ recordWrittenEntry(receiver, index, false, ctx);
79147
79159
  invalidateEvaluatorIndexes(ctx, receiver);
79148
79160
  return;
79149
79161
  }
79150
79162
  const object2 = objectArg(receiver, "Assignment target");
79151
79163
  const stringKey = String(key);
79164
+ const field = target.memberId !== void 0;
79152
79165
  if (referenceValueId !== null) {
79153
79166
  const parentId = findKnownRowIdByValueReference(receiver, ctx);
79154
79167
  if (parentId !== null) {
@@ -79163,26 +79176,41 @@ function applyOverlayAssignment(target, targetTypeInfo, value, scope, ctx, desti
79163
79176
  );
79164
79177
  }
79165
79178
  object2[stringKey] = referenceValueId;
79179
+ if (!field) recordWrittenEntry(object2, stringKey, true, ctx);
79166
79180
  invalidateEvaluatorIndexes(ctx, receiver);
79167
79181
  return;
79168
79182
  }
79169
- const existing = object2[stringKey];
79170
- if (typeof existing === "string") {
79171
- const row = evalValueById(
79172
- ctx,
79173
- existing,
79174
- ctx.__runtimeSessionValues,
79175
- ctx.__valueOverlay
79176
- );
79177
- if (row !== null) {
79178
- replaceRowValue(row, value, receiver, ctx);
79179
- updateUnorderedListProjectionAfterAssignment(row, value, ctx);
79180
- return;
79181
- }
79182
- }
79183
+ if (collectionReferences(object2, ctx) === 0 /* RowIds */ && replaceEntryRowValue(object2, object2[stringKey], value, targetTypeInfo, ctx))
79184
+ return;
79183
79185
  object2[stringKey] = value;
79186
+ if (!field) recordWrittenEntry(object2, stringKey, false, ctx);
79184
79187
  invalidateEvaluatorIndexes(ctx, receiver);
79185
79188
  }
79189
+ function replaceEntryRowValue(receiver, existing, value, targetTypeInfo, ctx) {
79190
+ if (typeof existing !== "string") return false;
79191
+ const row = evalValueById(
79192
+ ctx,
79193
+ existing,
79194
+ ctx.__runtimeSessionValues,
79195
+ ctx.__valueOverlay
79196
+ );
79197
+ if (row === null) return false;
79198
+ keepAssignedCollectionValues(value, targetTypeInfo, ctx);
79199
+ replaceRowValue(row, value, receiver, ctx);
79200
+ updateUnorderedListProjectionAfterAssignment(row, value, ctx);
79201
+ return true;
79202
+ }
79203
+ function keepAssignedCollectionValues(value, targetTypeInfo, ctx) {
79204
+ const cache = unorderedListProjectionCache(ctx);
79205
+ if (Array.isArray(value) && (targetTypeInfo.type === 6 /* List */ || targetTypeInfo.type === 28 /* Set */)) {
79206
+ if (!cache.referenceEntryIndexesByArray.has(value))
79207
+ cache.referenceEntryIndexesByArray.set(value, /* @__PURE__ */ new Set());
79208
+ return;
79209
+ }
79210
+ if (targetTypeInfo.type === 5 /* Dictionary */ && typeof value === "object" && value !== null && !cache.referenceEntryKeysByRecord.has(value)) {
79211
+ cache.referenceEntryKeysByRecord.set(value, /* @__PURE__ */ new Set());
79212
+ }
79213
+ }
79186
79214
  function replaceRowValue(row, value, receiver, ctx) {
79187
79215
  const indexes3 = ctx.__indexes;
79188
79216
  if (indexes3 === void 0 || ctx.__runtimeSessionValues?.get(row.id) !== row || !indexes3.indexedRowIds.has(row.id)) {
@@ -79620,9 +79648,11 @@ function evalCollectionMutationInstruction(ins, scope, ctx, options) {
79620
79648
  );
79621
79649
  }
79622
79650
  const unorderedEntriesBeforeMutation = unorderedContainerValueId === null || !Array.isArray(targetValue) || ins.mutation === "Add" /* Add */ ? null : [...targetValue];
79623
- if ((ins.mutation === "Add" /* Add */ || ins.mutation === "Insert" /* Insert */) && !isLookupSet) {
79651
+ const writesEntry = (ins.mutation === "Add" /* Add */ || ins.mutation === "Insert" /* Insert */) && !isLookupSet;
79652
+ let attachedValueId = null;
79653
+ if (writesEntry) {
79624
79654
  const attachedValue = isArrayCollection(targetValue) && ins.mutation !== "Insert" /* Insert */ ? args[0] : args[1];
79625
- const attachedValueId = findKnownRowIdByValueReference(attachedValue, ctx);
79655
+ attachedValueId = findKnownRowIdByValueReference(attachedValue, ctx);
79626
79656
  const parentId = findKnownRowIdByValueReference(targetValue, ctx);
79627
79657
  if (attachedValueId !== null && parentId !== null) {
79628
79658
  ctx.assertCollectionEntryAttachable?.(
@@ -79659,6 +79689,23 @@ function evalCollectionMutationInstruction(ins, scope, ctx, options) {
79659
79689
  removedIndex,
79660
79690
  ctx
79661
79691
  );
79692
+ if (writesEntry && !(targetValue instanceof RuntimeSet)) {
79693
+ const writtenAsRowId = attachedValueId !== null || unorderedContainerValueId !== null;
79694
+ if (Array.isArray(targetValue))
79695
+ recordWrittenEntry(
79696
+ targetValue,
79697
+ removedIndex ?? targetValue.length - 1,
79698
+ writtenAsRowId,
79699
+ ctx
79700
+ );
79701
+ else
79702
+ recordWrittenEntry(
79703
+ objectArg(targetValue, "Dictionary Add target"),
79704
+ String(args[0]),
79705
+ writtenAsRowId,
79706
+ ctx
79707
+ );
79708
+ }
79662
79709
  if (unorderedEntriesBeforeMutation !== null && Array.isArray(targetValue)) {
79663
79710
  detachRemovedUnorderedScalarEntries(
79664
79711
  unorderedEntriesBeforeMutation,
@@ -79860,9 +79907,10 @@ function runtimeSet(array3, reference2, enumEntries, ctx) {
79860
79907
  const existing = sets.get(array3);
79861
79908
  if (existing !== void 0) return existing;
79862
79909
  const set = new RuntimeSet(array3, reference2, enumEntries);
79910
+ const references = collectionReferences(array3, ctx);
79863
79911
  for (let index = 0; index < array3.length; index++) {
79864
79912
  const raw = array3[index];
79865
- const resolves = collectionEntryUsesReferenceResolution(array3, index, ctx);
79913
+ const resolves = isReferenceEntry(references, index);
79866
79914
  const value = resolves ? resolveValueIfId(raw, ctx) : raw;
79867
79915
  const key = runtimeSetKey(value, set, ctx);
79868
79916
  set.add(key, enumEntries ? key : raw, !enumEntries && resolves);
@@ -79871,9 +79919,9 @@ function runtimeSet(array3, reference2, enumEntries, ctx) {
79871
79919
  (ctx.__dirtyRuntimeSets ??= /* @__PURE__ */ new Set()).add(set);
79872
79920
  return set;
79873
79921
  }
79874
- function storedSetEntryMatch(raw, entryMember, ctx) {
79922
+ function storedSetEntryMatch(raw, reference2, entryMember, ctx) {
79875
79923
  const byIdentity = entryMember.kind === 7 /* Class */;
79876
- const row = byIdentity || typeof raw !== "string" ? null : evalValueById(ctx, raw, ctx.__runtimeSessionValues, ctx.__valueOverlay);
79924
+ const row = byIdentity || !reference2 || typeof raw !== "string" ? null : evalValueById(ctx, raw, ctx.__runtimeSessionValues, ctx.__valueOverlay);
79877
79925
  const valueId = byIdentity && typeof raw === "string" ? raw : row?.id ?? null;
79878
79926
  const entry = row === null ? { id: "", value: raw } : { id: row.id, value: row.value };
79879
79927
  const key = byIdentity ? valueId ?? referenceIdOf(raw, ctx) : setEntryKey(entryMember, entry);
@@ -79884,8 +79932,14 @@ function storedSetEntries(set, entryMember, ctx) {
79884
79932
  const existing = indexes3.get(set);
79885
79933
  if (existing !== void 0) return existing;
79886
79934
  const entries = /* @__PURE__ */ new Map();
79887
- for (const raw of set) {
79888
- const match = storedSetEntryMatch(raw, entryMember, ctx);
79935
+ const references = collectionReferences(set, ctx);
79936
+ for (let index = 0; index < set.length; index++) {
79937
+ const match = storedSetEntryMatch(
79938
+ set[index],
79939
+ isReferenceEntry(references, index),
79940
+ entryMember,
79941
+ ctx
79942
+ );
79889
79943
  if (match !== null && !entries.has(match.key)) {
79890
79944
  entries.set(match.key, match);
79891
79945
  }
@@ -79897,7 +79951,13 @@ function syncStoredSetEntries(set, mutation, removed, entryMember, ctx) {
79897
79951
  const entries = ctx.__setEntryIndexes?.get(set);
79898
79952
  if (entries === void 0) return;
79899
79953
  if (entryMember !== null && mutation === "Add" /* Add */) {
79900
- const added = storedSetEntryMatch(set[set.length - 1], entryMember, ctx);
79954
+ const index = set.length - 1;
79955
+ const added = storedSetEntryMatch(
79956
+ set[index],
79957
+ isReferenceEntry(collectionReferences(set, ctx), index),
79958
+ entryMember,
79959
+ ctx
79960
+ );
79901
79961
  if (added !== null) entries.set(added.key, added);
79902
79962
  return;
79903
79963
  }
@@ -79963,6 +80023,7 @@ function applyLocalCollectionMutation(targetValue, mutation, args, ctx, unique =
79963
80023
  return null;
79964
80024
  case "Remove" /* Remove */:
79965
80025
  if (Array.isArray(targetValue)) {
80026
+ const references = resolveRemovalEntries ? collectionReferences(targetValue, ctx) : recordedReferenceEntries(targetValue, ctx) ?? 1 /* Values */;
79966
80027
  let index = -1;
79967
80028
  for (let candidate = 0; candidate < targetValue.length; candidate += 1) {
79968
80029
  const entry = targetValue[candidate];
@@ -79973,9 +80034,8 @@ function applyLocalCollectionMutation(targetValue, mutation, args, ctx, unique =
79973
80034
  }
79974
80035
  continue;
79975
80036
  }
79976
- const referenceEntry = ctx.__unorderedListProjections?.referenceEntryIndexesByArray.get(targetValue)?.has(candidate) === true;
79977
80037
  if (jsEqual(
79978
- resolveRemovalEntries || referenceEntry ? resolveCollectionEntry(targetValue, entry, candidate, ctx) : entry,
80038
+ typeof entry === "string" && isReferenceEntry(references, candidate) ? resolveValueIfId(entry, ctx) : entry,
79979
80039
  args[0]
79980
80040
  )) {
79981
80041
  index = candidate;
@@ -80008,13 +80068,6 @@ function applyLocalCollectionMutation(targetValue, mutation, args, ctx, unique =
80008
80068
  return null;
80009
80069
  }
80010
80070
  }
80011
- function setCollectionReferenceProvenance(targetValue, index, reference2, ctx) {
80012
- const cache = ctx.__unorderedListProjections;
80013
- const indexes3 = cache?.referenceEntryIndexesByArray.get(targetValue);
80014
- if (cache === void 0 || indexes3 === void 0) return;
80015
- if (reference2) indexes3.add(index);
80016
- else indexes3.delete(index);
80017
- }
80018
80071
  function updateCollectionReferenceProvenance(targetValue, mutation, removedIndex, ctx) {
80019
80072
  if (!Array.isArray(targetValue)) return;
80020
80073
  const cache = ctx.__unorderedListProjections;
@@ -80288,7 +80341,7 @@ function evalPointerCore(pointer, scope, ctx, resultUsage = "value") {
80288
80341
  case "staticMember" /* staticMember */:
80289
80342
  return evalStaticMember(pointer.memberId, ctx);
80290
80343
  case "keyOf" /* keyOf */:
80291
- return evalKeyOf(pointer.keyOf, scope, ctx, pointer.optional === true);
80344
+ return evalKeyOf(pointer, scope, ctx);
80292
80345
  case "operation" /* operation */:
80293
80346
  return evalOperation(pointer.operation, scope, ctx);
80294
80347
  case "function" /* function */:
@@ -80938,15 +80991,9 @@ function readActionWithOwner(pointer, scope, ctx) {
80938
80991
  return { action: evalPointer(pointer, scope, ctx), owner: null };
80939
80992
  }
80940
80993
  let owner = null;
80941
- const action = evalKeyOf(
80942
- pointer.keyOf,
80943
- scope,
80944
- ctx,
80945
- pointer.optional === true,
80946
- (destination) => {
80947
- owner = destination.receiver;
80948
- }
80949
- );
80994
+ const action = evalKeyOf(pointer, scope, ctx, (destination) => {
80995
+ owner = destination.receiver;
80996
+ });
80950
80997
  return { action, owner };
80951
80998
  }
80952
80999
  function actionPointerLabel(pointer, ctx) {
@@ -81863,7 +81910,9 @@ function isRuntimeSpriteValue(value) {
81863
81910
  const sliceIndex = value.sliceIndex;
81864
81911
  return typeof sliceIndex === "number" && Number.isInteger(sliceIndex) && sliceIndex >= 0;
81865
81912
  }
81866
- function evalKeyOf(keyOf, scope, ctx, optional2 = false, onDestination) {
81913
+ function evalKeyOf(pointer, scope, ctx, onDestination) {
81914
+ const { keyOf } = pointer;
81915
+ const optional2 = pointer.optional === true;
81867
81916
  const receiver = evalPointer(keyOf.pointer, scope, ctx);
81868
81917
  if (optional2 && (receiver === null || receiver === void 0)) {
81869
81918
  return null;
@@ -81924,7 +81973,7 @@ function evalKeyOf(keyOf, scope, ctx, optional2 = false, onDestination) {
81924
81973
  if (dispatched.kind === "ok") return dispatched.value;
81925
81974
  if (Object.prototype.hasOwnProperty.call(receiver, k)) {
81926
81975
  const at3 = receiver[k];
81927
- return resolveValueIfId(at3, ctx);
81976
+ return typeof at3 === "string" && (pointer.memberId !== void 0 || isReferenceEntry(collectionReferences(receiver, ctx), k)) ? resolveValueIfId(at3, ctx) : at3;
81928
81977
  }
81929
81978
  const expanded = virtualExpandedRecordForReceiver(receiver, ctx);
81930
81979
  if (expanded !== null && Object.prototype.hasOwnProperty.call(expanded, k)) {
@@ -82656,7 +82705,7 @@ function evaluateSystemNative(memberId, receiver, args, ctx, typeArguments) {
82656
82705
  shift,
82657
82706
  accepts
82658
82707
  );
82659
- return { handled: true, value };
82708
+ return { handled: true, value: referenceEntryList(value, ctx) };
82660
82709
  }
82661
82710
  if (memberId === NEO_OBJECT_GRID_MEMBER_IDS.GetTiles) {
82662
82711
  const value = index.tiles(
@@ -82666,7 +82715,7 @@ function evaluateSystemNative(memberId, receiver, args, ctx, typeArguments) {
82666
82715
  shift,
82667
82716
  accepts
82668
82717
  );
82669
- return { handled: true, value };
82718
+ return { handled: true, value: referenceEntryList(value, ctx) };
82670
82719
  }
82671
82720
  const tile = index.tile(
82672
82721
  placement,
@@ -83275,7 +83324,17 @@ function evalDeclaredListIndex(info, scope, ctx) {
83275
83324
  collectionIndexes.set(cacheKey, index);
83276
83325
  }
83277
83326
  if (info.keyPointer === void 0) {
83278
- return Object.fromEntries(index);
83327
+ const view = Object.fromEntries(index);
83328
+ if (info.unique) {
83329
+ unorderedListProjectionCache(ctx).referenceEntryKeysByRecord.set(
83330
+ view,
83331
+ new Set(index.keys())
83332
+ );
83333
+ } else {
83334
+ for (const bucket of index.values())
83335
+ if (Array.isArray(bucket)) referenceEntryList(bucket, ctx);
83336
+ }
83337
+ return view;
83279
83338
  }
83280
83339
  const key = evalPointer(info.keyPointer, scope, ctx);
83281
83340
  if (typeof key !== "string") {
@@ -83287,7 +83346,12 @@ function evalDeclaredListIndex(info, scope, ctx) {
83287
83346
  if (info.unique) {
83288
83347
  return typeof hit === "string" ? resolveValueIfId(hit, ctx) : null;
83289
83348
  }
83290
- return Array.isArray(hit) ? [...hit] : [];
83349
+ return referenceEntryList(Array.isArray(hit) ? [...hit] : [], ctx);
83350
+ }
83351
+ function referenceEntryList(list, ctx) {
83352
+ const indexes3 = unorderedListProjectionCache(ctx).referenceEntryIndexesByArray;
83353
+ if (!indexes3.has(list)) indexes3.set(list, new Set(list.keys()));
83354
+ return list;
83291
83355
  }
83292
83356
  function prepareCollectionCallback(callback, parentScope, ctx, isList, returnContract, onPredicateMatch) {
83293
83357
  const metrics = ctx.__collectionCallbackPreparationMetrics;
@@ -83851,7 +83915,7 @@ function evalFunction(fn, scope, ctx) {
83851
83915
  if (fn.info.reference === true) {
83852
83916
  return referenceIndexOf(c, target, ctx) !== null;
83853
83917
  }
83854
- const targetReferenceId = typeof target === "string" ? target : findKnownRowIdByValueReference(target, ctx);
83918
+ const targetReferenceId = typeof target === "string" ? null : findKnownRowIdByValueReference(target, ctx);
83855
83919
  let containsResolvedEntry = false;
83856
83920
  iterateCollection(c, ctx, (entry, _key, valueId) => {
83857
83921
  if (valueId !== null && valueId === targetReferenceId || jsEqual(entry, target)) {
@@ -83872,7 +83936,7 @@ function evalFunction(fn, scope, ctx) {
83872
83936
  const index = referenceIndexOf(collection, target, ctx);
83873
83937
  return index === null ? -1 : numberArg(index, "IndexOf index");
83874
83938
  }
83875
- const targetReferenceId = typeof target === "string" ? target : findKnownRowIdByValueReference(target, ctx);
83939
+ const targetReferenceId = typeof target === "string" ? null : findKnownRowIdByValueReference(target, ctx);
83876
83940
  let found = -1;
83877
83941
  iterateCollection(collection, ctx, (entry, key, valueId) => {
83878
83942
  if (valueId !== null && valueId === targetReferenceId || jsEqual(entry, target)) {
@@ -84136,9 +84200,27 @@ function validateClassConstructorDescriptor(info, ctx, requireEveryRequiredField
84136
84200
  `Cannot construct abstract Class '${schemaClass2.name}'.`
84137
84201
  );
84138
84202
  }
84139
- const genericSlot = ctx.__constructionGenericSlots?.toReversed().find((slot) => slot.classId === classId) ?? ctx.__storedConstructionReplaySlot;
84140
- const slotArguments = genericSlot?.classId === classId ? genericSlot.classArguments : void 0;
84141
- const typeArguments = slotArguments === void 0 ? receiverClosedTypeArguments(info.schemaClassInfo.typeArguments, ctx) : void 0;
84203
+ const typeArguments = receiverClosedTypeArguments(
84204
+ info.schemaClassInfo.typeArguments,
84205
+ ctx
84206
+ );
84207
+ const matchesSlot = (slot) => {
84208
+ if (slot.classId !== classId) return false;
84209
+ if (typeArguments === void 0) return true;
84210
+ const env = cachedInstanceEnv(classId, slot.classArguments, ctx);
84211
+ return Object.entries(typeArguments).every(([parameterId, typeInfo]) => {
84212
+ const binding = env.get(parameterId);
84213
+ if (binding?.kind !== "member") return false;
84214
+ const member = evalMemberById(ctx.vm, binding.memberId);
84215
+ return member !== null && typeInfosInvariantlyEqual(
84216
+ runtimeTypeInfoForMember(member, env, ctx, /* @__PURE__ */ new Set()),
84217
+ typeInfo
84218
+ );
84219
+ });
84220
+ };
84221
+ const genericSlot = ctx.__constructionGenericSlots?.findLast(matchesSlot);
84222
+ const replaySlot = ctx.__storedConstructionReplaySlot;
84223
+ const slotArguments = genericSlot?.classArguments ?? (replaySlot !== void 0 && matchesSlot(replaySlot) ? replaySlot.classArguments : void 0);
84142
84224
  const descriptorCache = evaluatorValueGeneration(ctx).constructorDescriptors;
84143
84225
  const descriptorCacheKey = `${requireEveryRequiredField}:${ctx.storedConstructionReplay === true}:${JSON.stringify(slotArguments ?? typeArguments ?? null)}`;
84144
84226
  const cachedDescriptor = descriptorCache.get(info)?.get(descriptorCacheKey);
@@ -85014,6 +85096,8 @@ function evaluateDeclaredConstructorArguments(info, record7, scope, ctx) {
85014
85096
  );
85015
85097
  }
85016
85098
  const value = byName.get(parameter4.name);
85099
+ if (parameter4.type === 9 /* Lookup */ && Array.isArray(value))
85100
+ return referenceEntryList(value, ctx);
85017
85101
  if (typeof value !== "number") return value;
85018
85102
  if (parameter4.type === 4 /* Float */) return Math.fround(value);
85019
85103
  if (parameter4.type !== 20 /* Decimal */) return value;
@@ -87967,14 +88051,10 @@ function collectionLength(c) {
87967
88051
  }
87968
88052
  function snapshotCollectionMembership(collection, ctx) {
87969
88053
  const membership = [];
87970
- const valid = forEachRawCollectionEntry(collection, (entry) => {
88054
+ const valid = forEachRawCollectionEntry(collection, ctx, (entry) => {
87971
88055
  membership.push({
87972
88056
  raw: entry.raw,
87973
- resolveAsReference: collectionEntryUsesReferenceResolution(
87974
- collection,
87975
- entry.key,
87976
- ctx
87977
- )
88057
+ resolveAsReference: entry.valueId !== null
87978
88058
  });
87979
88059
  return 0 /* Continue */;
87980
88060
  });
@@ -87983,7 +88063,7 @@ function snapshotCollectionMembership(collection, ctx) {
87983
88063
  "NeoScript foreach requires a present collection."
87984
88064
  );
87985
88065
  }
87986
- function forEachRawCollectionEntry(c, callback) {
88066
+ function forEachRawCollectionEntry(c, ctx, callback) {
87987
88067
  if (c instanceof RuntimeSet) {
87988
88068
  for (const [key, entry] of c.membership().entries()) {
87989
88069
  if (callback({
@@ -87995,35 +88075,34 @@ function forEachRawCollectionEntry(c, callback) {
87995
88075
  }
87996
88076
  return true;
87997
88077
  }
88078
+ if (typeof c !== "object" || c === null) return false;
88079
+ const references = collectionReferences(c, ctx);
87998
88080
  if (Array.isArray(c)) {
87999
88081
  for (let key = 0; key < c.length; key += 1) {
88000
88082
  const raw = c[key];
88001
88083
  const control = callback({
88002
88084
  raw,
88003
88085
  key,
88004
- valueId: typeof raw === "string" ? raw : null
88086
+ valueId: typeof raw === "string" && isReferenceEntry(references, key) ? raw : null
88005
88087
  });
88006
88088
  if (control === 1 /* Break */) break;
88007
88089
  }
88008
88090
  return true;
88009
88091
  }
88010
- if (typeof c === "object" && c !== null) {
88011
- for (const [key, raw] of Object.entries(c)) {
88012
- const control = callback({
88013
- raw,
88014
- key,
88015
- valueId: typeof raw === "string" ? raw : null
88016
- });
88017
- if (control === 1 /* Break */) break;
88018
- }
88019
- return true;
88092
+ for (const [key, raw] of Object.entries(c)) {
88093
+ const control = callback({
88094
+ raw,
88095
+ key,
88096
+ valueId: typeof raw === "string" && isReferenceEntry(references, key) ? raw : null
88097
+ });
88098
+ if (control === 1 /* Break */) break;
88020
88099
  }
88021
- return false;
88100
+ return true;
88022
88101
  }
88023
88102
  function collectionEntries(c, ctx) {
88024
88103
  const entries = [];
88025
- forEachRawCollectionEntry(c, ({ raw, key }) => {
88026
- entries.push(resolveCollectionEntry(c, raw, key, ctx));
88104
+ forEachRawCollectionEntry(c, ctx, ({ raw, valueId }) => {
88105
+ entries.push(valueId === null ? raw : resolveValueIfId(valueId, ctx));
88027
88106
  return 0 /* Continue */;
88028
88107
  });
88029
88108
  return entries;
@@ -88031,7 +88110,7 @@ function collectionEntries(c, ctx) {
88031
88110
  function referenceIndexOf(c, target, ctx) {
88032
88111
  const targetId = target === null || target === void 0 ? null : referenceIdOf(target, ctx);
88033
88112
  let found = null;
88034
- forEachRawCollectionEntry(c, ({ raw, key }) => {
88113
+ forEachRawCollectionEntry(c, ctx, ({ raw, key }) => {
88035
88114
  if (raw === target || targetId !== null && raw !== null && raw !== void 0 && referenceIdOf(raw, ctx) === targetId) {
88036
88115
  found = key;
88037
88116
  return 1 /* Break */;
@@ -88041,26 +88120,61 @@ function referenceIndexOf(c, target, ctx) {
88041
88120
  return found;
88042
88121
  }
88043
88122
  function iterateCollection(c, ctx, callback) {
88044
- forEachRawCollectionEntry(c, ({ raw, key, valueId }) => {
88045
- const effectiveValueId = collectionEntryUsesReferenceResolution(c, key, ctx) ? valueId : null;
88046
- return callback(
88047
- resolveCollectionEntry(c, raw, key, ctx),
88123
+ forEachRawCollectionEntry(
88124
+ c,
88125
+ ctx,
88126
+ ({ raw, key, valueId }) => callback(
88127
+ valueId === null ? raw : resolveValueIfId(valueId, ctx),
88048
88128
  key,
88049
- effectiveValueId
88050
- );
88051
- });
88129
+ valueId
88130
+ )
88131
+ );
88052
88132
  }
88053
88133
  function resolveCollectionEntry(collection, raw, key, ctx) {
88054
- return collectionEntryUsesReferenceResolution(collection, key, ctx) ? resolveValueIfId(raw, ctx) : raw;
88134
+ return typeof raw === "string" && isReferenceEntry(collectionReferences(collection, ctx), key) ? resolveValueIfId(raw, ctx) : raw;
88055
88135
  }
88056
- function collectionEntryUsesReferenceResolution(collection, key, ctx) {
88057
- if (collection instanceof RuntimeSet && typeof key === "number")
88058
- return collection.membership()[key]?.reference === true;
88059
- if (!Array.isArray(collection) || typeof key !== "number") return true;
88060
- const referenceIndexes = ctx.__unorderedListProjections?.referenceEntryIndexesByArray.get(
88061
- collection
88062
- );
88063
- return referenceIndexes === void 0 || referenceIndexes.has(key);
88136
+ function recordedReferenceEntries(collection, ctx) {
88137
+ const cache = ctx.__unorderedListProjections;
88138
+ if (Array.isArray(collection))
88139
+ return cache?.referenceEntryIndexesByArray.get(collection);
88140
+ if (typeof collection === "object" && collection !== null)
88141
+ return cache?.referenceEntryKeysByRecord.get(collection);
88142
+ return void 0;
88143
+ }
88144
+ function collectionReferences(collection, ctx) {
88145
+ return recordedReferenceEntries(collection, ctx) ?? (findKnownRowIdByValueReference(collection, ctx) === null ? 1 /* Values */ : 0 /* RowIds */);
88146
+ }
88147
+ function isReferenceEntry(references, key) {
88148
+ if (references === 0 /* RowIds */) return true;
88149
+ if (references === 1 /* Values */) return false;
88150
+ return references.has(key);
88151
+ }
88152
+ function recordWrittenEntry(collection, key, reference2, ctx) {
88153
+ const references = collectionReferences(collection, ctx);
88154
+ if (typeof references !== "object") {
88155
+ if (reference2 === (references === 0 /* RowIds */)) return;
88156
+ const written = Array.isArray(collection) ? collection[Number(key)] : collection[String(key)];
88157
+ if (!reference2 && typeof written !== "string") return;
88158
+ }
88159
+ const rowIds = references === 0 /* RowIds */;
88160
+ const cache = unorderedListProjectionCache(ctx);
88161
+ if (Array.isArray(collection)) {
88162
+ let indexes3 = cache.referenceEntryIndexesByArray.get(collection);
88163
+ if (indexes3 === void 0) {
88164
+ indexes3 = new Set(rowIds ? collection.keys() : []);
88165
+ cache.referenceEntryIndexesByArray.set(collection, indexes3);
88166
+ }
88167
+ if (reference2) indexes3.add(Number(key));
88168
+ else indexes3.delete(Number(key));
88169
+ return;
88170
+ }
88171
+ let keys = cache.referenceEntryKeysByRecord.get(collection);
88172
+ if (keys === void 0) {
88173
+ keys = new Set(rowIds ? Object.keys(collection) : []);
88174
+ cache.referenceEntryKeysByRecord.set(collection, keys);
88175
+ }
88176
+ if (reference2) keys.add(String(key));
88177
+ else keys.delete(String(key));
88064
88178
  }
88065
88179
  var DELEGATE_LEXICAL_THIS, DELEGATE_LEXICAL_ROOT, DELEGATE_LEXICAL_TYPE_ARGUMENTS, NonCatchableNSGetterRuntimeError, NativeFunctionDelegateUnavailableError, CorruptNeoScriptIRError, NeoScriptWallClockTimeoutError, liveListIndexesByProject, evaluatorOwnershipCachesByBase, MAX_CONSTRUCTION_DEPTH, resolutionCacheByMembers, NO_SCHEMA_REVISION, LazyValueOverlay, READONLY_FOREACH_BINDING_ERROR, READONLY_CATCH_BINDING_ERROR, DIALOGUE_CONTEXT_PARAMETER_ID, FORWARDING_TYPE_ARGUMENTS, constantDeclarationRoots, NS_MATH_OP_NAMES, DOUBLE_INTEGRAL_MAGNITUDE, EMPTY_SUPPLIED_CONSTRUCTOR_FIELDS, variantResolutionCopiesByOverlay;
88066
88180
  var init_evaluateNSGetter = __esm({
@@ -89290,20 +89404,6 @@ var init_variant_value_graph = __esm({
89290
89404
  }
89291
89405
  });
89292
89406
 
89293
- // ../packages/neoscript-runtime/src/declaration-default-source.ts
89294
- function declarationDefaultSource(id2, stored, resolveGraph) {
89295
- if (stored !== null && !isCollapseStampedInstanceRoot(stored)) return stored;
89296
- const graph = resolveGraph(id2);
89297
- return defaultSourceWithListeners(graph?.rowsById.get(id2) ?? stored, graph);
89298
- }
89299
- var init_declaration_default_source = __esm({
89300
- "../packages/neoscript-runtime/src/declaration-default-source.ts"() {
89301
- "use strict";
89302
- init_instance_provenance();
89303
- init_member_change_listeners();
89304
- }
89305
- });
89306
-
89307
89407
  // ../packages/models/src/members/stored-value-placement-index.ts
89308
89408
  function buildStoredValuePlacementIndex(args) {
89309
89409
  return createStoredValuePlacementTraversal(args)();
@@ -89683,6 +89783,20 @@ var init_stored_value_placement_index = __esm({
89683
89783
  }
89684
89784
  });
89685
89785
 
89786
+ // ../packages/neoscript-runtime/src/declaration-default-source.ts
89787
+ function declarationDefaultSource(id2, stored, resolveGraph) {
89788
+ if (stored !== null && !isCollapseStampedInstanceRoot(stored)) return stored;
89789
+ const graph = resolveGraph(id2);
89790
+ return defaultSourceWithListeners(graph?.rowsById.get(id2) ?? stored, graph);
89791
+ }
89792
+ var init_declaration_default_source = __esm({
89793
+ "../packages/neoscript-runtime/src/declaration-default-source.ts"() {
89794
+ "use strict";
89795
+ init_instance_provenance();
89796
+ init_member_change_listeners();
89797
+ }
89798
+ });
89799
+
89686
89800
  // ../packages/neoscript-runtime/src/listener-endpoint-projection.ts
89687
89801
  function projectListenerEndpoint(args) {
89688
89802
  const { descriptor } = args;
@@ -89763,6 +89877,14 @@ var init_overlay_readonly_map = __esm({
89763
89877
  });
89764
89878
 
89765
89879
  // ../packages/neoscript-runtime/src/virtual-instance-graph.ts
89880
+ function isMaterializedSpine(location3) {
89881
+ const stored = location3?.materializedRow;
89882
+ if (stored == null || location3?.parentId == null) return false;
89883
+ const virtual = location3.virtualRow;
89884
+ if (!isLiteralValueContent(stored) || !isLiteralValueContent(virtual))
89885
+ return false;
89886
+ return stored.id === virtual.id && (stored.instanceVariantId ?? null) === (virtual.instanceVariantId ?? null) && (stored.instanceVariantRowValueId ?? null) === (virtual.instanceVariantRowValueId ?? null) && (stored.instanceAppliedVariantId ?? null) === (virtual.instanceAppliedVariantId ?? null) && (stored.instanceAppliedVariantRowValueId ?? null) === (virtual.instanceAppliedVariantRowValueId ?? null);
89887
+ }
89766
89888
  function buildVirtualInstanceMaterializedIndex(args) {
89767
89889
  const rowsById = new Map(
89768
89890
  (args.materializedRows ?? args.document.values).map((row) => [row.id, row])
@@ -91007,6 +91129,7 @@ function resolveStoredInstanceGraphs(args) {
91007
91129
  if (next === void 0 || resolvedRootIds.has(next.root.id)) continue;
91008
91130
  resolvedRootIds.add(next.root.id);
91009
91131
  enqueueStoredRoots(stored.includeRoot(next.root, next.member));
91132
+ if (isMaterializedSpine(resolvedLocations.get(next.root.id))) continue;
91010
91133
  const graph = isMemberClassBase(next.member) ? args.resolveClassGraph?.(next.root, next.member) ?? resolveStoredClassValue({
91011
91134
  evaluateInitializer: args.evaluateInitializer,
91012
91135
  document,
@@ -93072,6 +93195,10 @@ function createHeadlessVirtualInstanceResolver(args) {
93072
93195
  graphByValueId.set(graph.instanceRootId, graph);
93073
93196
  };
93074
93197
  const expandRoot = (rootId, declaredMember) => {
93198
+ const containing = graphByValueId.get(rootId);
93199
+ if (containing !== void 0 && isMaterializedSpine(containing.locationsById.get(rootId))) {
93200
+ return expandRoot(containing.instanceRootId, void 0);
93201
+ }
93075
93202
  const cached = graphRowsByRootId.get(rootId);
93076
93203
  if (cached !== void 0) {
93077
93204
  const reads2 = readsByRootId.get(rootId);
@@ -93161,17 +93288,21 @@ function createHeadlessVirtualInstanceResolver(args) {
93161
93288
  recorder.recordValuePlacementRead();
93162
93289
  recorder.recordValueRead(receiverValueId);
93163
93290
  let placement = placements().get(receiverValueId) ?? null;
93291
+ const roots = [];
93164
93292
  while (placement !== null) {
93165
93293
  recorder.recordValueRead(placement.valueId);
93166
93294
  const raw = rawById.get(placement.valueId);
93167
93295
  if (raw !== void 0 && isLiteralValueContent(raw) && isStoredClassResolutionRoot(raw)) {
93168
- return expandRoot(
93169
- placement.valueId,
93170
- membersById.get(placement.memberId)
93171
- );
93296
+ roots.push(placement);
93172
93297
  }
93173
93298
  placement = placement.parentValueId === null ? null : placements().get(placement.parentValueId) ?? null;
93174
93299
  }
93300
+ let resolved = emptyRows;
93301
+ for (let index = roots.length - 1; index >= 0; index -= 1) {
93302
+ const root2 = roots[index];
93303
+ resolved = expandRoot(root2.valueId, membersById.get(root2.memberId));
93304
+ }
93305
+ if (roots.length > 0) return resolved;
93175
93306
  const root = rawById.get(receiverValueId);
93176
93307
  if (root !== void 0 && typeof root.classId === "string" && isStoredClassResolutionRoot(root)) {
93177
93308
  return expandRoot(receiverValueId, {
@@ -93206,7 +93337,7 @@ function createHeadlessVirtualInstanceResolver(args) {
93206
93337
  const known = graphByValueId.get(valueId);
93207
93338
  if (known?.instanceRootId === valueId) return known;
93208
93339
  const stored = rawById.get(valueId);
93209
- if (known !== void 0 && (stored === void 0 || !isStoredClassResolutionRoot(stored)))
93340
+ if (known !== void 0 && (stored === void 0 || !isStoredClassResolutionRoot(stored) || isMaterializedSpine(known.locationsById.get(valueId))))
93210
93341
  return known;
93211
93342
  virtualInstanceRowsForValue(valueId);
93212
93343
  return graphByValueId.get(valueId) ?? null;
@@ -94307,6 +94438,28 @@ function createTypedValueNormalizer(reader, document, childrenByContainerId, par
94307
94438
  }
94308
94439
  return normalizeLiteral(value);
94309
94440
  };
94441
+ const bindingTypes = /* @__PURE__ */ new Map();
94442
+ const bindingType = (memberId) => {
94443
+ const member = memberById2(memberId);
94444
+ if (member === void 0) return memberId;
94445
+ try {
94446
+ return genericBindingTypeInfo(member, /* @__PURE__ */ new Map(), document.members);
94447
+ } catch {
94448
+ return memberId;
94449
+ }
94450
+ };
94451
+ const normalizeGenericBindings = (bindings) => {
94452
+ const result = /* @__PURE__ */ Object.create(null);
94453
+ for (const [paramId, memberId] of Object.entries(bindings)) {
94454
+ let type = bindingTypes.get(memberId);
94455
+ if (type === void 0) {
94456
+ type = bindingType(memberId);
94457
+ bindingTypes.set(memberId, type);
94458
+ }
94459
+ result[paramId] = type;
94460
+ }
94461
+ return result;
94462
+ };
94310
94463
  const normalizeTypedRow = (valueId, typeInfo, placement, parentEnv = /* @__PURE__ */ new Map()) => {
94311
94464
  const row = reader.row(valueId, typeInfo, placement);
94312
94465
  if (row === void 0) return valueId;
@@ -94388,7 +94541,7 @@ function createTypedValueNormalizer(reader, document, childrenByContainerId, par
94388
94541
  const normalized = {
94389
94542
  ...rowIdentities?.has(valueId) ? { id: valueId } : {},
94390
94543
  ...typeof row.classId === "string" ? { classId: row.classId } : {},
94391
- ...row.genericBindings === void 0 ? {} : { genericBindings: row.genericBindings },
94544
+ ...row.genericBindings === void 0 ? {} : { genericBindings: normalizeGenericBindings(row.genericBindings) },
94392
94545
  value,
94393
94546
  ...carriesSemanticConstructorArguments(row) ? {
94394
94547
  constructorArgs: normalizeConstructorArgs(
@@ -94425,7 +94578,7 @@ function createTypedValueNormalizer(reader, document, childrenByContainerId, par
94425
94578
  const normalized = {
94426
94579
  ...rowIdentities?.has(valueId) ? { id: valueId } : {},
94427
94580
  ...typeof row.classId === "string" ? { classId: row.classId } : {},
94428
- ...row.genericBindings === void 0 ? {} : { genericBindings: row.genericBindings },
94581
+ ...row.genericBindings === void 0 ? {} : { genericBindings: normalizeGenericBindings(row.genericBindings) },
94429
94582
  // The containing Class schema proves this is an owned row edge, but an
94430
94583
  // unresolved generic member does not prove anything about strings in
94431
94584
  // the row's payload. Keep those strings literal instead of guessing
@@ -94539,6 +94692,7 @@ var init_effective_value_reader = __esm({
94539
94692
  init_core();
94540
94693
  init_members();
94541
94694
  init_packed_value_encoding();
94695
+ init_stored_value_placement_index();
94542
94696
  init_read_class_member();
94543
94697
  init_initializer_materialization();
94544
94698
  init_evaluateInitializer();
@@ -94603,6 +94757,7 @@ var init_effective_value_reader = __esm({
94603
94757
  resolvedDocument;
94604
94758
  indexedDocument;
94605
94759
  materializedIndex;
94760
+ storedPlacements;
94606
94761
  graphCache;
94607
94762
  createNormalizer(rowIdentities) {
94608
94763
  return createTypedValueNormalizer(
@@ -94777,10 +94932,15 @@ var init_effective_value_reader = __esm({
94777
94932
  return row;
94778
94933
  if (this.resolvedRoots.has(valueId)) return row;
94779
94934
  if (this.mode(valueId) === "partial") return row;
94935
+ if (this.context.overrideRows === "constructed" && this.overrides.has(valueId) && !this.graph.valuesById.has(valueId))
94936
+ return row;
94780
94937
  const schema = this.schema(classId);
94781
- if (schema.every(
94782
- (entry) => Object.prototype.hasOwnProperty.call(row.value, entry.schemaKey)
94783
- ))
94938
+ const record7 = row.value;
94939
+ if (schema.every((entry) => {
94940
+ if (Object.hasOwn(record7, entry.schemaKey)) return true;
94941
+ const member2 = this.memberForId(entry.memberId);
94942
+ return member2 !== null && !memberKindOwnsStoredValue(member2.kind);
94943
+ }))
94784
94944
  return row;
94785
94945
  this.resolvedRoots.add(valueId);
94786
94946
  const member = this.placementFor(valueId) ?? this.graph.ownerForValue(valueId) ?? {
@@ -94871,6 +95031,30 @@ var init_effective_value_reader = __esm({
94871
95031
  unorderedListEntryIds: unorderedListEntryIds2
94872
95032
  });
94873
95033
  }
95034
+ const materializedIndex = this.materializedIndex;
95035
+ this.storedPlacements ??= buildStoredValuePlacementIndex({
95036
+ ...this.readDocument,
95037
+ constructors: this.readDocument.constructors ?? [],
95038
+ indexedRows: {
95039
+ valuesById: this.materializedIndex.rowsById,
95040
+ unorderedListEntryIds: (id2) => materializedIndex.unorderedEntryIdsByContainerId.get(id2) ?? []
95041
+ },
95042
+ resolveStaticValueId: (memberId) => this.memberForId(memberId)?.valueId ?? null
95043
+ });
95044
+ const positions = this.storedPlacements.placementByValueId;
95045
+ let parentId = positions.get(valueId)?.parentValueId;
95046
+ while (parentId != null) {
95047
+ const position = positions.get(parentId);
95048
+ if (position === void 0) break;
95049
+ const parentMember = this.memberForId(position.memberId);
95050
+ if (parentMember !== null && isMemberClassBase(parentMember)) {
95051
+ const containingRows = this.resolveGraph(parentId, parentMember);
95052
+ if (isMaterializedSpine(this.locations.get(valueId)))
95053
+ return containingRows;
95054
+ break;
95055
+ }
95056
+ parentId = position.parentValueId;
95057
+ }
94874
95058
  const rows = resolveStoredInstanceGraphs({
94875
95059
  ...this.context,
94876
95060
  readRecorder: this.context.readTracking === void 0 ? void 0 : virtualReadRecorder(this.context.readTracking),
@@ -94977,6 +95161,8 @@ var init_effective_value_reader = __esm({
94977
95161
  {
94978
95162
  ...this.context,
94979
95163
  containerMembership: options.containerMembership ?? this.context.containerMembership,
95164
+ // Describes this reader's overrides, not a fork's.
95165
+ overrideRows: void 0,
94980
95166
  ...options.readTracking === void 0 ? {} : { readTracking: options.readTracking }
94981
95167
  },
94982
95168
  this,
@@ -117746,6 +117932,7 @@ function* prepareServerOwnedSchemaCommitPasses(args) {
117746
117932
  });
117747
117933
  materializePreparedInstanceInitializers({
117748
117934
  document: args.document,
117935
+ physicalValues: args.document.physicalValues,
117749
117936
  prepared,
117750
117937
  contentHashHeads: args.contentHashHeads
117751
117938
  });
@@ -118065,6 +118252,7 @@ function materializePreparedInstanceInitializers(args) {
118065
118252
  args.contentHashHeads,
118066
118253
  "value"
118067
118254
  );
118255
+ let writeBaseHashFor;
118068
118256
  const owners = resolveSemanticOwnerMembersForValues(
118069
118257
  materializationScope.document,
118070
118258
  new Set(sites.keys()),
@@ -118205,7 +118393,14 @@ function materializePreparedInstanceInitializers(args) {
118205
118393
  const existing = existingValueById.get(created.id);
118206
118394
  if (existing !== void 0) {
118207
118395
  if (materializedValueRowsEqual(existing, created)) continue;
118208
- const contentHash = liveValueHashes().get(created.id);
118396
+ writeBaseHashFor ??= createValueWriteBaseHashResolver({
118397
+ document: args.document,
118398
+ physicalValues: args.physicalValues,
118399
+ prepared: args.prepared,
118400
+ contentHashHeads: args.contentHashHeads,
118401
+ source: "server-initializer-materialization"
118402
+ });
118403
+ const contentHash = writeBaseHashFor(created.id);
118209
118404
  if (contentHash === void 0) {
118210
118405
  throw new Error(
118211
118406
  `Cannot reconcile materialized initializer row "${created.id}": its live content hash is unavailable.`
@@ -118220,7 +118415,7 @@ function materializePreparedInstanceInitializers(args) {
118220
118415
  source: "server-initializer-materialization",
118221
118416
  sourceValueId: valueId
118222
118417
  }),
118223
- expectedBaseContentHash: contentHash
118418
+ ...contentHash === null ? {} : { expectedBaseContentHash: contentHash }
118224
118419
  });
118225
118420
  existingValueById.set(created.id, created);
118226
118421
  continue;
@@ -120153,7 +120348,7 @@ function valueIdsFromRows(explicitRows, sweepRows) {
120153
120348
  for (const row of sweepRows) ids.add(row.id);
120154
120349
  return ids;
120155
120350
  }
120156
- function createValueRecompileBaseHashResolver(args) {
120351
+ function createValueWriteBaseHashResolver(args) {
120157
120352
  const hashById = indexLiveContentHashesByRecordId(
120158
120353
  args.contentHashHeads,
120159
120354
  "value"
@@ -120198,7 +120393,7 @@ function createValueRecompileBaseHashResolver(args) {
120198
120393
  nextData: root,
120199
120394
  expectedBaseContentHash: rootHash,
120200
120395
  intent: createProjectVersionIntent("value.update", {
120201
- source: "server-neoscript-recompile"
120396
+ source: args.source
120202
120397
  })
120203
120398
  });
120204
120399
  }
@@ -120316,7 +120511,8 @@ function prepareServerOwnedValueInitializerBodies(args) {
120316
120511
  const currentById = new Map(
120317
120512
  args.document.values.map((value) => [value.id, value])
120318
120513
  );
120319
- const baseHashFor = createValueRecompileBaseHashResolver({
120514
+ const baseHashFor = createValueWriteBaseHashResolver({
120515
+ source: "server-neoscript-recompile",
120320
120516
  document: committedDocument,
120321
120517
  physicalValues: args.document.physicalValues,
120322
120518
  prepared: args.prepared,
@@ -120788,7 +120984,8 @@ function prepareServerOwnedDelegateValueBodies(args) {
120788
120984
  const currentById = new Map(
120789
120985
  args.document.values.map((value) => [value.id, value])
120790
120986
  );
120791
- const baseHashFor = createValueRecompileBaseHashResolver({
120987
+ const baseHashFor = createValueWriteBaseHashResolver({
120988
+ source: "server-neoscript-recompile",
120792
120989
  document: committedDocument,
120793
120990
  physicalValues: args.physicalValues,
120794
120991
  prepared: args.prepared,
@@ -138894,7 +139091,7 @@ function classValueBody(context, member, value, visited, targetTyped, outerEnvir
138894
139091
  context,
138895
139092
  value.id,
138896
139093
  replayConstruction,
138897
- concreteClassMemberForReplay(member, environment)
139094
+ concreteClassMemberForReplay(context, member, environment)
138898
139095
  );
138899
139096
  const replayRoot = replayRows === null || typeof value.id !== "string" ? void 0 : replayRows.get(value.id);
138900
139097
  const graph = replayRows === null || typeof value.id !== "string" ? null : context.readEffectiveValues().withRowOverrides(
@@ -138941,7 +139138,11 @@ function classValueBody(context, member, value, visited, targetTyped, outerEnvir
138941
139138
  if (!context.values.has(childId)) {
138942
139139
  const reader = context.readEffectiveValues();
138943
139140
  if (reader.row(childId) === void 0) {
138944
- const placement = concreteClassMemberForReplay(member, environment);
139141
+ const placement = concreteClassMemberForReplay(
139142
+ context,
139143
+ member,
139144
+ environment
139145
+ );
138945
139146
  if (!isAnyMemberBase(placement))
138946
139147
  throw new Error(
138947
139148
  `Stored class ${name} has no typed member placement.`
@@ -139217,22 +139418,23 @@ function storedConstructionReplayRows(context, valueId, code, member) {
139217
139418
  context.constructionReplays.set(valueId, replay);
139218
139419
  return replay;
139219
139420
  }
139220
- function concreteClassMemberForReplay(member, environment) {
139421
+ function concreteClassMemberForReplay(context, member, environment) {
139221
139422
  if (numberField(member, "kind") !== 7 /* Class */) return member;
139222
139423
  const classArguments2 = isObjectRecord2(member.classArguments) ? member.classArguments : {};
139424
+ const parameters = context.manifestClasses.get(stringField2(member, "classId"))?.genericParameters ?? [];
139223
139425
  let changed = false;
139224
- const concreteArguments = Object.fromEntries(
139225
- Object.entries(classArguments2).map(([genericParamId, binding]) => {
139226
- const forwardedParamId = isObjectRecord2(binding) && (binding.kind === void 0 || binding.kind === 0 /* Generic */) && typeof binding.genericParamId === "string" ? binding.genericParamId : null;
139227
- const bindingMemberId = environment.get(genericParamId) ?? (forwardedParamId === null ? void 0 : environment.get(forwardedParamId));
139228
- if (bindingMemberId === void 0) return [genericParamId, binding];
139229
- changed = true;
139230
- return [
139231
- genericParamId,
139232
- { kind: 1 /* Member */, memberId: bindingMemberId }
139233
- ];
139234
- })
139235
- );
139426
+ const concreteArguments = { ...classArguments2 };
139427
+ for (const { id: genericParamId } of parameters) {
139428
+ const binding = classArguments2[genericParamId];
139429
+ const forwardedParamId = isObjectRecord2(binding) && (binding.kind === void 0 || binding.kind === 0 /* Generic */) && typeof binding.genericParamId === "string" ? binding.genericParamId : null;
139430
+ const bindingMemberId = environment.get(genericParamId) ?? (forwardedParamId === null ? void 0 : environment.get(forwardedParamId));
139431
+ if (bindingMemberId === void 0) continue;
139432
+ changed = true;
139433
+ concreteArguments[genericParamId] = {
139434
+ kind: 1 /* Member */,
139435
+ memberId: bindingMemberId
139436
+ };
139437
+ }
139236
139438
  return changed ? { ...member, classArguments: concreteArguments } : member;
139237
139439
  }
139238
139440
  function storedLookupIdentityIds(values, reader) {
@@ -139959,6 +140161,19 @@ function storedTypedRowSource(context, type, valueId, environment, visited, writ
139959
140161
  `Stored ${type.kind} constructor argument references missing value row ${valueId}.`
139960
140162
  );
139961
140163
  }
140164
+ if (type.kind === "generic" && typeof row.classId !== "string") {
140165
+ return storedTypedRowSource(
140166
+ context,
140167
+ storedGenericArgumentType(context, type, environment),
140168
+ valueId,
140169
+ environment,
140170
+ visited,
140171
+ writeIdentity,
140172
+ partial,
140173
+ constructorOwnsGraph,
140174
+ cloneAggregateArguments
140175
+ );
140176
+ }
139962
140177
  if (cloneAggregateArguments) {
139963
140178
  const settled = type.kind === "generic" ? storedGenericArgumentType(context, type, environment) : type;
139964
140179
  if (settled.kind === "class" || settled.kind === "interface") {
@@ -139983,8 +140198,8 @@ function storedTypedRowSource(context, type, valueId, environment, visited, writ
139983
140198
  visited.add(valueId);
139984
140199
  try {
139985
140200
  if (type.kind === "class" || type.kind === "interface" || type.kind === "generic") {
139986
- const classId = type.kind === "class" ? type.classId : typeof row.classId === "string" ? row.classId : null;
139987
- if (classId === null) {
140201
+ const classId = type.kind === "class" ? type.classId : row.classId;
140202
+ if (typeof classId !== "string") {
139988
140203
  throw new Error(
139989
140204
  `Stored ${type.kind} constructor argument ${valueId} has no concrete class.`
139990
140205
  );
@@ -201632,7 +201847,7 @@ There is no --keep-current: preserving current semantic state defines flatten.
201632
201847
  async function main() {
201633
201848
  const args = parseArgs(process.argv.slice(2));
201634
201849
  if (args.command === "--version") {
201635
- console.log("0.81.1");
201850
+ console.log("0.81.3");
201636
201851
  return;
201637
201852
  }
201638
201853
  if (args.command === null || args.command === "help" || args.command === "--help" || args.command === "-h") {