@neocompose/cli 0.78.0 → 0.79.0

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.
@@ -1071,7 +1071,8 @@ var SystemProtectionKind = {
1071
1071
  DialoguePriorityDefault: "dialoguePriorityDefault",
1072
1072
  PolicyImmutable: "policyImmutable",
1073
1073
  PolicyDeleteBlocked: "policyDeleteBlocked",
1074
- ScriptRuntime: "scriptRuntime"
1074
+ ScriptRuntime: "scriptRuntime",
1075
+ SystemPreset: "systemPreset"
1075
1076
  };
1076
1077
  function isWithId(value) {
1077
1078
  return typeof value?.id === "string";
@@ -1088,7 +1089,7 @@ function isEpochMillis(value) {
1088
1089
  return Number.isFinite(value);
1089
1090
  }
1090
1091
  function isSystemProtectionKind(value) {
1091
- return value === SystemProtectionKind.WorldAuthoring || value === SystemProtectionKind.DialogueMemorySchema || value === SystemProtectionKind.DialogueMemoryContainer || value === SystemProtectionKind.DialoguePriorityDefault || value === SystemProtectionKind.PolicyImmutable || value === SystemProtectionKind.PolicyDeleteBlocked || value === SystemProtectionKind.ScriptRuntime;
1092
+ return value === SystemProtectionKind.WorldAuthoring || value === SystemProtectionKind.DialogueMemorySchema || value === SystemProtectionKind.DialogueMemoryContainer || value === SystemProtectionKind.DialoguePriorityDefault || value === SystemProtectionKind.PolicyImmutable || value === SystemProtectionKind.PolicyDeleteBlocked || value === SystemProtectionKind.ScriptRuntime || value === SystemProtectionKind.SystemPreset;
1092
1093
  }
1093
1094
  function isSystemMetadata(value) {
1094
1095
  const v = value;
@@ -6622,7 +6623,7 @@ var WORLD_SYSTEM_CLASS_DEFINITIONS = [
6622
6623
  {
6623
6624
  classId: "system_fb9c4080-0148-530e-b9c0-8cd1c17ff8e7",
6624
6625
  name: "NeoCellPattern",
6625
- docsText: "An immutable ordered pattern of cell offsets, relative to an origin.\nHand-built patterns preserve order and duplicates; factories order cells nearest first.",
6626
+ docsText: "An ordered pattern of cell offsets, relative to an origin.\nHand-built patterns preserve order and duplicates; factories order cells nearest first.",
6626
6627
  modifier: 2 /* Sealed */,
6627
6628
  constructorIds: ["system_f68684d6-6ea0-5d57-9f96-d544b17bf369"],
6628
6629
  constructors: [
@@ -6661,63 +6662,55 @@ var WORLD_SYSTEM_CLASS_DEFINITIONS = [
6661
6662
  },
6662
6663
  {
6663
6664
  memberId: "system_d90a6e51-0b1e-5354-b4e2-ad4155a833f1",
6664
- memberKind: "computed",
6665
+ memberKind: "class",
6666
+ protection: SystemProtectionKind.SystemPreset,
6665
6667
  modifier: 3 /* Static */,
6668
+ storage: 1 /* Immutable */,
6669
+ staticInitializerCode: "new NeoCellPattern(offsets: [new(0, 0)])",
6666
6670
  docsText: "Only the origin cell.",
6667
- returnTypeInfo: {
6668
- type: 7,
6669
- required: true,
6670
- classId: "system_fb9c4080-0148-530e-b9c0-8cd1c17ff8e7"
6671
- },
6672
- code: "return new NeoCellPattern(offsets: [new(0, 0)]);",
6671
+ schemaClassWorldKind: "cellPattern",
6673
6672
  requirement: 1 /* Required */,
6674
6673
  schemaKey: "Center"
6675
6674
  },
6676
6675
  {
6677
6676
  memberId: "system_57290d57-16dd-54d6-ad1e-81a72bd7f457",
6678
- memberKind: "computed",
6677
+ memberKind: "class",
6678
+ protection: SystemProtectionKind.SystemPreset,
6679
6679
  modifier: 3 /* Static */,
6680
+ storage: 1 /* Immutable */,
6681
+ staticInitializerCode: "NeoCellPattern.Cross(1, null, .Center)",
6680
6682
  docsText: "The four edge-adjacent cells, excluding the origin.",
6681
- returnTypeInfo: {
6682
- type: 7,
6683
- required: true,
6684
- classId: "system_fb9c4080-0148-530e-b9c0-8cd1c17ff8e7"
6685
- },
6686
- code: "return NeoCellPattern.Cross(1, null, .Center);",
6683
+ schemaClassWorldKind: "cellPattern",
6687
6684
  requirement: 1 /* Required */,
6688
6685
  schemaKey: "FourNeighbors"
6689
6686
  },
6690
6687
  {
6691
6688
  memberId: "system_a8f2f798-7988-5df8-8294-decdd4316c7e",
6692
- memberKind: "computed",
6689
+ memberKind: "class",
6690
+ protection: SystemProtectionKind.SystemPreset,
6693
6691
  modifier: 3 /* Static */,
6692
+ storage: 1 /* Immutable */,
6693
+ staticInitializerCode: "NeoCellPattern.Box(1, null, .Center)",
6694
6694
  docsText: "The eight surrounding cells, excluding the origin.",
6695
- returnTypeInfo: {
6696
- type: 7,
6697
- required: true,
6698
- classId: "system_fb9c4080-0148-530e-b9c0-8cd1c17ff8e7"
6699
- },
6700
- code: "return NeoCellPattern.Box(1, null, .Center);",
6695
+ schemaClassWorldKind: "cellPattern",
6701
6696
  requirement: 1 /* Required */,
6702
6697
  schemaKey: "EightNeighbors"
6703
6698
  },
6704
6699
  {
6705
6700
  memberId: "system_98d035f6-9f7d-5d2b-ae01-70ce90621333",
6706
- memberKind: "computed",
6701
+ memberKind: "class",
6702
+ protection: SystemProtectionKind.SystemPreset,
6707
6703
  modifier: 3 /* Static */,
6704
+ storage: 1 /* Immutable */,
6705
+ staticInitializerCode: "new NeoCellPattern(offsets: [])",
6708
6706
  docsText: "No cells.",
6709
- returnTypeInfo: {
6710
- type: 7,
6711
- required: true,
6712
- classId: "system_fb9c4080-0148-530e-b9c0-8cd1c17ff8e7"
6713
- },
6714
- code: "return new NeoCellPattern(offsets: []);",
6707
+ schemaClassWorldKind: "cellPattern",
6715
6708
  requirement: 1 /* Required */,
6716
6709
  schemaKey: "Empty"
6717
6710
  },
6718
6711
  {
6719
6712
  memberId: "system_aaad2df6-e31e-5f5d-95b9-e265211faed5",
6720
- memberKind: "function",
6713
+ memberKind: "nsFunction",
6721
6714
  modifier: 3 /* Static */,
6722
6715
  docsText: "A filled rectangle of offsets. Omitting radiusY uses radiusX on both axes.",
6723
6716
  returnTypeInfo: {
@@ -6744,11 +6737,12 @@ var WORLD_SYSTEM_CLASS_DEFINITIONS = [
6744
6737
  }
6745
6738
  ],
6746
6739
  dispatch: 0 /* Synchronous */,
6740
+ code: 'int y = radiusY ?? radiusX;\nif (radiusX < 0 || y < 0) {\n throw $"Box radii must be non-negative; got {radiusX}, {y}.";\n}\nreturn NeoCellPattern.Shells(-radiusX, radiusX, -y, y, excluding == NeoCellPatternExcluding.Center ? 1 : 0);',
6747
6741
  schemaKey: "Box"
6748
6742
  },
6749
6743
  {
6750
6744
  memberId: "system_df8ebca6-a1d1-57c1-8762-227943fc51d8",
6751
- memberKind: "function",
6745
+ memberKind: "nsFunction",
6752
6746
  modifier: 3 /* Static */,
6753
6747
  docsText: "Axis-aligned offsets. Omitting radiusY uses radiusX on both axes.",
6754
6748
  returnTypeInfo: {
@@ -6775,11 +6769,12 @@ var WORLD_SYSTEM_CLASS_DEFINITIONS = [
6775
6769
  }
6776
6770
  ],
6777
6771
  dispatch: 0 /* Synchronous */,
6772
+ code: 'int y = radiusY ?? radiusX;\nif (radiusX < 0 || y < 0) {\n throw $"Cross radii must be non-negative; got {radiusX}, {y}.";\n}\nList<Vector2Int> cells = [];\nif (excluding == NeoCellPatternExcluding.None) {\n cells.Add(new(0, 0));\n}\nfor (int distance = 1; distance <= Math.Max(radiusX, y); distance++) {\n if (distance <= radiusX) {\n cells.Add(new(-distance, 0));\n cells.Add(new(distance, 0));\n }\n if (distance <= y) {\n cells.Add(new(0, -distance));\n cells.Add(new(0, distance));\n }\n}\nreturn new NeoCellPattern(offsets: cells);',
6778
6773
  schemaKey: "Cross"
6779
6774
  },
6780
6775
  {
6781
6776
  memberId: "system_82222600-f67f-5127-bb2d-278381b4ef2f",
6782
- memberKind: "function",
6777
+ memberKind: "nsFunction",
6783
6778
  modifier: 3 /* Static */,
6784
6779
  docsText: "The square ring at the given Chebyshev radius. Zero returns the center.",
6785
6780
  returnTypeInfo: {
@@ -6789,11 +6784,12 @@ var WORLD_SYSTEM_CLASS_DEFINITIONS = [
6789
6784
  },
6790
6785
  argumentTypes: [{ name: "radius", type: 2, required: true }],
6791
6786
  dispatch: 0 /* Synchronous */,
6787
+ code: 'if (radius < 0) {\n throw $"Ring radius must be non-negative; got {radius}.";\n}\nreturn NeoCellPattern.Shells(-radius, radius, -radius, radius, radius);',
6792
6788
  schemaKey: "Ring"
6793
6789
  },
6794
6790
  {
6795
6791
  memberId: "system_d803cfd5-ce53-57da-abc2-7cd69befeb01",
6796
- memberKind: "function",
6792
+ memberKind: "nsFunction",
6797
6793
  modifier: 3 /* Static */,
6798
6794
  docsText: "Cells from the origin through size minus one. Both dimensions must be positive.",
6799
6795
  returnTypeInfo: {
@@ -6803,11 +6799,12 @@ var WORLD_SYSTEM_CLASS_DEFINITIONS = [
6803
6799
  },
6804
6800
  argumentTypes: [{ name: "size", type: 15, required: true }],
6805
6801
  dispatch: 0 /* Synchronous */,
6802
+ code: 'if (size.x < 1 || size.y < 1) {\n throw $"Rect size must be positive; got {size.x}, {size.y}.";\n}\nreturn NeoCellPattern.Shells(0, size.x - 1, 0, size.y - 1, 0);',
6806
6803
  schemaKey: "Rect"
6807
6804
  },
6808
6805
  {
6809
6806
  memberId: "system_ef0d4cbb-7182-5d93-9bb8-60a5a18f81a5",
6810
- memberKind: "function",
6807
+ memberKind: "nsFunction",
6811
6808
  modifier: 3 /* Static */,
6812
6809
  docsText: "Offsets from the origin through length steps in direction. Center excludes only the origin.",
6813
6810
  returnTypeInfo: {
@@ -6829,6 +6826,7 @@ var WORLD_SYSTEM_CLASS_DEFINITIONS = [
6829
6826
  }
6830
6827
  ],
6831
6828
  dispatch: 0 /* Synchronous */,
6829
+ code: 'if (direction.x == 0 && direction.y == 0) {\n throw "Line direction must be non-zero.";\n}\nif (length < 0) {\n throw $"Line length must be non-negative; got {length}.";\n}\nList<Vector2Int> cells = [];\nif (excluding == NeoCellPatternExcluding.None) {\n cells.Add(new(0, 0));\n}\nfor (int step = 1; step <= length; step++) {\n cells.Add(new(direction.x * step, direction.y * step));\n}\nreturn new NeoCellPattern(offsets: cells);',
6832
6830
  schemaKey: "Line"
6833
6831
  },
6834
6832
  {
@@ -6911,6 +6909,28 @@ var WORLD_SYSTEM_CLASS_DEFINITIONS = [
6911
6909
  ],
6912
6910
  dispatch: 0 /* Synchronous */,
6913
6911
  schemaKey: "Union"
6912
+ },
6913
+ {
6914
+ memberId: "system_faf10f4f-f5c2-47d8-b4e2-8f196c756668",
6915
+ memberKind: "nsFunction",
6916
+ access: 2 /* Private */,
6917
+ modifier: 3 /* Static */,
6918
+ docsText: "Square shells firstShell through the rectangle's Chebyshev radius, each clipped to the rectangle.\nA shell runs left column, then bottom/top pairs by x, then right column.",
6919
+ returnTypeInfo: {
6920
+ type: 7,
6921
+ required: true,
6922
+ classId: "system_fb9c4080-0148-530e-b9c0-8cd1c17ff8e7"
6923
+ },
6924
+ argumentTypes: [
6925
+ { name: "minX", type: 2, required: true },
6926
+ { name: "maxX", type: 2, required: true },
6927
+ { name: "minY", type: 2, required: true },
6928
+ { name: "maxY", type: 2, required: true },
6929
+ { name: "firstShell", type: 2, required: true }
6930
+ ],
6931
+ dispatch: 0 /* Synchronous */,
6932
+ code: "List<Vector2Int> cells = [];\nint radius = Math.Max(Math.Max(-minX, maxX), Math.Max(-minY, maxY));\nfor (int shell = firstShell; shell <= radius; shell++) {\n int firstY = Math.Max(minY, -shell);\n int lastY = Math.Min(maxY, shell);\n if (shell == 0) {\n if (minX <= 0 && maxX >= 0 && firstY <= lastY) {\n cells.Add(new(0, 0));\n }\n } else if (firstY <= lastY) {\n if (-shell >= minX && -shell <= maxX) {\n for (int y = firstY; y <= lastY; y++) {\n cells.Add(new(-shell, y));\n }\n }\n bool bottom = -shell >= minY && -shell <= maxY;\n bool top = shell >= minY && shell <= maxY;\n if (bottom || top) {\n for (int x = Math.Max(minX, -shell + 1); x <= Math.Min(maxX, shell - 1); x++) {\n if (bottom) {\n cells.Add(new(x, -shell));\n }\n if (top) {\n cells.Add(new(x, shell));\n }\n }\n }\n if (shell >= minX && shell <= maxX) {\n for (int y = firstY; y <= lastY; y++) {\n cells.Add(new(shell, y));\n }\n }\n }\n}\nreturn new NeoCellPattern(offsets: cells);",
6933
+ schemaKey: "Shells"
6914
6934
  }
6915
6935
  ],
6916
6936
  supportingFields: [
@@ -7379,7 +7399,7 @@ var WORLD_SYSTEM_CLASS_DEFINITIONS = [
7379
7399
  {
7380
7400
  memberId: "system_f5ca386c-990c-54a1-8473-2d49d2cd887d",
7381
7401
  memberKind: "function",
7382
- docsText: "Objects at the cells around this placement, in pattern order. Use GetObjects<T>(pattern) to filter by class. A repeated footprint can appear more than once.",
7402
+ docsText: "Objects at the cells around this placement, shifted by offset, in pattern order. Use GetObjects<T>(pattern, offset) to filter by class. A repeated footprint can appear more than once.",
7383
7403
  returnTypeInfo: {
7384
7404
  type: 6,
7385
7405
  required: true,
@@ -7395,6 +7415,12 @@ var WORLD_SYSTEM_CLASS_DEFINITIONS = [
7395
7415
  type: 7,
7396
7416
  required: true,
7397
7417
  classId: "system_fb9c4080-0148-530e-b9c0-8cd1c17ff8e7"
7418
+ },
7419
+ {
7420
+ name: "offset",
7421
+ type: 15,
7422
+ required: false,
7423
+ defaultValue: { value: null }
7398
7424
  }
7399
7425
  ],
7400
7426
  dispatch: 0 /* Synchronous */,
@@ -7403,7 +7429,7 @@ var WORLD_SYSTEM_CLASS_DEFINITIONS = [
7403
7429
  {
7404
7430
  memberId: "system_593e6208-e2ca-505e-9933-04b17102b6d2",
7405
7431
  memberKind: "function",
7406
- docsText: "The first tile found in pattern order around this placement, or null. Each cell uses the grid layer precedence.",
7432
+ docsText: "The first tile found in pattern order around this placement, shifted by offset, or null. Each cell uses the grid layer precedence.",
7407
7433
  returnTypeInfo: {
7408
7434
  type: 7,
7409
7435
  required: false,
@@ -7415,10 +7441,46 @@ var WORLD_SYSTEM_CLASS_DEFINITIONS = [
7415
7441
  type: 7,
7416
7442
  required: true,
7417
7443
  classId: "system_fb9c4080-0148-530e-b9c0-8cd1c17ff8e7"
7444
+ },
7445
+ {
7446
+ name: "offset",
7447
+ type: 15,
7448
+ required: false,
7449
+ defaultValue: { value: null }
7418
7450
  }
7419
7451
  ],
7420
7452
  dispatch: 0 /* Synchronous */,
7421
7453
  schemaKey: "GetTile"
7454
+ },
7455
+ {
7456
+ memberId: "system_5a41d36a-bcd9-4867-9e46-d743f6e09582",
7457
+ memberKind: "function",
7458
+ docsText: "The tiles at the cells around this placement, shifted by offset, in pattern order. Each cell uses the grid layer precedence and empty cells are skipped.",
7459
+ returnTypeInfo: {
7460
+ type: 6,
7461
+ required: true,
7462
+ entryTypeInfo: {
7463
+ type: 7,
7464
+ required: true,
7465
+ classId: "system_d7fa161b-b269-4bf1-9ec9-3aebec67e6e0"
7466
+ }
7467
+ },
7468
+ argumentTypes: [
7469
+ {
7470
+ name: "pattern",
7471
+ type: 7,
7472
+ required: true,
7473
+ classId: "system_fb9c4080-0148-530e-b9c0-8cd1c17ff8e7"
7474
+ },
7475
+ {
7476
+ name: "offset",
7477
+ type: 15,
7478
+ required: false,
7479
+ defaultValue: { value: null }
7480
+ }
7481
+ ],
7482
+ dispatch: 0 /* Synchronous */,
7483
+ schemaKey: "GetTiles"
7422
7484
  }
7423
7485
  ],
7424
7486
  supportingFields: [
@@ -14016,7 +14078,8 @@ var NSGetterRuntimeError = class extends Error {
14016
14078
  node: { writable: true, value: void 0 },
14017
14079
  callerNode: { writable: true, value: void 0 },
14018
14080
  initializerValueId: { writable: true, value: void 0 },
14019
- sourceOwnerId: { writable: true, value: void 0 }
14081
+ sourceOwnerId: { writable: true, value: void 0 },
14082
+ attachedValueId: { writable: true, value: void 0 }
14020
14083
  });
14021
14084
  if (options?.cause instanceof Error && "neoScriptFrames" in options.cause && Array.isArray(options.cause.neoScriptFrames)) {
14022
14085
  const frames = options.cause.neoScriptFrames;
@@ -14425,6 +14488,9 @@ function initializerOwnerContext(document2, valueId, rootOwners, valuesById, rec
14425
14488
  const ownerClass = typeof lexicalRootId === "string" ? findSchemaPlacement(lexicalRootId, document2.classes)?.ownerClass ?? null : null;
14426
14489
  return { ownerClass, lexicalThisClass: ownerClass };
14427
14490
  }
14491
+ function isClassRecordValue(value) {
14492
+ return value !== null && typeof value === "object" && !Array.isArray(value);
14493
+ }
14428
14494
  function isRecordValue(value) {
14429
14495
  if (value === null) return false;
14430
14496
  if (typeof value !== "object") return false;
@@ -14530,7 +14596,7 @@ function resolveOwnerMembersForValues(document2, targetValueIds, additionalRoots
14530
14596
  }
14531
14597
  function searchChildren(member, rootOwner, body, ambientEnv, rootKind) {
14532
14598
  if (isMemberClassBase(member)) {
14533
- if (!isRecordValue(body.value)) return;
14599
+ if (!isClassRecordValue(body.value)) return;
14534
14600
  const effectiveClassId = body.classId ?? member.classId;
14535
14601
  const schemaClass2 = classesById.get(effectiveClassId);
14536
14602
  if (schemaClass2 === void 0) return;
@@ -14545,7 +14611,7 @@ function resolveOwnerMembersForValues(document2, targetValueIds, additionalRoots
14545
14611
  if (complete) break;
14546
14612
  if (entry.memberId === null) continue;
14547
14613
  const childValueId = body.value[entry.schemaKey];
14548
- if (childValueId === void 0) continue;
14614
+ if (typeof childValueId !== "string") continue;
14549
14615
  const childMember = membersById.get(entry.memberId);
14550
14616
  if (childMember === void 0) continue;
14551
14617
  const substituted = trySubstituteMember(childMember, env);
@@ -14655,10 +14721,6 @@ function overlayStamp(env, stamp) {
14655
14721
  // ../packages/neoscript-language/src/cell-pattern.ts
14656
14722
  var NEO_CELL_PATTERN_CLASS_ID = "system_fb9c4080-0148-530e-b9c0-8cd1c17ff8e7";
14657
14723
  var NEO_CELL_PATTERN_CONSTRUCTOR_ID = "system_f68684d6-6ea0-5d57-9f96-d544b17bf369";
14658
- var NEO_CELL_PATTERN_EXCLUDING_OPTION_IDS = {
14659
- None: "system_5c30e23b-1767-5e15-b633-40ae182157a7",
14660
- Center: "system_456431b5-aa5b-5ea0-9f72-0e16f7114e09"
14661
- };
14662
14724
  var NEO_CELL_PATTERN_MEMBER_IDS = {
14663
14725
  Count: "system_51d883c9-d451-5747-bcf0-e314e44bffa8",
14664
14726
  Center: "system_d90a6e51-0b1e-5354-b4e2-ad4155a833f1",
@@ -14681,14 +14743,10 @@ var NEO_OBJECT_GRID_MEMBER_IDS = {
14681
14743
  Cell: "system_c609fed3-53e4-5147-b493-e4aa23031d79",
14682
14744
  GetCell: "system_df1c2d06-eeec-5340-addc-740f3668c9e4",
14683
14745
  GetObjects: "system_f5ca386c-990c-54a1-8473-2d49d2cd887d",
14684
- GetTile: "system_593e6208-e2ca-505e-9933-04b17102b6d2"
14746
+ GetTile: "system_593e6208-e2ca-505e-9933-04b17102b6d2",
14747
+ GetTiles: "system_5a41d36a-bcd9-4867-9e46-d743f6e09582"
14685
14748
  };
14686
14749
  var NEO_CELL_PATTERN_PURE_NATIVE_MEMBER_IDS = /* @__PURE__ */ new Set([
14687
- NEO_CELL_PATTERN_MEMBER_IDS.Box,
14688
- NEO_CELL_PATTERN_MEMBER_IDS.Cross,
14689
- NEO_CELL_PATTERN_MEMBER_IDS.Ring,
14690
- NEO_CELL_PATTERN_MEMBER_IDS.Rect,
14691
- NEO_CELL_PATTERN_MEMBER_IDS.Line,
14692
14750
  NEO_CELL_PATTERN_MEMBER_IDS.Contains,
14693
14751
  NEO_CELL_PATTERN_MEMBER_IDS.Cells,
14694
14752
  NEO_CELL_PATTERN_MEMBER_IDS.WithCenter,
@@ -14699,12 +14757,12 @@ var NEO_CELL_PATTERN_PURE_NATIVE_MEMBER_IDS = /* @__PURE__ */ new Set([
14699
14757
  var NEO_OBJECT_CLASS_ID = "system_f671535d-0eb6-4139-9caf-5c5276febd31";
14700
14758
 
14701
14759
  // ../packages/neoscript-runtime/src/neoscript/cell-pattern.ts
14702
- function integer(value, name, minimum = -2147483648) {
14760
+ function integer(value, name) {
14703
14761
  if (typeof value !== "number" || !Number.isInteger(value)) {
14704
14762
  throw new TypeError(`${name} must be an integer.`);
14705
14763
  }
14706
- if (value < minimum) {
14707
- throw new RangeError(`${name} must be at least ${minimum}.`);
14764
+ if (value < -2147483648) {
14765
+ throw new RangeError(`${name} is below the supported integer range.`);
14708
14766
  }
14709
14767
  if (value > 2147483647) {
14710
14768
  throw new RangeError(`${name} exceeds the supported integer range.`);
@@ -14717,61 +14775,7 @@ function vector(value, name) {
14717
14775
  }
14718
14776
  return { x: integer(value.x, `${name}.x`), y: integer(value.y, `${name}.y`) };
14719
14777
  }
14720
- function exclusion(value) {
14721
- if (!Array.isArray(value) || value.length !== 1) {
14722
- throw new TypeError(
14723
- "excluding must select one NeoCellPatternExcluding option."
14724
- );
14725
- }
14726
- if (value[0] === NEO_CELL_PATTERN_EXCLUDING_OPTION_IDS.None) return "none";
14727
- if (value[0] === NEO_CELL_PATTERN_EXCLUDING_OPTION_IDS.Center)
14728
- return "center";
14729
- throw new RangeError("excluding is not a NeoCellPatternExcluding option.");
14730
- }
14731
- function reserve(ctx, count) {
14732
- if (!Number.isSafeInteger(count) || count < 0) {
14733
- throw new RangeError("Cell pattern contains too many offsets.");
14734
- }
14735
- ctx.reserveEntries(count);
14736
- }
14737
- function appendShell(result, radius, minX, maxX, minY, maxY) {
14738
- if (radius === 0) {
14739
- if (minX <= 0 && maxX >= 0 && minY <= 0 && maxY >= 0)
14740
- result.push({ x: 0, y: 0 });
14741
- return;
14742
- }
14743
- const firstY = Math.max(minY, -radius) || 0;
14744
- const lastY = Math.min(maxY, radius);
14745
- if (firstY > lastY) return;
14746
- if (-radius >= minX && -radius <= maxX) {
14747
- for (let y = firstY; y <= lastY; y++) result.push({ x: -radius, y });
14748
- }
14749
- const bottom = -radius >= minY && -radius <= maxY;
14750
- const top = radius !== 0 && radius >= minY && radius <= maxY;
14751
- if (bottom || top) {
14752
- const firstX = Math.max(minX, -radius + 1) || 0;
14753
- const lastX = Math.min(maxX, radius - 1);
14754
- for (let x = firstX; x <= lastX; x++) {
14755
- if (bottom) result.push({ x, y: -radius });
14756
- if (top) result.push({ x, y: radius });
14757
- }
14758
- }
14759
- if (radius !== 0 && radius >= minX && radius <= maxX) {
14760
- for (let y = firstY; y <= lastY; y++) result.push({ x: radius, y });
14761
- }
14762
- }
14763
- function rectangle(ctx, minX, maxX, minY, maxY, excluding) {
14764
- const count = (maxX - minX + 1) * (maxY - minY + 1);
14765
- reserve(ctx, count - (excluding === "center" ? 1 : 0));
14766
- const offsets = [];
14767
- const radius = Math.max(-minX, maxX, -minY, maxY);
14768
- for (let shell = excluding === "center" ? 1 : 0; shell <= radius; shell++) {
14769
- appendShell(offsets, shell, minX, maxX, minY, maxY);
14770
- }
14771
- return offsets;
14772
- }
14773
- function translated(offsets, origin, ctx) {
14774
- reserve(ctx, offsets.length);
14778
+ function translated(offsets, origin) {
14775
14779
  return offsets.map((offset) => ({
14776
14780
  x: integer(offset.x + origin.x, "Translated cell.x"),
14777
14781
  y: integer(offset.y + origin.y, "Translated cell.y")
@@ -14788,57 +14792,7 @@ function evaluateCellPatternNative(memberId, receiver, args, ctx) {
14788
14792
  handled: true,
14789
14793
  value: ctx.constructPattern(offsets2)
14790
14794
  });
14791
- switch (memberId) {
14792
- case NEO_CELL_PATTERN_MEMBER_IDS.Box: {
14793
- const x = integer(args[0], "Box radiusX", 0);
14794
- const y = args[1] === null ? x : integer(args[1], "Box radiusY", 0);
14795
- return pattern(rectangle(ctx, -x, x, -y, y, exclusion(args[2])));
14796
- }
14797
- case NEO_CELL_PATTERN_MEMBER_IDS.Cross: {
14798
- const x = integer(args[0], "Cross radiusX", 0);
14799
- const y = args[1] === null ? x : integer(args[1], "Cross radiusY", 0);
14800
- const excluding = exclusion(args[2]);
14801
- reserve(ctx, 2 * (x + y) + (excluding === "none" ? 1 : 0));
14802
- const offsets2 = excluding === "none" ? [{ x: 0, y: 0 }] : [];
14803
- for (let distance = 1; distance <= Math.max(x, y); distance++) {
14804
- if (distance <= x)
14805
- offsets2.push({ x: -distance, y: 0 }, { x: distance, y: 0 });
14806
- if (distance <= y)
14807
- offsets2.push({ x: 0, y: -distance }, { x: 0, y: distance });
14808
- }
14809
- return pattern(offsets2);
14810
- }
14811
- case NEO_CELL_PATTERN_MEMBER_IDS.Ring: {
14812
- const radius = integer(args[0], "Ring radius", 0);
14813
- reserve(ctx, radius === 0 ? 1 : 8 * radius);
14814
- const offsets2 = [];
14815
- appendShell(offsets2, radius, -radius, radius, -radius, radius);
14816
- return pattern(offsets2);
14817
- }
14818
- case NEO_CELL_PATTERN_MEMBER_IDS.Rect: {
14819
- const size = vector(args[0], "Rect size");
14820
- integer(size.x, "Rect size.x", 1);
14821
- integer(size.y, "Rect size.y", 1);
14822
- return pattern(rectangle(ctx, 0, size.x - 1, 0, size.y - 1, "none"));
14823
- }
14824
- case NEO_CELL_PATTERN_MEMBER_IDS.Line: {
14825
- const direction = vector(args[0], "Line direction");
14826
- if (isCenter(direction))
14827
- throw new RangeError("Line direction must be non-zero.");
14828
- const length = integer(args[1], "Line length", 0);
14829
- const excluding = exclusion(args[2]);
14830
- reserve(ctx, length + (excluding === "none" ? 1 : 0));
14831
- integer(direction.x * length, "Line endpoint.x");
14832
- integer(direction.y * length, "Line endpoint.y");
14833
- const offsets2 = excluding === "none" ? [{ x: 0, y: 0 }] : [];
14834
- for (let step = 1; step <= length; step++) {
14835
- offsets2.push({ x: direction.x * step, y: direction.y * step });
14836
- }
14837
- return pattern(offsets2);
14838
- }
14839
- }
14840
14795
  const offsets = ctx.readPattern(receiver);
14841
- ctx.visitEntries(offsets.length);
14842
14796
  switch (memberId) {
14843
14797
  case NEO_CELL_PATTERN_MEMBER_IDS.Contains: {
14844
14798
  const offset = vector(args[0], "Contains offset");
@@ -14852,34 +14806,27 @@ function evaluateCellPatternNative(memberId, receiver, args, ctx) {
14852
14806
  case NEO_CELL_PATTERN_MEMBER_IDS.Cells:
14853
14807
  return {
14854
14808
  handled: true,
14855
- value: translated(offsets, vector(args[0], "Cells origin"), ctx)
14809
+ value: translated(offsets, vector(args[0], "Cells origin"))
14856
14810
  };
14857
14811
  case NEO_CELL_PATTERN_MEMBER_IDS.WithCenter:
14858
14812
  if (offsets.some(isCenter)) return { handled: true, value: receiver };
14859
- reserve(ctx, offsets.length + 1);
14860
14813
  return pattern([{ x: 0, y: 0 }, ...offsets]);
14861
- case NEO_CELL_PATTERN_MEMBER_IDS.WithoutCenter: {
14862
- let count = 0;
14863
- for (const offset of offsets) if (!isCenter(offset)) count++;
14864
- if (count === offsets.length) return { handled: true, value: receiver };
14865
- reserve(ctx, count);
14814
+ case NEO_CELL_PATTERN_MEMBER_IDS.WithoutCenter:
14815
+ if (!offsets.some(isCenter)) return { handled: true, value: receiver };
14866
14816
  return pattern(offsets.filter((offset) => !isCenter(offset)));
14867
- }
14868
14817
  case NEO_CELL_PATTERN_MEMBER_IDS.Translate: {
14869
14818
  const offset = vector(args[0], "Translate offset");
14870
14819
  if (isCenter(offset)) return { handled: true, value: receiver };
14871
- return pattern(translated(offsets, offset, ctx));
14820
+ return pattern(translated(offsets, offset));
14872
14821
  }
14873
14822
  case NEO_CELL_PATTERN_MEMBER_IDS.Union: {
14874
14823
  const other = ctx.readPattern(args[0]);
14875
- ctx.visitEntries(other.length);
14876
14824
  const seen = /* @__PURE__ */ new Set();
14877
14825
  const result = [];
14878
14826
  for (const source of [offsets, other]) {
14879
14827
  for (const offset of source) {
14880
14828
  const key = `${offset.x},${offset.y}`;
14881
14829
  if (seen.has(key)) continue;
14882
- reserve(ctx, 1);
14883
14830
  seen.add(key);
14884
14831
  result.push(offset);
14885
14832
  }
@@ -15724,29 +15671,44 @@ var WorldGridQueryIndex = class {
15724
15671
  );
15725
15672
  return matches[0];
15726
15673
  }
15727
- objects(placement, offsets, reads, reserveResults) {
15674
+ /** `shift` moves the whole pattern; null queries around the placement cell. */
15675
+ objects(placement, offsets, reads, shift = null) {
15728
15676
  reads?.add({ kind: "placement", valueId: placement.valueId });
15677
+ const origin = shiftedOrigin(placement, shift);
15729
15678
  const result = [];
15730
15679
  for (const offset of offsets) {
15731
- const cell = translated2(placement.cell, offset);
15680
+ const cell = translated2(origin, offset);
15732
15681
  reads?.add({ kind: "objects", gridId: placement.gridId, cell });
15733
15682
  for (const item of this.objectsAt(placement.gridId, cell)) {
15734
- reserveResults?.(1);
15735
15683
  result.push(item.valueId);
15736
15684
  }
15737
15685
  }
15738
15686
  return result;
15739
15687
  }
15740
- tile(placement, offsets, reads) {
15688
+ tile(placement, offsets, reads, shift = null) {
15741
15689
  reads?.add({ kind: "placement", valueId: placement.valueId });
15690
+ const origin = shiftedOrigin(placement, shift);
15742
15691
  let result = null;
15743
15692
  for (const offset of offsets) {
15744
- const cell = translated2(placement.cell, offset);
15693
+ const cell = translated2(origin, offset);
15745
15694
  reads?.add({ kind: "tile", gridId: placement.gridId, cell });
15746
15695
  result ??= this.tileAt(placement.gridId, cell);
15747
15696
  }
15748
15697
  return result;
15749
15698
  }
15699
+ /** One tile per occupied pattern cell, in pattern order. */
15700
+ tiles(placement, offsets, reads, shift = null) {
15701
+ reads?.add({ kind: "placement", valueId: placement.valueId });
15702
+ const origin = shiftedOrigin(placement, shift);
15703
+ const result = [];
15704
+ for (const offset of offsets) {
15705
+ const cell = translated2(origin, offset);
15706
+ reads?.add({ kind: "tile", gridId: placement.gridId, cell });
15707
+ const tile = this.tileAt(placement.gridId, cell);
15708
+ if (tile !== null) result.push(tile.placementValueId);
15709
+ }
15710
+ return result;
15711
+ }
15750
15712
  /** Stable dependency value: unrelated cells and non-geometric payload edits compare equal. */
15751
15713
  signature(read) {
15752
15714
  if (read.kind === "placement") {
@@ -16009,6 +15971,9 @@ function timestamp(value) {
16009
15971
  if (typeof value === "string") return Date.parse(value) || 0;
16010
15972
  return 0;
16011
15973
  }
15974
+ function shiftedOrigin(placement, shift) {
15975
+ return shift === null ? placement.cell : translated2(placement.cell, shift);
15976
+ }
16012
15977
  function translated2(cell, offset) {
16013
15978
  return {
16014
15979
  x: checkedCoordinate(cell.x + offset.x),
@@ -16633,25 +16598,12 @@ var NativeFunctionDelegateUnavailableError = class extends NonCatchableNSGetterR
16633
16598
  };
16634
16599
  var CorruptNeoScriptIRError = class extends NonCatchableNSGetterRuntimeError {
16635
16600
  };
16636
- var NeoScriptResourceLimitError = class extends NonCatchableNSGetterRuntimeError {
16637
- constructor(message) {
16638
- super(message);
16639
- this.name = "NeoScriptResourceLimitError";
16640
- }
16641
- };
16642
- var NeoScriptWallClockTimeoutError = class extends NeoScriptResourceLimitError {
16601
+ var NeoScriptWallClockTimeoutError = class extends NonCatchableNSGetterRuntimeError {
16643
16602
  constructor() {
16644
16603
  super("NeoScript wall-clock timeout exceeded.");
16645
16604
  this.name = "NeoScriptWallClockTimeoutError";
16646
16605
  }
16647
16606
  };
16648
- var DEFAULT_NEO_SCRIPT_EXECUTION_BUDGET_LIMITS = Object.freeze({
16649
- workUnits: 1e5,
16650
- collectionVisits: 1e5,
16651
- producedCollectionEntries: 1e4,
16652
- constructedSessionRows: 4096,
16653
- producedStringCharacters: 1024 * 1024
16654
- });
16655
16607
  function isCatchableNeoScriptRuntimeError(error) {
16656
16608
  return error instanceof NSGetterRuntimeError && !(error instanceof UncompiledInitializerRuntimeError) && !(error instanceof PendingInitializerDependency) && !(error instanceof NonCatchableNSGetterRuntimeError);
16657
16609
  }
@@ -16771,7 +16723,8 @@ function blankEvaluatorIndexes(memberByValueId) {
16771
16723
  indexedVirtualRowSets: /* @__PURE__ */ new WeakSet(),
16772
16724
  ownedValueAttachmentsByValueId: /* @__PURE__ */ new Map(),
16773
16725
  constructorOwnershipDirtyValueIds: /* @__PURE__ */ new Set(),
16774
- memberByRowId: /* @__PURE__ */ new Map()
16726
+ memberByRowId: /* @__PURE__ */ new Map(),
16727
+ invalidated: false
16775
16728
  };
16776
16729
  }
16777
16730
  function createEvaluatorBaseIndexBuild(members, values, valueById) {
@@ -16980,7 +16933,7 @@ function layerEvaluatorLookups(base, overlay) {
16980
16933
  }
16981
16934
  function evaluatorIndexes(ctx) {
16982
16935
  const overlayRevision = ctx.__valueOverlay instanceof LazyValueOverlay ? ctx.__valueOverlay.revision : void 0;
16983
- if (ctx.__indexes !== void 0 && ctx.__indexes.overlayRevision === overlayRevision) {
16936
+ if (ctx.__indexes !== void 0 && !ctx.__indexes.invalidated && ctx.__indexes.overlayRevision === overlayRevision) {
16984
16937
  syncLazyOverlayReferences(ctx.__indexes, ctx.__valueOverlay);
16985
16938
  return ctx.__indexes;
16986
16939
  }
@@ -17015,7 +16968,8 @@ function evaluatorIndexes(ctx) {
17015
16968
  indexedVirtualRowSets: /* @__PURE__ */ new WeakSet(),
17016
16969
  ownedValueAttachmentsByValueId: /* @__PURE__ */ new Map(),
17017
16970
  constructorOwnershipDirtyValueIds: /* @__PURE__ */ new Set(),
17018
- memberByRowId: /* @__PURE__ */ new Map()
16971
+ memberByRowId: /* @__PURE__ */ new Map(),
16972
+ invalidated: false
17019
16973
  };
17020
16974
  if (base === void 0) {
17021
16975
  for (const member of ctx.vm.members) {
@@ -17339,13 +17293,21 @@ function resolveRuntimeReferenceRow(sourceValueId, ctx, withProvenance) {
17339
17293
  );
17340
17294
  }
17341
17295
  function invalidateEvaluatorIndexes(ctx, changedValue) {
17342
- if (ctx.__valueOverlay instanceof LazyValueOverlay) {
17343
- const overlay = ctx.__valueOverlay;
17344
- const constructionLocal = changedValue !== void 0 && (ctx.__executionState?.constructionStack.length ?? 0) > 0 && !overlay.isSourceValueReference(changedValue);
17345
- overlay.markMutated(changedValue !== null && !constructionLocal);
17346
- }
17296
+ markOverlayMutated(ctx, changedValue);
17297
+ if (ctx.__indexes !== void 0) ctx.__indexes.invalidated = true;
17347
17298
  ctx.__indexes = void 0;
17348
17299
  }
17300
+ function markOverlayMutated(ctx, changedValue) {
17301
+ if (!(ctx.__valueOverlay instanceof LazyValueOverlay)) return;
17302
+ const overlay = ctx.__valueOverlay;
17303
+ const constructionLocal = changedValue !== void 0 && (ctx.__executionState?.constructionStack.length ?? 0) > 0 && !overlay.isSourceValueReference(changedValue);
17304
+ overlay.markMutated(changedValue !== null && !constructionLocal);
17305
+ }
17306
+ function forgetLocalListIndexes(ctx, list) {
17307
+ ctx.__setEntryIndexes?.delete(list);
17308
+ ctx.__indexes?.listIdentityByArray.delete(list);
17309
+ ctx.__indexes?.declaredListByArray.delete(list);
17310
+ }
17349
17311
  function trackedRowForValueReference(value, ctx) {
17350
17312
  if (typeof value !== "object" || value === null) return null;
17351
17313
  const indexes3 = evaluatorIndexes(ctx);
@@ -17398,7 +17360,6 @@ function assertStoredReplayMutableValue(value, ctx, label, key) {
17398
17360
  );
17399
17361
  }
17400
17362
  var MAX_CONSTRUCTION_DEPTH = 64;
17401
- var MAX_LOOP_ITERATIONS = 1e4;
17402
17363
  function pushConstructionFrame(ctx, label) {
17403
17364
  const state = ctx.__executionState;
17404
17365
  if (state === void 0) {
@@ -17406,7 +17367,7 @@ function pushConstructionFrame(ctx, label) {
17406
17367
  "Class construction requires an effect-capable evaluator Session scope."
17407
17368
  );
17408
17369
  }
17409
- consumeBudget(ctx, "workUnits", 1, "work unit");
17370
+ checkDeadline(ctx);
17410
17371
  if (state.constructionStack.length >= MAX_CONSTRUCTION_DEPTH) {
17411
17372
  const chain = [...state.constructionStack, label].join(" -> ");
17412
17373
  throw new NSGetterRuntimeError(
@@ -17672,12 +17633,6 @@ function exportInitializerCollections(created, writes, ctx) {
17672
17633
  createdValues: [encoded, ...children],
17673
17634
  declarationByValueId: declarations
17674
17635
  });
17675
- consumeBudget(
17676
- ctx,
17677
- "constructedSessionRows",
17678
- children.length,
17679
- "constructed Session row"
17680
- );
17681
17636
  for (const child of children) {
17682
17637
  if (!isLiteralValueContent(child)) {
17683
17638
  throw new NSGetterRuntimeError(
@@ -17724,7 +17679,7 @@ function evaluateNSGetterWithEffects(getter, ctx, argumentValues = [], options =
17724
17679
  const ownsInvocationState = ctx.__executionState === void 0;
17725
17680
  const requestedWrites = [];
17726
17681
  const runtimeCtx = withEvaluationRuntime(ctx, requestedWrites);
17727
- consumeBudget(runtimeCtx, "workUnits", 1, "work unit");
17682
+ checkDeadline(runtimeCtx);
17728
17683
  const writes = runtimeCtx.__executionState?.writes ?? requestedWrites;
17729
17684
  const writeCheckpoint = writes.length;
17730
17685
  const creationCheckpoint = sessionCreationCheckpoint(runtimeCtx);
@@ -17784,6 +17739,13 @@ function evaluateNSGetterWithEffects(getter, ctx, argumentValues = [], options =
17784
17739
  const rootIndex = created.findIndex(
17785
17740
  (row) => row.value === result.value
17786
17741
  );
17742
+ if (initializerResult !== void 0 && rootIndex === -1) {
17743
+ assertExportedPlacement(
17744
+ result.value,
17745
+ initializerResult.member,
17746
+ runtimeCtx
17747
+ );
17748
+ }
17787
17749
  const exported2 = exportInitializerCollections(
17788
17750
  created,
17789
17751
  writes,
@@ -17838,11 +17800,17 @@ function evaluateNSGetterWithEffects(getter, ctx, argumentValues = [], options =
17838
17800
  finalizeConstructorAllocations(runtimeCtx, void 0, ownsInvocationState);
17839
17801
  throw new NSGetterRuntimeError("Function ended without a return statement");
17840
17802
  }
17803
+ function assertExportedPlacement(value, member, ctx) {
17804
+ if (!isMemberClassBase(member) && !isMemberWithEntries(member)) return;
17805
+ const existing = trackedRowForValueReference(value, ctx);
17806
+ if (existing === null) return;
17807
+ assertInitializerPlacement(existing.id, member, ctx);
17808
+ }
17841
17809
  function evaluateNSFunction(action, ctx, args) {
17842
17810
  const ownsInvocationState = ctx.__executionState === void 0;
17843
17811
  const requestedWrites = [];
17844
17812
  const runtimeCtx = withEvaluationRuntime(ctx, requestedWrites);
17845
- consumeBudget(runtimeCtx, "workUnits", 1, "work unit");
17813
+ checkDeadline(runtimeCtx);
17846
17814
  const writes = runtimeCtx.__executionState?.writes ?? requestedWrites;
17847
17815
  const writeCheckpoint = writes.length;
17848
17816
  const creationCheckpoint = sessionCreationCheckpoint(runtimeCtx);
@@ -17971,63 +17939,15 @@ function withEvaluationRuntime(ctx, writes) {
17971
17939
  constructionTimestamp: Date.now(),
17972
17940
  ownedValueAttachments: /* @__PURE__ */ new Map(),
17973
17941
  constructionStack: [],
17974
- openConstructions: /* @__PURE__ */ new Map(),
17975
- loopIterations: 0,
17976
- budgetedConstructedRowIds: /* @__PURE__ */ new Set(),
17977
- budgetedProducedEntriesByRowId: /* @__PURE__ */ new Map(),
17978
- budget: ctx.sharedExecutionBudget ?? createNeoScriptExecutionBudget(ctx.executionBudgetLimits)
17942
+ openConstructions: /* @__PURE__ */ new Map()
17979
17943
  },
17980
17944
  __indexes: ctx.__executionState === void 0 || ctx.__valueOverlay === void 0 ? void 0 : ctx.__indexes
17981
17945
  };
17982
17946
  }
17983
- function createNeoScriptExecutionBudget(requested) {
17984
- const limits = { ...DEFAULT_NEO_SCRIPT_EXECUTION_BUDGET_LIMITS };
17985
- for (const key of Object.keys(limits)) {
17986
- const value = requested?.[key];
17987
- if (value === void 0) continue;
17988
- if (!Number.isSafeInteger(value)) {
17989
- throw new NeoScriptResourceLimitError(
17990
- `NeoScript ${key} limit must be a safe integer.`
17991
- );
17992
- }
17993
- if (value < 0) {
17994
- throw new NeoScriptResourceLimitError(
17995
- `NeoScript ${key} limit must not be negative.`
17996
- );
17997
- }
17998
- if (value > DEFAULT_NEO_SCRIPT_EXECUTION_BUDGET_LIMITS[key]) {
17999
- throw new NeoScriptResourceLimitError(
18000
- `NeoScript ${key} limit cannot exceed the safety ceiling of ${DEFAULT_NEO_SCRIPT_EXECUTION_BUDGET_LIMITS[key]}.`
18001
- );
18002
- }
18003
- limits[key] = value;
18004
- }
18005
- return {
18006
- limits,
18007
- workUnits: 0,
18008
- collectionVisits: 0,
18009
- producedCollectionEntries: 0,
18010
- constructedSessionRows: 0,
18011
- producedStringCharacters: 0
18012
- };
18013
- }
18014
- function consumeBudget(ctx, counter, amount, label) {
17947
+ function checkDeadline(ctx) {
18015
17948
  if (ctx.wallClockDeadlineMs !== void 0 && Date.now() >= ctx.wallClockDeadlineMs) {
18016
17949
  throw new NeoScriptWallClockTimeoutError();
18017
17950
  }
18018
- const budget = ctx.__executionState?.budget;
18019
- if (budget === void 0) {
18020
- throw new NSGetterRuntimeError(
18021
- "NeoScript work executed without a shared execution budget."
18022
- );
18023
- }
18024
- const limit = budget.limits[counter];
18025
- if (amount > limit - budget[counter]) {
18026
- throw new NeoScriptResourceLimitError(
18027
- `NeoScript ${label} limit of ${limit} exceeded.`
18028
- );
18029
- }
18030
- budget[counter] += amount;
18031
17951
  }
18032
17952
  function staticBindingMap(bindings) {
18033
17953
  if (bindings === void 0) return /* @__PURE__ */ new Map();
@@ -18779,21 +18699,6 @@ function createTopLevelScope(ctx) {
18779
18699
  );
18780
18700
  return scope;
18781
18701
  }
18782
- function consumeLoopIteration(ctx) {
18783
- const state = ctx.__executionState;
18784
- if (state === void 0) {
18785
- throw new NSGetterRuntimeError(
18786
- "NeoScript loop executed without a shared execution state."
18787
- );
18788
- }
18789
- if (state.loopIterations >= MAX_LOOP_ITERATIONS) {
18790
- throw new NeoScriptResourceLimitError(
18791
- `NeoScript loop iteration limit of ${MAX_LOOP_ITERATIONS} exceeded.`
18792
- );
18793
- }
18794
- state.loopIterations += 1;
18795
- consumeBudget(ctx, "workUnits", 1, "work unit");
18796
- }
18797
18702
  function synchronizeExistingBindings(parent, child, bindingIds) {
18798
18703
  for (const bindingId of bindingIds) {
18799
18704
  parent.setLocal(bindingId, child.get(bindingId));
@@ -18998,7 +18903,7 @@ function positionNeoScriptFrame(ctx, position) {
18998
18903
  function evalInstructions(instructions, scope, ctx, options) {
18999
18904
  for (const ins of instructions) {
19000
18905
  try {
19001
- consumeBudget(ctx, "workUnits", 1, "work unit");
18906
+ checkDeadline(ctx);
19002
18907
  switch (ins.type) {
19003
18908
  case "debug" /* debug */: {
19004
18909
  const condition = ins.condition === void 0 ? false : evalPointer(ins.condition, scope, ctx);
@@ -19167,7 +19072,7 @@ function evalInstructions(instructions, scope, ctx, options) {
19167
19072
  let firstIteration = ins.type === "doWhile" /* doWhile */;
19168
19073
  while (firstIteration || evalBooleanExpression(ins.condition, scope, ctx)) {
19169
19074
  firstIteration = false;
19170
- consumeLoopIteration(ctx);
19075
+ checkDeadline(ctx);
19171
19076
  const result = evalInstructionsInChildScope(
19172
19077
  ins.instructions,
19173
19078
  scope,
@@ -19190,7 +19095,7 @@ function evalInstructions(instructions, scope, ctx, options) {
19190
19095
  );
19191
19096
  loopScope.setLocal(ins.initializer.id, initialValue);
19192
19097
  while (evalBooleanExpression(ins.condition, loopScope, ctx)) {
19193
- consumeLoopIteration(ctx);
19098
+ checkDeadline(ctx);
19194
19099
  const result = evalInstructionsInChildScope(
19195
19100
  ins.instructions,
19196
19101
  loopScope,
@@ -19218,7 +19123,7 @@ function evalInstructions(instructions, scope, ctx, options) {
19218
19123
  );
19219
19124
  try {
19220
19125
  for (const rawEntry of membership) {
19221
- consumeLoopIteration(ctx);
19126
+ checkDeadline(ctx);
19222
19127
  loopScope.setLocal(
19223
19128
  ins.binding.id,
19224
19129
  coerceAssignmentValue(
@@ -19831,9 +19736,8 @@ function applyOverlayAssignment(target, targetTypeInfo, value, scope, ctx, desti
19831
19736
  ctx.__valueOverlay
19832
19737
  );
19833
19738
  if (row !== null) {
19834
- row.value = value;
19739
+ replaceRowValue(row, value, receiver, ctx);
19835
19740
  updateUnorderedListProjectionAfterAssignment(row, value, ctx);
19836
- invalidateEvaluatorIndexes(ctx, receiver);
19837
19741
  return;
19838
19742
  }
19839
19743
  }
@@ -19869,15 +19773,28 @@ function applyOverlayAssignment(target, targetTypeInfo, value, scope, ctx, desti
19869
19773
  ctx.__valueOverlay
19870
19774
  );
19871
19775
  if (row !== null) {
19872
- row.value = value;
19776
+ replaceRowValue(row, value, receiver, ctx);
19873
19777
  updateUnorderedListProjectionAfterAssignment(row, value, ctx);
19874
- invalidateEvaluatorIndexes(ctx, receiver);
19875
19778
  return;
19876
19779
  }
19877
19780
  }
19878
19781
  object[stringKey] = value;
19879
19782
  invalidateEvaluatorIndexes(ctx, receiver);
19880
19783
  }
19784
+ function replaceRowValue(row, value, receiver, ctx) {
19785
+ const indexes3 = ctx.__indexes;
19786
+ if (indexes3 === void 0 || ctx.__runtimeSessionValues?.get(row.id) !== row || !indexes3.indexedRowIds.has(row.id)) {
19787
+ row.value = value;
19788
+ invalidateEvaluatorIndexes(ctx, receiver);
19789
+ return;
19790
+ }
19791
+ unindexEvaluatorRow(indexes3, row, true);
19792
+ row.value = value;
19793
+ indexEvaluatorRow(indexes3, row, true);
19794
+ markOverlayMutated(ctx, receiver);
19795
+ if (ctx.__valueOverlay instanceof LazyValueOverlay)
19796
+ indexes3.overlayRevision = ctx.__valueOverlay.revision;
19797
+ }
19881
19798
  function applyOverlayStaticAssignment(memberId, value, ctx) {
19882
19799
  const member = evalMemberById(ctx.vm, memberId);
19883
19800
  if (member === null || !isStaticMember(member)) {
@@ -20117,7 +20034,7 @@ function resolvedDestinationFieldsForContainer(targetValue, ctx) {
20117
20034
  return containerValueId === null ? {} : { resolvedDestination: { containerValueId } };
20118
20035
  }
20119
20036
  function dispatchNSSetter(target, value, scope, ctx, writes) {
20120
- consumeBudget(ctx, "workUnits", 1, "work unit");
20037
+ checkDeadline(ctx);
20121
20038
  if (target.type !== "callGetter" /* callGetter */) {
20122
20039
  throw new NSGetterRuntimeError(
20123
20040
  "Setter write target must be a callGetter pointer."
@@ -20245,14 +20162,6 @@ function evalCollectionMutationInstruction(ins, scope, ctx, options) {
20245
20162
  if (ins.mutation === "Remove" /* Remove */ && setEntryMember !== null && setMatch === null) {
20246
20163
  return;
20247
20164
  }
20248
- if (ins.mutation === "Add" /* Add */ || ins.mutation === "Insert" /* Insert */) {
20249
- consumeBudget(
20250
- ctx,
20251
- "producedCollectionEntries",
20252
- 1,
20253
- "produced collection entry"
20254
- );
20255
- }
20256
20165
  if (mutatesLocalVariable && variablePointer !== null) {
20257
20166
  if (isLookupSet && (ins.mutation === "Add" /* Add */ || ins.mutation === "Remove" /* Remove */)) {
20258
20167
  args[0] = lookupSetSelectionValue(args[0], ins.target.typeInfo, ctx);
@@ -20272,8 +20181,7 @@ function evalCollectionMutationInstruction(ins, scope, ctx, options) {
20272
20181
  removedIndex2,
20273
20182
  ctx
20274
20183
  );
20275
- if (Array.isArray(targetValue)) ctx.__setEntryIndexes?.delete(targetValue);
20276
- invalidateEvaluatorIndexes(ctx, targetValue);
20184
+ if (Array.isArray(targetValue)) forgetLocalListIndexes(ctx, targetValue);
20277
20185
  scope.setLocal(variablePointer.variableId, targetValue);
20278
20186
  return;
20279
20187
  }
@@ -20298,8 +20206,7 @@ function evalCollectionMutationInstruction(ins, scope, ctx, options) {
20298
20206
  overlayArgs[0] = createUnorderedScalarProjectionEntry(
20299
20207
  unorderedContainerValueId,
20300
20208
  args[0],
20301
- ctx,
20302
- false
20209
+ ctx
20303
20210
  );
20304
20211
  }
20305
20212
  const unorderedEntriesBeforeMutation = unorderedContainerValueId === null || !Array.isArray(targetValue) || ins.mutation === "Add" /* Add */ ? null : [...targetValue];
@@ -20471,7 +20378,6 @@ function storedSetEntries(set, entryMember, ctx) {
20471
20378
  const indexes3 = ctx.__setEntryIndexes ??= /* @__PURE__ */ new WeakMap();
20472
20379
  const existing = indexes3.get(set);
20473
20380
  if (existing !== void 0) return existing;
20474
- consumeBudget(ctx, "collectionVisits", set.length, "collection visit");
20475
20381
  const entries = /* @__PURE__ */ new Map();
20476
20382
  for (const raw of set) {
20477
20383
  const match = storedSetEntryMatch(raw, entryMember, ctx);
@@ -20507,12 +20413,6 @@ function applyLocalCollectionMutation(targetValue, mutation, args, ctx, unique =
20507
20413
  case "Insert" /* Insert */: {
20508
20414
  const list = listArg(targetValue, "Insert target");
20509
20415
  const index = numberArg(args[0], "Insert index");
20510
- consumeBudget(
20511
- ctx,
20512
- "collectionVisits",
20513
- list.length - index,
20514
- "collection visit"
20515
- );
20516
20416
  list.splice(index, 0, args[1]);
20517
20417
  return index;
20518
20418
  }
@@ -20521,7 +20421,6 @@ function applyLocalCollectionMutation(targetValue, mutation, args, ctx, unique =
20521
20421
  let alreadyPresent = false;
20522
20422
  if (unique) {
20523
20423
  for (const entry of targetValue) {
20524
- consumeBudget(ctx, "collectionVisits", 1, "collection visit");
20525
20424
  if (reference ? referenceEqual(entry, args[0], ctx) : jsEqual(entry, args[0])) {
20526
20425
  alreadyPresent = true;
20527
20426
  break;
@@ -20539,7 +20438,6 @@ function applyLocalCollectionMutation(targetValue, mutation, args, ctx, unique =
20539
20438
  if (Array.isArray(targetValue)) {
20540
20439
  let index = -1;
20541
20440
  for (let candidate = 0; candidate < targetValue.length; candidate += 1) {
20542
- consumeBudget(ctx, "collectionVisits", 1, "collection visit");
20543
20441
  const entry = targetValue[candidate];
20544
20442
  if (reference) {
20545
20443
  if (referenceEqual(entry, args[0], ctx)) {
@@ -20573,17 +20471,10 @@ function applyLocalCollectionMutation(targetValue, mutation, args, ctx, unique =
20573
20471
  }
20574
20472
  case "Clear" /* Clear */:
20575
20473
  if (Array.isArray(targetValue)) {
20576
- consumeBudget(
20577
- ctx,
20578
- "collectionVisits",
20579
- targetValue.length,
20580
- "collection visit"
20581
- );
20582
20474
  targetValue.length = 0;
20583
20475
  return null;
20584
20476
  }
20585
20477
  const keys = Object.keys(objectArg(targetValue, "Clear target"));
20586
- consumeBudget(ctx, "collectionVisits", keys.length, "collection visit");
20587
20478
  for (const key of keys) {
20588
20479
  delete objectArg(targetValue, "Clear target")[key];
20589
20480
  }
@@ -20870,20 +20761,8 @@ function evalPointerCore(pointer, scope, ctx, resultUsage = "value") {
20870
20761
  case "function" /* function */:
20871
20762
  return evalFunction(pointer.function, scope, ctx);
20872
20763
  case "listLiteral" /* listLiteral */:
20873
- consumeBudget(
20874
- ctx,
20875
- "producedCollectionEntries",
20876
- pointer.entries.length,
20877
- "produced collection entry"
20878
- );
20879
20764
  return pointer.entries.map((e) => evalPointer(e, scope, ctx));
20880
20765
  case "dictLiteral" /* dictLiteral */: {
20881
- consumeBudget(
20882
- ctx,
20883
- "producedCollectionEntries",
20884
- pointer.entries.length,
20885
- "produced collection entry"
20886
- );
20887
20766
  const out = {};
20888
20767
  for (const e of pointer.entries) {
20889
20768
  const k = evalPointer(e.key, scope, ctx);
@@ -20949,7 +20828,7 @@ function evalPointerCore(pointer, scope, ctx, resultUsage = "value") {
20949
20828
  }
20950
20829
  const args = fillCallableCallSiteArguments(suppliedArgs, member, ctx);
20951
20830
  const interceptedMemberId = member?.id ?? pointer.memberId ?? pointer.memberKey ?? pointer.callSiteId;
20952
- consumeBudget(ctx, "workUnits", 1, "work unit");
20831
+ checkDeadline(ctx);
20953
20832
  const intercepted = ctx.callInterceptor?.({
20954
20833
  resultUsage,
20955
20834
  memberId: interceptedMemberId,
@@ -21092,7 +20971,7 @@ function evalPointerCore(pointer, scope, ctx, resultUsage = "value") {
21092
20971
  case "callAction" /* callAction */: {
21093
20972
  const read = readActionWithOwner(pointer.action, scope, ctx);
21094
20973
  const args = pointer.args.map((arg) => evalPointer(arg, scope, ctx));
21095
- consumeBudget(ctx, "workUnits", 1, "work unit");
20974
+ checkDeadline(ctx);
21096
20975
  invokeActionListeners(
21097
20976
  actionListenersOf(
21098
20977
  read.action,
@@ -21150,12 +21029,6 @@ function evalPointerCore(pointer, scope, ctx, resultUsage = "value") {
21150
21029
  case "stringify" /* stringify */: {
21151
21030
  const v = evalPointer(pointer.pointer, scope, ctx);
21152
21031
  const formatted = formatForInterp(v, pointer.sourceType, ctx);
21153
- consumeBudget(
21154
- ctx,
21155
- "producedStringCharacters",
21156
- formatted.length,
21157
- "produced string character"
21158
- );
21159
21032
  return formatted;
21160
21033
  }
21161
21034
  }
@@ -21283,7 +21156,7 @@ function invokeDelegateValue(value, args, ctx, callSiteId, ownerReceiver, result
21283
21156
  ].join(" -> ")}.`
21284
21157
  );
21285
21158
  }
21286
- consumeBudget(ctx, "workUnits", 1, "work unit");
21159
+ checkDeadline(ctx);
21287
21160
  const intercept = () => ctx.callInterceptor?.({
21288
21161
  resultUsage,
21289
21162
  memberId: member.id,
@@ -22678,7 +22551,7 @@ function createUnorderedListProjectionCache() {
22678
22551
  referenceEntryKeysByRecord: /* @__PURE__ */ new WeakMap()
22679
22552
  };
22680
22553
  }
22681
- function createUnorderedScalarProjectionEntry(containerValueId, value, ctx, consumeEntryBudget = true) {
22554
+ function createUnorderedScalarProjectionEntry(containerValueId, value, ctx) {
22682
22555
  const container = evalValueById(
22683
22556
  ctx,
22684
22557
  containerValueId,
@@ -22690,14 +22563,6 @@ function createUnorderedScalarProjectionEntry(containerValueId, value, ctx, cons
22690
22563
  `Unordered List container '${containerValueId}' is missing.`
22691
22564
  );
22692
22565
  }
22693
- if (consumeEntryBudget) {
22694
- consumeBudget(
22695
- ctx,
22696
- "producedCollectionEntries",
22697
- 1,
22698
- "produced collection entry"
22699
- );
22700
- }
22701
22566
  ctx.beforeValueAllocation?.();
22702
22567
  const now = Date.now();
22703
22568
  const row = {
@@ -23085,9 +22950,16 @@ function readCellPattern(value, ctx) {
23085
22950
  }
23086
22951
  return offsets;
23087
22952
  }
22953
+ function readGridQueryOffset(value) {
22954
+ if (value === void 0 || value === null) return null;
22955
+ if (!isVector2IntValue(value)) {
22956
+ throw new NSGetterRuntimeError("Grid query offset must be a Vector2Int.");
22957
+ }
22958
+ return value;
22959
+ }
23088
22960
  function evaluateSystemNative(memberId, receiver, args, ctx) {
23089
22961
  try {
23090
- if (memberId === NEO_OBJECT_GRID_MEMBER_IDS.GetCell || memberId === NEO_OBJECT_GRID_MEMBER_IDS.GetObjects || memberId === NEO_OBJECT_GRID_MEMBER_IDS.GetTile) {
22962
+ if (memberId === NEO_OBJECT_GRID_MEMBER_IDS.GetCell || memberId === NEO_OBJECT_GRID_MEMBER_IDS.GetObjects || memberId === NEO_OBJECT_GRID_MEMBER_IDS.GetTile || memberId === NEO_OBJECT_GRID_MEMBER_IDS.GetTiles) {
23091
22963
  const receiverRow = trackedRowForValueReference(receiver, ctx);
23092
22964
  if (receiverRow === null) {
23093
22965
  throw new NSGetterRuntimeError(
@@ -23102,21 +22974,31 @@ function evaluateSystemNative(memberId, receiver, args, ctx) {
23102
22974
  if (memberId === NEO_OBJECT_GRID_MEMBER_IDS.GetCell)
23103
22975
  return { handled: true, value: { ...placement.cell } };
23104
22976
  const offsets = readCellPattern(args[0], ctx);
22977
+ const shift = readGridQueryOffset(args[1]);
23105
22978
  if (memberId === NEO_OBJECT_GRID_MEMBER_IDS.GetObjects) {
23106
22979
  const value = index.objects(
23107
22980
  placement,
23108
22981
  offsets,
23109
22982
  ctx.worldQueryDependencies,
23110
- (count) => consumeBudget(
23111
- ctx,
23112
- "producedCollectionEntries",
23113
- count,
23114
- "collection entry"
23115
- )
22983
+ shift
22984
+ );
22985
+ return { handled: true, value };
22986
+ }
22987
+ if (memberId === NEO_OBJECT_GRID_MEMBER_IDS.GetTiles) {
22988
+ const value = index.tiles(
22989
+ placement,
22990
+ offsets,
22991
+ ctx.worldQueryDependencies,
22992
+ shift
23116
22993
  );
23117
22994
  return { handled: true, value };
23118
22995
  }
23119
- const tile = index.tile(placement, offsets, ctx.worldQueryDependencies);
22996
+ const tile = index.tile(
22997
+ placement,
22998
+ offsets,
22999
+ ctx.worldQueryDependencies,
23000
+ shift
23001
+ );
23120
23002
  if (tile === null) return { handled: true, value: null };
23121
23003
  const row = evalValueById(
23122
23004
  ctx,
@@ -23164,14 +23046,7 @@ function evaluateSystemNative(memberId, receiver, args, ctx) {
23164
23046
  },
23165
23047
  createTopLevelScope(ctx),
23166
23048
  ctx
23167
- ),
23168
- reserveEntries: (count) => consumeBudget(
23169
- ctx,
23170
- "producedCollectionEntries",
23171
- count,
23172
- "collection entry"
23173
- ),
23174
- visitEntries: (count) => consumeBudget(ctx, "collectionVisits", count, "collection visit")
23049
+ )
23175
23050
  });
23176
23051
  } catch (error) {
23177
23052
  if (error instanceof RangeError || error instanceof TypeError || error instanceof WorldGridQueryError) {
@@ -23243,22 +23118,10 @@ function applyArithmetic(op, operands, decimal, ctx, numeric) {
23243
23118
  }
23244
23119
  if (op === "+" /* addition */ && operands.every((o) => typeof o === "string")) {
23245
23120
  const result = operands.join("");
23246
- consumeBudget(
23247
- ctx,
23248
- "producedStringCharacters",
23249
- result.length,
23250
- "produced string character"
23251
- );
23252
23121
  return result;
23253
23122
  }
23254
23123
  if (op === "+" /* addition */ && operands.some((o) => typeof o === "string")) {
23255
23124
  const result = operands.map((o) => stringifyForInterp(o)).join("");
23256
- consumeBudget(
23257
- ctx,
23258
- "producedStringCharacters",
23259
- result.length,
23260
- "produced string character"
23261
- );
23262
23125
  return result;
23263
23126
  }
23264
23127
  const numbers = operands.map((o) => {
@@ -23536,12 +23399,6 @@ function evalListRepeat(info, scope, ctx) {
23536
23399
  `List.Repeat count must be non-negative; got ${count}.`
23537
23400
  );
23538
23401
  }
23539
- consumeBudget(
23540
- ctx,
23541
- "producedCollectionEntries",
23542
- count,
23543
- "produced collection entry"
23544
- );
23545
23402
  return new Array(count).fill(value);
23546
23403
  }
23547
23404
  function stringifyForInterp(v) {
@@ -23849,7 +23706,7 @@ function prepareCollectionCallback(callback, parentScope, ctx, isList, returnCon
23849
23706
  if (ctx.__collectionCallbackStrategy === "fresh" || ctx.__collectionCallbackStrategy === "prepared") {
23850
23707
  return (entry, key, valueId) => {
23851
23708
  if (onPredicateMatch !== void 0) {
23852
- consumeBudget(ctx, "workUnits", 1, "work unit");
23709
+ checkDeadline(ctx);
23853
23710
  }
23854
23711
  const boundEntry = coerceAssignmentValue(
23855
23712
  entry,
@@ -23912,14 +23769,14 @@ function prepareCollectionCallback(callback, parentScope, ctx, isList, returnCon
23912
23769
  }
23913
23770
  if (requiresInvocationReset) {
23914
23771
  return (entry, key, valueId) => {
23915
- consumeBudget(ctx, "workUnits", 1, "work unit");
23772
+ checkDeadline(ctx);
23916
23773
  innerScope.resetInvocationLocals(parameterCount);
23917
23774
  bindValues(entry, key);
23918
23775
  return finishBody(innerScope) === true ? onPredicateMatch(entry, key, valueId) : 0 /* Continue */;
23919
23776
  };
23920
23777
  }
23921
23778
  return (entry, key, valueId) => {
23922
- consumeBudget(ctx, "workUnits", 1, "work unit");
23779
+ checkDeadline(ctx);
23923
23780
  bindValues(entry, key);
23924
23781
  return finishBody(innerScope) === true ? onPredicateMatch(entry, key, valueId) : 0 /* Continue */;
23925
23782
  };
@@ -23988,7 +23845,7 @@ function evalCollectionQuery(info, scope, ctx) {
23988
23845
  ) : null;
23989
23846
  const invoke = (entry, key, valueId) => {
23990
23847
  if (!callback) return true;
23991
- consumeBudget(ctx, "workUnits", 1, "work unit");
23848
+ checkDeadline(ctx);
23992
23849
  return callback(entry, key, valueId);
23993
23850
  };
23994
23851
  if (info.op === "Any" || info.op === "All" || info.op === "Last" || info.op === "LastOrDefault" || info.op === "Single" || info.op === "SingleOrDefault") {
@@ -24024,12 +23881,6 @@ function evalCollectionQuery(info, scope, ctx) {
24024
23881
  const output = [];
24025
23882
  let references = /* @__PURE__ */ new Set();
24026
23883
  const append2 = (entry, _key, valueId) => {
24027
- consumeBudget(
24028
- ctx,
24029
- "producedCollectionEntries",
24030
- 1,
24031
- "produced collection entry"
24032
- );
24033
23884
  if (valueId !== null && !info.enumEntries) references.add(output.length);
24034
23885
  output.push(collectionQueryEntry(entry, valueId, info.enumEntries));
24035
23886
  return 0 /* Continue */;
@@ -24046,12 +23897,6 @@ function evalCollectionQuery(info, scope, ctx) {
24046
23897
  let entries = [];
24047
23898
  iterateCollection(collection, ctx, (entry, key, valueId) => {
24048
23899
  const sortKey = invoke(entry, key, valueId);
24049
- consumeBudget(
24050
- ctx,
24051
- "producedCollectionEntries",
24052
- 1,
24053
- "produced collection entry"
24054
- );
24055
23900
  entries.push({ entry, valueId, key: sortKey });
24056
23901
  return 0 /* Continue */;
24057
23902
  });
@@ -24065,7 +23910,6 @@ function evalCollectionQuery(info, scope, ctx) {
24065
23910
  for (let destination = start; destination < end; destination++) {
24066
23911
  let useLeft = right >= end;
24067
23912
  if (left < middle && right < end) {
24068
- consumeBudget(ctx, "workUnits", 1, "work unit");
24069
23913
  const order = compareCollectionKeys(
24070
23914
  entries[left].key,
24071
23915
  entries[right].key,
@@ -24408,32 +24252,14 @@ function evalFunction(fn, scope, ctx) {
24408
24252
  switch (fn.info.op) {
24409
24253
  case "toLower": {
24410
24254
  const result = receiver.toLowerCase();
24411
- consumeBudget(
24412
- ctx,
24413
- "producedStringCharacters",
24414
- result.length,
24415
- "produced string character"
24416
- );
24417
24255
  return result;
24418
24256
  }
24419
24257
  case "toUpper": {
24420
24258
  const result = receiver.toUpperCase();
24421
- consumeBudget(
24422
- ctx,
24423
- "producedStringCharacters",
24424
- result.length,
24425
- "produced string character"
24426
- );
24427
24259
  return result;
24428
24260
  }
24429
24261
  case "trim": {
24430
24262
  const result = receiver.trim();
24431
- consumeBudget(
24432
- ctx,
24433
- "producedStringCharacters",
24434
- result.length,
24435
- "produced string character"
24436
- );
24437
24263
  return result;
24438
24264
  }
24439
24265
  case "replace": {
@@ -24463,32 +24289,7 @@ function evalFunction(fn, scope, ctx) {
24463
24289
  throw new NSGetterRuntimeError(
24464
24290
  "string.Replace search must not be empty."
24465
24291
  );
24466
- let count = 0;
24467
- let offset = 0;
24468
- let match = receiver.indexOf(search, offset);
24469
- while (match !== -1) {
24470
- consumeBudget(ctx, "workUnits", 1, "work unit");
24471
- count++;
24472
- offset = match + search.length;
24473
- match = receiver.indexOf(search, offset);
24474
- }
24475
- consumeBudget(
24476
- ctx,
24477
- "producedStringCharacters",
24478
- receiver.length + count * (replacement.length - search.length),
24479
- "produced string character"
24480
- );
24481
- if (count === 0) return receiver;
24482
- const parts = [];
24483
- offset = 0;
24484
- match = receiver.indexOf(search, offset);
24485
- while (match !== -1) {
24486
- parts.push(receiver.slice(offset, match), replacement);
24487
- offset = match + search.length;
24488
- match = receiver.indexOf(search, offset);
24489
- }
24490
- parts.push(receiver.slice(offset));
24491
- return parts.join("");
24292
+ return receiver.split(search).join(replacement);
24492
24293
  }
24493
24294
  case "startsWith":
24494
24295
  case "endsWith": {
@@ -24522,12 +24323,6 @@ function evalFunction(fn, scope, ctx) {
24522
24323
  isList,
24523
24324
  "predicate",
24524
24325
  (entry, key, valueId) => {
24525
- consumeBudget(
24526
- ctx,
24527
- "producedCollectionEntries",
24528
- 1,
24529
- "produced collection entry"
24530
- );
24531
24326
  if (isList) {
24532
24327
  if (valueId !== null) {
24533
24328
  referenceEntryIndexes.add(out.length);
@@ -24601,14 +24396,8 @@ function evalFunction(fn, scope, ctx) {
24601
24396
  );
24602
24397
  const out = [];
24603
24398
  iterateCollection(c, ctx, (entry, key, valueId) => {
24604
- consumeBudget(ctx, "workUnits", 1, "work unit");
24399
+ checkDeadline(ctx);
24605
24400
  const value = callback(entry, key, valueId);
24606
- consumeBudget(
24607
- ctx,
24608
- "producedCollectionEntries",
24609
- 1,
24610
- "produced collection entry"
24611
- );
24612
24401
  out.push(value);
24613
24402
  return 0 /* Continue */;
24614
24403
  });
@@ -25161,31 +24950,6 @@ function publishConstructedRows(args) {
25161
24950
  "Class construction requires an effect-capable evaluator Session scope."
25162
24951
  );
25163
24952
  }
25164
- let newlyConstructedRows = 0;
25165
- let newlyProducedEntries = 0;
25166
- for (const row of createdValues) {
25167
- if (!state.budgetedConstructedRowIds.has(row.id)) {
25168
- state.budgetedConstructedRowIds.add(row.id);
25169
- newlyConstructedRows += 1;
25170
- }
25171
- const currentEntries = Array.isArray(row.value) ? row.value.length : typeof row.value === "object" && row.value !== null ? Object.keys(row.value).length : 0;
25172
- const priorEntries = state.budgetedProducedEntriesByRowId.get(row.id) ?? 0;
25173
- if (currentEntries <= priorEntries) continue;
25174
- newlyProducedEntries += currentEntries - priorEntries;
25175
- state.budgetedProducedEntriesByRowId.set(row.id, currentEntries);
25176
- }
25177
- consumeBudget(
25178
- ctx,
25179
- "constructedSessionRows",
25180
- newlyConstructedRows,
25181
- "constructed Session row"
25182
- );
25183
- consumeBudget(
25184
- ctx,
25185
- "producedCollectionEntries",
25186
- newlyProducedEntries,
25187
- "produced collection entry"
25188
- );
25189
24953
  const retained = retainedIds;
25190
24954
  if (beforeRetain !== null) {
25191
24955
  for (const rowId of beforeRetain) {
@@ -26002,6 +25766,11 @@ function evaluateInitializerInContext(init, member, ctx, createdValues, argument
26002
25766
  existingValueRow
26003
25767
  };
26004
25768
  }
25769
+ if (existingValueRow !== null && (isMemberClassBase(member) || isMemberWithEntries(member)) && argumentValues.some(
25770
+ (argument2) => trackedRowForValueReference(argument2, ctx)?.id === existingValueRow.id
25771
+ )) {
25772
+ assertInitializerPlacement(existingValueRow.id, member, ctx);
25773
+ }
26005
25774
  if (existingValueRow !== null && existingRuntimeClassId !== null && isMemberClassBase(member)) {
26006
25775
  const storage = constructorArgumentStorage(existingValueRow.id, ctx);
26007
25776
  if (storage !== 3 /* Session */) {
@@ -26706,7 +26475,6 @@ function applyVariantDeclarativeHalves(instance, graph, ctx, answeredValueIds) {
26706
26475
  }
26707
26476
  const entries = listRow.value;
26708
26477
  if (!Array.isArray(entries)) return;
26709
- consumeBudget(ctx, "workUnits", entries.length, "work unit");
26710
26478
  for (const entryId of entries) {
26711
26479
  if (typeof entryId !== "string") continue;
26712
26480
  const entryRow = evalValueById(
@@ -26847,7 +26615,6 @@ function collectVariantDeclarativeAnsweredSlots(instance, graph, ctx) {
26847
26615
  );
26848
26616
  }
26849
26617
  if (!Array.isArray(listRow.value)) return slots;
26850
- consumeBudget(ctx, "workUnits", listRow.value.length, "work unit");
26851
26618
  for (const entryId of listRow.value) {
26852
26619
  if (typeof entryId !== "string") continue;
26853
26620
  const entryRow = evalValueById(
@@ -26885,7 +26652,6 @@ function collectVariantDeclarativeAnsweredSlots(instance, graph, ctx) {
26885
26652
  return slots;
26886
26653
  }
26887
26654
  function evalVariantInitialize(info, scope, ctx) {
26888
- consumeBudget(ctx, "workUnits", 1, "work unit");
26889
26655
  const selection = readVariantSelection(
26890
26656
  evalPointer(info.variantPointer, scope, ctx),
26891
26657
  "Variant.Initialize receiver"
@@ -26942,7 +26708,6 @@ function evalVariantInitialize(info, scope, ctx) {
26942
26708
  }
26943
26709
  }
26944
26710
  function evalVariantApply(info, scope, ctx) {
26945
- consumeBudget(ctx, "workUnits", 1, "work unit");
26946
26711
  const receiver = evalPointer(info.receiverPointer, scope, ctx);
26947
26712
  if (receiver === null || receiver === void 0) {
26948
26713
  throw new NSGetterRuntimeError(
@@ -27060,6 +26825,15 @@ function constructDeclaredClassValue(info, scope, ctx) {
27060
26825
  closeFrame();
27061
26826
  }
27062
26827
  }
26828
+ function positionAtPassingArgument(error, info, record4, argumentValues, ctx) {
26829
+ if (error.attachedValueId === void 0 || record4 === null) return;
26830
+ const index = argumentValues.findIndex(
26831
+ (value) => findKnownRowIdByValueReference(value, ctx) === error.attachedValueId
26832
+ );
26833
+ const name = record4.argumentTypes[index]?.name;
26834
+ const argument2 = info.args.find((candidate) => candidate.name === name);
26835
+ if (argument2 !== void 0) error.at(argument2.valuePointer);
26836
+ }
27063
26837
  function constructDeclaredClassValueWithinFrame(descriptor, record4, info, scope, ctx) {
27064
26838
  const schemaClass2 = descriptor.schemaClass;
27065
26839
  const classId = schemaClass2.id;
@@ -27102,7 +26876,10 @@ function constructDeclaredClassValueWithinFrame(descriptor, record4, info, scope
27102
26876
  root.classId = classId;
27103
26877
  stampConstructedRootGenericBindings(root, descriptor);
27104
26878
  } catch (error) {
27105
- if (error instanceof NSGetterRuntimeError) throw error;
26879
+ if (error instanceof NSGetterRuntimeError) {
26880
+ positionAtPassingArgument(error, info, record4, argumentValues, ctx);
26881
+ throw error;
26882
+ }
27106
26883
  throw new NSGetterRuntimeError(
27107
26884
  `Failed to construct '${schemaClass2.name}': ${error instanceof Error ? error.message : String(error)}`
27108
26885
  );
@@ -27265,9 +27042,11 @@ function assertOwnedValueAttachable(valueId, destination, destinationName, ctx,
27265
27042
  }
27266
27043
  for (const owner of currentOwnedValueAttachments(valueId, ctx)) {
27267
27044
  if (mode === "assign" && owner.identity === destination.identity) continue;
27268
- throw new NSGetterRuntimeError(
27045
+ const error = new NSGetterRuntimeError(
27269
27046
  `Aggregate value '${valueId}' is already owned by parent value '${owner.label}' and cannot be attached to '${destinationName}'. Call Clone() explicitly.`
27270
27047
  );
27048
+ error.attachedValueId = valueId;
27049
+ throw error;
27271
27050
  }
27272
27051
  const reserved = ctx.__executionState?.ownedValueAttachments.get(valueId);
27273
27052
  if (reserved !== void 0 && (mode === "insert" || reserved.identity !== destination.identity)) {
@@ -27292,6 +27071,16 @@ function assertOwnedValueAttachable(valueId, destination, destinationName, ctx,
27292
27071
  }
27293
27072
  recordConstructorGroupDependency(valueId, destination, ctx);
27294
27073
  }
27074
+ function assertInitializerPlacement(valueId, member, ctx) {
27075
+ const replayRowId = ctx.__storedConstructionReplayRowId;
27076
+ const memberId = Reflect.get(member, "id");
27077
+ const schemaKey = replayRowId === void 0 || typeof memberId !== "string" ? null : cachedSchemaKeyForMember(memberId, ctx);
27078
+ const destination = schemaKey === null ? { identity: `initializer:${member.name}`, label: member.name } : {
27079
+ identity: `value:${replayRowId}:slot:${schemaKey}`,
27080
+ label: member.name
27081
+ };
27082
+ assertOwnedValueAttachable(valueId, destination, member.name, ctx);
27083
+ }
27295
27084
  function currentOwnedValueAttachments(valueId, ctx) {
27296
27085
  const indexes3 = evaluatorIndexes(ctx);
27297
27086
  const cached = indexes3.ownedValueAttachmentsByValueId.get(valueId);
@@ -27353,7 +27142,7 @@ function currentOwnedValueAttachments(valueId, ctx) {
27353
27142
  if (parent.id === valueId) continue;
27354
27143
  let member = null;
27355
27144
  let classId = parent.classId;
27356
- if (classId === void 0) {
27145
+ if (classId === void 0 || classId === null) {
27357
27146
  member = activeStaticBindingRoot(parent.id, ctx)?.member ?? memberForValueRow(parent, ctx);
27358
27147
  if (member !== null) {
27359
27148
  try {
@@ -28399,7 +28188,6 @@ function collectionLength(c) {
28399
28188
  function snapshotCollectionMembership(collection, ctx) {
28400
28189
  const membership = [];
28401
28190
  const valid = forEachRawCollectionEntry(collection, (entry) => {
28402
- consumeBudget(ctx, "collectionVisits", 1, "collection visit");
28403
28191
  membership.push({
28404
28192
  raw: entry.raw,
28405
28193
  resolveAsReference: collectionEntryUsesReferenceResolution(
@@ -28444,7 +28232,6 @@ function forEachRawCollectionEntry(c, callback) {
28444
28232
  function collectionEntries(c, ctx) {
28445
28233
  const entries = [];
28446
28234
  forEachRawCollectionEntry(c, ({ raw, key }) => {
28447
- consumeBudget(ctx, "collectionVisits", 1, "collection visit");
28448
28235
  entries.push(resolveCollectionEntry(c, raw, key, ctx));
28449
28236
  return 0 /* Continue */;
28450
28237
  });
@@ -28454,7 +28241,6 @@ function referenceIndexOf(c, target, ctx) {
28454
28241
  const targetId = target === null || target === void 0 ? null : referenceIdOf(target, ctx);
28455
28242
  let found = null;
28456
28243
  forEachRawCollectionEntry(c, ({ raw, key }) => {
28457
- consumeBudget(ctx, "collectionVisits", 1, "collection visit");
28458
28244
  if (raw === target || targetId !== null && raw !== null && raw !== void 0 && referenceIdOf(raw, ctx) === targetId) {
28459
28245
  found = key;
28460
28246
  return 1 /* Break */;
@@ -28465,7 +28251,6 @@ function referenceIndexOf(c, target, ctx) {
28465
28251
  }
28466
28252
  function iterateCollection(c, ctx, callback) {
28467
28253
  forEachRawCollectionEntry(c, ({ raw, key, valueId }) => {
28468
- consumeBudget(ctx, "collectionVisits", 1, "collection visit");
28469
28254
  const effectiveValueId = collectionEntryUsesReferenceResolution(c, key, ctx) ? valueId : null;
28470
28255
  return callback(
28471
28256
  resolveCollectionEntry(c, raw, key, ctx),
@@ -28864,7 +28649,10 @@ function resolveMemberDeclaredTypeInfoInternal(member, members, seen, ownerClass
28864
28649
  };
28865
28650
  }
28866
28651
  const collectionKind = resolved.kind;
28867
- if (collectionKind === 6 /* List */ || collectionKind === 28 /* Set */ || collectionKind === 5 /* Dictionary */ && isMemberDictionaryBase(resolved)) {
28652
+ if (collectionKind === 5 /* Dictionary */ && !isMemberDictionaryBase(resolved)) {
28653
+ return null;
28654
+ }
28655
+ if (collectionKind === 6 /* List */ || collectionKind === 28 /* Set */ || collectionKind === 5 /* Dictionary */) {
28868
28656
  const entryMemberId = getField(resolved, "entryMemberId");
28869
28657
  const entry = members.find((candidate) => candidate.id === entryMemberId);
28870
28658
  if (entry === void 0) return null;
@@ -28927,6 +28715,10 @@ function genericParamTypeInfo(ownerClass, genericParamId, required) {
28927
28715
  }
28928
28716
 
28929
28717
  // ../packages/neoscript-runtime/src/values/constructor-argument-ownership.ts
28718
+ function recordEntries(value) {
28719
+ if (typeof value !== "object" || value === null) return [];
28720
+ return Object.values(value);
28721
+ }
28930
28722
  var MaterializedValueGraphContext = class {
28931
28723
  /**
28932
28724
  * P79 §7a. Generic in the caller's document view so a pass typed against a
@@ -28942,6 +28734,7 @@ var MaterializedValueGraphContext = class {
28942
28734
  constructorsById;
28943
28735
  contextualRootMembersByValueId;
28944
28736
  parameterTypesByRow = /* @__PURE__ */ new WeakMap();
28737
+ argumentInteriorTypesById;
28945
28738
  settleConstructorParameter;
28946
28739
  aggregateTypeByTargetValueId = /* @__PURE__ */ new Map();
28947
28740
  ownership;
@@ -29018,13 +28811,16 @@ var MaterializedValueGraphContext = class {
29018
28811
  }
29019
28812
  return result;
29020
28813
  }
29021
- constructorEdges(row) {
28814
+ constructorEdges(row, contextualMember) {
29022
28815
  if (!isLiteralValueContent(row)) return [];
29023
28816
  if (row.constructorArgs === void 0 || row.constructorArgs === null) {
29024
28817
  return [];
29025
28818
  }
29026
28819
  const edges = [];
29027
- for (const [parameterId, typeInfo] of this.constructorParameterTypes(row)) {
28820
+ for (const [parameterId, typeInfo] of this.constructorParameterTypes(
28821
+ row,
28822
+ contextualMember
28823
+ )) {
29028
28824
  const targetValueId = row.constructorArgs[parameterId];
29029
28825
  if (typeof targetValueId !== "string") continue;
29030
28826
  if (!isAggregateTypeInfo(typeInfo)) continue;
@@ -29103,28 +28899,24 @@ var MaterializedValueGraphContext = class {
29103
28899
  if (!isLiteralValueContent(row)) {
29104
28900
  return { ...row, id: replacements.get(row.id) ?? row.id };
29105
28901
  }
29106
- const ownerId = args.ownerValueId ?? row.id;
29107
- const owner = args.owner ?? this.ownerForValue(ownerId);
29108
- const aggregateType = owner === void 0 ? this.aggregateTypeForRow(ownerId) : void 0;
29109
28902
  const rewriteId = (value2) => replacements.get(value2) ?? value2;
29110
28903
  let value = row.value;
29111
- if (owner !== void 0 || aggregateType !== void 0) {
29112
- if ((owner !== void 0 ? isMemberEntryCollectionBase(owner) : aggregateType === 6 /* List */ || aggregateType === 28 /* Set */) && Array.isArray(value)) {
29113
- value = value.map(
29114
- (entry) => typeof entry === "string" ? rewriteId(entry) : entry
29115
- );
29116
- } else if ((owner !== void 0 && (isMemberClassBase(owner) || isMemberDictionaryBase(owner)) || aggregateType === 7 /* Class */ || aggregateType === 22 /* Interface */ || aggregateType === 5 /* Dictionary */) && value !== null && typeof value === "object" && !Array.isArray(value)) {
29117
- value = Object.fromEntries(
29118
- Object.entries(value).map(([key, entry]) => [
29119
- key,
29120
- typeof entry === "string" ? rewriteId(entry) : entry
29121
- ])
29122
- );
29123
- } else if (owner?.kind === 9 /* Lookup */ && Array.isArray(value)) {
29124
- value = value.map(
29125
- (entry) => typeof entry === "string" ? rewriteId(entry) : entry
29126
- );
29127
- }
28904
+ const slots = this.referenceSlots(
28905
+ args.ownerValueId ?? row.id,
28906
+ args.owner,
28907
+ value
28908
+ );
28909
+ if (slots === 1 /* Entries */ && Array.isArray(value)) {
28910
+ value = value.map(
28911
+ (entry) => typeof entry === "string" ? rewriteId(entry) : entry
28912
+ );
28913
+ } else if (slots === 2 /* Fields */) {
28914
+ value = Object.fromEntries(
28915
+ Object.entries(value).map(([key, entry]) => [
28916
+ key,
28917
+ typeof entry === "string" ? rewriteId(entry) : entry
28918
+ ])
28919
+ );
29128
28920
  }
29129
28921
  const parameterTypes = this.constructorParameterTypes(row);
29130
28922
  const constructorArgs = row.constructorArgs === void 0 || row.constructorArgs === null ? row.constructorArgs : Object.fromEntries(
@@ -29154,11 +28946,101 @@ var MaterializedValueGraphContext = class {
29154
28946
  preservedValueIds
29155
28947
  );
29156
28948
  }
28949
+ /**
28950
+ * Row ids an indexed row names through its typed slots: body entries or
28951
+ * fields and aggregate constructor arguments. Leaf text that happens to
28952
+ * equal an id is not a reference.
28953
+ */
28954
+ referencedValueIds(row) {
28955
+ if (!isLiteralValueContent(row)) return [];
28956
+ const ids = [];
28957
+ for (const entry of this.slotEntries(row)) {
28958
+ if (typeof entry === "string") ids.push(entry);
28959
+ }
28960
+ for (const edge of this.edgesByOwnerValueId.get(row.id) ?? [])
28961
+ ids.push(edge.targetValueId);
28962
+ return ids;
28963
+ }
28964
+ slotEntries(row) {
28965
+ const value = row.value;
28966
+ switch (this.referenceSlots(row.id, void 0, value)) {
28967
+ case 1 /* Entries */:
28968
+ return Array.isArray(value) ? value : [];
28969
+ case 2 /* Fields */:
28970
+ return recordEntries(value);
28971
+ case 0 /* None */:
28972
+ return [];
28973
+ }
28974
+ }
28975
+ referenceSlots(ownerId, explicitOwner, value) {
28976
+ const owner = explicitOwner ?? this.ownerForValue(ownerId);
28977
+ const aggregateType = owner === void 0 ? this.aggregateTypeForRow(ownerId) : void 0;
28978
+ if (owner === void 0 && aggregateType === void 0)
28979
+ return 0 /* None */;
28980
+ if (Array.isArray(value)) {
28981
+ const entries = owner !== void 0 ? isMemberEntryCollectionBase(owner) || owner.kind === 9 /* Lookup */ : aggregateType === 6 /* List */ || aggregateType === 28 /* Set */;
28982
+ return entries ? 1 /* Entries */ : 0 /* None */;
28983
+ }
28984
+ if (typeof value !== "object" || value === null) return 0 /* None */;
28985
+ const fields = owner !== void 0 ? isMemberClassBase(owner) || isMemberDictionaryBase(owner) : aggregateType === 7 /* Class */ || aggregateType === 22 /* Interface */ || aggregateType === 5 /* Dictionary */;
28986
+ return fields ? 2 /* Fields */ : 0 /* None */;
28987
+ }
29157
28988
  aggregateTypeForRow(valueId) {
29158
28989
  if (typeof this.valuesById.get(valueId)?.classId === "string") {
29159
28990
  return 7 /* Class */;
29160
28991
  }
29161
- return this.aggregateTypeByTargetValueId.get(valueId);
28992
+ return this.aggregateTypeByTargetValueId.get(valueId) ?? this.argumentInteriorTypes().get(valueId);
28993
+ }
28994
+ /**
28995
+ * Aggregate kinds of rows nested inside constructor arguments, typed by the
28996
+ * declared argument type. A row two edges name is typed by the first: both
28997
+ * must agree on it.
28998
+ */
28999
+ argumentInteriorTypes() {
29000
+ if (this.argumentInteriorTypesById !== void 0)
29001
+ return this.argumentInteriorTypesById;
29002
+ const types = /* @__PURE__ */ new Map();
29003
+ const visit = (valueId, type) => {
29004
+ if (type === null || !isAggregateTypeInfo(type)) return;
29005
+ if (types.has(valueId)) return;
29006
+ types.set(valueId, type.type);
29007
+ const row = this.valuesById.get(valueId);
29008
+ if (row === void 0 || !isLiteralValueContent(row)) return;
29009
+ if (typeof row.classId === "string") {
29010
+ if (typeof row.value !== "object" || row.value === null) return;
29011
+ const body = row.value;
29012
+ const env = this.genericEnvironmentForRow(row);
29013
+ for (const entry of mergeInstanceSurfaceSchema(
29014
+ row.classId,
29015
+ this.document.classes,
29016
+ this.document.members
29017
+ )) {
29018
+ const childId = body[entry.schemaKey];
29019
+ const member = this.membersById.get(entry.memberId);
29020
+ if (typeof childId !== "string" || member === void 0) continue;
29021
+ visit(childId, this.memberTypeInfo(member, env));
29022
+ }
29023
+ return;
29024
+ }
29025
+ if (type.type === 7 /* Class */ || type.type === 22 /* Interface */)
29026
+ return;
29027
+ for (const entryId of this.collectionEntryIds(row, type.type)) {
29028
+ if (typeof entryId === "string") visit(entryId, type.entryTypeInfo);
29029
+ }
29030
+ };
29031
+ for (const edges of this.edgesByOwnerValueId.values())
29032
+ for (const edge of edges) visit(edge.targetValueId, edge.typeInfo);
29033
+ this.argumentInteriorTypesById = types;
29034
+ return types;
29035
+ }
29036
+ /** A collection row's entry ids: dictionary values, contained or listed. */
29037
+ collectionEntryIds(row, kind) {
29038
+ if (kind === 5 /* Dictionary */) {
29039
+ return recordEntries(row.value);
29040
+ }
29041
+ const contained = this.childrenByContainerId.get(row.id);
29042
+ if (contained !== void 0) return contained.map((entry) => entry.id);
29043
+ return Array.isArray(row.value) ? row.value : [];
29162
29044
  }
29163
29045
  resolveTypeInfo(rawTypeInfo, env) {
29164
29046
  if (rawTypeInfo.type === 21 /* Generic */) {
@@ -31933,7 +31815,7 @@ function claimVirtualIdentity(args) {
31933
31815
  virtualId: args.fixedVirtualId
31934
31816
  };
31935
31817
  }
31936
- const valueId = (sourceIdentity3) => args.instanceRootId.startsWith("__pending__:") || hasPendingVirtualSourceIdentity(sourceIdentity3) ? pendingVirtualValueId(args.instanceRootId, sourceIdentity3) : virtualValueId(args.instanceRootId, sourceIdentity3);
31818
+ const valueId = (sourceIdentity3) => derivedVirtualValueId(args.instanceRootId, sourceIdentity3);
31937
31819
  const derivedId = valueId(args.rawSourceIdentity);
31938
31820
  const claimedPath = args.claimedVirtualIds.get(derivedId);
31939
31821
  if (claimedPath === void 0 || claimedPath === args.pathKey) {
@@ -31945,6 +31827,9 @@ function claimVirtualIdentity(args) {
31945
31827
  args.claimedVirtualIds.set(virtualId, args.pathKey);
31946
31828
  return { sourceIdentity: sourceIdentity2, virtualId };
31947
31829
  }
31830
+ function derivedVirtualValueId(instanceRootId, sourceIdentity2) {
31831
+ return instanceRootId.startsWith("__pending__:") || hasPendingVirtualSourceIdentity(sourceIdentity2) ? pendingVirtualValueId(instanceRootId, sourceIdentity2) : virtualValueId(instanceRootId, sourceIdentity2);
31832
+ }
31948
31833
  var VirtualExpansionUnsupportedError = class extends Error {
31949
31834
  constructor(message) {
31950
31835
  super(message);
@@ -32263,7 +32148,7 @@ function resolveVirtualInstanceGraph(args) {
32263
32148
  });
32264
32149
  if (!expansion.nodesByPath.has(childPath)) continue;
32265
32150
  const storedChildId = storedRecord[entry.schemaKey] ?? constructedChildren.get(entry.schemaKey) ?? null;
32266
- if (args.preserveUnloadedStoredChildren && storedChildId !== null && !materializedById.has(storedChildId)) {
32151
+ if (storedChildId !== null && !materializedById.has(storedChildId) && (typeof args.preserveUnloadedStoredChildren === "function" ? args.preserveUnloadedStoredChildren(storedChildId) : args.preserveUnloadedStoredChildren)) {
32267
32152
  effectiveRecord[entry.schemaKey] = storedChildId;
32268
32153
  continue;
32269
32154
  }
@@ -32674,12 +32559,149 @@ function resolveVirtualInstanceGraph(args) {
32674
32559
  ),
32675
32560
  normalizeLeafPayload(location.virtualRow, location.member)
32676
32561
  );
32562
+ let expandedEntryIdsByContainerId;
32563
+ const argumentChildren = (row, type) => {
32564
+ if (typeof row.classId === "string") {
32565
+ const body = stringRecord(row.value);
32566
+ const env = materializedGraph.genericEnvironmentForRow(row);
32567
+ return resolvedClassSchema(
32568
+ row.classId,
32569
+ args.document.classes,
32570
+ args.document.members
32571
+ ).surface.flatMap((entry) => {
32572
+ const id = body[entry.schemaKey];
32573
+ const member = materializedGraph.memberForId(entry.memberId);
32574
+ if (id === void 0 || member === void 0) return [];
32575
+ return [
32576
+ {
32577
+ id,
32578
+ segment: { kind: "class", schemaKey: entry.schemaKey },
32579
+ type: materializedGraph.typeInfoForMember(member, env)
32580
+ }
32581
+ ];
32582
+ });
32583
+ }
32584
+ if (type?.type === 5 /* Dictionary */) {
32585
+ const entryType2 = type.entryTypeInfo;
32586
+ return Object.entries(stringRecord(row.value)).map(([key, id]) => ({
32587
+ id,
32588
+ segment: { kind: "dictionary", key },
32589
+ type: entryType2
32590
+ }));
32591
+ }
32592
+ if (type?.type !== 6 /* List */ && type?.type !== 28 /* Set */)
32593
+ return [];
32594
+ const entryType = type.entryTypeInfo;
32595
+ expandedEntryIdsByContainerId ??= buildUnorderedListMembershipIndex(
32596
+ args.expandedRows
32597
+ );
32598
+ const entries = expandedEntryIdsByContainerId.get(row.id) ?? (Array.isArray(row.value) ? row.value : []);
32599
+ return entries.flatMap(
32600
+ (id, index) => typeof id === "string" ? [{ id, segment: { kind: "list", index }, type: entryType }] : []
32601
+ );
32602
+ };
32603
+ const constructionArguments = (location) => {
32604
+ const node = expansion.nodesByPath.get(location.pathKey);
32605
+ if (node === void 0) return null;
32606
+ const owner = node.expandedRow;
32607
+ const pending = [];
32608
+ const enqueueArguments = (row, path, member) => {
32609
+ const edges = materializedGraph.constructorEdges(row, member);
32610
+ for (const edge of edges)
32611
+ pending.push({
32612
+ id: edge.targetValueId,
32613
+ path: appendVirtualValuePath(path, {
32614
+ kind: "class",
32615
+ schemaKey: `@constructor:${edge.parameterId}`
32616
+ }),
32617
+ type: edge.typeInfo
32618
+ });
32619
+ return edges;
32620
+ };
32621
+ const ownerEdges = enqueueArguments(owner, ROOT_PATH, node.member);
32622
+ if (ownerEdges.length === 0) return null;
32623
+ const ids = /* @__PURE__ */ new Map();
32624
+ const aliasedValueIds = [];
32625
+ const argumentRows = [];
32626
+ for (let index = 0; index < pending.length; index += 1) {
32627
+ const { id, path, type } = pending[index];
32628
+ if (ids.has(id)) continue;
32629
+ const aliased = expansion.nodesByExpandedId.get(id);
32630
+ if (aliased !== void 0) {
32631
+ const target = locationsByPath.get(aliased.pathKey);
32632
+ if (target === void 0) continue;
32633
+ ids.set(id, target.id);
32634
+ aliasedValueIds.push(target.id);
32635
+ continue;
32636
+ }
32637
+ const row = expansion.rowsByExpandedId.get(id);
32638
+ if (row === void 0) continue;
32639
+ const argumentId = derivedVirtualValueId(
32640
+ location.instanceRootId,
32641
+ `${location.sourceIdentity}:${path}`
32642
+ );
32643
+ ids.set(id, argumentId);
32644
+ const bodyIds = /* @__PURE__ */ new Set();
32645
+ for (const child of argumentChildren(row, type)) {
32646
+ bodyIds.add(child.id);
32647
+ pending.push({
32648
+ id: child.id,
32649
+ path: appendVirtualValuePath(path, child.segment),
32650
+ type: child.type
32651
+ });
32652
+ }
32653
+ argumentRows.push({
32654
+ row,
32655
+ id: argumentId,
32656
+ edges: enqueueArguments(row, path),
32657
+ bodyIds
32658
+ });
32659
+ }
32660
+ const retargetArguments = (row, edges) => {
32661
+ const stored = literalRow(row).constructorArgs;
32662
+ if (stored == null || edges.length === 0) return stored;
32663
+ const next = { ...stored };
32664
+ for (const edge of edges)
32665
+ next[edge.parameterId] = ids.get(edge.targetValueId) ?? edge.targetValueId;
32666
+ return next;
32667
+ };
32668
+ const retargetBody = (value, bodyIds) => {
32669
+ if (bodyIds.size === 0) return value;
32670
+ const retarget = (entry) => typeof entry === "string" && bodyIds.has(entry) ? ids.get(entry) ?? entry : entry;
32671
+ if (Array.isArray(value)) return value.map(retarget);
32672
+ return Object.fromEntries(
32673
+ Object.entries(value).map(
32674
+ ([key, entry]) => [key, retarget(entry)]
32675
+ )
32676
+ );
32677
+ };
32678
+ return {
32679
+ constructorArgs: retargetArguments(owner, ownerEdges) ?? {},
32680
+ rows: argumentRows.map(({ row, id, edges, bodyIds }) => {
32681
+ const create = createFromRow(
32682
+ literalRow(row),
32683
+ id,
32684
+ retargetBody(row.value, bodyIds)
32685
+ );
32686
+ const constructorArgs = retargetArguments(row, edges);
32687
+ return {
32688
+ ...create,
32689
+ ...constructorArgs === void 0 ? {} : { constructorArgs },
32690
+ ...create.containerId === void 0 ? {} : {
32691
+ containerId: ids.get(create.containerId) ?? create.containerId
32692
+ }
32693
+ };
32694
+ }),
32695
+ aliasedValueIds
32696
+ };
32697
+ };
32677
32698
  return {
32678
32699
  instanceRootId: args.instanceRoot.id,
32679
32700
  ...listenerDefaultsByOwner === void 0 ? {} : { listenerDefaultsByOwner },
32680
32701
  pinnedRootSchemaKeys: args.pinnedRootSchemaKeys,
32681
32702
  compareCreationProvenance,
32682
32703
  compareLeafContent,
32704
+ constructionArguments,
32683
32705
  rowsById,
32684
32706
  locationsById,
32685
32707
  locationsByPath,
@@ -32753,6 +32775,7 @@ function prepareStoredClassValueResolution(args) {
32753
32775
  expandedRows: expanded.rows,
32754
32776
  pinnedRootSchemaKeys: expanded.pinnedRootSchemaKeys,
32755
32777
  materializedIndex: args.materializedIndex,
32778
+ preserveUnloadedStoredChildren: args.preserveUnloadedStoredChildren,
32756
32779
  readRecorder: args.readRecorder
32757
32780
  };
32758
32781
  }
@@ -33153,6 +33176,21 @@ function rewriteExpandedRow(node, expansion) {
33153
33176
  }
33154
33177
  return row;
33155
33178
  }
33179
+ function createFromRow(prior, id, value, update) {
33180
+ const row = update?.classId !== void 0 && update.classId !== prior.classId ? replaceLiteralValueClass(prior, update.classId) : prior;
33181
+ const create = {
33182
+ id,
33183
+ value,
33184
+ ...typeof row.classId !== "string" ? {} : { classId: row.classId },
33185
+ ...pickInstanceProvenance(row),
33186
+ ...update === void 0 ? {} : pickInstanceProvenance(update),
33187
+ ...row.containerId === void 0 ? {} : { containerId: row.containerId },
33188
+ ...row.mapKey === void 0 ? {} : { mapKey: row.mapKey },
33189
+ ...row.genericBindings === void 0 ? {} : { genericBindings: { ...row.genericBindings } },
33190
+ ...row.sourceValueId === void 0 ? {} : { sourceValueId: row.sourceValueId }
33191
+ };
33192
+ return create;
33193
+ }
33156
33194
  function remapMemberDelegateReceiver(value, remap) {
33157
33195
  if (!isMemberDelegateTarget(value) || value.valueId === null) return value;
33158
33196
  const valueId = remap(value.valueId);
@@ -34116,7 +34154,6 @@ function evaluateMemberInitializer(args) {
34116
34154
  );
34117
34155
  const compiled = compileMemberInitializer(args, databaseVM);
34118
34156
  const ctx = {
34119
- ...args.document.evaluationLimits,
34120
34157
  debugSink: args.document.debugSink,
34121
34158
  beforeValueAllocation: args.document.beforeValueAllocation,
34122
34159
  listenerDefaultCapture: args.document.listenerDefaultCapture,
@@ -34163,6 +34200,7 @@ function evaluateMemberInitializer(args) {
34163
34200
  sessionStaticBindings: args.sessionStaticBindings,
34164
34201
  ...args.storedConstructionReplay === true ? {
34165
34202
  storedConstructionReplay: true,
34203
+ ...args.sourceValueId == null ? {} : { __storedConstructionReplayRowId: args.sourceValueId },
34166
34204
  ...isMemberClassBase(args.member) ? {
34167
34205
  __storedConstructionReplaySlot: {
34168
34206
  classId: args.member.classId,
@@ -52502,7 +52540,7 @@ var PROJECT_TRANSACTION_IMMEDIATE_BUDGET = {
52502
52540
  bytesRead: 6 * MIB,
52503
52541
  bytesWritten: 4 * MIB,
52504
52542
  documentsRead: 4e3,
52505
- documentsWritten: 1800,
52543
+ documentsWritten: 2100,
52506
52544
  databaseQueries: 1140,
52507
52545
  indexRanges: 1140,
52508
52546
  functionsScheduled: 24,
@@ -52793,11 +52831,6 @@ var STRING_TYPE_INFO = {
52793
52831
  // ../src/database/project-version-whole-graph-validation.ts
52794
52832
  import { ConvexError as ConvexError3 } from "convex/values";
52795
52833
 
52796
- // ../src/models/exports/unity-static-members.ts
52797
- var nativePatternMembers = new Set(
52798
- Object.values(NEO_CELL_PATTERN_MEMBER_IDS)
52799
- );
52800
-
52801
52834
  // ../convex/projectInterfaceValidation.ts
52802
52835
  var MEMBER_REQUIREMENT_KINDS = [
52803
52836
  0 /* Optional */,
@@ -53594,6 +53627,15 @@ var SYSTEM_PROTECTION_RULES = {
53594
53627
  ],
53595
53628
  reasonKey: "systemProtection.reasons.scriptRuntime",
53596
53629
  serverReason: "Lifecycle interface the Neo Compose script runtime calls."
53630
+ },
53631
+ [SystemProtectionKind.SystemPreset]: {
53632
+ disallow: [
53633
+ SystemDisallowedOperation.EditRecord,
53634
+ SystemDisallowedOperation.DeleteRecord,
53635
+ SystemDisallowedOperation.ReplaceValue
53636
+ ],
53637
+ reasonKey: "systemProtection.reasons.systemPreset",
53638
+ serverReason: "Built-in preset value shared by every Neo Compose project."
53597
53639
  }
53598
53640
  };
53599
53641
 
@@ -54528,7 +54570,8 @@ var systemProtectionKindSchema = picklist([
54528
54570
  "dialoguePriorityDefault",
54529
54571
  "policyImmutable",
54530
54572
  "policyDeleteBlocked",
54531
- "scriptRuntime"
54573
+ "scriptRuntime",
54574
+ "systemPreset"
54532
54575
  ]);
54533
54576
  var worldSystemClassKindSchema = picklist([
54534
54577
  "cellPattern",
@@ -56333,7 +56376,8 @@ function isSchemaSystemMetadata(value) {
56333
56376
  "dialoguePriorityDefault",
56334
56377
  "policyImmutable",
56335
56378
  "policyDeleteBlocked",
56336
- "scriptRuntime"
56379
+ "scriptRuntime",
56380
+ "systemPreset"
56337
56381
  ]);
56338
56382
  const worlds = /* @__PURE__ */ new Set([
56339
56383
  "cellPattern",
@@ -57712,7 +57756,7 @@ var INITIALIZER_KEY_PLACEHOLDER = new RegExp(
57712
57756
 
57713
57757
  // ../packages/manifest/schema-contract/registry.mjs
57714
57758
  var PROJECT_SCHEMA_CONTRACT = Object.freeze({
57715
- cliVersion: "0.78.0",
57759
+ cliVersion: "0.79.0",
57716
57760
  projectFileUploadBatchSize: 32,
57717
57761
  documentRecords: {
57718
57762
  member: {
@@ -58432,7 +58476,8 @@ var PROJECT_SCHEMA_CONTRACT = Object.freeze({
58432
58476
  "DialoguePriorityDefault",
58433
58477
  "PolicyImmutable",
58434
58478
  "PolicyDeleteBlocked",
58435
- "ScriptRuntime"
58479
+ "ScriptRuntime",
58480
+ "SystemPreset"
58436
58481
  ],
58437
58482
  NeoMemberRequirement: ["Optional", "Required"],
58438
58483
  NeoMemberMutability: ["Mutable", "ReadOnly"],
@@ -59550,7 +59595,7 @@ var SCRIPT_COLLECTION_READERS = {
59550
59595
  };
59551
59596
 
59552
59597
  // ../src/models/exports/unity-codegen-revision.ts
59553
- var UNITY_CODEGEN_REVISION = "8e940ebfec562d0be7fe7b82014f66293ea075c2ca394c3a3eaac419eaddfeb8";
59598
+ var UNITY_CODEGEN_REVISION = "bac1e765b6731dfd0abb8404c7b4c2b65f161f2a539cc485ee297e555852f3ab";
59554
59599
 
59555
59600
  // src/export-cache.ts
59556
59601
  var CACHE_BUILD = JSON.stringify([