@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.
@@ -2339,6 +2339,16 @@ function neoScriptRegistryEntryType(typeName) {
2339
2339
  }
2340
2340
  return REGISTRY_ENTRY_TYPES[typeName] ?? null;
2341
2341
  }
2342
+ function typeArgumentArityMessage(typeName, expected, provided) {
2343
+ return `Type '${typeName}' expects ${expected} type argument${expected === 1 ? "" : "s"}, but ${provided} ${provided === 1 ? "was" : "were"} provided.`;
2344
+ }
2345
+ function genericParameterArgumentsMessage(name) {
2346
+ return `Generic parameter '${name}' cannot receive type arguments.`;
2347
+ }
2348
+ var NEOSCRIPT_DELEGATE_MAX_PARAMETERS = 16;
2349
+ function delegateArityMessage(provided) {
2350
+ return `Type 'NeoDelegate' expects a return type followed by up to ${NEOSCRIPT_DELEGATE_MAX_PARAMETERS} parameter types, but ${provided} type arguments were provided.`;
2351
+ }
2342
2352
  function neoScriptRegistryReferenceType(entryTypeName) {
2343
2353
  for (const definition of Object.values(REGISTRY_ENTRY_TYPES)) {
2344
2354
  if (definition.entryType === entryTypeName) return definition.refType;
@@ -20010,15 +20020,9 @@ function evalActionListenerInstruction(ins, scope, ctx, options) {
20010
20020
  }
20011
20021
  let destination;
20012
20022
  const target = ins.target.pointer;
20013
- const currentValue = target.type === "keyOf" /* keyOf */ ? evalKeyOf(
20014
- target.keyOf,
20015
- scope,
20016
- ctx,
20017
- target.optional === true,
20018
- (resolved) => {
20019
- destination = resolved;
20020
- }
20021
- ) : evalPointer(target, scope, ctx);
20023
+ const currentValue = target.type === "keyOf" /* keyOf */ ? evalKeyOf(target, scope, ctx, (resolved) => {
20024
+ destination = resolved;
20025
+ }) : evalPointer(target, scope, ctx);
20022
20026
  const current = actionListenersOf(currentValue, () => `'${operator}' target`);
20023
20027
  const identity = nsActionListenerIdentity(listener);
20024
20028
  const present = current.some(
@@ -20089,38 +20093,26 @@ function applyOverlayAssignment(target, targetTypeInfo, value, scope, ctx, desti
20089
20093
  );
20090
20094
  }
20091
20095
  receiver[index] = referenceValueId;
20092
- setCollectionReferenceProvenance(receiver, index, true, ctx);
20096
+ recordWrittenEntry(receiver, index, true, ctx);
20093
20097
  invalidateEvaluatorIndexes(ctx, receiver);
20094
20098
  return;
20095
20099
  }
20096
- if (ctx.__unorderedListProjections?.referenceEntryIndexesByArray.has(
20097
- receiver
20098
- ) === true) {
20099
- receiver[index] = value;
20100
- setCollectionReferenceProvenance(receiver, index, false, ctx);
20101
- invalidateEvaluatorIndexes(ctx, receiver);
20100
+ if (collectionReferences(receiver, ctx) === 0 /* RowIds */ && replaceEntryRowValue(
20101
+ receiver,
20102
+ receiver[index],
20103
+ value,
20104
+ targetTypeInfo,
20105
+ ctx
20106
+ ))
20102
20107
  return;
20103
- }
20104
- const existing2 = receiver[index];
20105
- if (typeof existing2 === "string") {
20106
- const row = evalValueById(
20107
- ctx,
20108
- existing2,
20109
- ctx.__runtimeSessionValues,
20110
- ctx.__valueOverlay
20111
- );
20112
- if (row !== null) {
20113
- replaceRowValue(row, value, receiver, ctx);
20114
- updateUnorderedListProjectionAfterAssignment(row, value, ctx);
20115
- return;
20116
- }
20117
- }
20118
20108
  receiver[index] = value;
20109
+ recordWrittenEntry(receiver, index, false, ctx);
20119
20110
  invalidateEvaluatorIndexes(ctx, receiver);
20120
20111
  return;
20121
20112
  }
20122
20113
  const object = objectArg(receiver, "Assignment target");
20123
20114
  const stringKey = String(key);
20115
+ const field = target.memberId !== void 0;
20124
20116
  if (referenceValueId !== null) {
20125
20117
  const parentId = findKnownRowIdByValueReference(receiver, ctx);
20126
20118
  if (parentId !== null) {
@@ -20135,26 +20127,41 @@ function applyOverlayAssignment(target, targetTypeInfo, value, scope, ctx, desti
20135
20127
  );
20136
20128
  }
20137
20129
  object[stringKey] = referenceValueId;
20130
+ if (!field) recordWrittenEntry(object, stringKey, true, ctx);
20138
20131
  invalidateEvaluatorIndexes(ctx, receiver);
20139
20132
  return;
20140
20133
  }
20141
- const existing = object[stringKey];
20142
- if (typeof existing === "string") {
20143
- const row = evalValueById(
20144
- ctx,
20145
- existing,
20146
- ctx.__runtimeSessionValues,
20147
- ctx.__valueOverlay
20148
- );
20149
- if (row !== null) {
20150
- replaceRowValue(row, value, receiver, ctx);
20151
- updateUnorderedListProjectionAfterAssignment(row, value, ctx);
20152
- return;
20153
- }
20154
- }
20134
+ if (collectionReferences(object, ctx) === 0 /* RowIds */ && replaceEntryRowValue(object, object[stringKey], value, targetTypeInfo, ctx))
20135
+ return;
20155
20136
  object[stringKey] = value;
20137
+ if (!field) recordWrittenEntry(object, stringKey, false, ctx);
20156
20138
  invalidateEvaluatorIndexes(ctx, receiver);
20157
20139
  }
20140
+ function replaceEntryRowValue(receiver, existing, value, targetTypeInfo, ctx) {
20141
+ if (typeof existing !== "string") return false;
20142
+ const row = evalValueById(
20143
+ ctx,
20144
+ existing,
20145
+ ctx.__runtimeSessionValues,
20146
+ ctx.__valueOverlay
20147
+ );
20148
+ if (row === null) return false;
20149
+ keepAssignedCollectionValues(value, targetTypeInfo, ctx);
20150
+ replaceRowValue(row, value, receiver, ctx);
20151
+ updateUnorderedListProjectionAfterAssignment(row, value, ctx);
20152
+ return true;
20153
+ }
20154
+ function keepAssignedCollectionValues(value, targetTypeInfo, ctx) {
20155
+ const cache = unorderedListProjectionCache(ctx);
20156
+ if (Array.isArray(value) && (targetTypeInfo.type === 6 /* List */ || targetTypeInfo.type === 28 /* Set */)) {
20157
+ if (!cache.referenceEntryIndexesByArray.has(value))
20158
+ cache.referenceEntryIndexesByArray.set(value, /* @__PURE__ */ new Set());
20159
+ return;
20160
+ }
20161
+ if (targetTypeInfo.type === 5 /* Dictionary */ && typeof value === "object" && value !== null && !cache.referenceEntryKeysByRecord.has(value)) {
20162
+ cache.referenceEntryKeysByRecord.set(value, /* @__PURE__ */ new Set());
20163
+ }
20164
+ }
20158
20165
  function replaceRowValue(row, value, receiver, ctx) {
20159
20166
  const indexes3 = ctx.__indexes;
20160
20167
  if (indexes3 === void 0 || ctx.__runtimeSessionValues?.get(row.id) !== row || !indexes3.indexedRowIds.has(row.id)) {
@@ -20592,9 +20599,11 @@ function evalCollectionMutationInstruction(ins, scope, ctx, options) {
20592
20599
  );
20593
20600
  }
20594
20601
  const unorderedEntriesBeforeMutation = unorderedContainerValueId === null || !Array.isArray(targetValue) || ins.mutation === "Add" /* Add */ ? null : [...targetValue];
20595
- if ((ins.mutation === "Add" /* Add */ || ins.mutation === "Insert" /* Insert */) && !isLookupSet) {
20602
+ const writesEntry = (ins.mutation === "Add" /* Add */ || ins.mutation === "Insert" /* Insert */) && !isLookupSet;
20603
+ let attachedValueId = null;
20604
+ if (writesEntry) {
20596
20605
  const attachedValue = isArrayCollection(targetValue) && ins.mutation !== "Insert" /* Insert */ ? args[0] : args[1];
20597
- const attachedValueId = findKnownRowIdByValueReference(attachedValue, ctx);
20606
+ attachedValueId = findKnownRowIdByValueReference(attachedValue, ctx);
20598
20607
  const parentId = findKnownRowIdByValueReference(targetValue, ctx);
20599
20608
  if (attachedValueId !== null && parentId !== null) {
20600
20609
  ctx.assertCollectionEntryAttachable?.(
@@ -20631,6 +20640,23 @@ function evalCollectionMutationInstruction(ins, scope, ctx, options) {
20631
20640
  removedIndex,
20632
20641
  ctx
20633
20642
  );
20643
+ if (writesEntry && !(targetValue instanceof RuntimeSet)) {
20644
+ const writtenAsRowId = attachedValueId !== null || unorderedContainerValueId !== null;
20645
+ if (Array.isArray(targetValue))
20646
+ recordWrittenEntry(
20647
+ targetValue,
20648
+ removedIndex ?? targetValue.length - 1,
20649
+ writtenAsRowId,
20650
+ ctx
20651
+ );
20652
+ else
20653
+ recordWrittenEntry(
20654
+ objectArg(targetValue, "Dictionary Add target"),
20655
+ String(args[0]),
20656
+ writtenAsRowId,
20657
+ ctx
20658
+ );
20659
+ }
20634
20660
  if (unorderedEntriesBeforeMutation !== null && Array.isArray(targetValue)) {
20635
20661
  detachRemovedUnorderedScalarEntries(
20636
20662
  unorderedEntriesBeforeMutation,
@@ -20832,9 +20858,10 @@ function runtimeSet(array2, reference, enumEntries, ctx) {
20832
20858
  const existing = sets.get(array2);
20833
20859
  if (existing !== void 0) return existing;
20834
20860
  const set = new RuntimeSet(array2, reference, enumEntries);
20861
+ const references = collectionReferences(array2, ctx);
20835
20862
  for (let index = 0; index < array2.length; index++) {
20836
20863
  const raw = array2[index];
20837
- const resolves = collectionEntryUsesReferenceResolution(array2, index, ctx);
20864
+ const resolves = isReferenceEntry(references, index);
20838
20865
  const value = resolves ? resolveValueIfId(raw, ctx) : raw;
20839
20866
  const key = runtimeSetKey(value, set, ctx);
20840
20867
  set.add(key, enumEntries ? key : raw, !enumEntries && resolves);
@@ -20843,9 +20870,9 @@ function runtimeSet(array2, reference, enumEntries, ctx) {
20843
20870
  (ctx.__dirtyRuntimeSets ??= /* @__PURE__ */ new Set()).add(set);
20844
20871
  return set;
20845
20872
  }
20846
- function storedSetEntryMatch(raw, entryMember, ctx) {
20873
+ function storedSetEntryMatch(raw, reference, entryMember, ctx) {
20847
20874
  const byIdentity = entryMember.kind === 7 /* Class */;
20848
- const row = byIdentity || typeof raw !== "string" ? null : evalValueById(ctx, raw, ctx.__runtimeSessionValues, ctx.__valueOverlay);
20875
+ const row = byIdentity || !reference || typeof raw !== "string" ? null : evalValueById(ctx, raw, ctx.__runtimeSessionValues, ctx.__valueOverlay);
20849
20876
  const valueId = byIdentity && typeof raw === "string" ? raw : row?.id ?? null;
20850
20877
  const entry = row === null ? { id: "", value: raw } : { id: row.id, value: row.value };
20851
20878
  const key = byIdentity ? valueId ?? referenceIdOf(raw, ctx) : setEntryKey(entryMember, entry);
@@ -20856,8 +20883,14 @@ function storedSetEntries(set, entryMember, ctx) {
20856
20883
  const existing = indexes3.get(set);
20857
20884
  if (existing !== void 0) return existing;
20858
20885
  const entries = /* @__PURE__ */ new Map();
20859
- for (const raw of set) {
20860
- const match = storedSetEntryMatch(raw, entryMember, ctx);
20886
+ const references = collectionReferences(set, ctx);
20887
+ for (let index = 0; index < set.length; index++) {
20888
+ const match = storedSetEntryMatch(
20889
+ set[index],
20890
+ isReferenceEntry(references, index),
20891
+ entryMember,
20892
+ ctx
20893
+ );
20861
20894
  if (match !== null && !entries.has(match.key)) {
20862
20895
  entries.set(match.key, match);
20863
20896
  }
@@ -20869,7 +20902,13 @@ function syncStoredSetEntries(set, mutation, removed, entryMember, ctx) {
20869
20902
  const entries = ctx.__setEntryIndexes?.get(set);
20870
20903
  if (entries === void 0) return;
20871
20904
  if (entryMember !== null && mutation === "Add" /* Add */) {
20872
- const added = storedSetEntryMatch(set[set.length - 1], entryMember, ctx);
20905
+ const index = set.length - 1;
20906
+ const added = storedSetEntryMatch(
20907
+ set[index],
20908
+ isReferenceEntry(collectionReferences(set, ctx), index),
20909
+ entryMember,
20910
+ ctx
20911
+ );
20873
20912
  if (added !== null) entries.set(added.key, added);
20874
20913
  return;
20875
20914
  }
@@ -20935,6 +20974,7 @@ function applyLocalCollectionMutation(targetValue, mutation, args, ctx, unique =
20935
20974
  return null;
20936
20975
  case "Remove" /* Remove */:
20937
20976
  if (Array.isArray(targetValue)) {
20977
+ const references = resolveRemovalEntries ? collectionReferences(targetValue, ctx) : recordedReferenceEntries(targetValue, ctx) ?? 1 /* Values */;
20938
20978
  let index = -1;
20939
20979
  for (let candidate = 0; candidate < targetValue.length; candidate += 1) {
20940
20980
  const entry = targetValue[candidate];
@@ -20945,9 +20985,8 @@ function applyLocalCollectionMutation(targetValue, mutation, args, ctx, unique =
20945
20985
  }
20946
20986
  continue;
20947
20987
  }
20948
- const referenceEntry = ctx.__unorderedListProjections?.referenceEntryIndexesByArray.get(targetValue)?.has(candidate) === true;
20949
20988
  if (jsEqual(
20950
- resolveRemovalEntries || referenceEntry ? resolveCollectionEntry(targetValue, entry, candidate, ctx) : entry,
20989
+ typeof entry === "string" && isReferenceEntry(references, candidate) ? resolveValueIfId(entry, ctx) : entry,
20951
20990
  args[0]
20952
20991
  )) {
20953
20992
  index = candidate;
@@ -20980,13 +21019,6 @@ function applyLocalCollectionMutation(targetValue, mutation, args, ctx, unique =
20980
21019
  return null;
20981
21020
  }
20982
21021
  }
20983
- function setCollectionReferenceProvenance(targetValue, index, reference, ctx) {
20984
- const cache = ctx.__unorderedListProjections;
20985
- const indexes3 = cache?.referenceEntryIndexesByArray.get(targetValue);
20986
- if (cache === void 0 || indexes3 === void 0) return;
20987
- if (reference) indexes3.add(index);
20988
- else indexes3.delete(index);
20989
- }
20990
21022
  function updateCollectionReferenceProvenance(targetValue, mutation, removedIndex, ctx) {
20991
21023
  if (!Array.isArray(targetValue)) return;
20992
21024
  const cache = ctx.__unorderedListProjections;
@@ -21260,7 +21292,7 @@ function evalPointerCore(pointer, scope, ctx, resultUsage = "value") {
21260
21292
  case "staticMember" /* staticMember */:
21261
21293
  return evalStaticMember(pointer.memberId, ctx);
21262
21294
  case "keyOf" /* keyOf */:
21263
- return evalKeyOf(pointer.keyOf, scope, ctx, pointer.optional === true);
21295
+ return evalKeyOf(pointer, scope, ctx);
21264
21296
  case "operation" /* operation */:
21265
21297
  return evalOperation(pointer.operation, scope, ctx);
21266
21298
  case "function" /* function */:
@@ -21910,15 +21942,9 @@ function readActionWithOwner(pointer, scope, ctx) {
21910
21942
  return { action: evalPointer(pointer, scope, ctx), owner: null };
21911
21943
  }
21912
21944
  let owner = null;
21913
- const action = evalKeyOf(
21914
- pointer.keyOf,
21915
- scope,
21916
- ctx,
21917
- pointer.optional === true,
21918
- (destination) => {
21919
- owner = destination.receiver;
21920
- }
21921
- );
21945
+ const action = evalKeyOf(pointer, scope, ctx, (destination) => {
21946
+ owner = destination.receiver;
21947
+ });
21922
21948
  return { action, owner };
21923
21949
  }
21924
21950
  function actionPointerLabel(pointer, ctx) {
@@ -22836,7 +22862,9 @@ function isRuntimeSpriteValue(value) {
22836
22862
  const sliceIndex = value.sliceIndex;
22837
22863
  return typeof sliceIndex === "number" && Number.isInteger(sliceIndex) && sliceIndex >= 0;
22838
22864
  }
22839
- function evalKeyOf(keyOf, scope, ctx, optional2 = false, onDestination) {
22865
+ function evalKeyOf(pointer, scope, ctx, onDestination) {
22866
+ const { keyOf } = pointer;
22867
+ const optional2 = pointer.optional === true;
22840
22868
  const receiver = evalPointer(keyOf.pointer, scope, ctx);
22841
22869
  if (optional2 && (receiver === null || receiver === void 0)) {
22842
22870
  return null;
@@ -22897,7 +22925,7 @@ function evalKeyOf(keyOf, scope, ctx, optional2 = false, onDestination) {
22897
22925
  if (dispatched.kind === "ok") return dispatched.value;
22898
22926
  if (Object.prototype.hasOwnProperty.call(receiver, k)) {
22899
22927
  const at2 = receiver[k];
22900
- return resolveValueIfId(at2, ctx);
22928
+ return typeof at2 === "string" && (pointer.memberId !== void 0 || isReferenceEntry(collectionReferences(receiver, ctx), k)) ? resolveValueIfId(at2, ctx) : at2;
22901
22929
  }
22902
22930
  const expanded = virtualExpandedRecordForReceiver(receiver, ctx);
22903
22931
  if (expanded !== null && Object.prototype.hasOwnProperty.call(expanded, k)) {
@@ -23630,7 +23658,7 @@ function evaluateSystemNative(memberId, receiver, args, ctx, typeArguments) {
23630
23658
  shift,
23631
23659
  accepts
23632
23660
  );
23633
- return { handled: true, value };
23661
+ return { handled: true, value: referenceEntryList(value, ctx) };
23634
23662
  }
23635
23663
  if (memberId === NEO_OBJECT_GRID_MEMBER_IDS.GetTiles) {
23636
23664
  const value = index.tiles(
@@ -23640,7 +23668,7 @@ function evaluateSystemNative(memberId, receiver, args, ctx, typeArguments) {
23640
23668
  shift,
23641
23669
  accepts
23642
23670
  );
23643
- return { handled: true, value };
23671
+ return { handled: true, value: referenceEntryList(value, ctx) };
23644
23672
  }
23645
23673
  const tile = index.tile(
23646
23674
  placement,
@@ -24262,7 +24290,17 @@ function evalDeclaredListIndex(info, scope, ctx) {
24262
24290
  collectionIndexes.set(cacheKey, index);
24263
24291
  }
24264
24292
  if (info.keyPointer === void 0) {
24265
- return Object.fromEntries(index);
24293
+ const view = Object.fromEntries(index);
24294
+ if (info.unique) {
24295
+ unorderedListProjectionCache(ctx).referenceEntryKeysByRecord.set(
24296
+ view,
24297
+ new Set(index.keys())
24298
+ );
24299
+ } else {
24300
+ for (const bucket of index.values())
24301
+ if (Array.isArray(bucket)) referenceEntryList(bucket, ctx);
24302
+ }
24303
+ return view;
24266
24304
  }
24267
24305
  const key = evalPointer(info.keyPointer, scope, ctx);
24268
24306
  if (typeof key !== "string") {
@@ -24274,7 +24312,12 @@ function evalDeclaredListIndex(info, scope, ctx) {
24274
24312
  if (info.unique) {
24275
24313
  return typeof hit === "string" ? resolveValueIfId(hit, ctx) : null;
24276
24314
  }
24277
- return Array.isArray(hit) ? [...hit] : [];
24315
+ return referenceEntryList(Array.isArray(hit) ? [...hit] : [], ctx);
24316
+ }
24317
+ function referenceEntryList(list, ctx) {
24318
+ const indexes3 = unorderedListProjectionCache(ctx).referenceEntryIndexesByArray;
24319
+ if (!indexes3.has(list)) indexes3.set(list, new Set(list.keys()));
24320
+ return list;
24278
24321
  }
24279
24322
  function prepareCollectionCallback(callback, parentScope, ctx, isList, returnContract, onPredicateMatch) {
24280
24323
  const metrics = ctx.__collectionCallbackPreparationMetrics;
@@ -24838,7 +24881,7 @@ function evalFunction(fn, scope, ctx) {
24838
24881
  if (fn.info.reference === true) {
24839
24882
  return referenceIndexOf(c, target, ctx) !== null;
24840
24883
  }
24841
- const targetReferenceId = typeof target === "string" ? target : findKnownRowIdByValueReference(target, ctx);
24884
+ const targetReferenceId = typeof target === "string" ? null : findKnownRowIdByValueReference(target, ctx);
24842
24885
  let containsResolvedEntry = false;
24843
24886
  iterateCollection(c, ctx, (entry, _key, valueId) => {
24844
24887
  if (valueId !== null && valueId === targetReferenceId || jsEqual(entry, target)) {
@@ -24859,7 +24902,7 @@ function evalFunction(fn, scope, ctx) {
24859
24902
  const index = referenceIndexOf(collection, target, ctx);
24860
24903
  return index === null ? -1 : numberArg(index, "IndexOf index");
24861
24904
  }
24862
- const targetReferenceId = typeof target === "string" ? target : findKnownRowIdByValueReference(target, ctx);
24905
+ const targetReferenceId = typeof target === "string" ? null : findKnownRowIdByValueReference(target, ctx);
24863
24906
  let found = -1;
24864
24907
  iterateCollection(collection, ctx, (entry, key, valueId) => {
24865
24908
  if (valueId !== null && valueId === targetReferenceId || jsEqual(entry, target)) {
@@ -25123,9 +25166,27 @@ function validateClassConstructorDescriptor(info, ctx, requireEveryRequiredField
25123
25166
  `Cannot construct abstract Class '${schemaClass2.name}'.`
25124
25167
  );
25125
25168
  }
25126
- const genericSlot = ctx.__constructionGenericSlots?.toReversed().find((slot) => slot.classId === classId) ?? ctx.__storedConstructionReplaySlot;
25127
- const slotArguments = genericSlot?.classId === classId ? genericSlot.classArguments : void 0;
25128
- const typeArguments = slotArguments === void 0 ? receiverClosedTypeArguments(info.schemaClassInfo.typeArguments, ctx) : void 0;
25169
+ const typeArguments = receiverClosedTypeArguments(
25170
+ info.schemaClassInfo.typeArguments,
25171
+ ctx
25172
+ );
25173
+ const matchesSlot = (slot) => {
25174
+ if (slot.classId !== classId) return false;
25175
+ if (typeArguments === void 0) return true;
25176
+ const env = cachedInstanceEnv(classId, slot.classArguments, ctx);
25177
+ return Object.entries(typeArguments).every(([parameterId, typeInfo]) => {
25178
+ const binding = env.get(parameterId);
25179
+ if (binding?.kind !== "member") return false;
25180
+ const member = evalMemberById(ctx.vm, binding.memberId);
25181
+ return member !== null && typeInfosInvariantlyEqual(
25182
+ runtimeTypeInfoForMember(member, env, ctx, /* @__PURE__ */ new Set()),
25183
+ typeInfo
25184
+ );
25185
+ });
25186
+ };
25187
+ const genericSlot = ctx.__constructionGenericSlots?.findLast(matchesSlot);
25188
+ const replaySlot = ctx.__storedConstructionReplaySlot;
25189
+ const slotArguments = genericSlot?.classArguments ?? (replaySlot !== void 0 && matchesSlot(replaySlot) ? replaySlot.classArguments : void 0);
25129
25190
  const descriptorCache = evaluatorValueGeneration(ctx).constructorDescriptors;
25130
25191
  const descriptorCacheKey = `${requireEveryRequiredField}:${ctx.storedConstructionReplay === true}:${JSON.stringify(slotArguments ?? typeArguments ?? null)}`;
25131
25192
  const cachedDescriptor = descriptorCache.get(info)?.get(descriptorCacheKey);
@@ -26002,6 +26063,8 @@ function evaluateDeclaredConstructorArguments(info, record4, scope, ctx) {
26002
26063
  );
26003
26064
  }
26004
26065
  const value = byName.get(parameter3.name);
26066
+ if (parameter3.type === 9 /* Lookup */ && Array.isArray(value))
26067
+ return referenceEntryList(value, ctx);
26005
26068
  if (typeof value !== "number") return value;
26006
26069
  if (parameter3.type === 4 /* Float */) return Math.fround(value);
26007
26070
  if (parameter3.type !== 20 /* Decimal */) return value;
@@ -28956,14 +29019,10 @@ function collectionLength(c) {
28956
29019
  }
28957
29020
  function snapshotCollectionMembership(collection, ctx) {
28958
29021
  const membership = [];
28959
- const valid = forEachRawCollectionEntry(collection, (entry) => {
29022
+ const valid = forEachRawCollectionEntry(collection, ctx, (entry) => {
28960
29023
  membership.push({
28961
29024
  raw: entry.raw,
28962
- resolveAsReference: collectionEntryUsesReferenceResolution(
28963
- collection,
28964
- entry.key,
28965
- ctx
28966
- )
29025
+ resolveAsReference: entry.valueId !== null
28967
29026
  });
28968
29027
  return 0 /* Continue */;
28969
29028
  });
@@ -28972,7 +29031,7 @@ function snapshotCollectionMembership(collection, ctx) {
28972
29031
  "NeoScript foreach requires a present collection."
28973
29032
  );
28974
29033
  }
28975
- function forEachRawCollectionEntry(c, callback) {
29034
+ function forEachRawCollectionEntry(c, ctx, callback) {
28976
29035
  if (c instanceof RuntimeSet) {
28977
29036
  for (const [key, entry] of c.membership().entries()) {
28978
29037
  if (callback({
@@ -28984,35 +29043,34 @@ function forEachRawCollectionEntry(c, callback) {
28984
29043
  }
28985
29044
  return true;
28986
29045
  }
29046
+ if (typeof c !== "object" || c === null) return false;
29047
+ const references = collectionReferences(c, ctx);
28987
29048
  if (Array.isArray(c)) {
28988
29049
  for (let key = 0; key < c.length; key += 1) {
28989
29050
  const raw = c[key];
28990
29051
  const control = callback({
28991
29052
  raw,
28992
29053
  key,
28993
- valueId: typeof raw === "string" ? raw : null
29054
+ valueId: typeof raw === "string" && isReferenceEntry(references, key) ? raw : null
28994
29055
  });
28995
29056
  if (control === 1 /* Break */) break;
28996
29057
  }
28997
29058
  return true;
28998
29059
  }
28999
- if (typeof c === "object" && c !== null) {
29000
- for (const [key, raw] of Object.entries(c)) {
29001
- const control = callback({
29002
- raw,
29003
- key,
29004
- valueId: typeof raw === "string" ? raw : null
29005
- });
29006
- if (control === 1 /* Break */) break;
29007
- }
29008
- return true;
29060
+ for (const [key, raw] of Object.entries(c)) {
29061
+ const control = callback({
29062
+ raw,
29063
+ key,
29064
+ valueId: typeof raw === "string" && isReferenceEntry(references, key) ? raw : null
29065
+ });
29066
+ if (control === 1 /* Break */) break;
29009
29067
  }
29010
- return false;
29068
+ return true;
29011
29069
  }
29012
29070
  function collectionEntries(c, ctx) {
29013
29071
  const entries = [];
29014
- forEachRawCollectionEntry(c, ({ raw, key }) => {
29015
- entries.push(resolveCollectionEntry(c, raw, key, ctx));
29072
+ forEachRawCollectionEntry(c, ctx, ({ raw, valueId }) => {
29073
+ entries.push(valueId === null ? raw : resolveValueIfId(valueId, ctx));
29016
29074
  return 0 /* Continue */;
29017
29075
  });
29018
29076
  return entries;
@@ -29020,7 +29078,7 @@ function collectionEntries(c, ctx) {
29020
29078
  function referenceIndexOf(c, target, ctx) {
29021
29079
  const targetId = target === null || target === void 0 ? null : referenceIdOf(target, ctx);
29022
29080
  let found = null;
29023
- forEachRawCollectionEntry(c, ({ raw, key }) => {
29081
+ forEachRawCollectionEntry(c, ctx, ({ raw, key }) => {
29024
29082
  if (raw === target || targetId !== null && raw !== null && raw !== void 0 && referenceIdOf(raw, ctx) === targetId) {
29025
29083
  found = key;
29026
29084
  return 1 /* Break */;
@@ -29030,26 +29088,61 @@ function referenceIndexOf(c, target, ctx) {
29030
29088
  return found;
29031
29089
  }
29032
29090
  function iterateCollection(c, ctx, callback) {
29033
- forEachRawCollectionEntry(c, ({ raw, key, valueId }) => {
29034
- const effectiveValueId = collectionEntryUsesReferenceResolution(c, key, ctx) ? valueId : null;
29035
- return callback(
29036
- resolveCollectionEntry(c, raw, key, ctx),
29091
+ forEachRawCollectionEntry(
29092
+ c,
29093
+ ctx,
29094
+ ({ raw, key, valueId }) => callback(
29095
+ valueId === null ? raw : resolveValueIfId(valueId, ctx),
29037
29096
  key,
29038
- effectiveValueId
29039
- );
29040
- });
29097
+ valueId
29098
+ )
29099
+ );
29041
29100
  }
29042
29101
  function resolveCollectionEntry(collection, raw, key, ctx) {
29043
- return collectionEntryUsesReferenceResolution(collection, key, ctx) ? resolveValueIfId(raw, ctx) : raw;
29102
+ return typeof raw === "string" && isReferenceEntry(collectionReferences(collection, ctx), key) ? resolveValueIfId(raw, ctx) : raw;
29044
29103
  }
29045
- function collectionEntryUsesReferenceResolution(collection, key, ctx) {
29046
- if (collection instanceof RuntimeSet && typeof key === "number")
29047
- return collection.membership()[key]?.reference === true;
29048
- if (!Array.isArray(collection) || typeof key !== "number") return true;
29049
- const referenceIndexes = ctx.__unorderedListProjections?.referenceEntryIndexesByArray.get(
29050
- collection
29051
- );
29052
- return referenceIndexes === void 0 || referenceIndexes.has(key);
29104
+ function recordedReferenceEntries(collection, ctx) {
29105
+ const cache = ctx.__unorderedListProjections;
29106
+ if (Array.isArray(collection))
29107
+ return cache?.referenceEntryIndexesByArray.get(collection);
29108
+ if (typeof collection === "object" && collection !== null)
29109
+ return cache?.referenceEntryKeysByRecord.get(collection);
29110
+ return void 0;
29111
+ }
29112
+ function collectionReferences(collection, ctx) {
29113
+ return recordedReferenceEntries(collection, ctx) ?? (findKnownRowIdByValueReference(collection, ctx) === null ? 1 /* Values */ : 0 /* RowIds */);
29114
+ }
29115
+ function isReferenceEntry(references, key) {
29116
+ if (references === 0 /* RowIds */) return true;
29117
+ if (references === 1 /* Values */) return false;
29118
+ return references.has(key);
29119
+ }
29120
+ function recordWrittenEntry(collection, key, reference, ctx) {
29121
+ const references = collectionReferences(collection, ctx);
29122
+ if (typeof references !== "object") {
29123
+ if (reference === (references === 0 /* RowIds */)) return;
29124
+ const written = Array.isArray(collection) ? collection[Number(key)] : collection[String(key)];
29125
+ if (!reference && typeof written !== "string") return;
29126
+ }
29127
+ const rowIds = references === 0 /* RowIds */;
29128
+ const cache = unorderedListProjectionCache(ctx);
29129
+ if (Array.isArray(collection)) {
29130
+ let indexes3 = cache.referenceEntryIndexesByArray.get(collection);
29131
+ if (indexes3 === void 0) {
29132
+ indexes3 = new Set(rowIds ? collection.keys() : []);
29133
+ cache.referenceEntryIndexesByArray.set(collection, indexes3);
29134
+ }
29135
+ if (reference) indexes3.add(Number(key));
29136
+ else indexes3.delete(Number(key));
29137
+ return;
29138
+ }
29139
+ let keys = cache.referenceEntryKeysByRecord.get(collection);
29140
+ if (keys === void 0) {
29141
+ keys = new Set(rowIds ? Object.keys(collection) : []);
29142
+ cache.referenceEntryKeysByRecord.set(collection, keys);
29143
+ }
29144
+ if (reference) keys.add(String(key));
29145
+ else keys.delete(String(key));
29053
29146
  }
29054
29147
 
29055
29148
  // ../packages/neoscript-runtime/src/declaration-default-source.ts
@@ -32529,6 +32622,14 @@ function materializeMemberDefaultValue(args) {
32529
32622
  }
32530
32623
 
32531
32624
  // ../packages/neoscript-runtime/src/virtual-instance-graph.ts
32625
+ function isMaterializedSpine(location) {
32626
+ const stored = location?.materializedRow;
32627
+ if (stored == null || location?.parentId == null) return false;
32628
+ const virtual = location.virtualRow;
32629
+ if (!isLiteralValueContent(stored) || !isLiteralValueContent(virtual))
32630
+ return false;
32631
+ 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);
32632
+ }
32532
32633
  function buildVirtualInstanceMaterializedIndex(args) {
32533
32634
  const rowsById = new Map(
32534
32635
  (args.materializedRows ?? args.document.values).map((row) => [row.id, row])
@@ -35081,6 +35182,10 @@ function createHeadlessVirtualInstanceResolver(args) {
35081
35182
  graphByValueId.set(graph.instanceRootId, graph);
35082
35183
  };
35083
35184
  const expandRoot = (rootId, declaredMember) => {
35185
+ const containing = graphByValueId.get(rootId);
35186
+ if (containing !== void 0 && isMaterializedSpine(containing.locationsById.get(rootId))) {
35187
+ return expandRoot(containing.instanceRootId, void 0);
35188
+ }
35084
35189
  const cached = graphRowsByRootId.get(rootId);
35085
35190
  if (cached !== void 0) {
35086
35191
  const reads2 = readsByRootId.get(rootId);
@@ -35170,17 +35275,21 @@ function createHeadlessVirtualInstanceResolver(args) {
35170
35275
  recorder.recordValuePlacementRead();
35171
35276
  recorder.recordValueRead(receiverValueId);
35172
35277
  let placement = placements().get(receiverValueId) ?? null;
35278
+ const roots = [];
35173
35279
  while (placement !== null) {
35174
35280
  recorder.recordValueRead(placement.valueId);
35175
35281
  const raw = rawById.get(placement.valueId);
35176
35282
  if (raw !== void 0 && isLiteralValueContent(raw) && isStoredClassResolutionRoot(raw)) {
35177
- return expandRoot(
35178
- placement.valueId,
35179
- membersById.get(placement.memberId)
35180
- );
35283
+ roots.push(placement);
35181
35284
  }
35182
35285
  placement = placement.parentValueId === null ? null : placements().get(placement.parentValueId) ?? null;
35183
35286
  }
35287
+ let resolved = emptyRows;
35288
+ for (let index = roots.length - 1; index >= 0; index -= 1) {
35289
+ const root2 = roots[index];
35290
+ resolved = expandRoot(root2.valueId, membersById.get(root2.memberId));
35291
+ }
35292
+ if (roots.length > 0) return resolved;
35184
35293
  const root = rawById.get(receiverValueId);
35185
35294
  if (root !== void 0 && typeof root.classId === "string" && isStoredClassResolutionRoot(root)) {
35186
35295
  return expandRoot(receiverValueId, {
@@ -35215,7 +35324,7 @@ function createHeadlessVirtualInstanceResolver(args) {
35215
35324
  const known = graphByValueId.get(valueId);
35216
35325
  if (known?.instanceRootId === valueId) return known;
35217
35326
  const stored = rawById.get(valueId);
35218
- if (known !== void 0 && (stored === void 0 || !isStoredClassResolutionRoot(stored)))
35327
+ if (known !== void 0 && (stored === void 0 || !isStoredClassResolutionRoot(stored) || isMaterializedSpine(known.locationsById.get(valueId))))
35219
35328
  return known;
35220
35329
  virtualInstanceRowsForValue(valueId);
35221
35330
  return graphByValueId.get(valueId) ?? null;
@@ -43110,13 +43219,12 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
43110
43219
  const typeArguments = expression.typeArguments?.map(
43111
43220
  (argument2) => this.resolveType(argument2)
43112
43221
  );
43113
- if (typeArguments !== void 0 && typeArguments.length !== (schemaClass2.typeParameters?.length ?? 0)) {
43114
- throw new CompileError(
43115
- `Class '${schemaClass2.name}' expects ${schemaClass2.typeParameters?.length ?? 0} type argument${schemaClass2.typeParameters?.length === 1 ? "" : "s"} but got ${typeArguments.length}.`,
43222
+ if (typeArguments !== void 0) {
43223
+ assertTypeArgumentCount(
43224
+ schemaClass2,
43225
+ typeArguments.length,
43116
43226
  expression.pos
43117
43227
  );
43118
- }
43119
- if (typeArguments !== void 0) {
43120
43228
  const target = {
43121
43229
  kind: "named",
43122
43230
  typeId: schemaClass2.id,
@@ -47443,21 +47551,34 @@ function resolveNeoScriptType(type, context, project) {
47443
47551
  const declaringType = declaringTypeRef?.kind === "named" ? project.typeById.get(declaringTypeRef.typeId) : void 0;
47444
47552
  const byName = (candidate) => candidate.name === type.name;
47445
47553
  const typeParameter2 = context.typeParameters?.find(byName) ?? declaringType?.typeParameters?.find(byName);
47554
+ const written = type.typeArguments?.length ?? 0;
47446
47555
  if (typeParameter2?.type.kind === "typeParameter") {
47556
+ if (written > 0)
47557
+ throw new CompileError(
47558
+ genericParameterArgumentsMessage(type.name),
47559
+ type.pos
47560
+ );
47447
47561
  resolved = typeParameter2.type;
47448
47562
  break;
47449
47563
  }
47450
47564
  const builtin = namedPrimitive(type.name);
47565
+ const registryReference = builtin ? null : neoScriptRegistryReferenceType(type.name);
47566
+ if ((builtin || registryReference) && written > 0)
47567
+ throw new CompileError(
47568
+ typeArgumentArityMessage(type.name, 0, written),
47569
+ type.pos
47570
+ );
47451
47571
  if (builtin) {
47452
47572
  resolved = { kind: "primitive", name: builtin };
47453
47573
  break;
47454
47574
  }
47455
- const registryReference = neoScriptRegistryReferenceType(type.name);
47456
47575
  if (registryReference) {
47457
47576
  resolved = registryReference;
47458
47577
  break;
47459
47578
  }
47460
47579
  if (type.name === "NeoDelegate") {
47580
+ if (written > NEOSCRIPT_DELEGATE_MAX_PARAMETERS + 1)
47581
+ throw new CompileError(delegateArityMessage(written), type.pos);
47461
47582
  const [returnType, ...parameterTypes] = (type.typeArguments ?? []).map(
47462
47583
  (argument2) => resolveNeoScriptType(argument2, context, project)
47463
47584
  );
@@ -47475,6 +47596,7 @@ function resolveNeoScriptType(type, context, project) {
47475
47596
  renamedDialogueTypeMessage(type.name, "value") ?? `Unknown type '${type.name}'`,
47476
47597
  type.pos
47477
47598
  );
47599
+ if (written > 0) assertTypeArgumentCount(named, written, type.pos);
47478
47600
  resolved = {
47479
47601
  kind: "named",
47480
47602
  typeId: named.id,
@@ -47543,6 +47665,14 @@ function assertDirectTypeParameterArguments(target, pos, project) {
47543
47665
  const message = wrappedTypeParameterMessage(target, project);
47544
47666
  if (message !== null) throw new CompileError(message, pos);
47545
47667
  }
47668
+ function assertTypeArgumentCount(declaring, count, pos) {
47669
+ const expected = declaring.typeParameters?.length ?? 0;
47670
+ if (count === expected) return;
47671
+ throw new CompileError(
47672
+ typeArgumentArityMessage(declaring.name, expected, count),
47673
+ pos
47674
+ );
47675
+ }
47546
47676
  function assertTypeArgumentConstraints(declaring, type, pos, project) {
47547
47677
  declaring.typeParameters?.forEach((parameter3, index) => {
47548
47678
  const argument2 = type.typeArguments?.[index];
@@ -59463,7 +59593,7 @@ var INITIALIZER_KEY_PLACEHOLDER = new RegExp(
59463
59593
 
59464
59594
  // ../packages/manifest/schema-contract/registry.mjs
59465
59595
  var PROJECT_SCHEMA_CONTRACT = Object.freeze({
59466
- cliVersion: "0.81.1",
59596
+ cliVersion: "0.81.3",
59467
59597
  projectFileUploadBatchSize: 32,
59468
59598
  documentRecords: {
59469
59599
  member: {