@neocompose/cli 0.89.6 → 0.89.7

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.
@@ -19407,7 +19407,7 @@ var init_registry = __esm({
19407
19407
  "../packages/manifest/schema-contract/registry.mjs"() {
19408
19408
  "use strict";
19409
19409
  PROJECT_SCHEMA_CONTRACT = Object.freeze({
19410
- cliVersion: "0.89.6",
19410
+ cliVersion: "0.89.7",
19411
19411
  projectFileUploadBatchSize: 32,
19412
19412
  documentRecords: {
19413
19413
  member: {
@@ -38831,7 +38831,8 @@ function blankEvaluatorIndexes(memberByValueId) {
38831
38831
  return {
38832
38832
  rowByValueReference: /* @__PURE__ */ new WeakMap(),
38833
38833
  memberByValueId,
38834
- parentLinksByChildId: /* @__PURE__ */ new Map(),
38834
+ parentLinksByChildId: new EvaluatorParentLinks(),
38835
+ placementParentLinksByChildId: /* @__PURE__ */ new Map(),
38835
38836
  indexedRowIds: /* @__PURE__ */ new Set(),
38836
38837
  indexedOverlayValues: /* @__PURE__ */ new Map(),
38837
38838
  indexedOverlayRowCount: 0,
@@ -39070,8 +39071,15 @@ function evaluatorIndexes(ctx) {
39070
39071
  rowByValueReference: /* @__PURE__ */ new WeakMap(),
39071
39072
  baseRowByValueReference: base?.rowByValueReference,
39072
39073
  memberByValueId: base?.memberByValueId ?? /* @__PURE__ */ new Map(),
39073
- parentLinksByChildId: /* @__PURE__ */ new Map(),
39074
+ parentLinksByChildId: new EvaluatorParentLinks(),
39075
+ placementParentLinksByChildId: /* @__PURE__ */ new Map(),
39074
39076
  baseParentLinksByChildId: base?.parentLinksByChildId,
39077
+ isSelectionRow: (row) => {
39078
+ const member = runtimeCollectionMember(row, ctx);
39079
+ if (member === null || !isMemberLookupBase(member)) return false;
39080
+ const direct = indexes4.memberByValueId.get(row.id);
39081
+ return direct === void 0 || isMemberLookupBase(direct);
39082
+ },
39075
39083
  indexedRowIds: /* @__PURE__ */ new Set(),
39076
39084
  baseIndexedRowIds: base?.indexedRowIds,
39077
39085
  indexedOverlayValues: /* @__PURE__ */ new Map(),
@@ -39165,7 +39173,13 @@ function indexEvaluatorRow(indexes4, row, allowBaseShadow = false, sharedCachesA
39165
39173
  visitEvaluatorRecordOwnershipEdges(indexes4, row, (childId, key) => {
39166
39174
  indexes4.ownedValueAttachmentsByValueId.delete(childId);
39167
39175
  indexes4.constructorOwnershipDirtyValueIds.add(childId);
39168
- addEvaluatorParentLink(indexes4, childId, row.id, key);
39176
+ addEvaluatorParentLink(
39177
+ indexes4,
39178
+ childId,
39179
+ row.id,
39180
+ key,
39181
+ indexes4.isSelectionRow?.(row) === true
39182
+ );
39169
39183
  });
39170
39184
  }
39171
39185
  function indexEvaluatorRows(indexes4, rows, allowBaseShadow = false, liveOverlayRowById) {
@@ -39214,7 +39228,13 @@ function augmentEvaluatorOwnershipEdges(indexes4, row, liveRow) {
39214
39228
  if (links.some((link) => link.parentId === row.id && link.key === key)) {
39215
39229
  return;
39216
39230
  }
39217
- addEvaluatorParentLink(indexes4, childId, row.id, key);
39231
+ addEvaluatorParentLink(
39232
+ indexes4,
39233
+ childId,
39234
+ row.id,
39235
+ key,
39236
+ indexes4.isSelectionRow?.(row) === true
39237
+ );
39218
39238
  indexes4.ownedValueAttachmentsByValueId.delete(childId);
39219
39239
  indexes4.constructorOwnershipDirtyValueIds.add(childId);
39220
39240
  });
@@ -39260,12 +39280,11 @@ function unindexEvaluatorRow(indexes4, row, preserveIncomingLinks = false) {
39260
39280
  indexes4.indexedRowIds.delete(row.id);
39261
39281
  indexes4.ownedValueAttachmentsByValueId.delete(row.id);
39262
39282
  indexes4.constructorOwnershipDirtyValueIds.delete(row.id);
39263
- if (!preserveIncomingLinks) indexes4.parentLinksByChildId.delete(row.id);
39264
- else if (typeof row.containerId === "string") {
39265
- const retained = indexes4.parentLinksByChildId.get(row.id)?.filter((link) => link.parentId !== row.containerId || link.key !== "");
39266
- if (retained === void 0 || retained.length === 0)
39267
- indexes4.parentLinksByChildId.delete(row.id);
39268
- else indexes4.parentLinksByChildId.set(row.id, retained);
39283
+ if (!preserveIncomingLinks) {
39284
+ indexes4.parentLinksByChildId.delete(row.id);
39285
+ indexes4.placementParentLinksByChildId.delete(row.id);
39286
+ } else if (typeof row.containerId === "string") {
39287
+ removeEvaluatorParentLinks(indexes4, row.id, row.containerId, "");
39269
39288
  }
39270
39289
  if (typeof row.value === "object" && row.value !== null && indexes4.rowByValueReference.get(row.value) === row) {
39271
39290
  indexes4.rowByValueReference.delete(row.value);
@@ -39282,12 +39301,7 @@ function unindexEvaluatorRow(indexes4, row, preserveIncomingLinks = false) {
39282
39301
  }
39283
39302
  }
39284
39303
  visitEvaluatorRecordOwnershipEdges(indexes4, row, (childId) => {
39285
- const links = indexes4.parentLinksByChildId.get(childId);
39286
- if (links !== void 0) {
39287
- const retained = links.filter((link) => link.parentId !== row.id);
39288
- if (retained.length === 0) indexes4.parentLinksByChildId.delete(childId);
39289
- else indexes4.parentLinksByChildId.set(childId, retained);
39290
- }
39304
+ removeEvaluatorParentLinks(indexes4, childId, row.id);
39291
39305
  indexes4.ownedValueAttachmentsByValueId.delete(childId);
39292
39306
  indexes4.constructorOwnershipDirtyValueIds.add(childId);
39293
39307
  });
@@ -39300,36 +39314,101 @@ function dropReconciledOwnershipRows(indexes4) {
39300
39314
  indexes4.reconciledOwnershipRows = /* @__PURE__ */ new WeakSet();
39301
39315
  indexes4.indexedVirtualRowSets = /* @__PURE__ */ new WeakSet();
39302
39316
  }
39303
- function addEvaluatorParentLink(indexes4, childId, parentId, key) {
39304
- const links = indexes4.parentLinksByChildId.get(childId) ?? [];
39305
- links.push({ parentId, key });
39306
- indexes4.parentLinksByChildId.set(childId, links);
39317
+ function addEvaluatorParentLink(indexes4, childId, parentId, key, selectionOnly = false) {
39318
+ const placements = indexes4.placementParentLinksByChildId.get(childId);
39319
+ if (selectionOnly) {
39320
+ if (placements === void 0) {
39321
+ indexes4.placementParentLinksByChildId.set(childId, [
39322
+ ...indexes4.parentLinksByChildId.get(childId) ?? []
39323
+ ]);
39324
+ indexes4.parentLinksByChildId.indexParents(childId);
39325
+ }
39326
+ } else {
39327
+ placements?.push({ parentId, key });
39328
+ }
39329
+ indexes4.parentLinksByChildId.add(childId, { parentId, key });
39330
+ }
39331
+ function removeEvaluatorParentLinks(indexes4, childId, parentId, key) {
39332
+ indexes4.parentLinksByChildId.remove(childId, parentId, key);
39333
+ if (!indexes4.parentLinksByChildId.has(childId)) {
39334
+ indexes4.placementParentLinksByChildId.delete(childId);
39335
+ return;
39336
+ }
39337
+ const placements = indexes4.placementParentLinksByChildId.get(childId);
39338
+ if (placements !== void 0)
39339
+ indexes4.placementParentLinksByChildId.set(
39340
+ childId,
39341
+ placements.filter(
39342
+ (link) => link.parentId !== parentId || key !== void 0 && link.key !== key
39343
+ )
39344
+ );
39307
39345
  }
39308
- function indexRuntimeCollectionAppend(collection, entry, ctx) {
39346
+ function indexRuntimeCollectionChange(collection, entry, ctx, removedEntries = null, entryKey, change = "entry") {
39309
39347
  const indexes4 = ctx.__indexes;
39310
39348
  const row = indexes4?.rowByValueReference.get(collection);
39311
39349
  if (indexes4 === void 0 || indexes4.invalidated || row === void 0 || ctx.__runtimeSessionValues?.get(row.id) !== row || !indexes4.indexedRowIds.has(row.id))
39312
39350
  return false;
39313
- if (typeof entry === "string") {
39314
- addEvaluatorParentLink(indexes4, entry, row.id, "");
39315
- indexes4.ownedValueAttachmentsByValueId.delete(entry);
39316
- indexes4.constructorOwnershipDirtyValueIds.add(entry);
39351
+ if (removedEntries !== null)
39352
+ for (const removed of removedEntries) {
39353
+ removeEvaluatorParentLinks(indexes4, removed, row.id, entryKey);
39354
+ indexes4.ownedValueAttachmentsByValueId.delete(removed);
39355
+ indexes4.constructorOwnershipDirtyValueIds.add(removed);
39356
+ }
39357
+ const addEdge = (childId, key) => {
39358
+ addEvaluatorParentLink(
39359
+ indexes4,
39360
+ childId,
39361
+ row.id,
39362
+ key,
39363
+ indexes4.isSelectionRow?.(row) === true
39364
+ );
39365
+ indexes4.ownedValueAttachmentsByValueId.delete(childId);
39366
+ indexes4.constructorOwnershipDirtyValueIds.add(childId);
39367
+ };
39368
+ if (typeof entry === "string") addEdge(entry, entryKey ?? "");
39369
+ else if (change === "contents")
39370
+ visitEvaluatorRecordOwnershipEdges(indexes4, row, addEdge);
39371
+ if (typeof entry === "string" || removedEntries !== null && removedEntries.length > 0) {
39317
39372
  indexes4.ownershipRootIdsByRowId.clear();
39318
39373
  indexes4.ownershipDistancesByRowId.clear();
39319
39374
  indexes4.memberByRowId.clear();
39320
39375
  }
39321
- forgetLocalListIndexes(ctx, collection);
39376
+ if (Array.isArray(collection)) forgetLocalListIndexes(ctx, collection);
39322
39377
  markOverlayMutated(ctx, collection);
39323
39378
  if (ctx.__valueOverlay instanceof LazyValueOverlay)
39324
39379
  indexes4.overlayRevision = ctx.__valueOverlay.revision;
39325
39380
  return true;
39326
39381
  }
39327
- function evaluatorParentLinks(indexes4, childId) {
39382
+ function indexRuntimeCollectionEntryWrite(collection, previous, value, key, ctx) {
39383
+ if (!Array.isArray(collection))
39384
+ return indexRuntimeCollectionChange(
39385
+ collection,
39386
+ value,
39387
+ ctx,
39388
+ typeof previous === "string" ? [previous] : [],
39389
+ String(key)
39390
+ );
39391
+ if (typeof previous !== "string" && typeof value !== "string")
39392
+ return indexRuntimeCollectionChange(collection, void 0, ctx);
39393
+ const edges = collection.filter(
39394
+ (entry) => typeof entry === "string"
39395
+ );
39396
+ if (typeof previous === "string") edges.push(previous);
39397
+ return indexRuntimeCollectionChange(
39398
+ collection,
39399
+ void 0,
39400
+ ctx,
39401
+ edges,
39402
+ void 0,
39403
+ "contents"
39404
+ );
39405
+ }
39406
+ function evaluatorParentLinks(indexes4, childId, placementOnly = false) {
39328
39407
  const unfilteredBase = indexes4.baseParentLinksByChildId?.get(childId) ?? [];
39329
39408
  const base = indexes4.shadowedBaseRowIds.size === 0 ? unfilteredBase : unfilteredBase.filter(
39330
39409
  (link) => !indexes4.shadowedBaseRowIds.has(link.parentId)
39331
39410
  );
39332
- const local = indexes4.parentLinksByChildId.get(childId) ?? [];
39411
+ const local = (placementOnly ? indexes4.placementParentLinksByChildId.get(childId) : void 0) ?? indexes4.parentLinksByChildId.get(childId) ?? [];
39333
39412
  if (base.length === 0) return local;
39334
39413
  if (local.length === 0) return base;
39335
39414
  return [...base, ...local];
@@ -40252,6 +40331,7 @@ function withEvaluationRuntime(ctx, writes) {
40252
40331
  ctx.__setEntryIndexes ??= /* @__PURE__ */ new WeakMap();
40253
40332
  ctx.__runtimeSets ??= /* @__PURE__ */ new WeakMap();
40254
40333
  ctx.__collectionElementTypes ??= /* @__PURE__ */ new WeakMap();
40334
+ ctx.__runtimeCollectionMembers ??= /* @__PURE__ */ new WeakMap();
40255
40335
  ctx.__dirtyRuntimeSets ??= /* @__PURE__ */ new Set();
40256
40336
  ctx.__runtimeClassOverrides ??= /* @__PURE__ */ new Map();
40257
40337
  ctx.__getterSubscriptions ??= getterSubscriptionsFor(ctx);
@@ -40289,6 +40369,7 @@ function withEvaluationRuntime(ctx, writes) {
40289
40369
  __setEntryIndexes: ctx.__setEntryIndexes ?? /* @__PURE__ */ new WeakMap(),
40290
40370
  __runtimeSets: ctx.__runtimeSets ?? /* @__PURE__ */ new WeakMap(),
40291
40371
  __collectionElementTypes: ctx.__collectionElementTypes ?? /* @__PURE__ */ new WeakMap(),
40372
+ __runtimeCollectionMembers: ctx.__runtimeCollectionMembers ?? /* @__PURE__ */ new WeakMap(),
40292
40373
  __tupleHandleIdentity: ctx.__tupleHandleIdentity ??= new TupleHandleIdentity(),
40293
40374
  __dirtyRuntimeSets: ctx.__dirtyRuntimeSets ?? /* @__PURE__ */ new Set(),
40294
40375
  __runtimeReferenceRemap: referenceRemap,
@@ -41733,7 +41814,8 @@ function evalInstructions(instructions, scope, ctx, options) {
41733
41814
  target.pointer,
41734
41815
  scope,
41735
41816
  ctx,
41736
- destination
41817
+ destination,
41818
+ value
41737
41819
  );
41738
41820
  const through = genericSlotReference(
41739
41821
  member,
@@ -41757,7 +41839,8 @@ function evalInstructions(instructions, scope, ctx, options) {
41757
41839
  target.pointer,
41758
41840
  scope,
41759
41841
  ctx,
41760
- destination
41842
+ destination,
41843
+ value
41761
41844
  );
41762
41845
  }
41763
41846
  if (target.structuredLeafKind !== void 0 && destination !== void 0)
@@ -41774,6 +41857,11 @@ function evalInstructions(instructions, scope, ctx, options) {
41774
41857
  ctx
41775
41858
  );
41776
41859
  const lookupMember = member !== null && isMemberLookup(member) ? member : null;
41860
+ const inlineReferenceValue = lookupMember !== null && target.pointer.type === "keyOf" /* keyOf */ && target.pointer.memberId === void 0 && destination !== void 0 && materializedCollectionEntryId(
41861
+ destination.receiver,
41862
+ destination.key,
41863
+ ctx
41864
+ ) === null ? { value } : void 0;
41777
41865
  if (lookupMember !== null) {
41778
41866
  materializeReferencedSlots(value, ctx);
41779
41867
  const holder = destination === void 0 ? null : trackedRowForValueReference(destination.receiver, ctx);
@@ -41830,7 +41918,8 @@ function evalInstructions(instructions, scope, ctx, options) {
41830
41918
  value,
41831
41919
  scope,
41832
41920
  ctx,
41833
- destination
41921
+ destination,
41922
+ inlineReferenceValue
41834
41923
  );
41835
41924
  }
41836
41925
  const unorderedReplacement = assignedReferenceValueId === null && member !== null && isMemberEntryCollectionBase(member) && listKindOf(member) === 1 /* Unordered */ && Array.isArray(value) ? unorderedReplacementProjection(
@@ -42504,7 +42593,7 @@ function validateStructuredFieldAssignment(kind, field, value) {
42504
42593
  { errorClassId: NEO_ERROR_CLASS_IDS.NeoArgumentError }
42505
42594
  );
42506
42595
  }
42507
- function applyOverlayAssignment(target, targetTypeInfo, value, scope, ctx, destination) {
42596
+ function applyOverlayAssignment(target, targetTypeInfo, value, scope, ctx, destination, inlineReferenceValue) {
42508
42597
  if (target.type === "staticMember" /* staticMember */) {
42509
42598
  if (ctx.storedConstructionReplay === true) {
42510
42599
  throw new NSGetterRuntimeError(
@@ -42536,8 +42625,32 @@ function applyOverlayAssignment(target, targetTypeInfo, value, scope, ctx, desti
42536
42625
  "assignment target",
42537
42626
  reattachesReplaySlot ? void 0 : key
42538
42627
  );
42628
+ if (inlineReferenceValue !== void 0) {
42629
+ const entryId = trackInsertedCollection(
42630
+ inlineReferenceValue.value,
42631
+ targetTypeInfo,
42632
+ receiver,
42633
+ ctx
42634
+ );
42635
+ if (entryId !== null) {
42636
+ const collection = Array.isArray(receiver) ? receiver : objectArg(receiver, "Assignment target");
42637
+ const entryKey = typeof key === "number" ? key : String(key);
42638
+ Reflect.set(collection, String(entryKey), entryId);
42639
+ recordWrittenEntry(collection, entryKey, true, ctx);
42640
+ if (!indexRuntimeCollectionChange(
42641
+ collection,
42642
+ entryId,
42643
+ ctx,
42644
+ null,
42645
+ Array.isArray(collection) ? void 0 : String(entryKey)
42646
+ ))
42647
+ invalidateEvaluatorIndexes(ctx, receiver);
42648
+ return;
42649
+ }
42650
+ }
42539
42651
  if (Array.isArray(receiver)) {
42540
42652
  const index = numberArg(key, "List assignment index");
42653
+ const previous2 = receiver[index];
42541
42654
  if (referenceValueId !== null) {
42542
42655
  const parentId = findKnownRowIdByValueReference(receiver, ctx);
42543
42656
  if (parentId !== null) {
@@ -42561,10 +42674,17 @@ function applyOverlayAssignment(target, targetTypeInfo, value, scope, ctx, desti
42561
42674
  }
42562
42675
  receiver[index] = referenceValueId;
42563
42676
  recordWrittenEntry(receiver, index, true, ctx);
42564
- invalidateEvaluatorIndexes(ctx, receiver);
42677
+ if (!indexRuntimeCollectionEntryWrite(
42678
+ receiver,
42679
+ previous2,
42680
+ referenceValueId,
42681
+ index,
42682
+ ctx
42683
+ ))
42684
+ invalidateEvaluatorIndexes(ctx, receiver);
42565
42685
  return;
42566
42686
  }
42567
- if (collectionReferences(receiver, ctx) === 0 /* RowIds */ && replaceEntryRowValue(
42687
+ if (isReferenceEntry(collectionReferences(receiver, ctx), index) && replaceEntryRowValue(
42568
42688
  receiver,
42569
42689
  receiver[index],
42570
42690
  value,
@@ -42574,11 +42694,13 @@ function applyOverlayAssignment(target, targetTypeInfo, value, scope, ctx, desti
42574
42694
  return;
42575
42695
  receiver[index] = value;
42576
42696
  recordWrittenEntry(receiver, index, false, ctx);
42577
- invalidateEvaluatorIndexes(ctx, receiver);
42697
+ if (!indexRuntimeCollectionEntryWrite(receiver, previous2, value, index, ctx))
42698
+ invalidateEvaluatorIndexes(ctx, receiver);
42578
42699
  return;
42579
42700
  }
42580
42701
  const object2 = objectArg(receiver, "Assignment target");
42581
42702
  const stringKey = String(key);
42703
+ const previous = object2[stringKey];
42582
42704
  const field = target.memberId !== void 0;
42583
42705
  if (field && isTypeInfoWithEntries(targetTypeInfo)) {
42584
42706
  const slot = collectionSlotRow(target, { receiver, key }, ctx);
@@ -42611,16 +42733,25 @@ function applyOverlayAssignment(target, targetTypeInfo, value, scope, ctx, desti
42611
42733
  }
42612
42734
  object2[stringKey] = referenceValueId;
42613
42735
  if (!field) recordWrittenEntry(object2, stringKey, true, ctx);
42614
- invalidateEvaluatorIndexes(ctx, receiver);
42736
+ if (field || !indexRuntimeCollectionEntryWrite(
42737
+ object2,
42738
+ previous,
42739
+ referenceValueId,
42740
+ stringKey,
42741
+ ctx
42742
+ ))
42743
+ invalidateEvaluatorIndexes(ctx, receiver);
42615
42744
  return;
42616
42745
  }
42617
- if (collectionReferences(object2, ctx) === 0 /* RowIds */ && replaceEntryRowValue(object2, object2[stringKey], value, targetTypeInfo, ctx))
42746
+ if (isReferenceEntry(collectionReferences(object2, ctx), stringKey) && replaceEntryRowValue(object2, object2[stringKey], value, targetTypeInfo, ctx))
42618
42747
  return;
42619
42748
  if (field && (targetTypeInfo.type === 7 /* Class */ || targetTypeInfo.type === 22 /* Interface */))
42620
42749
  noteDetachedRow(object2[stringKey], value, ctx);
42621
42750
  object2[stringKey] = value;
42622
42751
  if (!field) recordWrittenEntry(object2, stringKey, false, ctx);
42623
- invalidateEvaluatorIndexes(ctx, receiver);
42752
+ const scalarField = (previous == null || typeof previous === "number" || typeof previous === "boolean" || typeof previous === "string") && (value == null || typeof value === "number" || typeof value === "boolean" || typeof value === "string");
42753
+ if (field && !scalarField || !indexRuntimeCollectionEntryWrite(object2, previous, value, stringKey, ctx))
42754
+ invalidateEvaluatorIndexes(ctx, receiver);
42624
42755
  }
42625
42756
  function keptCollectionSlotValue(target, targetTypeInfo, destination, value, ctx) {
42626
42757
  const sourceId3 = findKnownRowIdByValueReference(value, ctx);
@@ -43534,7 +43665,22 @@ function validateAssignmentTarget(target, scope, ctx, destination) {
43534
43665
  }
43535
43666
  return resolved;
43536
43667
  }
43537
- function assignmentTargetMember(target, scope, ctx, destination) {
43668
+ function materializedCollectionEntryId(receiver, key, ctx) {
43669
+ if (typeof receiver !== "object" || receiver === null) return null;
43670
+ const entryKey = typeof key === "number" ? key : String(key);
43671
+ if (!Object.prototype.hasOwnProperty.call(receiver, entryKey)) return null;
43672
+ const raw = Reflect.get(receiver, String(entryKey));
43673
+ if (typeof raw !== "string") return null;
43674
+ if (!isReferenceEntry(collectionReferences(receiver, ctx), entryKey))
43675
+ return null;
43676
+ return evalValueById(
43677
+ ctx,
43678
+ raw,
43679
+ ctx.__runtimeSessionValues,
43680
+ ctx.__valueOverlay
43681
+ ) === null ? null : raw;
43682
+ }
43683
+ function assignmentTargetMember(target, scope, ctx, destination, value) {
43538
43684
  if (target.type === "keyOf" /* keyOf */) {
43539
43685
  const receiver = destination === void 0 ? evalPointer(target.keyOf.pointer, scope, ctx) : destination.receiver;
43540
43686
  const key = destination === void 0 ? evalPointer(target.keyOf.key, scope, ctx) : destination.key;
@@ -43544,6 +43690,12 @@ function assignmentTargetMember(target, scope, ctx, destination) {
43544
43690
  ctx
43545
43691
  );
43546
43692
  if (runtimeMember2 !== null) return runtimeMember2;
43693
+ const raw = typeof receiver === "object" && receiver !== null ? Reflect.get(receiver, String(key)) : void 0;
43694
+ if (target.memberId === void 0 && typeof receiver === "object" && receiver !== null && (materializedCollectionEntryId(receiver, key, ctx) !== null || typeof raw !== "string" && findKnownRowIdByValueReference(value, ctx) !== null)) {
43695
+ const contract = storedCollectionEntryContract(receiver, ctx);
43696
+ if (contract !== null && isMemberLookupBase(contract.member))
43697
+ return { ...contract.entry, ...contract.member };
43698
+ }
43547
43699
  }
43548
43700
  if ((target.type === "keyOf" /* keyOf */ || target.type === "staticMember" /* staticMember */) && target.memberId !== void 0) {
43549
43701
  const member = evalMemberById(ctx.vm, target.memberId);
@@ -43816,14 +43968,17 @@ function evalCollectionMutationInstruction(ins, scope, ctx, options) {
43816
43968
  return;
43817
43969
  }
43818
43970
  validateCollectionMutation(targetValue, ins.mutation, args);
43971
+ let insertedReferenceRowId = null;
43819
43972
  if (!isLookupSet && entryArgumentIndex !== null && (ins.mutation === "Add" /* Add */ || ins.mutation === "Insert" /* Insert */) && findKnownRowIdByValueReference(targetValue, ctx) !== null)
43820
- trackInsertedCollection(
43973
+ insertedReferenceRowId = trackInsertedCollection(
43821
43974
  args[entryArgumentIndex],
43822
43975
  collectionEntryWriteType(ins.target.typeInfo, targetValue, ctx),
43823
43976
  targetValue,
43824
43977
  ctx
43825
43978
  );
43826
43979
  const overlayArgs = [...args];
43980
+ let removedReferenceRowId = null;
43981
+ let referenceRemoval = false;
43827
43982
  if ((ins.mutation === "Add" /* Add */ || ins.mutation === "Remove" /* Remove */) && isArrayCollection(targetValue)) {
43828
43983
  if (setMatch !== null) overlayArgs[0] = setMatch.entry;
43829
43984
  else if (isLookupSet)
@@ -43839,12 +43994,32 @@ function evalCollectionMutationInstruction(ins, scope, ctx, options) {
43839
43994
  } else if (ins.mutation === "Add" /* Add */ && !isArrayCollection(targetValue)) {
43840
43995
  overlayArgs[1] = findKnownRowIdByValueReference(args[1], ctx) ?? args[1];
43841
43996
  }
43997
+ if (ins.mutation === "Remove" /* Remove */ && Array.isArray(targetValue) && !isLookupSet && setEntryMember === null) {
43998
+ const contract = storedCollectionEntryContract(targetValue, ctx);
43999
+ if (contract !== null && isMemberLookupBase(contract.member)) {
44000
+ referenceRemoval = isMultiSelectionMember(contract.member) !== true;
44001
+ const references = collectionReferences(targetValue, ctx);
44002
+ const index = targetValue.findIndex(
44003
+ (entry, index2) => referenceEqual(
44004
+ isReferenceEntry(references, index2) ? resolveValueIfId(entry, ctx) : entry,
44005
+ args[0],
44006
+ ctx
44007
+ )
44008
+ );
44009
+ if (index >= 0 && typeof targetValue[index] === "string") {
44010
+ removedReferenceRowId = targetValue[index];
44011
+ overlayArgs[0] = removedReferenceRowId;
44012
+ }
44013
+ }
44014
+ }
44015
+ if (insertedReferenceRowId !== null && entryArgumentIndex !== null)
44016
+ overlayArgs[entryArgumentIndex] = insertedReferenceRowId;
43842
44017
  const unorderedEntriesBeforeMutation = unorderedContainerValueId === null || !Array.isArray(targetValue) || ins.mutation === "Add" /* Add */ ? null : [...targetValue];
43843
44018
  const writesEntry = (ins.mutation === "Add" /* Add */ || ins.mutation === "Insert" /* Insert */) && !isLookupSet;
43844
44019
  let attachedValueId = null;
43845
44020
  if (writesEntry) {
43846
44021
  const attachedValue = isArrayCollection(targetValue) && ins.mutation !== "Insert" /* Insert */ ? args[0] : args[1];
43847
- attachedValueId = findKnownRowIdByValueReference(attachedValue, ctx);
44022
+ attachedValueId = insertedReferenceRowId ?? findKnownRowIdByValueReference(attachedValue, ctx);
43848
44023
  const parentId = findKnownRowIdByValueReference(targetValue, ctx);
43849
44024
  if (attachedValueId !== null && parentId !== null) {
43850
44025
  assertInterfaceWriteAdmits(
@@ -43873,14 +44048,51 @@ function evalCollectionMutationInstruction(ins, scope, ctx, options) {
43873
44048
  );
43874
44049
  }
43875
44050
  }
43876
- if (ins.mutation === "Add" /* Add */ && isArrayCollection(targetValue) && unorderedContainerValueId !== null && !isLookupSet && findKnownRowIdByValueReference(args[0], ctx) === null) {
44051
+ if (ins.mutation === "Add" /* Add */ && isArrayCollection(targetValue) && unorderedContainerValueId !== null && !isLookupSet && insertedReferenceRowId === null && findKnownRowIdByValueReference(args[0], ctx) === null) {
43877
44052
  overlayArgs[0] = createUnorderedScalarProjectionEntry(
43878
44053
  unorderedContainerValueId,
43879
44054
  args[0] instanceof NSSlotReference ? [args[0].targetId] : args[0],
43880
44055
  ctx
43881
44056
  );
43882
44057
  }
43883
- const removableRowIds = isLookupSet || ins.reference === true ? null : removableEntryRowIds(targetValue, ins.mutation, overlayArgs, ctx);
44058
+ const removableRowIds = isLookupSet ? null : removableEntryRowIds(targetValue, ins.mutation, overlayArgs, ctx);
44059
+ let previousEdges = null;
44060
+ if (ins.mutation !== "Add" /* Add */ && ins.mutation !== "Insert" /* Insert */) {
44061
+ const contents = targetValue instanceof RuntimeSet ? targetValue.source : targetValue;
44062
+ const entries = Array.isArray(contents) ? contents : Object.values(objectArg(contents, "collection mutation target"));
44063
+ previousEdges = entries.filter(
44064
+ (entry) => typeof entry === "string"
44065
+ );
44066
+ }
44067
+ const removedMembers = removableRowIds === null ? null : /* @__PURE__ */ new Map();
44068
+ for (const [, id2] of removableRowIds ?? []) {
44069
+ if (ins.mutation === "Remove" /* Remove */ && Array.isArray(targetValue) && id2 !== overlayArgs[0])
44070
+ continue;
44071
+ const row = evalValueById(
44072
+ ctx,
44073
+ id2,
44074
+ ctx.__runtimeSessionValues,
44075
+ ctx.__valueOverlay
44076
+ );
44077
+ if (row === null) continue;
44078
+ const placed = memberForValueRow(row, ctx);
44079
+ if (placed === null) continue;
44080
+ const member = {
44081
+ ...placed,
44082
+ ...substituteMember(placed, rowGenericEnv(row, ctx), ctx.vm.members)
44083
+ };
44084
+ if (isMemberEntryCollectionBase(member) || isMemberDictionaryBase(member))
44085
+ removedMembers?.set(id2, {
44086
+ row,
44087
+ contract: {
44088
+ member,
44089
+ members: ctx.vm.members,
44090
+ classes: ctx.vm.classes,
44091
+ bindings: row.genericBindings === void 0 ? void 0 : { ...row.genericBindings }
44092
+ }
44093
+ });
44094
+ }
44095
+ const replacedEntry = writesEntry && dictionary && isPlainRecord(targetValue) ? Reflect.get(targetValue, String(args[0])) : null;
43884
44096
  const previousSetSize = targetValue instanceof RuntimeSet ? targetValue.size : null;
43885
44097
  const removedIndex = applyLocalCollectionMutation(
43886
44098
  targetValue,
@@ -43889,7 +44101,7 @@ function evalCollectionMutationInstruction(ins, scope, ctx, options) {
43889
44101
  ctx,
43890
44102
  isLookupSet,
43891
44103
  ins.reference !== true && ins.mutation === "Remove" /* Remove */ && isArrayCollection(targetValue) && setEntryMember === null && !isLookupSet && findKnownRowIdByValueReference(args[0], ctx) === null,
43892
- ins.reference === true,
44104
+ ins.reference === true || referenceRemoval || removedReferenceRowId !== null,
43893
44105
  setEntryMember === null && decimalEntries
43894
44106
  );
43895
44107
  updateCollectionReferenceProvenance(
@@ -43901,8 +44113,12 @@ function evalCollectionMutationInstruction(ins, scope, ctx, options) {
43901
44113
  if (removableRowIds !== null) {
43902
44114
  const key = Array.isArray(targetValue) ? removedIndex : String(args[0]);
43903
44115
  for (const [entryKey, rowId] of removableRowIds) {
43904
- if (ins.mutation === "Clear" /* Clear */ || entryKey === key)
44116
+ if (ins.mutation === "Clear" /* Clear */ || entryKey === key) {
43905
44117
  noteDetachedRow(rowId, null, ctx);
44118
+ const known = removedMembers?.get(rowId);
44119
+ if (known !== void 0)
44120
+ ctx.__runtimeCollectionMembers?.set(known.row, known.contract);
44121
+ }
43906
44122
  }
43907
44123
  }
43908
44124
  if (writesEntry && !(targetValue instanceof RuntimeSet)) {
@@ -43964,7 +44180,7 @@ function evalCollectionMutationInstruction(ins, scope, ctx, options) {
43964
44180
  targetValue.reference,
43965
44181
  ctx
43966
44182
  );
43967
- indexedAppend = indexRuntimeCollectionAppend(
44183
+ indexedAppend = indexRuntimeCollectionChange(
43968
44184
  targetValue.source,
43969
44185
  overlayArgs[0],
43970
44186
  ctx
@@ -43974,6 +44190,34 @@ function evalCollectionMutationInstruction(ins, scope, ctx, options) {
43974
44190
  exportRuntimeSetValue(targetValue, ctx);
43975
44191
  }
43976
44192
  }
44193
+ if (writesEntry && !(targetValue instanceof RuntimeSet)) {
44194
+ if (Array.isArray(targetValue))
44195
+ indexedAppend = indexRuntimeCollectionChange(
44196
+ targetValue,
44197
+ ins.mutation === "Insert" /* Insert */ ? overlayArgs[1] : overlayArgs[0],
44198
+ ctx
44199
+ );
44200
+ else if (dictionary && isPlainRecord(targetValue))
44201
+ indexedAppend = indexRuntimeCollectionChange(
44202
+ targetValue,
44203
+ overlayArgs[1],
44204
+ ctx,
44205
+ typeof replacedEntry === "string" ? [replacedEntry] : [],
44206
+ String(args[0])
44207
+ );
44208
+ }
44209
+ if (previousEdges !== null) {
44210
+ const collection = targetValue instanceof RuntimeSet ? targetValue.source : targetValue;
44211
+ if (Array.isArray(collection) || isPlainRecord(collection))
44212
+ indexedAppend = indexRuntimeCollectionChange(
44213
+ collection,
44214
+ void 0,
44215
+ ctx,
44216
+ previousEdges,
44217
+ void 0,
44218
+ "contents"
44219
+ );
44220
+ }
43977
44221
  if (!indexedAppend) invalidateEvaluatorIndexes(ctx, targetValue);
43978
44222
  switch (ins.mutation) {
43979
44223
  case "Insert" /* Insert */:
@@ -43982,7 +44226,7 @@ function evalCollectionMutationInstruction(ins, scope, ctx, options) {
43982
44226
  target: ins.target,
43983
44227
  index: numberArg(args[0], "Insert index"),
43984
44228
  value: args[1],
43985
- valueId: findKnownRowIdByValueReference(args[1], ctx) ?? void 0,
44229
+ valueId: insertedReferenceRowId ?? findKnownRowIdByValueReference(args[1], ctx) ?? void 0,
43986
44230
  ...resolvedDestinationFieldsForContainer(targetValue, ctx)
43987
44231
  });
43988
44232
  return;
@@ -43993,7 +44237,7 @@ function evalCollectionMutationInstruction(ins, scope, ctx, options) {
43993
44237
  target: ins.target,
43994
44238
  value: isLookupSet ? overlayArgs[0] : args[0],
43995
44239
  ...!isLookupSet ? {
43996
- valueId: unorderedContainerValueId !== null && typeof overlayArgs[0] === "string" ? overlayArgs[0] : findKnownRowIdByValueReference(args[0], ctx) ?? void 0
44240
+ valueId: insertedReferenceRowId ?? (unorderedContainerValueId !== null && typeof overlayArgs[0] === "string" ? overlayArgs[0] : findKnownRowIdByValueReference(args[0], ctx) ?? void 0)
43997
44241
  } : {},
43998
44242
  ...resolvedDestinationFieldsForContainer(targetValue, ctx)
43999
44243
  });
@@ -44004,7 +44248,7 @@ function evalCollectionMutationInstruction(ins, scope, ctx, options) {
44004
44248
  target: ins.target,
44005
44249
  key: String(args[0]),
44006
44250
  value: args[1],
44007
- valueId: findKnownRowIdByValueReference(args[1], ctx) ?? void 0,
44251
+ valueId: insertedReferenceRowId ?? findKnownRowIdByValueReference(args[1], ctx) ?? void 0,
44008
44252
  ...resolvedDestinationFieldsForContainer(targetValue, ctx)
44009
44253
  });
44010
44254
  return;
@@ -44015,7 +44259,7 @@ function evalCollectionMutationInstruction(ins, scope, ctx, options) {
44015
44259
  target: ins.target,
44016
44260
  value: isLookupSet ? overlayArgs[0] : args[0],
44017
44261
  ...!isLookupSet ? {
44018
- valueId: setMatch?.valueId ?? findKnownRowIdByValueReference(args[0], ctx) ?? void 0
44262
+ valueId: removedReferenceRowId ?? setMatch?.valueId ?? findKnownRowIdByValueReference(args[0], ctx) ?? void 0
44019
44263
  } : {},
44020
44264
  ...resolvedDestinationFieldsForContainer(targetValue, ctx)
44021
44265
  });
@@ -44111,7 +44355,15 @@ function sortCollectionInPlace(ins, value, scope, ctx, options) {
44111
44355
  references
44112
44356
  );
44113
44357
  forgetLocalListIndexes(ctx, list);
44114
- invalidateEvaluatorIndexes(ctx, list);
44358
+ if (!indexRuntimeCollectionChange(
44359
+ list,
44360
+ void 0,
44361
+ ctx,
44362
+ list.filter((entry) => typeof entry === "string"),
44363
+ void 0,
44364
+ "contents"
44365
+ ))
44366
+ invalidateEvaluatorIndexes(ctx, list);
44115
44367
  if (id2 !== null)
44116
44368
  options.writes.push({
44117
44369
  kind: "reorder",
@@ -44120,18 +44372,36 @@ function sortCollectionInPlace(ins, value, scope, ctx, options) {
44120
44372
  ...resolvedDestinationFieldsForContainer(list, ctx)
44121
44373
  });
44122
44374
  }
44123
- function trackInsertedCollection(value, type2, parentValue, ctx) {
44124
- if (!isTypeInfoWithEntries(type2) && type2.type !== 9 /* Lookup */ || value === null || typeof value !== "object" || findKnownRowIdByValueReference(value, ctx) !== null)
44125
- return;
44126
- const parent = trackedRowForValueReference(parentValue, ctx);
44375
+ function storedCollectionEntryContract(collection, ctx) {
44376
+ const parent = trackedRowForValueReference(collection, ctx);
44127
44377
  const placement = parent === null ? null : memberForValueRow(parent, ctx);
44128
- if (parent === null || placement === null) return;
44378
+ if (parent === null || placement === null) return null;
44129
44379
  const genericEnv = rowGenericEnv(parent, ctx);
44130
44380
  const parentMember = substituteMember(placement, genericEnv, ctx.vm.members);
44131
- if (!isMemberWithEntries(parentMember)) return;
44381
+ if (!isMemberWithEntries(parentMember)) return null;
44132
44382
  const entry = evalMemberById(ctx.vm, parentMember.entryMemberId);
44133
- if (entry === null) return;
44134
- const member = substituteMember(entry, genericEnv, ctx.vm.members);
44383
+ if (entry === null) return null;
44384
+ return {
44385
+ entry,
44386
+ member: substituteMember(entry, genericEnv, ctx.vm.members),
44387
+ genericEnv
44388
+ };
44389
+ }
44390
+ function trackInsertedCollection(value, type2, parentValue, ctx) {
44391
+ if (value !== null && typeof value !== "object" && type2.type !== 9 /* Lookup */)
44392
+ return null;
44393
+ const contract = storedCollectionEntryContract(parentValue, ctx);
44394
+ if (contract === null) return null;
44395
+ const { entry, member, genericEnv } = contract;
44396
+ const referenceEntry = isMemberLookupBase(member);
44397
+ if (referenceEntry && isMultiSelectionMember(member) !== true) {
44398
+ const target = lookupTargetTypeInfo(member, null, ctx);
44399
+ const localCollection = target.type === 6 /* List */ && Array.isArray(value) || (target.type === 28 /* Set */ || target.type === 9 /* Lookup */) && value instanceof RuntimeSet || target.type === 5 /* Dictionary */ && isPlainRecord(value);
44400
+ if (localCollection && findKnownRowIdByValueReference(value, ctx) === null)
44401
+ return null;
44402
+ }
44403
+ if (!referenceEntry && (!isTypeInfoWithEntries(type2) && type2.type !== 9 /* Lookup */ || value === null || typeof value !== "object" || findKnownRowIdByValueReference(value, ctx) !== null))
44404
+ return null;
44135
44405
  const createdValues = [];
44136
44406
  const collectionAliases = /* @__PURE__ */ new Map();
44137
44407
  const reservations = /* @__PURE__ */ new Map();
@@ -44146,13 +44416,21 @@ function trackInsertedCollection(value, type2, parentValue, ctx) {
44146
44416
  storageKeyDeclarations: /* @__PURE__ */ new Map(),
44147
44417
  collectionEntriesAreReferences: false,
44148
44418
  collectionAliases,
44149
- attachmentReservations: reservations
44419
+ attachmentReservations: reservations,
44420
+ insertedCollections: /* @__PURE__ */ new Set()
44150
44421
  });
44151
44422
  row.genericBindings = computeGenericBindingsStamp(
44152
44423
  entry,
44153
44424
  genericEnv,
44154
44425
  ctx.vm.members
44155
44426
  );
44427
+ if (referenceEntry)
44428
+ ctx.__runtimeCollectionMembers?.set(row, {
44429
+ member: { ...entry, ...member },
44430
+ members: ctx.vm.members,
44431
+ classes: ctx.vm.classes,
44432
+ bindings: row.genericBindings === void 0 ? void 0 : { ...row.genericBindings }
44433
+ });
44156
44434
  for (const [encoded, alias] of collectionAliases) {
44157
44435
  retainEncodedCollectionAlias(encoded, alias, ctx);
44158
44436
  }
@@ -44160,6 +44438,7 @@ function trackInsertedCollection(value, type2, parentValue, ctx) {
44160
44438
  registerRuntimeSessionValue(ctx, created);
44161
44439
  if (ctx.__indexes !== void 0)
44162
44440
  indexEvaluatorRows(ctx.__indexes, createdValues);
44441
+ return referenceEntry ? row.id : null;
44163
44442
  } catch (error) {
44164
44443
  for (const created of createdValues)
44165
44444
  ctx.__executionState?.constructorGroupDependencies.delete(created.id);
@@ -44230,7 +44509,7 @@ function storedSetEntryMember(collection, ctx) {
44230
44509
  }
44231
44510
  return substituteMember(
44232
44511
  entry,
44233
- runtimeGenericEnvForValueRow(container, ctx),
44512
+ rowGenericEnv(container, ctx),
44234
44513
  ctx.vm.members
44235
44514
  );
44236
44515
  }
@@ -46345,7 +46624,11 @@ function runtimeParentGenericEnv(row, ctx, visited, readRow) {
46345
46624
  ctx.onUnattributableValueRead?.(
46346
46625
  ownershipChainRead("generic-parent-resolution", row.id)
46347
46626
  );
46348
- for (const link of evaluatorParentLinks(evaluatorIndexes(ctx), row.id)) {
46627
+ for (const link of evaluatorParentLinks(
46628
+ evaluatorIndexes(ctx),
46629
+ row.id,
46630
+ true
46631
+ )) {
46349
46632
  const parent = readRow === void 0 ? evalValueById(
46350
46633
  ctx,
46351
46634
  link.parentId,
@@ -47476,7 +47759,11 @@ function resolveValueIfId(at3, ctx) {
47476
47759
  ctx.__valueOverlay
47477
47760
  );
47478
47761
  if (!row) return at3;
47479
- const member = memberForValueRow(row, ctx);
47762
+ const placed = memberForValueRow(row, ctx);
47763
+ const member = placed?.kind === 21 /* Generic */ ? {
47764
+ ...placed,
47765
+ ...substituteMember(placed, rowGenericEnv(row, ctx), ctx.vm.members)
47766
+ } : placed;
47480
47767
  if (member !== null && isMemberEntryCollectionBase(member) && listKindOf(member) === 1 /* Unordered */ && Array.isArray(row.value)) {
47481
47768
  return evaluatorUnorderedListEntryIds(row.id, ctx);
47482
47769
  }
@@ -47815,7 +48102,25 @@ function resolveMemberForValueRow(row, ctx, visited) {
47815
48102
  const member = memberForCustomSchemaValue(classId, link.key, ctx);
47816
48103
  if (member !== null) return member;
47817
48104
  }
47818
- return null;
48105
+ return runtimeCollectionMember(row, ctx);
48106
+ }
48107
+ function runtimeCollectionMember(row, ctx) {
48108
+ const known = ctx.__runtimeCollectionMembers?.get(row);
48109
+ if (known === void 0) return null;
48110
+ if (known.members !== ctx.vm.members || known.classes !== ctx.vm.classes)
48111
+ return null;
48112
+ const bindings = row.genericBindings;
48113
+ if (Object.keys(bindings ?? {}).length !== Object.keys(known.bindings ?? {}).length)
48114
+ return null;
48115
+ for (const [id2, memberId] of Object.entries(known.bindings ?? {}))
48116
+ if (bindings?.[id2] !== memberId) return null;
48117
+ if (row.value !== null) {
48118
+ if ((isMemberEntryCollectionBase(known.member) || isMemberLookupBase(known.member)) && !Array.isArray(row.value))
48119
+ return null;
48120
+ if (isMemberDictionaryBase(known.member) && !isPlainRecord(row.value))
48121
+ return null;
48122
+ }
48123
+ return known.member;
47819
48124
  }
47820
48125
  function* evaluatorParentEdges(row, ctx, indexes4) {
47821
48126
  const cache = ctx.__unorderedListProjections;
@@ -47824,7 +48129,7 @@ function* evaluatorParentEdges(row, ctx, indexes4) {
47824
48129
  yield { parentId: writtenParentId, key: "" };
47825
48130
  }
47826
48131
  const written = cache?.writtenContainerIds;
47827
- for (const link of indexes4.parentLinksByChildId.get(row.id) ?? []) {
48132
+ for (const link of indexes4.placementParentLinksByChildId.get(row.id) ?? indexes4.parentLinksByChildId.get(row.id) ?? []) {
47828
48133
  if (written?.has(link.parentId) !== true) yield link;
47829
48134
  }
47830
48135
  const database = ctx.vm.databaseVM;
@@ -53262,7 +53567,7 @@ function currentOwnedValueAttachments(valueId, ctx, parentEntries, placingMember
53262
53567
  ownershipChainRead("owned-value-parents", valueId)
53263
53568
  );
53264
53569
  const parentIds = new Set(
53265
- evaluatorParentLinks(indexes4, valueId).map((link) => link.parentId)
53570
+ evaluatorParentLinks(indexes4, valueId, true).map((link) => link.parentId)
53266
53571
  );
53267
53572
  for (const parentId of parentIds) {
53268
53573
  const parent = evalValueById(
@@ -53672,6 +53977,35 @@ function materializeConstructorArgumentValue(args) {
53672
53977
  args.destinationName ?? args.member.name,
53673
53978
  args.ctx
53674
53979
  );
53980
+ if (args.insertedCollections !== void 0 && (isMemberEntryCollectionBase(args.member) || isMemberDictionaryBase(args.member)) && typeof args.value === "object" && args.value !== null) {
53981
+ const tracked = trackedRowForValueReference(args.value, args.ctx);
53982
+ if (tracked !== null) {
53983
+ if (args.owner === void 0)
53984
+ throw new NSGetterRuntimeError(
53985
+ "Inserted collection has no destination."
53986
+ );
53987
+ if (!args.attachmentReservations?.has(tracked.id))
53988
+ args.attachmentReservations?.set(
53989
+ tracked.id,
53990
+ args.ctx.__executionState?.ownedValueAttachments.get(tracked.id)
53991
+ );
53992
+ assertOwnedValueAttachable(
53993
+ tracked.id,
53994
+ args.owner,
53995
+ args.destinationName ?? args.member.name,
53996
+ args.ctx,
53997
+ true,
53998
+ "insert"
53999
+ );
54000
+ return tracked;
54001
+ }
54002
+ const identity3 = args.value instanceof RuntimeSet ? args.value.source : args.value;
54003
+ if (args.insertedCollections.has(identity3))
54004
+ throw new NSGetterRuntimeError(
54005
+ "Inserted collection graph contains a duplicate owned collection. Call Clone() explicitly."
54006
+ );
54007
+ args.insertedCollections.add(identity3);
54008
+ }
53675
54009
  const collectionAlias = args.value;
53676
54010
  if (args.value instanceof RuntimeSet)
53677
54011
  args = {
@@ -53722,7 +54056,7 @@ function materializeConstructorArgumentValue(args) {
53722
54056
  args.ctx
53723
54057
  )
53724
54058
  );
53725
- if (collectionAlias instanceof RuntimeSet)
54059
+ if (collectionAlias instanceof RuntimeSet && isMultiSelectionMember(args.member) === true)
53726
54060
  args.collectionAliases?.set(row, collectionAlias);
53727
54061
  return row;
53728
54062
  }
@@ -54894,7 +55228,7 @@ function validateRangeBound(value, name) {
54894
55228
  if (typeof value !== "number" || !Number.isSafeInteger(value))
54895
55229
  throw new NSGetterRuntimeError(`Range ${name} must be a safe int.`);
54896
55230
  }
54897
- var DELEGATE_LEXICAL_THIS, DELEGATE_LEXICAL_ROOT, DELEGATE_LEXICAL_TYPE_ARGUMENTS, NonCatchableNSGetterRuntimeError, NativeFunctionDelegateUnavailableError, CorruptNeoScriptIRError, NeoScriptWallClockTimeoutError, liveListIndexesByProject, evaluatorOwnershipCachesByBase, MAX_CONSTRUCTION_DEPTH, resolutionCacheByMembers, NO_SCHEMA_REVISION, NO_INTERFACES, LazyValueOverlay, READONLY_FOREACH_BINDING_ERROR, READONLY_CATCH_BINDING_ERROR, DIALOGUE_CONTEXT_PARAMETER_ID, validatedExecutionBodies, validatedGeneratorSchemas, STRING_TYPE_INFO, INT_TYPE_INFO, STORE_LIFETIME, STORE_NAMES, FORWARDING_TYPE_ARGUMENTS, constantDeclarationRoots, UNKNOWN_LOOKUP_TARGET, MAX_AREA_DEPTH, getAreaNative, SYSTEM_NATIVE_HANDLERS, NS_MATH_OP_NAMES, DOUBLE_INTEGRAL_MAGNITUDE, orderedQueryResults, EMPTY_SUPPLIED_CONSTRUCTOR_FIELDS, variantResolutionCopiesByOverlay, NO_BOUND_MEMBERS, NO_GENERIC_ENV, RuntimeSequenceCursor, RuntimeSequence, RuntimeRange, RangeSequenceCursor, RuntimeGeneratorSequence, GeneratorSequenceCursor, CollectionSequenceCursor, sequenceProtocolPointers;
55231
+ var DELEGATE_LEXICAL_THIS, DELEGATE_LEXICAL_ROOT, DELEGATE_LEXICAL_TYPE_ARGUMENTS, NonCatchableNSGetterRuntimeError, NativeFunctionDelegateUnavailableError, CorruptNeoScriptIRError, NeoScriptWallClockTimeoutError, liveListIndexesByProject, EvaluatorParentLinks, evaluatorOwnershipCachesByBase, MAX_CONSTRUCTION_DEPTH, resolutionCacheByMembers, NO_SCHEMA_REVISION, NO_INTERFACES, LazyValueOverlay, READONLY_FOREACH_BINDING_ERROR, READONLY_CATCH_BINDING_ERROR, DIALOGUE_CONTEXT_PARAMETER_ID, validatedExecutionBodies, validatedGeneratorSchemas, STRING_TYPE_INFO, INT_TYPE_INFO, STORE_LIFETIME, STORE_NAMES, FORWARDING_TYPE_ARGUMENTS, constantDeclarationRoots, UNKNOWN_LOOKUP_TARGET, MAX_AREA_DEPTH, getAreaNative, SYSTEM_NATIVE_HANDLERS, NS_MATH_OP_NAMES, DOUBLE_INTEGRAL_MAGNITUDE, orderedQueryResults, EMPTY_SUPPLIED_CONSTRUCTOR_FIELDS, variantResolutionCopiesByOverlay, NO_BOUND_MEMBERS, NO_GENERIC_ENV, RuntimeSequenceCursor, RuntimeSequence, RuntimeRange, RangeSequenceCursor, RuntimeGeneratorSequence, GeneratorSequenceCursor, CollectionSequenceCursor, sequenceProtocolPointers;
54898
55232
  var init_evaluateNSGetter = __esm({
54899
55233
  "../packages/neoscript-runtime/src/neoscript/evaluateNSGetter.ts"() {
54900
55234
  "use strict";
@@ -54993,6 +55327,69 @@ var init_evaluateNSGetter = __esm({
54993
55327
  }
54994
55328
  };
54995
55329
  liveListIndexesByProject = /* @__PURE__ */ new WeakMap();
55330
+ EvaluatorParentLinks = class {
55331
+ ordinary = /* @__PURE__ */ new Map();
55332
+ buckets = /* @__PURE__ */ new Map();
55333
+ /** Only shared selection targets need direct parent removal. */
55334
+ indexParents(childId) {
55335
+ if (this.buckets.has(childId)) return;
55336
+ const links = this.ordinary.get(childId) ?? [];
55337
+ this.ordinary.delete(childId);
55338
+ this.buckets.set(childId, { links: /* @__PURE__ */ new Set(), byParent: /* @__PURE__ */ new Map() });
55339
+ for (const link of links) this.add(childId, link);
55340
+ }
55341
+ get(childId) {
55342
+ const bucket = this.buckets.get(childId);
55343
+ if (bucket === void 0) return this.ordinary.get(childId);
55344
+ return bucket.snapshot ??= [...bucket.links];
55345
+ }
55346
+ has(childId) {
55347
+ return this.buckets.has(childId) || this.ordinary.has(childId);
55348
+ }
55349
+ add(childId, link) {
55350
+ const bucket = this.buckets.get(childId);
55351
+ if (bucket === void 0) {
55352
+ const links = this.ordinary.get(childId) ?? [];
55353
+ links.push(link);
55354
+ this.ordinary.set(childId, links);
55355
+ return;
55356
+ }
55357
+ bucket.links.add(link);
55358
+ let parent = bucket.byParent.get(link.parentId);
55359
+ if (parent === void 0) {
55360
+ parent = /* @__PURE__ */ new Set();
55361
+ bucket.byParent.set(link.parentId, parent);
55362
+ }
55363
+ parent.add(link);
55364
+ bucket.snapshot = void 0;
55365
+ }
55366
+ remove(childId, parentId, key) {
55367
+ const bucket = this.buckets.get(childId);
55368
+ if (bucket === void 0) {
55369
+ const links = this.ordinary.get(childId)?.filter(
55370
+ (link) => link.parentId !== parentId || key !== void 0 && link.key !== key
55371
+ );
55372
+ if (links === void 0 || links.length === 0)
55373
+ this.ordinary.delete(childId);
55374
+ else this.ordinary.set(childId, links);
55375
+ return;
55376
+ }
55377
+ const parent = bucket.byParent.get(parentId);
55378
+ if (parent === void 0) return;
55379
+ for (const link of parent) {
55380
+ if (key !== void 0 && link.key !== key) continue;
55381
+ bucket.links.delete(link);
55382
+ parent.delete(link);
55383
+ bucket.snapshot = void 0;
55384
+ }
55385
+ if (parent.size === 0) bucket.byParent.delete(parentId);
55386
+ if (bucket.links.size === 0) this.buckets.delete(childId);
55387
+ }
55388
+ delete(childId) {
55389
+ this.ordinary.delete(childId);
55390
+ this.buckets.delete(childId);
55391
+ }
55392
+ };
54996
55393
  evaluatorOwnershipCachesByBase = /* @__PURE__ */ new WeakMap();
54997
55394
  MAX_CONSTRUCTION_DEPTH = 64;
54998
55395
  resolutionCacheByMembers = /* @__PURE__ */ new WeakMap();
@@ -141733,8 +142130,8 @@ var init_project_commit_preparation_scoped_loader = __esm({
141733
142130
  // ../src/database/compiled-construction-types.ts
141734
142131
  function compiledConstructionTypeMembers(members2, bodies, projectId) {
141735
142132
  const created = [];
141736
- const createdKeys = [];
141737
- let existingIds;
142133
+ const processedKeys = [];
142134
+ let existingMembers;
141738
142135
  const byType = /* @__PURE__ */ new Map();
141739
142136
  const key = (type2) => canonicalJsonStringify(type2);
141740
142137
  const intern = (type2, slot) => {
@@ -141747,21 +142144,21 @@ function compiledConstructionTypeMembers(members2, bodies, projectId) {
141747
142144
  `neo:compiled-construction-type:${projectId}:${cacheKey}`,
141748
142145
  v5_default.URL
141749
142146
  );
141750
- existingIds ??= new Set(members2.map((member) => member.id));
141751
- if (existingIds.has(id2)) {
141752
- byType.set(cacheKey, id2);
141753
- return id2;
141754
- }
142147
+ existingMembers ??= new Map(members2.map((member) => [member.id, member]));
142148
+ const storedMember = existingMembers.get(id2);
142149
+ const alreadyStored = storedMember !== void 0;
141755
142150
  const common = {
141756
142151
  id: id2,
141757
142152
  projectId,
141758
142153
  createdAt: 0,
141759
142154
  updatedAt: 0,
141760
142155
  name: slot?.name ?? "Type argument",
142156
+ ...slot?.format === void 0 ? {} : { format: slot.format },
141761
142157
  kind: type2.type,
141762
142158
  requirement: type2.required ? 1 /* Required */ : 0 /* Optional */
141763
142159
  };
141764
142160
  const mark = created.length;
142161
+ const processedMark = processedKeys.length;
141765
142162
  const fields = (() => {
141766
142163
  if (type2.type === 30 /* Tuple */) {
141767
142164
  const elementMemberIds = [];
@@ -141776,7 +142173,15 @@ function compiledConstructionTypeMembers(members2, bodies, projectId) {
141776
142173
  return { elementMemberIds };
141777
142174
  }
141778
142175
  if (type2.type === 6 /* List */ || type2.type === 28 /* Set */ || type2.type === 5 /* Dictionary */) {
141779
- const entryMemberId = intern(type2.entryTypeInfo);
142176
+ const storedEntryId = getField(storedMember, "entryMemberId");
142177
+ const entryMemberId = intern(
142178
+ type2.entryTypeInfo,
142179
+ type2.type === 28 /* Set */ && type2.entryTypeInfo.type === 3 /* String */ ? {
142180
+ id: typeof storedEntryId === "string" ? storedEntryId : derivedEntryMemberId(id2),
142181
+ name: "Item",
142182
+ format: 1 /* Plain */
142183
+ } : void 0
142184
+ );
141780
142185
  if (entryMemberId === null) return null;
141781
142186
  return {
141782
142187
  entryMemberId,
@@ -141808,6 +142213,16 @@ function compiledConstructionTypeMembers(members2, bodies, projectId) {
141808
142213
  } else if (type2.type === 26 /* NSAction */) {
141809
142214
  return { argumentTypes: namedArguments2(type2.argumentTypes) };
141810
142215
  } else if (type2.type === 29 /* Reference */) {
142216
+ const target = type2.targetTypeInfo;
142217
+ if (target.type === 6 /* List */ || target.type === 5 /* Dictionary */ || target.type === 28 /* Set */) {
142218
+ intern(target);
142219
+ } else if (target.type === 9 /* Lookup */ && target.collectionMemberId === void 0 && target.collectionValueId === void 0 && target.entryTypeInfo.type !== NS_TYPE_UNKNOWN && target.entryTypeInfo.required && SET_ENTRY_MEMBER_KINDS.has(target.entryTypeInfo.type)) {
142220
+ intern({
142221
+ type: 28 /* Set */,
142222
+ required: target.required,
142223
+ entryTypeInfo: target.entryTypeInfo
142224
+ });
142225
+ }
141811
142226
  return {
141812
142227
  kind: 9 /* Lookup */,
141813
142228
  declaredTypeInfo: type2.targetTypeInfo
@@ -141819,13 +142234,16 @@ function compiledConstructionTypeMembers(members2, bodies, projectId) {
141819
142234
  }
141820
142235
  })();
141821
142236
  if (fields === null) {
141822
- for (const member of created.splice(mark)) existingIds.delete(member.id);
141823
- for (const key2 of createdKeys.splice(mark)) byType.delete(key2);
141824
- return null;
141825
- }
141826
- created.push({ ...common, ...fields });
141827
- createdKeys.push(cacheKey);
141828
- existingIds.add(id2);
142237
+ for (const member of created.splice(mark))
142238
+ existingMembers.delete(member.id);
142239
+ for (const key2 of processedKeys.splice(processedMark)) byType.delete(key2);
142240
+ if (!alreadyStored) return null;
142241
+ } else if (!alreadyStored) {
142242
+ const member = { ...common, ...fields };
142243
+ created.push(member);
142244
+ existingMembers.set(id2, member);
142245
+ }
142246
+ processedKeys.push(cacheKey);
141829
142247
  byType.set(cacheKey, id2);
141830
142248
  return id2;
141831
142249
  };
@@ -141877,10 +142295,12 @@ var init_compiled_construction_types = __esm({
141877
142295
  "use strict";
141878
142296
  init_dist_node();
141879
142297
  init_core();
142298
+ init_set_entry_keys();
141880
142299
  init_neoscript_guards();
141881
142300
  init_neoscript();
141882
142301
  init_project_content_hash();
141883
142302
  init_tuple_element_member_id();
142303
+ init_entry_member_id();
141884
142304
  }
141885
142305
  });
141886
142306
 
@@ -239894,7 +240314,7 @@ var releaseWorkspaceLock = () => void 0;
239894
240314
  async function main() {
239895
240315
  const args = parseArgs(process.argv.slice(2));
239896
240316
  if (args.command === "--version") {
239897
- console.log("0.89.6");
240317
+ console.log("0.89.7");
239898
240318
  return;
239899
240319
  }
239900
240320
  if (args.command === null || args.command === "help" || args.command === "--help" || args.command === "-h") {