@neocompose/cli 0.83.0 → 0.84.1

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.
@@ -8152,6 +8152,35 @@ var init_world_system_classes_generated = __esm({
8152
8152
  ],
8153
8153
  dispatch: 0 /* Synchronous */,
8154
8154
  schemaKey: "TryConvert"
8155
+ },
8156
+ {
8157
+ memberId: "system_a92b0911-8e7e-48ef-a12e-f3c55c33f64b",
8158
+ memberKind: "function",
8159
+ docsText: "The nearest tile grid that owns this tile, or null when no grid owns it or that grid is not a T. A tile in an object's tile layer answers with the object's grid.",
8160
+ returnTypeInfo: {
8161
+ type: 21,
8162
+ required: false,
8163
+ ownerMemberId: "system_a92b0911-8e7e-48ef-a12e-f3c55c33f64b",
8164
+ index: 0
8165
+ },
8166
+ argumentTypes: [],
8167
+ genericParams: [
8168
+ {
8169
+ name: "T",
8170
+ constraint: {
8171
+ type: 7,
8172
+ required: true,
8173
+ classId: "system_b78f7f1d-f63c-4abb-ae65-852e69246534"
8174
+ },
8175
+ defaultType: {
8176
+ type: 7,
8177
+ required: true,
8178
+ classId: "system_b78f7f1d-f63c-4abb-ae65-852e69246534"
8179
+ }
8180
+ }
8181
+ ],
8182
+ dispatch: 0 /* Synchronous */,
8183
+ schemaKey: "GetArea"
8155
8184
  }
8156
8185
  ],
8157
8186
  worldKind: "tile"
@@ -8199,6 +8228,35 @@ var init_world_system_classes_generated = __esm({
8199
8228
  docsText: "The object's box collider, or null for none. Any world object can carry one: placed objects, nested children, and sprites alike.",
8200
8229
  schemaClassWorldKind: "objectCollider",
8201
8230
  schemaKey: "Collider"
8231
+ },
8232
+ {
8233
+ memberId: "system_7ad477e2-be5b-4892-b9ba-2a2f2476988d",
8234
+ memberKind: "function",
8235
+ docsText: "The nearest tile grid that owns this value, or null when no grid owns it or that grid is not a T. Nested children answer with their placed root's grid.",
8236
+ returnTypeInfo: {
8237
+ type: 21,
8238
+ required: false,
8239
+ ownerMemberId: "system_7ad477e2-be5b-4892-b9ba-2a2f2476988d",
8240
+ index: 0
8241
+ },
8242
+ argumentTypes: [],
8243
+ genericParams: [
8244
+ {
8245
+ name: "T",
8246
+ constraint: {
8247
+ type: 7,
8248
+ required: true,
8249
+ classId: "system_b78f7f1d-f63c-4abb-ae65-852e69246534"
8250
+ },
8251
+ defaultType: {
8252
+ type: 7,
8253
+ required: true,
8254
+ classId: "system_b78f7f1d-f63c-4abb-ae65-852e69246534"
8255
+ }
8256
+ }
8257
+ ],
8258
+ dispatch: 0 /* Synchronous */,
8259
+ schemaKey: "GetArea"
8202
8260
  }
8203
8261
  ],
8204
8262
  worldKind: "objectBase"
@@ -17529,7 +17587,7 @@ var init_registry = __esm({
17529
17587
  "../packages/manifest/schema-contract/registry.mjs"() {
17530
17588
  "use strict";
17531
17589
  PROJECT_SCHEMA_CONTRACT = Object.freeze({
17532
- cliVersion: "0.83.0",
17590
+ cliVersion: "0.84.1",
17533
17591
  projectFileUploadBatchSize: 32,
17534
17592
  documentRecords: {
17535
17593
  member: {
@@ -22807,9 +22865,14 @@ function indexFirstById(values) {
22807
22865
  }
22808
22866
  return result;
22809
22867
  }
22868
+ function isDerivedNewValueId(valueId, isStored) {
22869
+ return !isPendingId(valueId) && !isUuidV4Id(valueId) && !isStored(valueId);
22870
+ }
22810
22871
  var init_lower_support = __esm({
22811
22872
  "src/project-source/lower-support.ts"() {
22812
22873
  "use strict";
22874
+ init_value_comparison();
22875
+ init_pending_id();
22813
22876
  init_executable_parser();
22814
22877
  }
22815
22878
  });
@@ -32956,7 +33019,7 @@ var init_collection_query = __esm({
32956
33019
  });
32957
33020
 
32958
33021
  // ../packages/neoscript-language/src/cell-pattern.ts
32959
- var NEO_CELL_PATTERN_CLASS_ID, NEO_CELL_PATTERN_CONSTRUCTOR_ID, NEO_CELL_PATTERN_MEMBER_IDS, NEO_OBJECT_GRID_MEMBER_IDS, NEO_CELL_PATTERN_PURE_NATIVE_MEMBER_IDS, NEO_OBJECT_CLASS_ID;
33022
+ var NEO_CELL_PATTERN_CLASS_ID, NEO_CELL_PATTERN_CONSTRUCTOR_ID, NEO_CELL_PATTERN_MEMBER_IDS, NEO_OBJECT_GRID_MEMBER_IDS, NEO_GET_AREA_MEMBER_IDS, NEO_CELL_PATTERN_PURE_NATIVE_MEMBER_IDS, NEO_OBJECT_CLASS_ID, NEO_TILE_GRID_CLASS_ID;
32960
33023
  var init_cell_pattern = __esm({
32961
33024
  "../packages/neoscript-language/src/cell-pattern.ts"() {
32962
33025
  "use strict";
@@ -32987,6 +33050,10 @@ var init_cell_pattern = __esm({
32987
33050
  GetTile: "system_593e6208-e2ca-505e-9933-04b17102b6d2",
32988
33051
  GetTiles: "system_5a41d36a-bcd9-4867-9e46-d743f6e09582"
32989
33052
  };
33053
+ NEO_GET_AREA_MEMBER_IDS = {
33054
+ NeoObjectBase: "system_7ad477e2-be5b-4892-b9ba-2a2f2476988d",
33055
+ NeoTile: "system_a92b0911-8e7e-48ef-a12e-f3c55c33f64b"
33056
+ };
32990
33057
  NEO_CELL_PATTERN_PURE_NATIVE_MEMBER_IDS = /* @__PURE__ */ new Set([
32991
33058
  NEO_CELL_PATTERN_MEMBER_IDS.Contains,
32992
33059
  NEO_CELL_PATTERN_MEMBER_IDS.Cells,
@@ -32996,6 +33063,7 @@ var init_cell_pattern = __esm({
32996
33063
  NEO_CELL_PATTERN_MEMBER_IDS.Union
32997
33064
  ]);
32998
33065
  NEO_OBJECT_CLASS_ID = "system_f671535d-0eb6-4139-9caf-5c5276febd31";
33066
+ NEO_TILE_GRID_CLASS_ID = "system_b78f7f1d-f63c-4abb-ae65-852e69246534";
32999
33067
  }
33000
33068
  });
33001
33069
 
@@ -80192,39 +80260,26 @@ function isCenter(offset) {
80192
80260
  return offset.x === 0 && offset.y === 0;
80193
80261
  }
80194
80262
  function evaluateCellPatternNative(memberId, receiver, args, ctx) {
80195
- if (!NEO_CELL_PATTERN_PURE_NATIVE_MEMBER_IDS.has(memberId)) {
80196
- return { handled: false };
80197
- }
80198
- const pattern = (offsets2) => ({
80199
- handled: true,
80200
- value: ctx.constructPattern(offsets2)
80201
- });
80202
80263
  const offsets = ctx.readPattern(receiver);
80203
80264
  switch (memberId) {
80204
80265
  case NEO_CELL_PATTERN_MEMBER_IDS.Contains: {
80205
80266
  const offset = vector(args[0], "Contains offset");
80206
- return {
80207
- handled: true,
80208
- value: offsets.some(
80209
- (cell) => cell.x === offset.x && cell.y === offset.y
80210
- )
80211
- };
80267
+ return offsets.some((cell) => cell.x === offset.x && cell.y === offset.y);
80212
80268
  }
80213
80269
  case NEO_CELL_PATTERN_MEMBER_IDS.Cells:
80214
- return {
80215
- handled: true,
80216
- value: translated(offsets, vector(args[0], "Cells origin"))
80217
- };
80270
+ return translated(offsets, vector(args[0], "Cells origin"));
80218
80271
  case NEO_CELL_PATTERN_MEMBER_IDS.WithCenter:
80219
- if (offsets.some(isCenter)) return { handled: true, value: receiver };
80220
- return pattern([{ x: 0, y: 0 }, ...offsets]);
80272
+ if (offsets.some(isCenter)) return receiver;
80273
+ return ctx.constructPattern([{ x: 0, y: 0 }, ...offsets]);
80221
80274
  case NEO_CELL_PATTERN_MEMBER_IDS.WithoutCenter:
80222
- if (!offsets.some(isCenter)) return { handled: true, value: receiver };
80223
- return pattern(offsets.filter((offset) => !isCenter(offset)));
80275
+ if (!offsets.some(isCenter)) return receiver;
80276
+ return ctx.constructPattern(
80277
+ offsets.filter((offset) => !isCenter(offset))
80278
+ );
80224
80279
  case NEO_CELL_PATTERN_MEMBER_IDS.Translate: {
80225
80280
  const offset = vector(args[0], "Translate offset");
80226
- if (isCenter(offset)) return { handled: true, value: receiver };
80227
- return pattern(translated(offsets, offset));
80281
+ if (isCenter(offset)) return receiver;
80282
+ return ctx.constructPattern(translated(offsets, offset));
80228
80283
  }
80229
80284
  case NEO_CELL_PATTERN_MEMBER_IDS.Union: {
80230
80285
  const other = ctx.readPattern(args[0]);
@@ -80238,7 +80293,7 @@ function evaluateCellPatternNative(memberId, receiver, args, ctx) {
80238
80293
  result.push(offset);
80239
80294
  }
80240
80295
  }
80241
- return pattern(result);
80296
+ return ctx.constructPattern(result);
80242
80297
  }
80243
80298
  default:
80244
80299
  throw new Error(
@@ -85846,6 +85901,21 @@ function evalCollectionMutationInstruction(ins, scope, ctx, options) {
85846
85901
  ctx
85847
85902
  );
85848
85903
  }
85904
+ if (unorderedContainerValueId !== null && Array.isArray(targetValue)) {
85905
+ const cache = unorderedListProjectionCache(ctx);
85906
+ const appended = ins.mutation === "Add" /* Add */ && cache.writtenContainerIds.has(unorderedContainerValueId);
85907
+ releaseWrittenUnorderedEntries(
85908
+ unorderedContainerValueId,
85909
+ unorderedEntriesBeforeMutation ?? [],
85910
+ cache
85911
+ );
85912
+ trackWrittenUnorderedEntries(
85913
+ unorderedContainerValueId,
85914
+ targetValue,
85915
+ appended ? targetValue.length - 1 : 0,
85916
+ cache
85917
+ );
85918
+ }
85849
85919
  invalidateEvaluatorIndexes(ctx, targetValue);
85850
85920
  switch (ins.mutation) {
85851
85921
  case "Insert" /* Insert */:
@@ -86851,10 +86921,8 @@ function evalPointerCore(pointer, scope, ctx, resultUsage = "value") {
86851
86921
  if (member.kind === 13 /* Function */) {
86852
86922
  const systemResult = evaluateSystemNative(
86853
86923
  member.id,
86854
- innerThis,
86855
- args,
86856
- ctx,
86857
- typeArguments
86924
+ { receiver: innerThis, args, typeArguments },
86925
+ ctx
86858
86926
  );
86859
86927
  if (systemResult.handled) return systemResult.value;
86860
86928
  const hosted = ctx.unavailableNativeHandler?.({
@@ -87196,8 +87264,11 @@ function invokeDelegateValue(value, args, ctx, callSiteId, ownerReceiver, result
87196
87264
  if (member.kind === 13 /* Function */) {
87197
87265
  const systemResult = evaluateSystemNative(
87198
87266
  member.id,
87199
- receiver,
87200
- args,
87267
+ {
87268
+ receiver,
87269
+ args,
87270
+ typeArguments: calleeTypeArguments(void 0, member, ctx)
87271
+ },
87201
87272
  ctx
87202
87273
  );
87203
87274
  if (systemResult.handled) return systemResult.value;
@@ -88704,6 +88775,8 @@ function createUnorderedListProjectionCache() {
88704
88775
  return {
88705
88776
  byContainerId: /* @__PURE__ */ new Map(),
88706
88777
  containerIdByArray: /* @__PURE__ */ new WeakMap(),
88778
+ writtenContainerIds: /* @__PURE__ */ new Set(),
88779
+ writtenEntryParents: /* @__PURE__ */ new Map(),
88707
88780
  scalarEntryIds: /* @__PURE__ */ new Set(),
88708
88781
  referenceEntryIndexesByArray: /* @__PURE__ */ new WeakMap(),
88709
88782
  referenceEntryKeysByRecord: /* @__PURE__ */ new WeakMap()
@@ -88764,9 +88837,27 @@ function invalidateUnorderedListProjection(containerValueId, ctx) {
88764
88837
  const projection = cache.byContainerId.get(containerValueId);
88765
88838
  if (projection === void 0) return;
88766
88839
  detachRemovedUnorderedScalarEntries(projection, [], ctx);
88840
+ releaseWrittenUnorderedEntries(containerValueId, projection, cache);
88767
88841
  cache.byContainerId.delete(containerValueId);
88842
+ cache.writtenContainerIds.delete(containerValueId);
88768
88843
  cache.containerIdByArray.delete(projection);
88769
88844
  }
88845
+ function trackWrittenUnorderedEntries(containerValueId, projection, start, cache, references = cache.referenceEntryIndexesByArray.get(projection)) {
88846
+ cache.writtenContainerIds.add(containerValueId);
88847
+ for (let index = start; index < projection.length; index++) {
88848
+ const entry = projection[index];
88849
+ if (typeof entry === "string" && references?.has(index) !== true) {
88850
+ cache.writtenEntryParents.set(entry, containerValueId);
88851
+ }
88852
+ }
88853
+ }
88854
+ function releaseWrittenUnorderedEntries(containerValueId, entries, cache) {
88855
+ for (const entry of entries) {
88856
+ if (typeof entry === "string" && cache.writtenEntryParents.get(entry) === containerValueId) {
88857
+ cache.writtenEntryParents.delete(entry);
88858
+ }
88859
+ }
88860
+ }
88770
88861
  function updateUnorderedListProjectionAfterAssignment(row, value, ctx) {
88771
88862
  invalidateUnorderedListProjection(row.id, ctx);
88772
88863
  const member = memberForValueRow(row, ctx);
@@ -88785,6 +88876,7 @@ function updateUnorderedListProjectionAfterAssignment(row, value, ctx) {
88785
88876
  }
88786
88877
  cache.byContainerId.set(row.id, projection);
88787
88878
  cache.containerIdByArray.set(projection, row.id);
88879
+ trackWrittenUnorderedEntries(row.id, projection, 0, cache, referenceIndexes);
88788
88880
  }
88789
88881
  function evaluatorUnorderedListEntryIds(containerValueId, ctx) {
88790
88882
  ctx.containerDependencies?.add(containerValueId);
@@ -88937,7 +89029,8 @@ function resolveMemberForValueRow(row, ctx, visited) {
88937
89029
  ctx.onUnattributableValueRead?.(
88938
89030
  ownershipChainRead("member-owner-resolution", row.id)
88939
89031
  );
88940
- for (const link of evaluatorParentLinks(indexes4, row.id)) {
89032
+ for (const link of evaluatorParentEdges(row, ctx, indexes4)) {
89033
+ if ("memberId" in link) return evalMemberById(ctx.vm, link.memberId);
88941
89034
  const parent = evalValueById(
88942
89035
  ctx,
88943
89036
  link.parentId,
@@ -88960,6 +89053,93 @@ function resolveMemberForValueRow(row, ctx, visited) {
88960
89053
  }
88961
89054
  return null;
88962
89055
  }
89056
+ function* evaluatorParentEdges(row, ctx, indexes4) {
89057
+ const cache = ctx.__unorderedListProjections;
89058
+ const writtenParentId = cache?.writtenEntryParents.get(row.id);
89059
+ if (writtenParentId !== void 0) {
89060
+ yield { parentId: writtenParentId, key: "" };
89061
+ }
89062
+ const written = cache?.writtenContainerIds;
89063
+ for (const link of indexes4.parentLinksByChildId.get(row.id) ?? []) {
89064
+ if (written?.has(link.parentId) !== true) yield link;
89065
+ }
89066
+ const database = ctx.vm.databaseVM;
89067
+ const documentContainerId = database?.evaluatorIndexes?.valueById.get(
89068
+ row.id
89069
+ )?.containerId;
89070
+ const rewritten = indexes4.shadowedBaseRowIds.has(row.id);
89071
+ const stale = (parentId) => written?.has(parentId) === true || indexes4.shadowedBaseRowIds.has(parentId) || row.containerId !== parentId && (documentContainerId === parentId || rewritten && database?.valueById(row.id)?.containerId === parentId);
89072
+ const placement = database?.storedValuePlacementForValueId?.(row.id);
89073
+ const placedParentId = placement?.parentValueId;
89074
+ if (placement !== null && placement !== void 0 && typeof placedParentId === "string" && !stale(placedParentId)) {
89075
+ yield { parentId: placedParentId, memberId: placement.memberId };
89076
+ }
89077
+ for (const link of indexes4.baseParentLinksByChildId?.get(row.id) ?? []) {
89078
+ if (!stale(link.parentId)) yield link;
89079
+ }
89080
+ }
89081
+ function currentUnorderedContainerId(row, ctx) {
89082
+ const cache = ctx.__unorderedListProjections;
89083
+ const writtenParentId = cache?.writtenEntryParents.get(row.id);
89084
+ if (writtenParentId !== void 0) return writtenParentId;
89085
+ const containerId = row.containerId;
89086
+ if (typeof containerId !== "string") return void 0;
89087
+ const released = cache?.writtenContainerIds.has(containerId) === true;
89088
+ return released ? void 0 : containerId;
89089
+ }
89090
+ function firstOwnerEdge(row, ctx) {
89091
+ const indexes4 = evaluatorIndexes(ctx);
89092
+ const edge = evaluatorParentEdges(row, ctx, indexes4).next().value;
89093
+ if (edge !== void 0) return edge;
89094
+ const rows = ctx.vm.databaseVM?.virtualInstanceRowsForValue(row.id);
89095
+ if (rows === void 0 || rows.length === 0) return void 0;
89096
+ ensureVirtualExpansionIndexed(rows, ctx, indexes4);
89097
+ return evaluatorParentEdges(row, ctx, indexes4).next().value;
89098
+ }
89099
+ function untrackedValueById(id2, ctx) {
89100
+ if (ctx.__removedValueIds?.has(id2)) return null;
89101
+ const local = ctx.__runtimeSessionValues?.get(id2) ?? ctx.__valueOverlay?.get(id2);
89102
+ if (local !== void 0) return local;
89103
+ const database = ctx.vm.databaseVM;
89104
+ if (database !== void 0) return database.valueById(id2);
89105
+ return ctx.vm.values.find((value) => value.id === id2) ?? null;
89106
+ }
89107
+ function placingMemberBinding(row, ctx) {
89108
+ const direct = evaluatorIndexes(ctx).memberByValueId.get(row.id);
89109
+ if (direct !== void 0) return direct;
89110
+ const root = rootMemberForValueRow(row, ctx);
89111
+ if (root !== null) return root;
89112
+ const staticRoot = activeStaticBindingRoot(row.id, ctx);
89113
+ if (staticRoot !== null) return staticRoot.member;
89114
+ const placement = ctx.vm.databaseVM?.storedValuePlacementForValueId?.(row.id);
89115
+ if (placement !== null && placement !== void 0) {
89116
+ if (placement.parentValueId === null) {
89117
+ return evalMemberById(ctx.vm, placement.memberId);
89118
+ }
89119
+ }
89120
+ const syntheticMemberId = memberIdFromSyntheticDefaultValueId(row.id);
89121
+ return syntheticMemberId === null ? null : evalMemberById(ctx.vm, syntheticMemberId);
89122
+ }
89123
+ function placingMember(row, ctx, ownerEdge, depth = 0) {
89124
+ const bound = placingMemberBinding(row, ctx);
89125
+ if (bound !== null) return bound;
89126
+ const edge = ownerEdge ?? firstOwnerEdge(row, ctx);
89127
+ if (edge === void 0) return null;
89128
+ if ("memberId" in edge) return evalMemberById(ctx.vm, edge.memberId);
89129
+ if (depth >= MAX_AREA_DEPTH) return null;
89130
+ const parent = untrackedValueById(edge.parentId, ctx);
89131
+ if (parent === null) return null;
89132
+ const parentMember = parent.classId === void 0 ? placingMember(parent, ctx, void 0, depth + 1) : null;
89133
+ if (parentMember !== null && isMemberWithEntries(parentMember)) {
89134
+ return evalMemberById(ctx.vm, parentMember.entryMemberId);
89135
+ }
89136
+ const classId = parent.classId ?? (parentMember !== null && isClassTypedMember(parentMember) ? parentMember.classId : void 0);
89137
+ return classId === void 0 ? null : memberForCustomSchemaValue(classId, edge.key, ctx);
89138
+ }
89139
+ function placedClassId(row, ctx, ownerEdge) {
89140
+ const member = placingMember(row, ctx, ownerEdge);
89141
+ return member !== null && isClassTypedMember(member) ? member.classId : void 0;
89142
+ }
88963
89143
  function worldGridQueryIndexForContext(context) {
88964
89144
  const ctx = withEvaluationRuntime(context, []);
88965
89145
  const vm = ctx.vm;
@@ -89176,107 +89356,74 @@ function gridQueryClassFilter(typeArgument, ctx) {
89176
89356
  );
89177
89357
  }
89178
89358
  const classId = typeArgument.classId;
89179
- if (classId === NEO_OBJECT_CLASS_ID || classId === NEO_TILE_CLASS_ID) {
89359
+ if (classId === NEO_OBJECT_CLASS_ID || classId === NEO_TILE_CLASS_ID || classId === NEO_TILE_GRID_CLASS_ID) {
89180
89360
  return void 0;
89181
89361
  }
89182
89362
  const schema = evaluatorSchemaIndex(ctx);
89183
89363
  return (candidate) => schema.classIsOrExtends(candidate, classId);
89184
89364
  }
89185
- function evaluateSystemNative(memberId, receiver, args, ctx, typeArguments) {
89186
- try {
89187
- 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) {
89188
- const receiverRow = trackedRowForValueReference(receiver, ctx);
89189
- if (receiverRow === null) {
89190
- throw new NSGetterRuntimeError(
89191
- "Grid queries require a placed NeoObject receiver."
89192
- );
89193
- }
89194
- const index = worldGridQueryIndexForContext(ctx);
89195
- const placement = index.placement(
89196
- receiverRow.id,
89197
- ctx.worldQueryDependencies
89198
- );
89199
- if (memberId === NEO_OBJECT_GRID_MEMBER_IDS.GetCell)
89200
- return { handled: true, value: { ...placement.cell } };
89201
- const offsets = readCellPattern(args[0], ctx);
89202
- const shift = readGridQueryOffset(args[1]);
89203
- const accepts = gridQueryClassFilter(typeArguments?.[0], ctx);
89204
- if (memberId === NEO_OBJECT_GRID_MEMBER_IDS.GetObjects) {
89205
- const value = index.objects(
89206
- placement,
89207
- offsets,
89208
- ctx.worldQueryDependencies,
89209
- shift,
89210
- accepts
89211
- );
89212
- return { handled: true, value: referenceEntryList(value, ctx) };
89213
- }
89214
- if (memberId === NEO_OBJECT_GRID_MEMBER_IDS.GetTiles) {
89215
- const value = index.tiles(
89216
- placement,
89217
- offsets,
89218
- ctx.worldQueryDependencies,
89219
- shift,
89220
- accepts
89221
- );
89222
- return { handled: true, value: referenceEntryList(value, ctx) };
89223
- }
89224
- const tile = index.tile(
89225
- placement,
89226
- offsets,
89227
- ctx.worldQueryDependencies,
89228
- shift,
89229
- accepts
89230
- );
89231
- if (tile === null) return { handled: true, value: null };
89232
- const row = evalValueById(
89233
- ctx,
89234
- tile.placementValueId,
89235
- ctx.__runtimeSessionValues,
89236
- ctx.__valueOverlay
89237
- );
89238
- if (row === null) {
89239
- throw new NSGetterRuntimeError(
89240
- `Tile placement '${tile.placementValueId}' is missing.`
89241
- );
89242
- }
89243
- return { handled: true, value: readRowValue(row, ctx) };
89244
- }
89245
- return evaluateCellPatternNative(memberId, receiver, args, {
89246
- readPattern: (value) => readCellPattern(value, ctx),
89247
- constructPattern: (offsets) => constructDeclaredClassValue(
89248
- {
89249
- schemaClassInfo: {
89250
- type: 7 /* Class */,
89251
- required: true,
89252
- classId: NEO_CELL_PATTERN_CLASS_ID
89253
- },
89254
- constructorId: NEO_CELL_PATTERN_CONSTRUCTOR_ID,
89255
- args: [
89256
- {
89257
- name: "offsets",
89258
- valuePointer: {
89259
- type: "value" /* value */,
89260
- value: {
89261
- typeInfo: {
89262
- type: 6 /* List */,
89263
- required: true,
89264
- entryTypeInfo: {
89265
- type: 15 /* Vector2Int */,
89266
- required: true
89267
- }
89268
- },
89269
- value: offsets
89270
- }
89365
+ function gridQueryPlacement(receiver, ctx) {
89366
+ const receiverRow = trackedRowForValueReference(receiver, ctx);
89367
+ if (receiverRow === null) {
89368
+ throw new NSGetterRuntimeError(
89369
+ "Grid queries require a placed NeoObject receiver."
89370
+ );
89371
+ }
89372
+ const index = worldGridQueryIndexForContext(ctx);
89373
+ return {
89374
+ index,
89375
+ placement: index.placement(receiverRow.id, ctx.worldQueryDependencies)
89376
+ };
89377
+ }
89378
+ function gridQueryArguments(call, ctx) {
89379
+ return {
89380
+ offsets: readCellPattern(call.args[0], ctx),
89381
+ shift: readGridQueryOffset(call.args[1]),
89382
+ accepts: gridQueryClassFilter(call.typeArguments?.[0], ctx)
89383
+ };
89384
+ }
89385
+ function cellPatternNative(memberId) {
89386
+ return (call, ctx) => evaluateCellPatternNative(memberId, call.receiver, call.args, {
89387
+ readPattern: (value) => readCellPattern(value, ctx),
89388
+ constructPattern: (offsets) => constructDeclaredClassValue(
89389
+ {
89390
+ schemaClassInfo: {
89391
+ type: 7 /* Class */,
89392
+ required: true,
89393
+ classId: NEO_CELL_PATTERN_CLASS_ID
89394
+ },
89395
+ constructorId: NEO_CELL_PATTERN_CONSTRUCTOR_ID,
89396
+ args: [
89397
+ {
89398
+ name: "offsets",
89399
+ valuePointer: {
89400
+ type: "value" /* value */,
89401
+ value: {
89402
+ typeInfo: {
89403
+ type: 6 /* List */,
89404
+ required: true,
89405
+ entryTypeInfo: {
89406
+ type: 15 /* Vector2Int */,
89407
+ required: true
89408
+ }
89409
+ },
89410
+ value: offsets
89271
89411
  }
89272
89412
  }
89273
- ],
89274
- fields: []
89275
- },
89276
- createTopLevelScope(ctx),
89277
- ctx
89278
- )
89279
- });
89413
+ }
89414
+ ],
89415
+ fields: []
89416
+ },
89417
+ createTopLevelScope(ctx),
89418
+ ctx
89419
+ )
89420
+ });
89421
+ }
89422
+ function evaluateSystemNative(memberId, call, ctx) {
89423
+ const handler = SYSTEM_NATIVE_HANDLERS.get(memberId);
89424
+ if (handler === void 0) return { handled: false };
89425
+ try {
89426
+ return { handled: true, value: handler(call, ctx) };
89280
89427
  } catch (error) {
89281
89428
  if (error instanceof RangeError || error instanceof TypeError || error instanceof WorldGridQueryError) {
89282
89429
  throw new NSGetterRuntimeError(error.message, { cause: error });
@@ -93506,10 +93653,11 @@ function currentOwnedValueAttachments(valueId, ctx) {
93506
93653
  ctx.__runtimeSessionValues,
93507
93654
  ctx.__valueOverlay
93508
93655
  );
93509
- if (typeof row?.containerId === "string") {
93656
+ const containerId = row === null ? void 0 : currentUnorderedContainerId(row, ctx);
93657
+ if (containerId !== void 0) {
93510
93658
  add({
93511
- identity: `value:${row.containerId}:unordered-entry:${valueId}`,
93512
- label: row.containerId
93659
+ identity: `value:${containerId}:unordered-entry:${valueId}`,
93660
+ label: containerId
93513
93661
  });
93514
93662
  }
93515
93663
  const activeStaticRoot = activeStaticBindingRoot(valueId, ctx);
@@ -94889,7 +95037,7 @@ function recordWrittenEntry(collection, key, reference2, ctx) {
94889
95037
  if (reference2) keys.add(String(key));
94890
95038
  else keys.delete(String(key));
94891
95039
  }
94892
- var DELEGATE_LEXICAL_THIS, DELEGATE_LEXICAL_ROOT, DELEGATE_LEXICAL_TYPE_ARGUMENTS, NonCatchableNSGetterRuntimeError, NativeFunctionDelegateUnavailableError, CorruptNeoScriptIRError, NeoScriptWallClockTimeoutError, liveListIndexesByProject, evaluatorOwnershipCachesByBase, MAX_CONSTRUCTION_DEPTH, resolutionCacheByMembers, NO_SCHEMA_REVISION, NO_INTERFACES2, LazyValueOverlay, READONLY_FOREACH_BINDING_ERROR, READONLY_CATCH_BINDING_ERROR, DIALOGUE_CONTEXT_PARAMETER_ID, STRING_TYPE_INFO, INT_TYPE_INFO, STORE_LIFETIME, STORE_NAMES, FORWARDING_TYPE_ARGUMENTS, constantDeclarationRoots, UNKNOWN_LOOKUP_TARGET, NS_MATH_OP_NAMES, DOUBLE_INTEGRAL_MAGNITUDE, EMPTY_SUPPLIED_CONSTRUCTOR_FIELDS, variantResolutionCopiesByOverlay, NO_BOUND_MEMBERS, NO_GENERIC_ENV;
95040
+ var DELEGATE_LEXICAL_THIS, DELEGATE_LEXICAL_ROOT, DELEGATE_LEXICAL_TYPE_ARGUMENTS, NonCatchableNSGetterRuntimeError, NativeFunctionDelegateUnavailableError, CorruptNeoScriptIRError, NeoScriptWallClockTimeoutError, liveListIndexesByProject, evaluatorOwnershipCachesByBase, MAX_CONSTRUCTION_DEPTH, resolutionCacheByMembers, NO_SCHEMA_REVISION, NO_INTERFACES2, LazyValueOverlay, READONLY_FOREACH_BINDING_ERROR, READONLY_CATCH_BINDING_ERROR, DIALOGUE_CONTEXT_PARAMETER_ID, STRING_TYPE_INFO, INT_TYPE_INFO, STORE_LIFETIME, STORE_NAMES, FORWARDING_TYPE_ARGUMENTS, constantDeclarationRoots, UNKNOWN_LOOKUP_TARGET, MAX_AREA_DEPTH, getAreaNative, SYSTEM_NATIVE_HANDLERS, NS_MATH_OP_NAMES, DOUBLE_INTEGRAL_MAGNITUDE, EMPTY_SUPPLIED_CONSTRUCTOR_FIELDS, variantResolutionCopiesByOverlay, NO_BOUND_MEMBERS, NO_GENERIC_ENV;
94893
95041
  var init_evaluateNSGetter = __esm({
94894
95042
  "../packages/neoscript-runtime/src/neoscript/evaluateNSGetter.ts"() {
94895
95043
  "use strict";
@@ -95112,6 +95260,121 @@ var init_evaluateNSGetter = __esm({
95112
95260
  type: NS_TYPE_UNKNOWN,
95113
95261
  required: true
95114
95262
  };
95263
+ MAX_AREA_DEPTH = 256;
95264
+ getAreaNative = (call, ctx) => {
95265
+ const receiver = trackedRowForValueReference(call.receiver, ctx);
95266
+ let row = receiver === null ? null : evalValueById(
95267
+ ctx,
95268
+ receiver.id,
95269
+ ctx.__runtimeSessionValues,
95270
+ ctx.__valueOverlay
95271
+ );
95272
+ const schema = evaluatorSchemaIndex(ctx);
95273
+ for (let depth = 0; row !== null && depth < MAX_AREA_DEPTH; depth++) {
95274
+ let edge;
95275
+ if (!Array.isArray(row.value)) {
95276
+ let classId = row.classId ?? void 0;
95277
+ if (classId === void 0) {
95278
+ edge = firstOwnerEdge(row, ctx);
95279
+ classId = placedClassId(row, ctx, edge);
95280
+ }
95281
+ if (classId !== void 0 && schema.classIsOrExtends(classId, NEO_TILE_GRID_CLASS_ID)) {
95282
+ const accepts = gridQueryClassFilter(call.typeArguments?.[0], ctx);
95283
+ return accepts === void 0 || accepts(classId) ? readRowValue(row, ctx) : null;
95284
+ }
95285
+ }
95286
+ const parentId = (edge ?? firstOwnerEdge(row, ctx))?.parentId;
95287
+ if (parentId === void 0) {
95288
+ if (placingMemberBinding(row, ctx) === null) {
95289
+ ctx.onUnattributableValueRead?.(
95290
+ ownershipChainRead("owned-value-parents", row.id)
95291
+ );
95292
+ }
95293
+ return null;
95294
+ }
95295
+ row = currentUnorderedContainerId(row, ctx) === parentId ? untrackedValueById(parentId, ctx) : evalValueById(
95296
+ ctx,
95297
+ parentId,
95298
+ ctx.__runtimeSessionValues,
95299
+ ctx.__valueOverlay
95300
+ );
95301
+ }
95302
+ return null;
95303
+ };
95304
+ SYSTEM_NATIVE_HANDLERS = new Map([
95305
+ [
95306
+ NEO_OBJECT_GRID_MEMBER_IDS.GetCell,
95307
+ (call, ctx) => ({
95308
+ ...gridQueryPlacement(call.receiver, ctx).placement.cell
95309
+ })
95310
+ ],
95311
+ [
95312
+ NEO_OBJECT_GRID_MEMBER_IDS.GetObjects,
95313
+ (call, ctx) => {
95314
+ const { index, placement } = gridQueryPlacement(call.receiver, ctx);
95315
+ const { offsets, shift, accepts } = gridQueryArguments(call, ctx);
95316
+ return referenceEntryList(
95317
+ index.objects(
95318
+ placement,
95319
+ offsets,
95320
+ ctx.worldQueryDependencies,
95321
+ shift,
95322
+ accepts
95323
+ ),
95324
+ ctx
95325
+ );
95326
+ }
95327
+ ],
95328
+ [
95329
+ NEO_OBJECT_GRID_MEMBER_IDS.GetTiles,
95330
+ (call, ctx) => {
95331
+ const { index, placement } = gridQueryPlacement(call.receiver, ctx);
95332
+ const { offsets, shift, accepts } = gridQueryArguments(call, ctx);
95333
+ return referenceEntryList(
95334
+ index.tiles(
95335
+ placement,
95336
+ offsets,
95337
+ ctx.worldQueryDependencies,
95338
+ shift,
95339
+ accepts
95340
+ ),
95341
+ ctx
95342
+ );
95343
+ }
95344
+ ],
95345
+ [
95346
+ NEO_OBJECT_GRID_MEMBER_IDS.GetTile,
95347
+ (call, ctx) => {
95348
+ const { index, placement } = gridQueryPlacement(call.receiver, ctx);
95349
+ const { offsets, shift, accepts } = gridQueryArguments(call, ctx);
95350
+ const tile = index.tile(
95351
+ placement,
95352
+ offsets,
95353
+ ctx.worldQueryDependencies,
95354
+ shift,
95355
+ accepts
95356
+ );
95357
+ if (tile === null) return null;
95358
+ const row = evalValueById(
95359
+ ctx,
95360
+ tile.placementValueId,
95361
+ ctx.__runtimeSessionValues,
95362
+ ctx.__valueOverlay
95363
+ );
95364
+ if (row === null) {
95365
+ throw new NSGetterRuntimeError(
95366
+ `Tile placement '${tile.placementValueId}' is missing.`
95367
+ );
95368
+ }
95369
+ return readRowValue(row, ctx);
95370
+ }
95371
+ ],
95372
+ [NEO_GET_AREA_MEMBER_IDS.NeoObjectBase, getAreaNative],
95373
+ [NEO_GET_AREA_MEMBER_IDS.NeoTile, getAreaNative],
95374
+ ...[...NEO_CELL_PATTERN_PURE_NATIVE_MEMBER_IDS].map(
95375
+ (id2) => [id2, cellPatternNative(id2)]
95376
+ )
95377
+ ]);
95115
95378
  NS_MATH_OP_NAMES = {
95116
95379
  min: "Min",
95117
95380
  max: "Max",
@@ -96585,6 +96848,356 @@ var init_stored_value_placement_index = __esm({
96585
96848
  }
96586
96849
  });
96587
96850
 
96851
+ // ../packages/neoscript-runtime/src/values/initializer-identifiers.ts
96852
+ function initializerReferencedIdentifiers(source) {
96853
+ let expression;
96854
+ try {
96855
+ expression = parseExpression(source);
96856
+ } catch {
96857
+ return /* @__PURE__ */ new Set();
96858
+ }
96859
+ const identifiers = /* @__PURE__ */ new Set();
96860
+ const pending = [expression];
96861
+ const visited = /* @__PURE__ */ new Set();
96862
+ while (pending.length > 0) {
96863
+ const value = pending.pop();
96864
+ if (value === null || typeof value !== "object" || visited.has(value)) {
96865
+ continue;
96866
+ }
96867
+ visited.add(value);
96868
+ if (Reflect.get(value, "kind") === "ident") {
96869
+ const name = Reflect.get(value, "name");
96870
+ if (typeof name === "string") identifiers.add(name);
96871
+ }
96872
+ for (const child2 of Object.values(value)) pending.push(child2);
96873
+ }
96874
+ return identifiers;
96875
+ }
96876
+ function initializerReferencesAnyIdentifier(source, names) {
96877
+ const identifiers = initializerReferencedIdentifiers(source);
96878
+ for (const name of names) {
96879
+ if (identifiers.has(name)) return true;
96880
+ }
96881
+ return false;
96882
+ }
96883
+ var init_initializer_identifiers = __esm({
96884
+ "../packages/neoscript-runtime/src/values/initializer-identifiers.ts"() {
96885
+ "use strict";
96886
+ init_executable_parser();
96887
+ }
96888
+ });
96889
+
96890
+ // ../packages/neoscript-runtime/src/initializer-materialization.ts
96891
+ function declarationInitializerContext(document) {
96892
+ const key = initializerEvaluatorCacheKey(document);
96893
+ const revision = initializerEvaluatorCacheRevision(document);
96894
+ const cached = declarationInitializerContextByDocument.get(key);
96895
+ if (cached !== void 0 && (revision === void 0 ? cached.members === document.members && cached.values === document.values : cached.revision === revision)) {
96896
+ return cached.context;
96897
+ }
96898
+ const initializerValueIds = new Set(
96899
+ document.values.filter(isInitValueContent).map((value) => value.id)
96900
+ );
96901
+ const valuesById = new Map(
96902
+ document.values.map((value) => [value.id, value])
96903
+ );
96904
+ const rootOwners = /* @__PURE__ */ new Map();
96905
+ resolveOwnerMembersForValues(
96906
+ document,
96907
+ initializerValueIds,
96908
+ void 0,
96909
+ rootOwners
96910
+ );
96911
+ const created = { valuesById, rootOwners };
96912
+ declarationInitializerContextByDocument.set(key, {
96913
+ members: document.members,
96914
+ values: document.values,
96915
+ revision,
96916
+ context: created
96917
+ });
96918
+ return created;
96919
+ }
96920
+ function evaluateInitializerMaterialization(args) {
96921
+ const createdValues = [];
96922
+ const storageKeyDeclarations = /* @__PURE__ */ new Map();
96923
+ const evaluated = args.evaluateInitializer({
96924
+ genericEnv: args.genericEnv,
96925
+ init: args.init,
96926
+ member: args.member,
96927
+ document: args.document,
96928
+ createdValues,
96929
+ storageKeyDeclarations,
96930
+ ...args.storedConstructionReplay === true ? { storedConstructionReplay: true } : {},
96931
+ ...args.constructionBaselineReplay === true ? { constructionBaselineReplay: true } : {},
96932
+ ...args.argumentValues === void 0 ? {} : { argumentValues: args.argumentValues },
96933
+ sourceValueId: args.sourceValueId ?? null,
96934
+ readTracking: args.readTracking,
96935
+ saveStaticBindings: args.saveStaticBindings,
96936
+ sessionStaticBindings: args.sessionStaticBindings
96937
+ });
96938
+ return { evaluated, createdValues, storageKeyDeclarations };
96939
+ }
96940
+ function materializeInPlaceFields(document, root, createdValues) {
96941
+ const owners = [root, ...createdValues];
96942
+ for (const owner of owners) {
96943
+ const record7 = owner.value;
96944
+ if (typeof owner.classId !== "string") continue;
96945
+ if (typeof record7 !== "object" || record7 === null) continue;
96946
+ if (Array.isArray(record7)) continue;
96947
+ let memberIds;
96948
+ for (const [schemaKey, value] of Object.entries(record7)) {
96949
+ if (typeof value === "string" || value === null) continue;
96950
+ memberIds ??= new Map(
96951
+ resolvedClassSchema(
96952
+ owner.classId,
96953
+ document.classes,
96954
+ document.members
96955
+ ).surface.map((entry) => [entry.schemaKey, entry.memberId])
96956
+ );
96957
+ const memberId = memberIds.get(schemaKey);
96958
+ if (memberId === void 0) {
96959
+ throw new Error(
96960
+ `Class "${owner.classId}" holds "${schemaKey}" in place, which its schema doesn't declare.`
96961
+ );
96962
+ }
96963
+ const row = {
96964
+ id: virtualValueId(owner.id, memberId),
96965
+ projectId: owner.projectId,
96966
+ createdAt: owner.createdAt,
96967
+ updatedAt: owner.updatedAt,
96968
+ value
96969
+ };
96970
+ createdValues.push(row);
96971
+ record7[schemaKey] = row.id;
96972
+ }
96973
+ }
96974
+ }
96975
+ function finalizeMaterializedRoot(args) {
96976
+ materializeInPlaceFields(args.document, args.root, args.createdValues);
96977
+ const allCreated = [args.root, ...args.createdValues];
96978
+ for (const created of allCreated) {
96979
+ if (created === args.root) continue;
96980
+ if (created.classId === void 0) delete created.classId;
96981
+ }
96982
+ stampCreatedValuesMapKey(allCreated, args.mapKey);
96983
+ if (args.supersededRootId !== void 0) {
96984
+ args.storageKeyDeclarations.delete(args.supersededRootId);
96985
+ }
96986
+ args.storageKeyDeclarations.delete(args.root.id);
96987
+ applyDeclaredStorageKeyOverrides({
96988
+ createdValues: allCreated,
96989
+ declarationByValueId: args.storageKeyDeclarations,
96990
+ existingParentContextById: /* @__PURE__ */ new Map([
96991
+ [
96992
+ args.root.id,
96993
+ {
96994
+ mapKey: args.mapKey ?? null,
96995
+ classId: args.root.classId ?? void 0
96996
+ }
96997
+ ]
96998
+ ])
96999
+ });
97000
+ }
97001
+ function materializeInitializerValue(args) {
97002
+ const { evaluated, createdValues, storageKeyDeclarations } = evaluateInitializerMaterialization({
97003
+ evaluateInitializer: args.evaluateInitializer,
97004
+ init: args.row.init,
97005
+ member: args.member,
97006
+ document: args.document,
97007
+ ...args.storedConstructionReplay === true ? { storedConstructionReplay: true } : {},
97008
+ ...args.constructionBaselineReplay === true ? { constructionBaselineReplay: true } : {},
97009
+ ...args.argumentValues === void 0 ? {} : { argumentValues: args.argumentValues },
97010
+ genericEnv: envFromStamp(args.row.genericBindings),
97011
+ sourceValueId: args.row.id,
97012
+ readTracking: args.readTracking,
97013
+ saveStaticBindings: args.saveStaticBindings,
97014
+ sessionStaticBindings: args.sessionStaticBindings
97015
+ });
97016
+ const {
97017
+ init: _init,
97018
+ value: _value,
97019
+ classId: _classId,
97020
+ ...envelope
97021
+ } = args.row;
97022
+ void _init;
97023
+ void _value;
97024
+ void _classId;
97025
+ const root = {
97026
+ ...envelope,
97027
+ value: evaluated.value,
97028
+ ...evaluated.classId === null ? {} : { classId: evaluated.classId },
97029
+ ...evaluated.genericBindings === void 0 ? {} : { genericBindings: { ...evaluated.genericBindings } },
97030
+ ...deepClonePlainData(pickInstanceProvenance(evaluated))
97031
+ };
97032
+ if (evaluated.provisionalRootId !== void 0) {
97033
+ args.document.listenerDefaultCapture?.retarget(
97034
+ evaluated.provisionalRootId,
97035
+ root.id
97036
+ );
97037
+ retargetInitializerRootValueIds(
97038
+ [root, ...createdValues],
97039
+ evaluated.provisionalRootId,
97040
+ root.id
97041
+ );
97042
+ }
97043
+ finalizeMaterializedRoot({
97044
+ document: args.document,
97045
+ root,
97046
+ createdValues,
97047
+ mapKey: args.row.mapKey,
97048
+ storageKeyDeclarations
97049
+ });
97050
+ return {
97051
+ root,
97052
+ createdValues,
97053
+ pinnedRootSchemaKeys: evaluated.pinnedRootSchemaKeys ?? /* @__PURE__ */ new Set(),
97054
+ pinnedSchemaKeysByValueId: evaluated.pinnedSchemaKeysByValueId ?? /* @__PURE__ */ new Map()
97055
+ };
97056
+ }
97057
+ function materializeMemberDefaultValue(args) {
97058
+ const createdValues = [];
97059
+ const storageKeyDeclarations = /* @__PURE__ */ new Map();
97060
+ const declarationArguments = (member, init, sourceValueId) => {
97061
+ const { valuesById, rootOwners } = declarationInitializerContext(
97062
+ args.document
97063
+ );
97064
+ const ownerClass = typeof sourceValueId === "string" ? initializerOwnerContext(
97065
+ args.document,
97066
+ sourceValueId,
97067
+ rootOwners,
97068
+ valuesById,
97069
+ (id2) => args.readTracking?.valueIds.add(id2)
97070
+ ).ownerClass : typeof Reflect.get(member, "id") === "string" && !isStaticMember(member) ? findSchemaPlacement(
97071
+ String(Reflect.get(member, "id")),
97072
+ args.document.classes
97073
+ )?.ownerClass ?? null : null;
97074
+ if (ownerClass === null) return [];
97075
+ const constructorId = ownerClass.requiredConstructorId;
97076
+ if (typeof constructorId !== "string") return [];
97077
+ const constructor2 = args.document.constructors?.find(
97078
+ (candidate) => candidate.id === constructorId
97079
+ );
97080
+ if (constructor2 === void 0) return [];
97081
+ const parameterNames = new Set(
97082
+ constructor2.argumentTypes.map((argument2) => argument2.name)
97083
+ );
97084
+ return declarationInitializerArgumentValues(
97085
+ constructor2.argumentTypes,
97086
+ `Declaration template on '${ownerClass.name}'`,
97087
+ initializerReferencesAnyIdentifier(init.code, parameterNames)
97088
+ );
97089
+ };
97090
+ let lookups;
97091
+ const evaluatorLookups = () => lookups ??= args.initializerEvaluatorLookups(
97092
+ args.document,
97093
+ args.readTracking
97094
+ );
97095
+ const plans = args.readTracking !== void 0 && args.document.databaseVM === void 0 ? void 0 : args.defaultValuePlans(args.document);
97096
+ const database = args.document.databaseVM;
97097
+ const hostPlan = database?.materializationPlan;
97098
+ const built = buildDefaultMemberValue({
97099
+ document: {
97100
+ ...args.document,
97101
+ // The declaration rows a default clones are reads of this
97102
+ // materialization, like any row its initializers read.
97103
+ valueById: (id2) => {
97104
+ args.readTracking?.valueIds.add(id2);
97105
+ const database2 = evaluatorLookups();
97106
+ return database2.defaultValueById !== void 0 ? database2.defaultValueById(id2) : database2.valueById(id2);
97107
+ },
97108
+ unorderedListEntryIds: (containerId) => {
97109
+ args.readTracking?.containerIds.add(containerId);
97110
+ const entryIds = evaluatorLookups().unorderedListEntryIds?.(containerId);
97111
+ if (entryIds === void 0) {
97112
+ throw new Error(
97113
+ `Initializer lookups resolve no unordered-list membership for container "${containerId}".`
97114
+ );
97115
+ }
97116
+ return entryIds;
97117
+ },
97118
+ // Not `resolvedMember`: its id-keyed cache would answer for the
97119
+ // caller's rewritten copy of a member with the stored original.
97120
+ ...plans === void 0 ? {} : {
97121
+ instanceEnv: plans.instanceEnv,
97122
+ storedInstanceMaterializationPlan: hostPlan === void 0 ? plans.storedInstanceMaterializationPlan : (classId, instanceEnv) => hostPlan.call(database, classId, instanceEnv)
97123
+ },
97124
+ recordPlanReads: (reads) => {
97125
+ for (const id2 of reads.valueIds) args.readTracking?.valueIds.add(id2);
97126
+ for (const id2 of reads.containerIds)
97127
+ args.readTracking?.containerIds.add(id2);
97128
+ }
97129
+ },
97130
+ projectId: args.envelope.projectId,
97131
+ member: args.member,
97132
+ createdValues,
97133
+ storageKeyDeclarations,
97134
+ declarationRoot: args.declarationRoot,
97135
+ ...args.genericEnv === void 0 ? {} : { genericEnv: args.genericEnv },
97136
+ // A declaration default may itself be init-backed one level down (P43 §2),
97137
+ // and those nested initializers must evaluate against the same document.
97138
+ initEvaluator: (member, init, sourceValueId, genericEnv) => args.evaluateInitializer({
97139
+ genericEnv,
97140
+ storageKeyDeclarations,
97141
+ init,
97142
+ member,
97143
+ document: args.document,
97144
+ createdValues,
97145
+ storedConstructionReplay: true,
97146
+ argumentValues: declarationArguments(
97147
+ member,
97148
+ init,
97149
+ sourceValueId ?? null
97150
+ ),
97151
+ sourceValueId: sourceValueId ?? null,
97152
+ readTracking: args.readTracking,
97153
+ saveStaticBindings: args.saveStaticBindings,
97154
+ sessionStaticBindings: args.sessionStaticBindings
97155
+ })
97156
+ });
97157
+ const interior = createdValues.filter((created) => created.id !== built.id);
97158
+ const root = {
97159
+ ...args.envelope,
97160
+ value: built.value,
97161
+ ...built.changeListeners === void 0 ? {} : { changeListeners: built.changeListeners },
97162
+ ...built.changeListenerEndpoints === void 0 ? {} : { changeListenerEndpoints: built.changeListenerEndpoints },
97163
+ ...built.classId === void 0 ? {} : { classId: built.classId },
97164
+ ...built.genericBindings == null ? {} : { genericBindings: { ...built.genericBindings } }
97165
+ };
97166
+ args.document.listenerDefaultCapture?.retarget(built.id, root.id);
97167
+ retargetInitializerRootValueIds([root, ...interior], built.id, root.id);
97168
+ finalizeMaterializedRoot({
97169
+ document: args.document,
97170
+ root,
97171
+ createdValues: interior,
97172
+ mapKey: args.envelope.mapKey,
97173
+ storageKeyDeclarations,
97174
+ supersededRootId: built.id
97175
+ });
97176
+ return {
97177
+ root,
97178
+ createdValues: interior,
97179
+ pinnedRootSchemaKeys: /* @__PURE__ */ new Set(),
97180
+ pinnedSchemaKeysByValueId: /* @__PURE__ */ new Map()
97181
+ };
97182
+ }
97183
+ var declarationInitializerContextByDocument;
97184
+ var init_initializer_materialization = __esm({
97185
+ "../packages/neoscript-runtime/src/initializer-materialization.ts"() {
97186
+ "use strict";
97187
+ init_deep_clone_plain_data();
97188
+ init_members();
97189
+ init_inheritance();
97190
+ init_member_value_id();
97191
+ init_instance_provenance();
97192
+ init_generics();
97193
+ init_evaluateNSGetter();
97194
+ init_initializer_context();
97195
+ init_value_row_owner_members();
97196
+ init_initializer_identifiers();
97197
+ declarationInitializerContextByDocument = /* @__PURE__ */ new WeakMap();
97198
+ }
97199
+ });
97200
+
96588
97201
  // ../packages/neoscript-runtime/src/declaration-default-source.ts
96589
97202
  function declarationDefaultSource(id2, stored, resolveGraph) {
96590
97203
  if (stored !== null && !isCollapseStampedInstanceRoot(stored)) return stored;
@@ -96599,6 +97212,37 @@ var init_declaration_default_source = __esm({
96599
97212
  }
96600
97213
  });
96601
97214
 
97215
+ // ../packages/neoscript-runtime/src/virtual-value-identity.ts
97216
+ function claimVirtualIdentity(args) {
97217
+ if (args.fixedVirtualId !== void 0) {
97218
+ args.claimedVirtualIds.set(args.fixedVirtualId, args.pathKey);
97219
+ return {
97220
+ sourceIdentity: args.rawSourceIdentity,
97221
+ virtualId: args.fixedVirtualId
97222
+ };
97223
+ }
97224
+ const valueId = (sourceIdentity4) => derivedVirtualValueId(args.instanceRootId, sourceIdentity4);
97225
+ const derivedId = valueId(args.rawSourceIdentity);
97226
+ const claimedPath = args.claimedVirtualIds.get(derivedId);
97227
+ if (claimedPath === void 0 || claimedPath === args.pathKey) {
97228
+ args.claimedVirtualIds.set(derivedId, args.pathKey);
97229
+ return { sourceIdentity: args.rawSourceIdentity, virtualId: derivedId };
97230
+ }
97231
+ const sourceIdentity3 = `${args.rawSourceIdentity}:${args.pathKey}`;
97232
+ const virtualId = valueId(sourceIdentity3);
97233
+ args.claimedVirtualIds.set(virtualId, args.pathKey);
97234
+ return { sourceIdentity: sourceIdentity3, virtualId };
97235
+ }
97236
+ function derivedVirtualValueId(instanceRootId, sourceIdentity3) {
97237
+ return instanceRootId.startsWith("__pending__:") || hasPendingVirtualSourceIdentity(sourceIdentity3) ? pendingVirtualValueId(instanceRootId, sourceIdentity3) : virtualValueId(instanceRootId, sourceIdentity3);
97238
+ }
97239
+ var init_virtual_value_identity = __esm({
97240
+ "../packages/neoscript-runtime/src/virtual-value-identity.ts"() {
97241
+ "use strict";
97242
+ init_member_value_id();
97243
+ }
97244
+ });
97245
+
96602
97246
  // ../packages/neoscript-runtime/src/listener-endpoint-projection.ts
96603
97247
  function projectListenerEndpoint(args) {
96604
97248
  const { descriptor } = args;
@@ -96628,7 +97272,7 @@ function projectListenerEndpoint(args) {
96628
97272
  var init_listener_endpoint_projection = __esm({
96629
97273
  "../packages/neoscript-runtime/src/listener-endpoint-projection.ts"() {
96630
97274
  "use strict";
96631
- init_virtual_instance_graph();
97275
+ init_virtual_value_identity();
96632
97276
  }
96633
97277
  });
96634
97278
 
@@ -96783,29 +97427,6 @@ function projectNestedListenerEndpoint(id2, descriptor, sourceRoot, targetRoot)
96783
97427
  return derive(targetRoot, positional);
96784
97428
  return void 0;
96785
97429
  }
96786
- function claimVirtualIdentity(args) {
96787
- if (args.fixedVirtualId !== void 0) {
96788
- args.claimedVirtualIds.set(args.fixedVirtualId, args.pathKey);
96789
- return {
96790
- sourceIdentity: args.rawSourceIdentity,
96791
- virtualId: args.fixedVirtualId
96792
- };
96793
- }
96794
- const valueId = (sourceIdentity4) => derivedVirtualValueId(args.instanceRootId, sourceIdentity4);
96795
- const derivedId = valueId(args.rawSourceIdentity);
96796
- const claimedPath = args.claimedVirtualIds.get(derivedId);
96797
- if (claimedPath === void 0 || claimedPath === args.pathKey) {
96798
- args.claimedVirtualIds.set(derivedId, args.pathKey);
96799
- return { sourceIdentity: args.rawSourceIdentity, virtualId: derivedId };
96800
- }
96801
- const sourceIdentity3 = `${args.rawSourceIdentity}:${args.pathKey}`;
96802
- const virtualId = valueId(sourceIdentity3);
96803
- args.claimedVirtualIds.set(virtualId, args.pathKey);
96804
- return { sourceIdentity: sourceIdentity3, virtualId };
96805
- }
96806
- function derivedVirtualValueId(instanceRootId, sourceIdentity3) {
96807
- return instanceRootId.startsWith("__pending__:") || hasPendingVirtualSourceIdentity(sourceIdentity3) ? pendingVirtualValueId(instanceRootId, sourceIdentity3) : virtualValueId(instanceRootId, sourceIdentity3);
96808
- }
96809
97430
  function materializationReadTracking(recorder) {
96810
97431
  if (recorder === void 0)
96811
97432
  return { readTracking: void 0, trackMaterialization: (m) => m() };
@@ -96949,7 +97570,7 @@ function expandStoredInstance(args) {
96949
97570
  code: `virtual-replay:${args.instanceRoot.id}`
96950
97571
  });
96951
97572
  return trackMaterialization(
96952
- () => materializeInitializerValue({
97573
+ () => args.materializeInitializerValue({
96953
97574
  evaluateInitializer: args.evaluateInitializer,
96954
97575
  document: args.document,
96955
97576
  member: replayMember,
@@ -96965,7 +97586,7 @@ function expandStoredInstance(args) {
96965
97586
  const replayDeclaredDefault = () => {
96966
97587
  const stampEnv = instanceRoot.genericBindings == null || Object.keys(instanceRoot.genericBindings).length === 0 ? null : envFromStamp(instanceRoot.genericBindings);
96967
97588
  const built = trackMaterialization(
96968
- () => materializeMemberDefaultValue({
97589
+ () => args.materializeMemberDefaultValue({
96969
97590
  evaluateInitializer: args.evaluateInitializer,
96970
97591
  document: args.document,
96971
97592
  member: replayMember,
@@ -97958,6 +98579,8 @@ function resolveStoredInstanceGraphs(args) {
97958
98579
  if (isMaterializedSpine(resolvedLocations.get(next.root.id))) continue;
97959
98580
  const graph = isClassSlotMember(next.member) ? args.resolveClassGraph?.(next.root, next.member) ?? resolveStoredClassValue({
97960
98581
  evaluateInitializer: args.evaluateInitializer,
98582
+ materializeInitializerValue: args.materializeInitializerValue,
98583
+ materializeMemberDefaultValue: args.materializeMemberDefaultValue,
97961
98584
  document,
97962
98585
  instanceRoot: next.root,
97963
98586
  rootMember: next.member,
@@ -98054,7 +98677,7 @@ function expandStoredClassValue(args) {
98054
98677
  args.readRecorder
98055
98678
  );
98056
98679
  const materialized = trackMaterialization(
98057
- () => materializeMemberDefaultValue({
98680
+ () => args.materializeMemberDefaultValue({
98058
98681
  ...readTracking === void 0 ? {} : { readTracking },
98059
98682
  saveStaticBindings: args.saveStaticBindings,
98060
98683
  sessionStaticBindings: args.sessionStaticBindings,
@@ -99791,6 +100414,8 @@ function resolveVariantInstanceGraphForDocument(args) {
99791
100414
  materializedById.set(args.priorInstanceRoot.id, args.priorInstanceRoot);
99792
100415
  const priorExpanded = expandStoredInstance({
99793
100416
  evaluateInitializer: args.evaluateInitializer,
100417
+ materializeInitializerValue: args.materializeInitializerValue,
100418
+ materializeMemberDefaultValue: args.materializeMemberDefaultValue,
99794
100419
  document,
99795
100420
  instanceRoot: args.priorInstanceRoot,
99796
100421
  rootMember,
@@ -99864,6 +100489,8 @@ function resolveVariantInstanceGraphForDocument(args) {
99864
100489
  materializedById.set(nextInstanceRoot.id, nextInstanceRoot);
99865
100490
  const nextExpanded = expandStoredInstance({
99866
100491
  evaluateInitializer: args.evaluateInitializer,
100492
+ materializeInitializerValue: args.materializeInitializerValue,
100493
+ materializeMemberDefaultValue: args.materializeMemberDefaultValue,
99867
100494
  document,
99868
100495
  instanceRoot: nextInstanceRoot,
99869
100496
  rootMember,
@@ -100990,6 +101617,8 @@ function createHeadlessVirtualInstanceResolver(args) {
100990
101617
  const replayDocument = evidence === null ? resolverDocumentOnce() : frameDocument(evidence);
100991
101618
  const resolution2 = prepareStoredClassValueResolution({
100992
101619
  evaluateInitializer: args.evaluateInitializer,
101620
+ materializeInitializerValue: args.materializeInitializerValue,
101621
+ materializeMemberDefaultValue: args.materializeMemberDefaultValue,
100993
101622
  document: replayDocument,
100994
101623
  instanceRoot,
100995
101624
  rootMember: member,
@@ -101284,7 +101913,8 @@ var init_virtual_instance_graph = __esm({
101284
101913
  init_immutable_json();
101285
101914
  init_members();
101286
101915
  init_instance_provenance();
101287
- init_member_value_id();
101916
+ init_virtual_value_identity();
101917
+ init_virtual_value_identity();
101288
101918
  init_stored_value_placement_index();
101289
101919
  init_unordered_list_membership();
101290
101920
  init_neoscript_types();
@@ -101292,7 +101922,6 @@ var init_virtual_instance_graph = __esm({
101292
101922
  init_project_schema_index();
101293
101923
  init_initializer_context();
101294
101924
  init_strict_ir();
101295
- init_initializer_materialization();
101296
101925
  init_unattributable_reads();
101297
101926
  init_member_body_reads();
101298
101927
  KEPT_ROW_SAMPLE_LIMIT = 12;
@@ -101526,6 +102155,8 @@ function initializerEvaluatorLookups(document, readTracking) {
101526
102155
  const shareFrom = document.evaluatorOverlay === void 0 ? void 0 : sharedHeadlessResolver(document.evaluatorOverlay);
101527
102156
  const headlessVirtualResolver = createHeadlessVirtualInstanceResolver({
101528
102157
  evaluateInitializer: evaluateMemberInitializer,
102158
+ materializeInitializerValue,
102159
+ materializeMemberDefaultValue: materializeMemberDefaultValue2,
101529
102160
  documentMaterializationPlan,
101530
102161
  document,
101531
102162
  resolverLookups: () => lookups,
@@ -101554,6 +102185,8 @@ function initializerEvaluatorLookups(document, readTracking) {
101554
102185
  // nested resolver.
101555
102186
  resolveVariantInstanceGraph: (args) => resolveVariantInstanceGraphForDocument({
101556
102187
  evaluateInitializer: evaluateMemberInitializer,
102188
+ materializeInitializerValue,
102189
+ materializeMemberDefaultValue: materializeMemberDefaultValue2,
101557
102190
  document,
101558
102191
  resolverLookups: lookups,
101559
102192
  readRecorder: headlessVirtualResolver.readRecorder,
@@ -101742,6 +102375,8 @@ function createInitializerMaterializationBatch(authoredDocument, pendingInitiali
101742
102375
  let resolver;
101743
102376
  const virtual = () => resolver ??= createHeadlessVirtualInstanceResolver({
101744
102377
  evaluateInitializer: evaluateMemberInitializer,
102378
+ materializeInitializerValue,
102379
+ materializeMemberDefaultValue: materializeMemberDefaultValue2,
101745
102380
  documentMaterializationPlan,
101746
102381
  document,
101747
102382
  membersById: indexed.membersById,
@@ -101824,6 +102459,8 @@ function createInitializerMaterializationBatch(authoredDocument, pendingInitiali
101824
102459
  virtualInstanceRootIdForValue: (id2) => owningInstanceRootId(virtual().virtualInstanceGraphForValue(id2)),
101825
102460
  resolveVariantInstanceGraph: (args) => resolveVariantInstanceGraphForDocument({
101826
102461
  evaluateInitializer: evaluateMemberInitializer,
102462
+ materializeInitializerValue,
102463
+ materializeMemberDefaultValue: materializeMemberDefaultValue2,
101827
102464
  document,
101828
102465
  resolverLookups: lookups,
101829
102466
  ...args
@@ -102057,10 +102694,18 @@ function storedConstructionReplaySlot(member, sourceRow, document) {
102057
102694
  }
102058
102695
  };
102059
102696
  }
102697
+ function materializeMemberDefaultValue2(args) {
102698
+ return materializeMemberDefaultValue({
102699
+ ...args,
102700
+ initializerEvaluatorLookups,
102701
+ defaultValuePlans
102702
+ });
102703
+ }
102060
102704
  var evaluatorLookupsByDocument, headlessResolversByLookupKey, indexedEvaluatorLookupsByDocument, defaultValuePlansByDocument;
102061
102705
  var init_evaluateInitializer = __esm({
102062
102706
  "../packages/neoscript-runtime/src/neoscript/evaluateInitializer.ts"() {
102063
102707
  "use strict";
102708
+ init_initializer_materialization();
102064
102709
  init_NSGetterRuntimeError();
102065
102710
  init_declaration_default_source();
102066
102711
  init_member_change_listeners();
@@ -102081,354 +102726,6 @@ var init_evaluateInitializer = __esm({
102081
102726
  }
102082
102727
  });
102083
102728
 
102084
- // ../packages/neoscript-runtime/src/values/initializer-identifiers.ts
102085
- function initializerReferencedIdentifiers(source) {
102086
- let expression;
102087
- try {
102088
- expression = parseExpression(source);
102089
- } catch {
102090
- return /* @__PURE__ */ new Set();
102091
- }
102092
- const identifiers = /* @__PURE__ */ new Set();
102093
- const pending = [expression];
102094
- const visited = /* @__PURE__ */ new Set();
102095
- while (pending.length > 0) {
102096
- const value = pending.pop();
102097
- if (value === null || typeof value !== "object" || visited.has(value)) {
102098
- continue;
102099
- }
102100
- visited.add(value);
102101
- if (Reflect.get(value, "kind") === "ident") {
102102
- const name = Reflect.get(value, "name");
102103
- if (typeof name === "string") identifiers.add(name);
102104
- }
102105
- for (const child2 of Object.values(value)) pending.push(child2);
102106
- }
102107
- return identifiers;
102108
- }
102109
- function initializerReferencesAnyIdentifier(source, names) {
102110
- const identifiers = initializerReferencedIdentifiers(source);
102111
- for (const name of names) {
102112
- if (identifiers.has(name)) return true;
102113
- }
102114
- return false;
102115
- }
102116
- var init_initializer_identifiers = __esm({
102117
- "../packages/neoscript-runtime/src/values/initializer-identifiers.ts"() {
102118
- "use strict";
102119
- init_executable_parser();
102120
- }
102121
- });
102122
-
102123
- // ../packages/neoscript-runtime/src/initializer-materialization.ts
102124
- function declarationInitializerContext(document) {
102125
- const key = initializerEvaluatorCacheKey(document);
102126
- const revision = initializerEvaluatorCacheRevision(document);
102127
- const cached = declarationInitializerContextByDocument.get(key);
102128
- if (cached !== void 0 && (revision === void 0 ? cached.members === document.members && cached.values === document.values : cached.revision === revision)) {
102129
- return cached.context;
102130
- }
102131
- const initializerValueIds = new Set(
102132
- document.values.filter(isInitValueContent).map((value) => value.id)
102133
- );
102134
- const valuesById = new Map(
102135
- document.values.map((value) => [value.id, value])
102136
- );
102137
- const rootOwners = /* @__PURE__ */ new Map();
102138
- resolveOwnerMembersForValues(
102139
- document,
102140
- initializerValueIds,
102141
- void 0,
102142
- rootOwners
102143
- );
102144
- const created = { valuesById, rootOwners };
102145
- declarationInitializerContextByDocument.set(key, {
102146
- members: document.members,
102147
- values: document.values,
102148
- revision,
102149
- context: created
102150
- });
102151
- return created;
102152
- }
102153
- function evaluateInitializerMaterialization(args) {
102154
- const createdValues = [];
102155
- const storageKeyDeclarations = /* @__PURE__ */ new Map();
102156
- const evaluated = args.evaluateInitializer({
102157
- genericEnv: args.genericEnv,
102158
- init: args.init,
102159
- member: args.member,
102160
- document: args.document,
102161
- createdValues,
102162
- storageKeyDeclarations,
102163
- ...args.storedConstructionReplay === true ? { storedConstructionReplay: true } : {},
102164
- ...args.constructionBaselineReplay === true ? { constructionBaselineReplay: true } : {},
102165
- ...args.argumentValues === void 0 ? {} : { argumentValues: args.argumentValues },
102166
- sourceValueId: args.sourceValueId ?? null,
102167
- readTracking: args.readTracking,
102168
- saveStaticBindings: args.saveStaticBindings,
102169
- sessionStaticBindings: args.sessionStaticBindings
102170
- });
102171
- return { evaluated, createdValues, storageKeyDeclarations };
102172
- }
102173
- function materializeInPlaceFields(document, root, createdValues) {
102174
- const owners = [root, ...createdValues];
102175
- for (const owner of owners) {
102176
- const record7 = owner.value;
102177
- if (typeof owner.classId !== "string") continue;
102178
- if (typeof record7 !== "object" || record7 === null) continue;
102179
- if (Array.isArray(record7)) continue;
102180
- let memberIds;
102181
- for (const [schemaKey, value] of Object.entries(record7)) {
102182
- if (typeof value === "string" || value === null) continue;
102183
- memberIds ??= new Map(
102184
- resolvedClassSchema(
102185
- owner.classId,
102186
- document.classes,
102187
- document.members
102188
- ).surface.map((entry) => [entry.schemaKey, entry.memberId])
102189
- );
102190
- const memberId = memberIds.get(schemaKey);
102191
- if (memberId === void 0) {
102192
- throw new Error(
102193
- `Class "${owner.classId}" holds "${schemaKey}" in place, which its schema doesn't declare.`
102194
- );
102195
- }
102196
- const row = {
102197
- id: virtualValueId(owner.id, memberId),
102198
- projectId: owner.projectId,
102199
- createdAt: owner.createdAt,
102200
- updatedAt: owner.updatedAt,
102201
- value
102202
- };
102203
- createdValues.push(row);
102204
- record7[schemaKey] = row.id;
102205
- }
102206
- }
102207
- }
102208
- function finalizeMaterializedRoot(args) {
102209
- materializeInPlaceFields(args.document, args.root, args.createdValues);
102210
- const allCreated = [args.root, ...args.createdValues];
102211
- for (const created of allCreated) {
102212
- if (created === args.root) continue;
102213
- if (created.classId === void 0) delete created.classId;
102214
- }
102215
- stampCreatedValuesMapKey(allCreated, args.mapKey);
102216
- if (args.supersededRootId !== void 0) {
102217
- args.storageKeyDeclarations.delete(args.supersededRootId);
102218
- }
102219
- args.storageKeyDeclarations.delete(args.root.id);
102220
- applyDeclaredStorageKeyOverrides({
102221
- createdValues: allCreated,
102222
- declarationByValueId: args.storageKeyDeclarations,
102223
- existingParentContextById: /* @__PURE__ */ new Map([
102224
- [
102225
- args.root.id,
102226
- {
102227
- mapKey: args.mapKey ?? null,
102228
- classId: args.root.classId ?? void 0
102229
- }
102230
- ]
102231
- ])
102232
- });
102233
- }
102234
- function materializeInitializerValue(args) {
102235
- const { evaluated, createdValues, storageKeyDeclarations } = evaluateInitializerMaterialization({
102236
- evaluateInitializer: args.evaluateInitializer,
102237
- init: args.row.init,
102238
- member: args.member,
102239
- document: args.document,
102240
- ...args.storedConstructionReplay === true ? { storedConstructionReplay: true } : {},
102241
- ...args.constructionBaselineReplay === true ? { constructionBaselineReplay: true } : {},
102242
- ...args.argumentValues === void 0 ? {} : { argumentValues: args.argumentValues },
102243
- genericEnv: envFromStamp(args.row.genericBindings),
102244
- sourceValueId: args.row.id,
102245
- readTracking: args.readTracking,
102246
- saveStaticBindings: args.saveStaticBindings,
102247
- sessionStaticBindings: args.sessionStaticBindings
102248
- });
102249
- const {
102250
- init: _init,
102251
- value: _value,
102252
- classId: _classId,
102253
- ...envelope
102254
- } = args.row;
102255
- void _init;
102256
- void _value;
102257
- void _classId;
102258
- const root = {
102259
- ...envelope,
102260
- value: evaluated.value,
102261
- ...evaluated.classId === null ? {} : { classId: evaluated.classId },
102262
- ...evaluated.genericBindings === void 0 ? {} : { genericBindings: { ...evaluated.genericBindings } },
102263
- ...deepClonePlainData(pickInstanceProvenance(evaluated))
102264
- };
102265
- if (evaluated.provisionalRootId !== void 0) {
102266
- args.document.listenerDefaultCapture?.retarget(
102267
- evaluated.provisionalRootId,
102268
- root.id
102269
- );
102270
- retargetInitializerRootValueIds(
102271
- [root, ...createdValues],
102272
- evaluated.provisionalRootId,
102273
- root.id
102274
- );
102275
- }
102276
- finalizeMaterializedRoot({
102277
- document: args.document,
102278
- root,
102279
- createdValues,
102280
- mapKey: args.row.mapKey,
102281
- storageKeyDeclarations
102282
- });
102283
- return {
102284
- root,
102285
- createdValues,
102286
- pinnedRootSchemaKeys: evaluated.pinnedRootSchemaKeys ?? /* @__PURE__ */ new Set(),
102287
- pinnedSchemaKeysByValueId: evaluated.pinnedSchemaKeysByValueId ?? /* @__PURE__ */ new Map()
102288
- };
102289
- }
102290
- function materializeMemberDefaultValue(args) {
102291
- const createdValues = [];
102292
- const storageKeyDeclarations = /* @__PURE__ */ new Map();
102293
- const declarationArguments = (member, init, sourceValueId) => {
102294
- const { valuesById, rootOwners } = declarationInitializerContext(
102295
- args.document
102296
- );
102297
- const ownerClass = typeof sourceValueId === "string" ? initializerOwnerContext(
102298
- args.document,
102299
- sourceValueId,
102300
- rootOwners,
102301
- valuesById,
102302
- (id2) => args.readTracking?.valueIds.add(id2)
102303
- ).ownerClass : typeof Reflect.get(member, "id") === "string" && !isStaticMember(member) ? findSchemaPlacement(
102304
- String(Reflect.get(member, "id")),
102305
- args.document.classes
102306
- )?.ownerClass ?? null : null;
102307
- if (ownerClass === null) return [];
102308
- const constructorId = ownerClass.requiredConstructorId;
102309
- if (typeof constructorId !== "string") return [];
102310
- const constructor2 = args.document.constructors?.find(
102311
- (candidate) => candidate.id === constructorId
102312
- );
102313
- if (constructor2 === void 0) return [];
102314
- const parameterNames = new Set(
102315
- constructor2.argumentTypes.map((argument2) => argument2.name)
102316
- );
102317
- return declarationInitializerArgumentValues(
102318
- constructor2.argumentTypes,
102319
- `Declaration template on '${ownerClass.name}'`,
102320
- initializerReferencesAnyIdentifier(init.code, parameterNames)
102321
- );
102322
- };
102323
- let lookups;
102324
- const evaluatorLookups = () => lookups ??= initializerEvaluatorLookups(args.document, args.readTracking);
102325
- const plans = args.readTracking !== void 0 && args.document.databaseVM === void 0 ? void 0 : defaultValuePlans(args.document);
102326
- const database = args.document.databaseVM;
102327
- const hostPlan = database?.materializationPlan;
102328
- const built = buildDefaultMemberValue({
102329
- document: {
102330
- ...args.document,
102331
- // The declaration rows a default clones are reads of this
102332
- // materialization, like any row its initializers read.
102333
- valueById: (id2) => {
102334
- args.readTracking?.valueIds.add(id2);
102335
- const database2 = evaluatorLookups();
102336
- return database2.defaultValueById !== void 0 ? database2.defaultValueById(id2) : database2.valueById(id2);
102337
- },
102338
- unorderedListEntryIds: (containerId) => {
102339
- args.readTracking?.containerIds.add(containerId);
102340
- const entryIds = evaluatorLookups().unorderedListEntryIds?.(containerId);
102341
- if (entryIds === void 0) {
102342
- throw new Error(
102343
- `Initializer lookups resolve no unordered-list membership for container "${containerId}".`
102344
- );
102345
- }
102346
- return entryIds;
102347
- },
102348
- // Not `resolvedMember`: its id-keyed cache would answer for the
102349
- // caller's rewritten copy of a member with the stored original.
102350
- ...plans === void 0 ? {} : {
102351
- instanceEnv: plans.instanceEnv,
102352
- storedInstanceMaterializationPlan: hostPlan === void 0 ? plans.storedInstanceMaterializationPlan : (classId, instanceEnv) => hostPlan.call(database, classId, instanceEnv)
102353
- },
102354
- recordPlanReads: (reads) => {
102355
- for (const id2 of reads.valueIds) args.readTracking?.valueIds.add(id2);
102356
- for (const id2 of reads.containerIds)
102357
- args.readTracking?.containerIds.add(id2);
102358
- }
102359
- },
102360
- projectId: args.envelope.projectId,
102361
- member: args.member,
102362
- createdValues,
102363
- storageKeyDeclarations,
102364
- declarationRoot: args.declarationRoot,
102365
- ...args.genericEnv === void 0 ? {} : { genericEnv: args.genericEnv },
102366
- // A declaration default may itself be init-backed one level down (P43 §2),
102367
- // and those nested initializers must evaluate against the same document.
102368
- initEvaluator: (member, init, sourceValueId, genericEnv) => args.evaluateInitializer({
102369
- genericEnv,
102370
- storageKeyDeclarations,
102371
- init,
102372
- member,
102373
- document: args.document,
102374
- createdValues,
102375
- storedConstructionReplay: true,
102376
- argumentValues: declarationArguments(
102377
- member,
102378
- init,
102379
- sourceValueId ?? null
102380
- ),
102381
- sourceValueId: sourceValueId ?? null,
102382
- readTracking: args.readTracking,
102383
- saveStaticBindings: args.saveStaticBindings,
102384
- sessionStaticBindings: args.sessionStaticBindings
102385
- })
102386
- });
102387
- const interior = createdValues.filter((created) => created.id !== built.id);
102388
- const root = {
102389
- ...args.envelope,
102390
- value: built.value,
102391
- ...built.changeListeners === void 0 ? {} : { changeListeners: built.changeListeners },
102392
- ...built.changeListenerEndpoints === void 0 ? {} : { changeListenerEndpoints: built.changeListenerEndpoints },
102393
- ...built.classId === void 0 ? {} : { classId: built.classId },
102394
- ...built.genericBindings == null ? {} : { genericBindings: { ...built.genericBindings } }
102395
- };
102396
- args.document.listenerDefaultCapture?.retarget(built.id, root.id);
102397
- retargetInitializerRootValueIds([root, ...interior], built.id, root.id);
102398
- finalizeMaterializedRoot({
102399
- document: args.document,
102400
- root,
102401
- createdValues: interior,
102402
- mapKey: args.envelope.mapKey,
102403
- storageKeyDeclarations,
102404
- supersededRootId: built.id
102405
- });
102406
- return {
102407
- root,
102408
- createdValues: interior,
102409
- pinnedRootSchemaKeys: /* @__PURE__ */ new Set(),
102410
- pinnedSchemaKeysByValueId: /* @__PURE__ */ new Map()
102411
- };
102412
- }
102413
- var declarationInitializerContextByDocument;
102414
- var init_initializer_materialization = __esm({
102415
- "../packages/neoscript-runtime/src/initializer-materialization.ts"() {
102416
- "use strict";
102417
- init_deep_clone_plain_data();
102418
- init_members();
102419
- init_inheritance();
102420
- init_member_value_id();
102421
- init_instance_provenance();
102422
- init_generics();
102423
- init_evaluateInitializer();
102424
- init_evaluateNSGetter();
102425
- init_initializer_context();
102426
- init_value_row_owner_members();
102427
- init_initializer_identifiers();
102428
- declarationInitializerContextByDocument = /* @__PURE__ */ new WeakMap();
102429
- }
102430
- });
102431
-
102432
102729
  // ../packages/neoscript-runtime/src/effective-value-reader.ts
102433
102730
  function rootReadScope(document) {
102434
102731
  const cached = rootReadScopes.get(document);
@@ -103071,7 +103368,7 @@ var init_effective_value_reader = __esm({
103071
103368
  });
103072
103369
  if (slot.kind !== "declaration") continue;
103073
103370
  if (record7 === row.value) record7 = { ...record7 };
103074
- const materialized = materializeMemberDefaultValue({
103371
+ const materialized = materializeMemberDefaultValue2({
103075
103372
  ...this.context,
103076
103373
  evaluateInitializer: evaluateMemberInitializer,
103077
103374
  document: this.declarationDocument,
@@ -103148,6 +103445,8 @@ var init_effective_value_reader = __esm({
103148
103445
  instanceRoot: root,
103149
103446
  rootMember: placement,
103150
103447
  evaluateInitializer: evaluateMemberInitializer,
103448
+ materializeInitializerValue,
103449
+ materializeMemberDefaultValue: materializeMemberDefaultValue2,
103151
103450
  materializedIndex: this.materializedIndex,
103152
103451
  resolveClassGraph: this.context.readTracking === void 0 && this.context.saveStaticBindings === void 0 && this.context.sessionStaticBindings === void 0 ? (root2, member) => initializerStoredClassGraph(this.readDocument, root2.id, member) : void 0,
103153
103452
  onResolvedListenerDefaults: (ownerId, entry) => {
@@ -103192,7 +103491,7 @@ var init_effective_value_reader = __esm({
103192
103491
  const cached = this.defaultRows.get(memberKey)?.get(envKey);
103193
103492
  if (cached !== void 0) return cached;
103194
103493
  let evaluatedInitializer = false;
103195
- const result = materializeMemberDefaultValue({
103494
+ const result = materializeMemberDefaultValue2({
103196
103495
  ...this.context,
103197
103496
  evaluateInitializer: (args) => {
103198
103497
  evaluatedInitializer = true;
@@ -103456,31 +103755,40 @@ var init_neoscript2 = __esm({
103456
103755
  function expandStoredInstance2(args) {
103457
103756
  return expandStoredInstance({
103458
103757
  ...args,
103459
- evaluateInitializer: evaluateMemberInitializer
103758
+ evaluateInitializer: evaluateMemberInitializer,
103759
+ materializeInitializerValue,
103760
+ materializeMemberDefaultValue: materializeMemberDefaultValue2
103460
103761
  });
103461
103762
  }
103462
103763
  function resolveVariantInstanceGraphForDocument2(args) {
103463
103764
  return resolveVariantInstanceGraphForDocument({
103464
103765
  ...args,
103465
- evaluateInitializer: evaluateMemberInitializer
103766
+ evaluateInitializer: evaluateMemberInitializer,
103767
+ materializeInitializerValue,
103768
+ materializeMemberDefaultValue: materializeMemberDefaultValue2
103466
103769
  });
103467
103770
  }
103468
103771
  function createHeadlessVirtualInstanceResolver2(args) {
103469
103772
  return createHeadlessVirtualInstanceResolver({
103470
103773
  ...args,
103471
103774
  evaluateInitializer: evaluateMemberInitializer,
103775
+ materializeInitializerValue,
103776
+ materializeMemberDefaultValue: materializeMemberDefaultValue2,
103472
103777
  documentMaterializationPlan
103473
103778
  });
103474
103779
  }
103475
103780
  function resolveStoredClassValue2(args) {
103476
103781
  return resolveStoredClassValue({
103477
103782
  ...args,
103478
- evaluateInitializer: evaluateMemberInitializer
103783
+ evaluateInitializer: evaluateMemberInitializer,
103784
+ materializeInitializerValue,
103785
+ materializeMemberDefaultValue: materializeMemberDefaultValue2
103479
103786
  });
103480
103787
  }
103481
103788
  var init_virtual_instance_values = __esm({
103482
103789
  "../packages/neoscript-runtime/src/virtual-instance-values.ts"() {
103483
103790
  "use strict";
103791
+ init_initializer_materialization();
103484
103792
  init_evaluateInitializer();
103485
103793
  init_virtual_instance_graph();
103486
103794
  init_virtual_instance_graph();
@@ -126565,11 +126873,10 @@ function appendAuthoredOwnedValueCascadeDeletes(args) {
126565
126873
  for (const rootId of survivingConstructionIds) {
126566
126874
  const instanceRoot = compiledReplayRows.get(rootId) ?? postValuesById.get(rootId);
126567
126875
  const rootMember = postPlacements.get(rootId).member;
126568
- const expanded = expandStoredInstance({
126876
+ const expanded = expandStoredInstance2({
126569
126877
  document: resolverDocument,
126570
126878
  instanceRoot,
126571
- rootMember,
126572
- evaluateInitializer: evaluateMemberInitializer
126879
+ rootMember
126573
126880
  });
126574
126881
  const graph = resolveVirtualInstanceGraph({
126575
126882
  document: resolverDocument,
@@ -139445,6 +139752,10 @@ function verifyProjectSourceCommitAgainstStateV4(args) {
139445
139752
  trustedPendingProjectFiles.set(pendingId2, metadata);
139446
139753
  }
139447
139754
  }
139755
+ const derivedSeedRowIds = derivedCandidateSeedRowIds(
139756
+ args.authoredValueSeeds,
139757
+ args.stateRecords
139758
+ );
139448
139759
  const status = computeWorkspaceStatus(workspace, {
139449
139760
  forceRecompile: args.forceRecompile,
139450
139761
  skipProjectBinaryInspection: true,
@@ -139470,7 +139781,8 @@ ${blockingErrors.map((error) => error.message).join("\n")}` : `Trusted source lo
139470
139781
  auditAuthoredSeedRowIdentities(
139471
139782
  status.authoredValueSeeds,
139472
139783
  args.stateRecords,
139473
- assignments
139784
+ assignments,
139785
+ derivedSeedRowIds
139474
139786
  );
139475
139787
  const usedAssignments = /* @__PURE__ */ new Set();
139476
139788
  const positionless = positionIndependentAssignments(assignments);
@@ -139533,14 +139845,14 @@ function isDerivedOnlyRefresh(change, stateRecords) {
139533
139845
  if (!isObjectRecord(base.data)) return false;
139534
139846
  return canonicalStringify(comparisonData(change.recordKind, change.nextData)) === canonicalStringify(comparisonData(change.recordKind, base.data));
139535
139847
  }
139536
- function auditAuthoredSeedRowIdentities(seeds, stateRecords, assignments) {
139848
+ function auditAuthoredSeedRowIdentities(seeds, stateRecords, assignments, derivedRowIds = /* @__PURE__ */ new Set()) {
139537
139849
  const mintedIds = new Set(assignments.values());
139538
139850
  const authoredCreates = /* @__PURE__ */ new Set();
139539
139851
  for (const [memberId, seed] of seeds) {
139540
139852
  for (const row of seed.values ?? []) {
139541
139853
  if (isPendingId(row.id)) continue;
139542
139854
  if (stateRecords[`value:${row.id}`] !== void 0) continue;
139543
- if (!isUuidV4Id(row.id)) {
139855
+ if (!isUuidV4Id(row.id) && !derivedRowIds.has(row.id)) {
139544
139856
  throw new ProjectSourceCommitVerificationError(
139545
139857
  `Static value seed for member ${memberId} creates row ${row.id}, which is not a UUID v4. A new row's authored identity must wear the same shape a minted one does.`
139546
139858
  );
@@ -139559,6 +139871,19 @@ function auditAuthoredSeedRowIdentities(seeds, stateRecords, assignments) {
139559
139871
  }
139560
139872
  }
139561
139873
  }
139874
+ function derivedCandidateSeedRowIds(seeds, stateRecords) {
139875
+ const derived = /* @__PURE__ */ new Set();
139876
+ for (const seed of seeds) {
139877
+ for (const row of seed.values ?? []) {
139878
+ if (isDerivedNewValueId(
139879
+ row.id,
139880
+ (id2) => stateRecords[`value:${id2}`] !== void 0
139881
+ ))
139882
+ derived.add(row.id);
139883
+ }
139884
+ }
139885
+ return derived;
139886
+ }
139562
139887
  function validateAssignments(value) {
139563
139888
  const assignments = /* @__PURE__ */ new Map();
139564
139889
  const assignedIds = /* @__PURE__ */ new Set();
@@ -142011,6 +142336,9 @@ function emitStoredConstructorExpression(context, member, valueId, visited = /*
142011
142336
  targetTyped
142012
142337
  );
142013
142338
  if (constructor2 !== null) return constructor2;
142339
+ if (hasStoredConstruction && value.instanceConstructorId === null) {
142340
+ return targetTyped ? "new()" : `new ${className}`;
142341
+ }
142014
142342
  if (projection === null || projection.arguments.length === 0 && schemaClass2.requiredConstructorId === void 0) {
142015
142343
  throw new Error(
142016
142344
  `Stored materialized value ${valueId} has no constructor arguments.`
@@ -149559,6 +149887,9 @@ function classValueBody(context, member, value, visited, targetTyped, outerEnvir
149559
149887
  }
149560
149888
  continue;
149561
149889
  }
149890
+ const storedBase = context.storedValueBase;
149891
+ if (storedBase !== void 0 && isDerivedNewValueId(childId, (id2) => storedBase.has(id2)))
149892
+ continue;
149562
149893
  const preservesBinding = context.collectionBindingValueIds.has(childId) || context.localValues?.byValueId.has(childId) === true;
149563
149894
  const baseChildBody = context.storedValueBase?.get(childId)?.value;
149564
149895
  const clearedStoredClassOverrides = isObjectRecord(baseChildBody) && Object.keys(baseChildBody).length > 0;
@@ -151732,6 +152063,7 @@ var init_value_sources = __esm({
151732
152063
  "src/project-source/value-sources.ts"() {
151733
152064
  "use strict";
151734
152065
  init_immutable_json3();
152066
+ init_lower_support();
151735
152067
  init_record_fields();
151736
152068
  init_source_syntax_cache();
151737
152069
  init_lexer();
@@ -153003,8 +153335,7 @@ function materializeInitializersLocallyV4(args) {
153003
153335
  const sourceRoots = initializerSourceRootIds(
153004
153336
  args.changes,
153005
153337
  args.authoredValueSeeds,
153006
- records3,
153007
- args.workspace.state.records
153338
+ records3
153008
153339
  );
153009
153340
  const written = [...args.changes];
153010
153341
  for (const seed of args.authoredValueSeeds) {
@@ -153402,28 +153733,23 @@ function initializerCode(records3, valueId) {
153402
153733
  }
153403
153734
  return row.init.code;
153404
153735
  }
153405
- function initializerSourceRootIds(changes, seeds, records3, baseRecords) {
153736
+ function initializerSourceRootIds(changes, seeds, records3) {
153406
153737
  const ids = /* @__PURE__ */ new Set();
153407
- const needsFirstMaterialization = (valueId) => {
153408
- const base = baseRecords[`value:${valueId}`]?.data;
153409
- return base === void 0 || isObjectRecord(base) && isObjectRecord(base.init);
153410
- };
153411
153738
  for (const change of changes) {
153412
153739
  if (change.recordKind !== "value") continue;
153413
153740
  if (!isObjectRecord(change.nextData)) continue;
153414
153741
  if (!isObjectRecord(change.nextData.init)) continue;
153415
- if (!needsFirstMaterialization(change.recordId)) continue;
153416
153742
  ids.add(change.recordId);
153417
153743
  }
153418
153744
  for (const seed of seeds) {
153419
153745
  const member = records3.get(`member:${seed.memberId}`)?.data;
153420
153746
  const instanceBinding = isObjectRecord(member) && (member.modifier === 3 || member.valueId === seed.valueId);
153421
153747
  if (!instanceBinding) continue;
153422
- if (seed.nodeType === "initializer" && typeof seed.valueId === "string" && needsFirstMaterialization(seed.valueId)) {
153748
+ if (seed.nodeType === "initializer" && typeof seed.valueId === "string") {
153423
153749
  ids.add(seed.valueId);
153424
153750
  }
153425
153751
  for (const row of seed.values ?? []) {
153426
- if (row.nodeType === "initializer" && needsFirstMaterialization(row.id)) {
153752
+ if (row.nodeType === "initializer") {
153427
153753
  ids.add(row.id);
153428
153754
  }
153429
153755
  }
@@ -156757,6 +157083,13 @@ function walkValueSegments(walk, startId, segments, path, subject, fail2) {
156757
157083
  return null;
156758
157084
  }
156759
157085
  if (!isObjectRecord(body)) {
157086
+ const initializer = pending !== void 0 ? pending.nodeType === "initializer" : isInitValueContent(walk.state[`value:${cursor}`]?.data);
157087
+ if (initializer) {
157088
+ fail2(
157089
+ `${subject} ${path} stops before segment ${segment}: an init block constructs the row it reaches, so a path cannot name its members yet.`
157090
+ );
157091
+ return null;
157092
+ }
156760
157093
  fail2(
156761
157094
  `${subject} ${path} stops before segment ${segment}: the row it reaches stores no single-valued members.`
156762
157095
  );
@@ -156854,6 +157187,7 @@ var init_root_source = __esm({
156854
157187
  "use strict";
156855
157188
  init_project_root();
156856
157189
  init_value_comparison();
157190
+ init_members();
156857
157191
  init_value_sources();
156858
157192
  init_source_format();
156859
157193
  init_stored_value_placements();
@@ -182644,8 +182978,8 @@ function emitsStaticMember(ctx, member) {
182644
182978
  if (!isStaticMember(member)) return false;
182645
182979
  return ctx.singleton || requiresUnitySingleton(member);
182646
182980
  }
182647
- function isPlatformNativeMemberId(memberId) {
182648
- return memberId === NEO_TILE_CONVERT_MEMBER_ID || NEO_CELL_PATTERN_PURE_NATIVE_MEMBER_IDS.has(memberId) || Object.values(NEO_OBJECT_GRID_MEMBER_IDS).some((id2) => id2 === memberId);
182981
+ function isPlatformNative(memberId, member) {
182982
+ return member.kind === 13 /* Function */ && memberId.startsWith("system_");
182649
182983
  }
182650
182984
  function collectFunctionInvokers(ctx) {
182651
182985
  const invokers = [];
@@ -182656,13 +182990,13 @@ function collectFunctionInvokers(ctx) {
182656
182990
  for (const [schemaKey, memberId] of Object.entries(classDef.schema)) {
182657
182991
  if (memberId === null) continue;
182658
182992
  if (seen.has(memberId)) continue;
182659
- if (isPlatformNativeMemberId(memberId)) continue;
182660
182993
  const member = resolveMemberById(
182661
182994
  ctx,
182662
182995
  memberId,
182663
182996
  `classes.${classDef.id}.schema.${schemaKey}`
182664
182997
  );
182665
182998
  if (member === null || !isMemberFunctionBase(member)) continue;
182999
+ if (isPlatformNative(memberId, member)) continue;
182666
183000
  seen.add(memberId);
182667
183001
  if (isStaticMember(member) === true) {
182668
183002
  if (!emitsStaticMember(ctx, ctx.exportData.members[memberId])) continue;
@@ -184469,12 +184803,12 @@ function generateNeoSchemaClassLines(ctx, classId, constructions) {
184469
184803
  });
184470
184804
  const ownNativeFunctionEntries = ownCallableEntries.filter(([, memberId]) => {
184471
184805
  const member = resolveMemberById(ctx, memberId, `members.${memberId}`);
184472
- return member !== null && isMemberFunctionBase(member) && !isPlatformNativeMemberId(memberId);
184806
+ return member !== null && isMemberFunctionBase(member) && !isPlatformNative(memberId, member);
184473
184807
  });
184474
184808
  const ownStaticNativeFunctionEntries = ownStaticMemberEntries.filter(
184475
184809
  ([, memberId]) => {
184476
184810
  const member = resolveMemberById(ctx, memberId, `members.${memberId}`);
184477
- return member !== null && isMemberFunctionBase(member) && !isPlatformNativeMemberId(memberId);
184811
+ return member !== null && isMemberFunctionBase(member) && !isPlatformNative(memberId, member);
184478
184812
  }
184479
184813
  );
184480
184814
  const inheritedSchemaKeys = inheritedSchemaKeySet(ctx, classDef);
@@ -185996,9 +186330,9 @@ function classEmitsFunctionHandlerInterface(ctx, classId) {
185996
186330
  const classDef = ctx.exportData.classes[classId];
185997
186331
  if (classDef === void 0 || !ctx.typeNames.has(classId)) return false;
185998
186332
  return Object.values(classDef.schema).some((memberId) => {
185999
- if (memberId === null || isPlatformNativeMemberId(memberId)) return false;
186333
+ if (memberId === null) return false;
186000
186334
  const member = ctx.exportData.members[memberId];
186001
- return isMemberFunctionBase(member) && isStaticMember(member) !== true;
186335
+ return isMemberFunctionBase(member) && !isPlatformNative(memberId, member) && isStaticMember(member) !== true;
186002
186336
  });
186003
186337
  }
186004
186338
  function nearestFunctionHandlerAncestor(ctx, classDef) {
@@ -189164,7 +189498,7 @@ function generateFunctionMethod(ctx, member, schemaKey, modifier = "", emitBody
189164
189498
  "}"
189165
189499
  ];
189166
189500
  }
189167
- if (isPlatformNativeMemberId(member.id) && !isFunctionVoidTypeInfo(member.returnTypeInfo)) {
189501
+ if (isPlatformNative(member.id, member) && !isFunctionVoidTypeInfo(member.returnTypeInfo)) {
189168
189502
  return [
189169
189503
  ...docs,
189170
189504
  ...stamp,
@@ -190925,7 +191259,6 @@ var NEO_MEMORY_SCHEMA_KEYS, NEO_MEMORY_CLASS_NAMES, CELL_PATTERN_VALUE_BASE, DET
190925
191259
  var init_generate_unity_classes = __esm({
190926
191260
  "../src/models/exports/unity-codegen/generate-unity-classes.ts"() {
190927
191261
  "use strict";
190928
- init_cell_pattern();
190929
191262
  init_tile_conversion();
190930
191263
  init_project2();
190931
191264
  init_animation_clips();
@@ -194338,7 +194671,7 @@ var UNITY_CODEGEN_REVISION;
194338
194671
  var init_unity_codegen_revision = __esm({
194339
194672
  "../src/models/exports/unity-codegen-revision.ts"() {
194340
194673
  "use strict";
194341
- UNITY_CODEGEN_REVISION = "90421033eb03f03fcfab25a35784fa8890ae4377edbeee0b925a985754c15d42";
194674
+ UNITY_CODEGEN_REVISION = "231557c5a40a20ab9e630415d45556845d7561d54e335a4d92c1cdbc1024a705";
194342
194675
  }
194343
194676
  });
194344
194677
 
@@ -197094,12 +197427,36 @@ var init_export = __esm({
197094
197427
 
197095
197428
  // src/project-source/evaluation-workspace.ts
197096
197429
  function workspaceForLocalEvaluation(workspace) {
197430
+ const compiled = compilePendingBodies(
197431
+ Object.entries(workspace.state.records),
197432
+ () => {
197433
+ const records3 = /* @__PURE__ */ new Map();
197434
+ for (const [key, record7] of Object.entries(workspace.state.records))
197435
+ records3.set(key, { ...record7, deleted: false });
197436
+ return records3;
197437
+ }
197438
+ );
197439
+ if (compiled === null) return workspace;
197440
+ const refreshed = { ...workspace.state.records };
197441
+ for (const [key, data] of compiled.bodies)
197442
+ refreshed[key] = { ...refreshed[key], data };
197443
+ return { ...workspace, state: { ...workspace.state, records: refreshed } };
197444
+ }
197445
+ function recordsForLocalEvaluation(records3) {
197446
+ const compiled = compilePendingBodies(records3, () => new Map(records3));
197447
+ if (compiled === null) return records3;
197448
+ for (const [key, data] of compiled.bodies)
197449
+ compiled.records.set(key, { ...records3.get(key), data });
197450
+ return compiled.records;
197451
+ }
197452
+ function compilePendingBodies(entries, copyRecords) {
197097
197453
  const memberIds = /* @__PURE__ */ new Set();
197098
197454
  const constructorIds = /* @__PURE__ */ new Set();
197099
197455
  const pending = /* @__PURE__ */ new Map();
197100
197456
  const scriptSources = /* @__PURE__ */ new Map();
197101
- for (const [key, record7] of Object.entries(workspace.state.records)) {
197457
+ for (const [key, record7] of entries) {
197102
197458
  const kind = record7.recordKind;
197459
+ if (record7.deleted === true) continue;
197103
197460
  if (kind !== "member" && kind !== "constructor") continue;
197104
197461
  const stale = firstRejectedNeoScriptCompiledBody(record7.data, null);
197105
197462
  if (stale !== null) {
@@ -197110,34 +197467,27 @@ function workspaceForLocalEvaluation(workspace) {
197110
197467
  } else if (!hasPendingNeoScriptDerivation(kind, record7.data)) continue;
197111
197468
  (kind === "member" ? memberIds : constructorIds).add(record7.recordId);
197112
197469
  scriptSources.set(key, neoScriptRecordSources(record7.data));
197113
- pending.set(key, {
197114
- ...record7,
197115
- deleted: false,
197116
- data: stripClientDerivedBodies(kind, record7.data)
197117
- });
197470
+ pending.set(key, stripClientDerivedBodies(kind, record7.data));
197118
197471
  }
197119
- if (pending.size === 0) return workspace;
197120
- const records3 = /* @__PURE__ */ new Map();
197121
- for (const [key, record7] of Object.entries(workspace.state.records))
197122
- records3.set(key, pending.get(key) ?? { ...record7, deleted: false });
197123
- const document = readPulledProjectDocumentV4(records3);
197472
+ if (pending.size === 0) return null;
197473
+ const compilable = copyRecords();
197474
+ for (const [key, data] of pending)
197475
+ compilable.set(key, { ...compilable.get(key), data });
197476
+ const document = readPulledProjectDocumentV4(compilable);
197124
197477
  compilePulledProjectDocumentForEvaluationV4(document, void 0, {
197125
197478
  memberIds,
197126
197479
  constructorIds,
197127
197480
  scriptSources
197128
197481
  });
197129
- const refreshed = { ...workspace.state.records };
197482
+ const bodies = /* @__PURE__ */ new Map();
197130
197483
  for (const member of document.members) {
197131
- if (!memberIds.has(member.id)) continue;
197132
- const key = `member:${member.id}`;
197133
- refreshed[key] = { ...refreshed[key], data: member };
197484
+ if (memberIds.has(member.id)) bodies.set(`member:${member.id}`, member);
197134
197485
  }
197135
197486
  for (const constructor2 of document.constructors ?? []) {
197136
- if (!constructorIds.has(constructor2.id)) continue;
197137
- const key = `constructor:${constructor2.id}`;
197138
- refreshed[key] = { ...refreshed[key], data: constructor2 };
197487
+ if (constructorIds.has(constructor2.id))
197488
+ bodies.set(`constructor:${constructor2.id}`, constructor2);
197139
197489
  }
197140
- return { ...workspace, state: { ...workspace.state, records: refreshed } };
197490
+ return { records: compilable, bodies };
197141
197491
  }
197142
197492
  var init_evaluation_workspace = __esm({
197143
197493
  "src/project-source/evaluation-workspace.ts"() {
@@ -198453,11 +198803,7 @@ async function prepareLocalPushArtifactsV4(workspace, status, onPhase = () => vo
198453
198803
  } : void 0;
198454
198804
  onPhase("Hashing project source\u2026");
198455
198805
  const source = projectSourceIdentityForStatus(status);
198456
- const verificationSource = options.fullValidation ? createPendingProjectSourceIdentityV4(
198457
- workspace,
198458
- status,
198459
- status.authoredValueSeeds
198460
- ) : null;
198806
+ const verificationSource = options.fullValidation ? locatedPendingProjectSourceIdentity(workspace, status) : null;
198461
198807
  onPhase("Assigning pending value identities\u2026");
198462
198808
  const pendingAssignment = assignPendingIds(
198463
198809
  status.changes,
@@ -198589,6 +198935,17 @@ function locatePreparationError(error, status, assigned) {
198589
198935
  if (source === void 0) return error;
198590
198936
  return new Error(`${source.file}:${source.line} \u2014 ${error.message}`);
198591
198937
  }
198938
+ function locatedPendingProjectSourceIdentity(workspace, status) {
198939
+ try {
198940
+ return createPendingProjectSourceIdentityV4(
198941
+ workspace,
198942
+ status,
198943
+ status.authoredValueSeeds
198944
+ );
198945
+ } catch (error) {
198946
+ throw locatePreparationError(error, status, /* @__PURE__ */ new Map());
198947
+ }
198948
+ }
198592
198949
  async function prepareLocalCandidateV4(workspace, options = {}) {
198593
198950
  const pushOptions = {
198594
198951
  dryRun: options.dryRun ?? true,
@@ -198953,19 +199310,22 @@ function createPendingProjectSourceIdentityV4(workspace, status, authoredValueSe
198953
199310
  }
198954
199311
  }
198955
199312
  materializePendingSourceLocalization(records3, status);
198956
- const emission = emitProjectDocumentFilesV4(records3, {
198957
- dialogueGroupSymbols: authoredDialogueGroupSymbols(
198958
- status.sourceSnapshot?.analysis
198959
- ),
198960
- storedValueBase: storedValueRowsByIdV4(
198961
- Object.values(workspace.state.records)
198962
- ),
198963
- recordFiles: projectRecordFilesV4(
198964
- Object.values(workspace.state.records),
198965
- status.reconstructed.values()
198966
- ),
198967
- localValues: status.localValues
198968
- });
199313
+ const emission = emitProjectDocumentFilesV4(
199314
+ recordsForLocalEvaluation(records3),
199315
+ {
199316
+ dialogueGroupSymbols: authoredDialogueGroupSymbols(
199317
+ status.sourceSnapshot?.analysis
199318
+ ),
199319
+ storedValueBase: storedValueRowsByIdV4(
199320
+ Object.values(workspace.state.records)
199321
+ ),
199322
+ recordFiles: projectRecordFilesV4(
199323
+ Object.values(workspace.state.records),
199324
+ status.reconstructed.values()
199325
+ ),
199326
+ localValues: status.localValues
199327
+ }
199328
+ );
198969
199329
  const files = emission.files.map((file) => {
198970
199330
  const kind = neoProjectSourceKind(file.path, file.content);
198971
199331
  if (kind === null || !isNeoProjectProductionSourceKind(kind)) {
@@ -201985,7 +202345,7 @@ async function finishFormat4Pull(args) {
201985
202345
  const formatSource = createWorkspaceSourceFormatter(workspace.root);
201986
202346
  const localResult = emitProjectDocumentFilesV4(
201987
202347
  candidateValueRecordsForEmissionV4(
201988
- localRecords,
202348
+ recordsForLocalEvaluation(localRecords),
201989
202349
  workspace.state.records,
201990
202350
  workspace.config.projectId
201991
202351
  ),
@@ -202468,17 +202828,19 @@ function buildEmitRecordSet(document, plans, side) {
202468
202828
  resolvedRecordKind,
202469
202829
  resolvedRecordId,
202470
202830
  data,
202471
- serverRecord
202831
+ // A locally created record's derived fields, such as a new
202832
+ // static field's pending valueId, came from this same lowering.
202833
+ serverRecord ?? (plan.conflicted ? void 0 : { data })
202472
202834
  ) : data
202473
202835
  });
202474
202836
  }
202475
202837
  return records3;
202476
202838
  }
202477
- function composeProspectivePullRecord(recordKind, recordId, data, serverRecord) {
202839
+ function composeProspectivePullRecord(recordKind, recordId, data, base) {
202478
202840
  if (!isSchemaRecordKindV4(recordKind) || !isObjectRecord(data)) return data;
202479
202841
  let baseRecord = null;
202480
- if (serverRecord !== void 0) {
202481
- if (!isObjectRecord(serverRecord.data)) {
202842
+ if (base !== void 0) {
202843
+ if (!isObjectRecord(base.data)) {
202482
202844
  throw new Error(
202483
202845
  `Cannot compose pulled ${recordKind} record ${JSON.stringify(recordId)} because its server payload is not an object.`
202484
202846
  );
@@ -202486,7 +202848,7 @@ function composeProspectivePullRecord(recordKind, recordId, data, serverRecord)
202486
202848
  baseRecord = {
202487
202849
  recordKind,
202488
202850
  recordId,
202489
- data: serverRecord.data
202851
+ data: base.data
202490
202852
  };
202491
202853
  }
202492
202854
  return composeDocumentRecord(
@@ -202527,6 +202889,7 @@ var init_pull = __esm({
202527
202889
  init_static_member_ownership_recovery();
202528
202890
  init_value_base_desync();
202529
202891
  init_packed_value_parity();
202892
+ init_evaluation_workspace();
202530
202893
  init_compiler_metadata();
202531
202894
  }
202532
202895
  });
@@ -215446,7 +215809,7 @@ var releaseWorkspaceLock = () => void 0;
215446
215809
  async function main() {
215447
215810
  const args = parseArgs(process.argv.slice(2));
215448
215811
  if (args.command === "--version") {
215449
- console.log("0.83.0");
215812
+ console.log("0.84.1");
215450
215813
  return;
215451
215814
  }
215452
215815
  if (args.command === null || args.command === "help" || args.command === "--help" || args.command === "-h") {