@neocompose/cli 0.84.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.
@@ -17587,7 +17587,7 @@ var init_registry = __esm({
17587
17587
  "../packages/manifest/schema-contract/registry.mjs"() {
17588
17588
  "use strict";
17589
17589
  PROJECT_SCHEMA_CONTRACT = Object.freeze({
17590
- cliVersion: "0.84.0",
17590
+ cliVersion: "0.84.1",
17591
17591
  projectFileUploadBatchSize: 32,
17592
17592
  documentRecords: {
17593
17593
  member: {
@@ -22865,9 +22865,14 @@ function indexFirstById(values) {
22865
22865
  }
22866
22866
  return result;
22867
22867
  }
22868
+ function isDerivedNewValueId(valueId, isStored) {
22869
+ return !isPendingId(valueId) && !isUuidV4Id(valueId) && !isStored(valueId);
22870
+ }
22868
22871
  var init_lower_support = __esm({
22869
22872
  "src/project-source/lower-support.ts"() {
22870
22873
  "use strict";
22874
+ init_value_comparison();
22875
+ init_pending_id();
22871
22876
  init_executable_parser();
22872
22877
  }
22873
22878
  });
@@ -96843,6 +96848,356 @@ var init_stored_value_placement_index = __esm({
96843
96848
  }
96844
96849
  });
96845
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
+
96846
97201
  // ../packages/neoscript-runtime/src/declaration-default-source.ts
96847
97202
  function declarationDefaultSource(id2, stored, resolveGraph) {
96848
97203
  if (stored !== null && !isCollapseStampedInstanceRoot(stored)) return stored;
@@ -96857,6 +97212,37 @@ var init_declaration_default_source = __esm({
96857
97212
  }
96858
97213
  });
96859
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
+
96860
97246
  // ../packages/neoscript-runtime/src/listener-endpoint-projection.ts
96861
97247
  function projectListenerEndpoint(args) {
96862
97248
  const { descriptor } = args;
@@ -96886,7 +97272,7 @@ function projectListenerEndpoint(args) {
96886
97272
  var init_listener_endpoint_projection = __esm({
96887
97273
  "../packages/neoscript-runtime/src/listener-endpoint-projection.ts"() {
96888
97274
  "use strict";
96889
- init_virtual_instance_graph();
97275
+ init_virtual_value_identity();
96890
97276
  }
96891
97277
  });
96892
97278
 
@@ -97041,29 +97427,6 @@ function projectNestedListenerEndpoint(id2, descriptor, sourceRoot, targetRoot)
97041
97427
  return derive(targetRoot, positional);
97042
97428
  return void 0;
97043
97429
  }
97044
- function claimVirtualIdentity(args) {
97045
- if (args.fixedVirtualId !== void 0) {
97046
- args.claimedVirtualIds.set(args.fixedVirtualId, args.pathKey);
97047
- return {
97048
- sourceIdentity: args.rawSourceIdentity,
97049
- virtualId: args.fixedVirtualId
97050
- };
97051
- }
97052
- const valueId = (sourceIdentity4) => derivedVirtualValueId(args.instanceRootId, sourceIdentity4);
97053
- const derivedId = valueId(args.rawSourceIdentity);
97054
- const claimedPath = args.claimedVirtualIds.get(derivedId);
97055
- if (claimedPath === void 0 || claimedPath === args.pathKey) {
97056
- args.claimedVirtualIds.set(derivedId, args.pathKey);
97057
- return { sourceIdentity: args.rawSourceIdentity, virtualId: derivedId };
97058
- }
97059
- const sourceIdentity3 = `${args.rawSourceIdentity}:${args.pathKey}`;
97060
- const virtualId = valueId(sourceIdentity3);
97061
- args.claimedVirtualIds.set(virtualId, args.pathKey);
97062
- return { sourceIdentity: sourceIdentity3, virtualId };
97063
- }
97064
- function derivedVirtualValueId(instanceRootId, sourceIdentity3) {
97065
- return instanceRootId.startsWith("__pending__:") || hasPendingVirtualSourceIdentity(sourceIdentity3) ? pendingVirtualValueId(instanceRootId, sourceIdentity3) : virtualValueId(instanceRootId, sourceIdentity3);
97066
- }
97067
97430
  function materializationReadTracking(recorder) {
97068
97431
  if (recorder === void 0)
97069
97432
  return { readTracking: void 0, trackMaterialization: (m) => m() };
@@ -97207,7 +97570,7 @@ function expandStoredInstance(args) {
97207
97570
  code: `virtual-replay:${args.instanceRoot.id}`
97208
97571
  });
97209
97572
  return trackMaterialization(
97210
- () => materializeInitializerValue({
97573
+ () => args.materializeInitializerValue({
97211
97574
  evaluateInitializer: args.evaluateInitializer,
97212
97575
  document: args.document,
97213
97576
  member: replayMember,
@@ -97223,7 +97586,7 @@ function expandStoredInstance(args) {
97223
97586
  const replayDeclaredDefault = () => {
97224
97587
  const stampEnv = instanceRoot.genericBindings == null || Object.keys(instanceRoot.genericBindings).length === 0 ? null : envFromStamp(instanceRoot.genericBindings);
97225
97588
  const built = trackMaterialization(
97226
- () => materializeMemberDefaultValue({
97589
+ () => args.materializeMemberDefaultValue({
97227
97590
  evaluateInitializer: args.evaluateInitializer,
97228
97591
  document: args.document,
97229
97592
  member: replayMember,
@@ -98216,6 +98579,8 @@ function resolveStoredInstanceGraphs(args) {
98216
98579
  if (isMaterializedSpine(resolvedLocations.get(next.root.id))) continue;
98217
98580
  const graph = isClassSlotMember(next.member) ? args.resolveClassGraph?.(next.root, next.member) ?? resolveStoredClassValue({
98218
98581
  evaluateInitializer: args.evaluateInitializer,
98582
+ materializeInitializerValue: args.materializeInitializerValue,
98583
+ materializeMemberDefaultValue: args.materializeMemberDefaultValue,
98219
98584
  document,
98220
98585
  instanceRoot: next.root,
98221
98586
  rootMember: next.member,
@@ -98312,7 +98677,7 @@ function expandStoredClassValue(args) {
98312
98677
  args.readRecorder
98313
98678
  );
98314
98679
  const materialized = trackMaterialization(
98315
- () => materializeMemberDefaultValue({
98680
+ () => args.materializeMemberDefaultValue({
98316
98681
  ...readTracking === void 0 ? {} : { readTracking },
98317
98682
  saveStaticBindings: args.saveStaticBindings,
98318
98683
  sessionStaticBindings: args.sessionStaticBindings,
@@ -100049,6 +100414,8 @@ function resolveVariantInstanceGraphForDocument(args) {
100049
100414
  materializedById.set(args.priorInstanceRoot.id, args.priorInstanceRoot);
100050
100415
  const priorExpanded = expandStoredInstance({
100051
100416
  evaluateInitializer: args.evaluateInitializer,
100417
+ materializeInitializerValue: args.materializeInitializerValue,
100418
+ materializeMemberDefaultValue: args.materializeMemberDefaultValue,
100052
100419
  document,
100053
100420
  instanceRoot: args.priorInstanceRoot,
100054
100421
  rootMember,
@@ -100122,6 +100489,8 @@ function resolveVariantInstanceGraphForDocument(args) {
100122
100489
  materializedById.set(nextInstanceRoot.id, nextInstanceRoot);
100123
100490
  const nextExpanded = expandStoredInstance({
100124
100491
  evaluateInitializer: args.evaluateInitializer,
100492
+ materializeInitializerValue: args.materializeInitializerValue,
100493
+ materializeMemberDefaultValue: args.materializeMemberDefaultValue,
100125
100494
  document,
100126
100495
  instanceRoot: nextInstanceRoot,
100127
100496
  rootMember,
@@ -101248,6 +101617,8 @@ function createHeadlessVirtualInstanceResolver(args) {
101248
101617
  const replayDocument = evidence === null ? resolverDocumentOnce() : frameDocument(evidence);
101249
101618
  const resolution2 = prepareStoredClassValueResolution({
101250
101619
  evaluateInitializer: args.evaluateInitializer,
101620
+ materializeInitializerValue: args.materializeInitializerValue,
101621
+ materializeMemberDefaultValue: args.materializeMemberDefaultValue,
101251
101622
  document: replayDocument,
101252
101623
  instanceRoot,
101253
101624
  rootMember: member,
@@ -101542,7 +101913,8 @@ var init_virtual_instance_graph = __esm({
101542
101913
  init_immutable_json();
101543
101914
  init_members();
101544
101915
  init_instance_provenance();
101545
- init_member_value_id();
101916
+ init_virtual_value_identity();
101917
+ init_virtual_value_identity();
101546
101918
  init_stored_value_placement_index();
101547
101919
  init_unordered_list_membership();
101548
101920
  init_neoscript_types();
@@ -101550,7 +101922,6 @@ var init_virtual_instance_graph = __esm({
101550
101922
  init_project_schema_index();
101551
101923
  init_initializer_context();
101552
101924
  init_strict_ir();
101553
- init_initializer_materialization();
101554
101925
  init_unattributable_reads();
101555
101926
  init_member_body_reads();
101556
101927
  KEPT_ROW_SAMPLE_LIMIT = 12;
@@ -101784,6 +102155,8 @@ function initializerEvaluatorLookups(document, readTracking) {
101784
102155
  const shareFrom = document.evaluatorOverlay === void 0 ? void 0 : sharedHeadlessResolver(document.evaluatorOverlay);
101785
102156
  const headlessVirtualResolver = createHeadlessVirtualInstanceResolver({
101786
102157
  evaluateInitializer: evaluateMemberInitializer,
102158
+ materializeInitializerValue,
102159
+ materializeMemberDefaultValue: materializeMemberDefaultValue2,
101787
102160
  documentMaterializationPlan,
101788
102161
  document,
101789
102162
  resolverLookups: () => lookups,
@@ -101812,6 +102185,8 @@ function initializerEvaluatorLookups(document, readTracking) {
101812
102185
  // nested resolver.
101813
102186
  resolveVariantInstanceGraph: (args) => resolveVariantInstanceGraphForDocument({
101814
102187
  evaluateInitializer: evaluateMemberInitializer,
102188
+ materializeInitializerValue,
102189
+ materializeMemberDefaultValue: materializeMemberDefaultValue2,
101815
102190
  document,
101816
102191
  resolverLookups: lookups,
101817
102192
  readRecorder: headlessVirtualResolver.readRecorder,
@@ -102000,6 +102375,8 @@ function createInitializerMaterializationBatch(authoredDocument, pendingInitiali
102000
102375
  let resolver;
102001
102376
  const virtual = () => resolver ??= createHeadlessVirtualInstanceResolver({
102002
102377
  evaluateInitializer: evaluateMemberInitializer,
102378
+ materializeInitializerValue,
102379
+ materializeMemberDefaultValue: materializeMemberDefaultValue2,
102003
102380
  documentMaterializationPlan,
102004
102381
  document,
102005
102382
  membersById: indexed.membersById,
@@ -102082,6 +102459,8 @@ function createInitializerMaterializationBatch(authoredDocument, pendingInitiali
102082
102459
  virtualInstanceRootIdForValue: (id2) => owningInstanceRootId(virtual().virtualInstanceGraphForValue(id2)),
102083
102460
  resolveVariantInstanceGraph: (args) => resolveVariantInstanceGraphForDocument({
102084
102461
  evaluateInitializer: evaluateMemberInitializer,
102462
+ materializeInitializerValue,
102463
+ materializeMemberDefaultValue: materializeMemberDefaultValue2,
102085
102464
  document,
102086
102465
  resolverLookups: lookups,
102087
102466
  ...args
@@ -102315,10 +102694,18 @@ function storedConstructionReplaySlot(member, sourceRow, document) {
102315
102694
  }
102316
102695
  };
102317
102696
  }
102697
+ function materializeMemberDefaultValue2(args) {
102698
+ return materializeMemberDefaultValue({
102699
+ ...args,
102700
+ initializerEvaluatorLookups,
102701
+ defaultValuePlans
102702
+ });
102703
+ }
102318
102704
  var evaluatorLookupsByDocument, headlessResolversByLookupKey, indexedEvaluatorLookupsByDocument, defaultValuePlansByDocument;
102319
102705
  var init_evaluateInitializer = __esm({
102320
102706
  "../packages/neoscript-runtime/src/neoscript/evaluateInitializer.ts"() {
102321
102707
  "use strict";
102708
+ init_initializer_materialization();
102322
102709
  init_NSGetterRuntimeError();
102323
102710
  init_declaration_default_source();
102324
102711
  init_member_change_listeners();
@@ -102339,354 +102726,6 @@ var init_evaluateInitializer = __esm({
102339
102726
  }
102340
102727
  });
102341
102728
 
102342
- // ../packages/neoscript-runtime/src/values/initializer-identifiers.ts
102343
- function initializerReferencedIdentifiers(source) {
102344
- let expression;
102345
- try {
102346
- expression = parseExpression(source);
102347
- } catch {
102348
- return /* @__PURE__ */ new Set();
102349
- }
102350
- const identifiers = /* @__PURE__ */ new Set();
102351
- const pending = [expression];
102352
- const visited = /* @__PURE__ */ new Set();
102353
- while (pending.length > 0) {
102354
- const value = pending.pop();
102355
- if (value === null || typeof value !== "object" || visited.has(value)) {
102356
- continue;
102357
- }
102358
- visited.add(value);
102359
- if (Reflect.get(value, "kind") === "ident") {
102360
- const name = Reflect.get(value, "name");
102361
- if (typeof name === "string") identifiers.add(name);
102362
- }
102363
- for (const child2 of Object.values(value)) pending.push(child2);
102364
- }
102365
- return identifiers;
102366
- }
102367
- function initializerReferencesAnyIdentifier(source, names) {
102368
- const identifiers = initializerReferencedIdentifiers(source);
102369
- for (const name of names) {
102370
- if (identifiers.has(name)) return true;
102371
- }
102372
- return false;
102373
- }
102374
- var init_initializer_identifiers = __esm({
102375
- "../packages/neoscript-runtime/src/values/initializer-identifiers.ts"() {
102376
- "use strict";
102377
- init_executable_parser();
102378
- }
102379
- });
102380
-
102381
- // ../packages/neoscript-runtime/src/initializer-materialization.ts
102382
- function declarationInitializerContext(document) {
102383
- const key = initializerEvaluatorCacheKey(document);
102384
- const revision = initializerEvaluatorCacheRevision(document);
102385
- const cached = declarationInitializerContextByDocument.get(key);
102386
- if (cached !== void 0 && (revision === void 0 ? cached.members === document.members && cached.values === document.values : cached.revision === revision)) {
102387
- return cached.context;
102388
- }
102389
- const initializerValueIds = new Set(
102390
- document.values.filter(isInitValueContent).map((value) => value.id)
102391
- );
102392
- const valuesById = new Map(
102393
- document.values.map((value) => [value.id, value])
102394
- );
102395
- const rootOwners = /* @__PURE__ */ new Map();
102396
- resolveOwnerMembersForValues(
102397
- document,
102398
- initializerValueIds,
102399
- void 0,
102400
- rootOwners
102401
- );
102402
- const created = { valuesById, rootOwners };
102403
- declarationInitializerContextByDocument.set(key, {
102404
- members: document.members,
102405
- values: document.values,
102406
- revision,
102407
- context: created
102408
- });
102409
- return created;
102410
- }
102411
- function evaluateInitializerMaterialization(args) {
102412
- const createdValues = [];
102413
- const storageKeyDeclarations = /* @__PURE__ */ new Map();
102414
- const evaluated = args.evaluateInitializer({
102415
- genericEnv: args.genericEnv,
102416
- init: args.init,
102417
- member: args.member,
102418
- document: args.document,
102419
- createdValues,
102420
- storageKeyDeclarations,
102421
- ...args.storedConstructionReplay === true ? { storedConstructionReplay: true } : {},
102422
- ...args.constructionBaselineReplay === true ? { constructionBaselineReplay: true } : {},
102423
- ...args.argumentValues === void 0 ? {} : { argumentValues: args.argumentValues },
102424
- sourceValueId: args.sourceValueId ?? null,
102425
- readTracking: args.readTracking,
102426
- saveStaticBindings: args.saveStaticBindings,
102427
- sessionStaticBindings: args.sessionStaticBindings
102428
- });
102429
- return { evaluated, createdValues, storageKeyDeclarations };
102430
- }
102431
- function materializeInPlaceFields(document, root, createdValues) {
102432
- const owners = [root, ...createdValues];
102433
- for (const owner of owners) {
102434
- const record7 = owner.value;
102435
- if (typeof owner.classId !== "string") continue;
102436
- if (typeof record7 !== "object" || record7 === null) continue;
102437
- if (Array.isArray(record7)) continue;
102438
- let memberIds;
102439
- for (const [schemaKey, value] of Object.entries(record7)) {
102440
- if (typeof value === "string" || value === null) continue;
102441
- memberIds ??= new Map(
102442
- resolvedClassSchema(
102443
- owner.classId,
102444
- document.classes,
102445
- document.members
102446
- ).surface.map((entry) => [entry.schemaKey, entry.memberId])
102447
- );
102448
- const memberId = memberIds.get(schemaKey);
102449
- if (memberId === void 0) {
102450
- throw new Error(
102451
- `Class "${owner.classId}" holds "${schemaKey}" in place, which its schema doesn't declare.`
102452
- );
102453
- }
102454
- const row = {
102455
- id: virtualValueId(owner.id, memberId),
102456
- projectId: owner.projectId,
102457
- createdAt: owner.createdAt,
102458
- updatedAt: owner.updatedAt,
102459
- value
102460
- };
102461
- createdValues.push(row);
102462
- record7[schemaKey] = row.id;
102463
- }
102464
- }
102465
- }
102466
- function finalizeMaterializedRoot(args) {
102467
- materializeInPlaceFields(args.document, args.root, args.createdValues);
102468
- const allCreated = [args.root, ...args.createdValues];
102469
- for (const created of allCreated) {
102470
- if (created === args.root) continue;
102471
- if (created.classId === void 0) delete created.classId;
102472
- }
102473
- stampCreatedValuesMapKey(allCreated, args.mapKey);
102474
- if (args.supersededRootId !== void 0) {
102475
- args.storageKeyDeclarations.delete(args.supersededRootId);
102476
- }
102477
- args.storageKeyDeclarations.delete(args.root.id);
102478
- applyDeclaredStorageKeyOverrides({
102479
- createdValues: allCreated,
102480
- declarationByValueId: args.storageKeyDeclarations,
102481
- existingParentContextById: /* @__PURE__ */ new Map([
102482
- [
102483
- args.root.id,
102484
- {
102485
- mapKey: args.mapKey ?? null,
102486
- classId: args.root.classId ?? void 0
102487
- }
102488
- ]
102489
- ])
102490
- });
102491
- }
102492
- function materializeInitializerValue(args) {
102493
- const { evaluated, createdValues, storageKeyDeclarations } = evaluateInitializerMaterialization({
102494
- evaluateInitializer: args.evaluateInitializer,
102495
- init: args.row.init,
102496
- member: args.member,
102497
- document: args.document,
102498
- ...args.storedConstructionReplay === true ? { storedConstructionReplay: true } : {},
102499
- ...args.constructionBaselineReplay === true ? { constructionBaselineReplay: true } : {},
102500
- ...args.argumentValues === void 0 ? {} : { argumentValues: args.argumentValues },
102501
- genericEnv: envFromStamp(args.row.genericBindings),
102502
- sourceValueId: args.row.id,
102503
- readTracking: args.readTracking,
102504
- saveStaticBindings: args.saveStaticBindings,
102505
- sessionStaticBindings: args.sessionStaticBindings
102506
- });
102507
- const {
102508
- init: _init,
102509
- value: _value,
102510
- classId: _classId,
102511
- ...envelope
102512
- } = args.row;
102513
- void _init;
102514
- void _value;
102515
- void _classId;
102516
- const root = {
102517
- ...envelope,
102518
- value: evaluated.value,
102519
- ...evaluated.classId === null ? {} : { classId: evaluated.classId },
102520
- ...evaluated.genericBindings === void 0 ? {} : { genericBindings: { ...evaluated.genericBindings } },
102521
- ...deepClonePlainData(pickInstanceProvenance(evaluated))
102522
- };
102523
- if (evaluated.provisionalRootId !== void 0) {
102524
- args.document.listenerDefaultCapture?.retarget(
102525
- evaluated.provisionalRootId,
102526
- root.id
102527
- );
102528
- retargetInitializerRootValueIds(
102529
- [root, ...createdValues],
102530
- evaluated.provisionalRootId,
102531
- root.id
102532
- );
102533
- }
102534
- finalizeMaterializedRoot({
102535
- document: args.document,
102536
- root,
102537
- createdValues,
102538
- mapKey: args.row.mapKey,
102539
- storageKeyDeclarations
102540
- });
102541
- return {
102542
- root,
102543
- createdValues,
102544
- pinnedRootSchemaKeys: evaluated.pinnedRootSchemaKeys ?? /* @__PURE__ */ new Set(),
102545
- pinnedSchemaKeysByValueId: evaluated.pinnedSchemaKeysByValueId ?? /* @__PURE__ */ new Map()
102546
- };
102547
- }
102548
- function materializeMemberDefaultValue(args) {
102549
- const createdValues = [];
102550
- const storageKeyDeclarations = /* @__PURE__ */ new Map();
102551
- const declarationArguments = (member, init, sourceValueId) => {
102552
- const { valuesById, rootOwners } = declarationInitializerContext(
102553
- args.document
102554
- );
102555
- const ownerClass = typeof sourceValueId === "string" ? initializerOwnerContext(
102556
- args.document,
102557
- sourceValueId,
102558
- rootOwners,
102559
- valuesById,
102560
- (id2) => args.readTracking?.valueIds.add(id2)
102561
- ).ownerClass : typeof Reflect.get(member, "id") === "string" && !isStaticMember(member) ? findSchemaPlacement(
102562
- String(Reflect.get(member, "id")),
102563
- args.document.classes
102564
- )?.ownerClass ?? null : null;
102565
- if (ownerClass === null) return [];
102566
- const constructorId = ownerClass.requiredConstructorId;
102567
- if (typeof constructorId !== "string") return [];
102568
- const constructor2 = args.document.constructors?.find(
102569
- (candidate) => candidate.id === constructorId
102570
- );
102571
- if (constructor2 === void 0) return [];
102572
- const parameterNames = new Set(
102573
- constructor2.argumentTypes.map((argument2) => argument2.name)
102574
- );
102575
- return declarationInitializerArgumentValues(
102576
- constructor2.argumentTypes,
102577
- `Declaration template on '${ownerClass.name}'`,
102578
- initializerReferencesAnyIdentifier(init.code, parameterNames)
102579
- );
102580
- };
102581
- let lookups;
102582
- const evaluatorLookups = () => lookups ??= initializerEvaluatorLookups(args.document, args.readTracking);
102583
- const plans = args.readTracking !== void 0 && args.document.databaseVM === void 0 ? void 0 : defaultValuePlans(args.document);
102584
- const database = args.document.databaseVM;
102585
- const hostPlan = database?.materializationPlan;
102586
- const built = buildDefaultMemberValue({
102587
- document: {
102588
- ...args.document,
102589
- // The declaration rows a default clones are reads of this
102590
- // materialization, like any row its initializers read.
102591
- valueById: (id2) => {
102592
- args.readTracking?.valueIds.add(id2);
102593
- const database2 = evaluatorLookups();
102594
- return database2.defaultValueById !== void 0 ? database2.defaultValueById(id2) : database2.valueById(id2);
102595
- },
102596
- unorderedListEntryIds: (containerId) => {
102597
- args.readTracking?.containerIds.add(containerId);
102598
- const entryIds = evaluatorLookups().unorderedListEntryIds?.(containerId);
102599
- if (entryIds === void 0) {
102600
- throw new Error(
102601
- `Initializer lookups resolve no unordered-list membership for container "${containerId}".`
102602
- );
102603
- }
102604
- return entryIds;
102605
- },
102606
- // Not `resolvedMember`: its id-keyed cache would answer for the
102607
- // caller's rewritten copy of a member with the stored original.
102608
- ...plans === void 0 ? {} : {
102609
- instanceEnv: plans.instanceEnv,
102610
- storedInstanceMaterializationPlan: hostPlan === void 0 ? plans.storedInstanceMaterializationPlan : (classId, instanceEnv) => hostPlan.call(database, classId, instanceEnv)
102611
- },
102612
- recordPlanReads: (reads) => {
102613
- for (const id2 of reads.valueIds) args.readTracking?.valueIds.add(id2);
102614
- for (const id2 of reads.containerIds)
102615
- args.readTracking?.containerIds.add(id2);
102616
- }
102617
- },
102618
- projectId: args.envelope.projectId,
102619
- member: args.member,
102620
- createdValues,
102621
- storageKeyDeclarations,
102622
- declarationRoot: args.declarationRoot,
102623
- ...args.genericEnv === void 0 ? {} : { genericEnv: args.genericEnv },
102624
- // A declaration default may itself be init-backed one level down (P43 §2),
102625
- // and those nested initializers must evaluate against the same document.
102626
- initEvaluator: (member, init, sourceValueId, genericEnv) => args.evaluateInitializer({
102627
- genericEnv,
102628
- storageKeyDeclarations,
102629
- init,
102630
- member,
102631
- document: args.document,
102632
- createdValues,
102633
- storedConstructionReplay: true,
102634
- argumentValues: declarationArguments(
102635
- member,
102636
- init,
102637
- sourceValueId ?? null
102638
- ),
102639
- sourceValueId: sourceValueId ?? null,
102640
- readTracking: args.readTracking,
102641
- saveStaticBindings: args.saveStaticBindings,
102642
- sessionStaticBindings: args.sessionStaticBindings
102643
- })
102644
- });
102645
- const interior = createdValues.filter((created) => created.id !== built.id);
102646
- const root = {
102647
- ...args.envelope,
102648
- value: built.value,
102649
- ...built.changeListeners === void 0 ? {} : { changeListeners: built.changeListeners },
102650
- ...built.changeListenerEndpoints === void 0 ? {} : { changeListenerEndpoints: built.changeListenerEndpoints },
102651
- ...built.classId === void 0 ? {} : { classId: built.classId },
102652
- ...built.genericBindings == null ? {} : { genericBindings: { ...built.genericBindings } }
102653
- };
102654
- args.document.listenerDefaultCapture?.retarget(built.id, root.id);
102655
- retargetInitializerRootValueIds([root, ...interior], built.id, root.id);
102656
- finalizeMaterializedRoot({
102657
- document: args.document,
102658
- root,
102659
- createdValues: interior,
102660
- mapKey: args.envelope.mapKey,
102661
- storageKeyDeclarations,
102662
- supersededRootId: built.id
102663
- });
102664
- return {
102665
- root,
102666
- createdValues: interior,
102667
- pinnedRootSchemaKeys: /* @__PURE__ */ new Set(),
102668
- pinnedSchemaKeysByValueId: /* @__PURE__ */ new Map()
102669
- };
102670
- }
102671
- var declarationInitializerContextByDocument;
102672
- var init_initializer_materialization = __esm({
102673
- "../packages/neoscript-runtime/src/initializer-materialization.ts"() {
102674
- "use strict";
102675
- init_deep_clone_plain_data();
102676
- init_members();
102677
- init_inheritance();
102678
- init_member_value_id();
102679
- init_instance_provenance();
102680
- init_generics();
102681
- init_evaluateInitializer();
102682
- init_evaluateNSGetter();
102683
- init_initializer_context();
102684
- init_value_row_owner_members();
102685
- init_initializer_identifiers();
102686
- declarationInitializerContextByDocument = /* @__PURE__ */ new WeakMap();
102687
- }
102688
- });
102689
-
102690
102729
  // ../packages/neoscript-runtime/src/effective-value-reader.ts
102691
102730
  function rootReadScope(document) {
102692
102731
  const cached = rootReadScopes.get(document);
@@ -103329,7 +103368,7 @@ var init_effective_value_reader = __esm({
103329
103368
  });
103330
103369
  if (slot.kind !== "declaration") continue;
103331
103370
  if (record7 === row.value) record7 = { ...record7 };
103332
- const materialized = materializeMemberDefaultValue({
103371
+ const materialized = materializeMemberDefaultValue2({
103333
103372
  ...this.context,
103334
103373
  evaluateInitializer: evaluateMemberInitializer,
103335
103374
  document: this.declarationDocument,
@@ -103406,6 +103445,8 @@ var init_effective_value_reader = __esm({
103406
103445
  instanceRoot: root,
103407
103446
  rootMember: placement,
103408
103447
  evaluateInitializer: evaluateMemberInitializer,
103448
+ materializeInitializerValue,
103449
+ materializeMemberDefaultValue: materializeMemberDefaultValue2,
103409
103450
  materializedIndex: this.materializedIndex,
103410
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,
103411
103452
  onResolvedListenerDefaults: (ownerId, entry) => {
@@ -103450,7 +103491,7 @@ var init_effective_value_reader = __esm({
103450
103491
  const cached = this.defaultRows.get(memberKey)?.get(envKey);
103451
103492
  if (cached !== void 0) return cached;
103452
103493
  let evaluatedInitializer = false;
103453
- const result = materializeMemberDefaultValue({
103494
+ const result = materializeMemberDefaultValue2({
103454
103495
  ...this.context,
103455
103496
  evaluateInitializer: (args) => {
103456
103497
  evaluatedInitializer = true;
@@ -103714,31 +103755,40 @@ var init_neoscript2 = __esm({
103714
103755
  function expandStoredInstance2(args) {
103715
103756
  return expandStoredInstance({
103716
103757
  ...args,
103717
- evaluateInitializer: evaluateMemberInitializer
103758
+ evaluateInitializer: evaluateMemberInitializer,
103759
+ materializeInitializerValue,
103760
+ materializeMemberDefaultValue: materializeMemberDefaultValue2
103718
103761
  });
103719
103762
  }
103720
103763
  function resolveVariantInstanceGraphForDocument2(args) {
103721
103764
  return resolveVariantInstanceGraphForDocument({
103722
103765
  ...args,
103723
- evaluateInitializer: evaluateMemberInitializer
103766
+ evaluateInitializer: evaluateMemberInitializer,
103767
+ materializeInitializerValue,
103768
+ materializeMemberDefaultValue: materializeMemberDefaultValue2
103724
103769
  });
103725
103770
  }
103726
103771
  function createHeadlessVirtualInstanceResolver2(args) {
103727
103772
  return createHeadlessVirtualInstanceResolver({
103728
103773
  ...args,
103729
103774
  evaluateInitializer: evaluateMemberInitializer,
103775
+ materializeInitializerValue,
103776
+ materializeMemberDefaultValue: materializeMemberDefaultValue2,
103730
103777
  documentMaterializationPlan
103731
103778
  });
103732
103779
  }
103733
103780
  function resolveStoredClassValue2(args) {
103734
103781
  return resolveStoredClassValue({
103735
103782
  ...args,
103736
- evaluateInitializer: evaluateMemberInitializer
103783
+ evaluateInitializer: evaluateMemberInitializer,
103784
+ materializeInitializerValue,
103785
+ materializeMemberDefaultValue: materializeMemberDefaultValue2
103737
103786
  });
103738
103787
  }
103739
103788
  var init_virtual_instance_values = __esm({
103740
103789
  "../packages/neoscript-runtime/src/virtual-instance-values.ts"() {
103741
103790
  "use strict";
103791
+ init_initializer_materialization();
103742
103792
  init_evaluateInitializer();
103743
103793
  init_virtual_instance_graph();
103744
103794
  init_virtual_instance_graph();
@@ -126823,11 +126873,10 @@ function appendAuthoredOwnedValueCascadeDeletes(args) {
126823
126873
  for (const rootId of survivingConstructionIds) {
126824
126874
  const instanceRoot = compiledReplayRows.get(rootId) ?? postValuesById.get(rootId);
126825
126875
  const rootMember = postPlacements.get(rootId).member;
126826
- const expanded = expandStoredInstance({
126876
+ const expanded = expandStoredInstance2({
126827
126877
  document: resolverDocument,
126828
126878
  instanceRoot,
126829
- rootMember,
126830
- evaluateInitializer: evaluateMemberInitializer
126879
+ rootMember
126831
126880
  });
126832
126881
  const graph = resolveVirtualInstanceGraph({
126833
126882
  document: resolverDocument,
@@ -139703,6 +139752,10 @@ function verifyProjectSourceCommitAgainstStateV4(args) {
139703
139752
  trustedPendingProjectFiles.set(pendingId2, metadata);
139704
139753
  }
139705
139754
  }
139755
+ const derivedSeedRowIds = derivedCandidateSeedRowIds(
139756
+ args.authoredValueSeeds,
139757
+ args.stateRecords
139758
+ );
139706
139759
  const status = computeWorkspaceStatus(workspace, {
139707
139760
  forceRecompile: args.forceRecompile,
139708
139761
  skipProjectBinaryInspection: true,
@@ -139728,7 +139781,8 @@ ${blockingErrors.map((error) => error.message).join("\n")}` : `Trusted source lo
139728
139781
  auditAuthoredSeedRowIdentities(
139729
139782
  status.authoredValueSeeds,
139730
139783
  args.stateRecords,
139731
- assignments
139784
+ assignments,
139785
+ derivedSeedRowIds
139732
139786
  );
139733
139787
  const usedAssignments = /* @__PURE__ */ new Set();
139734
139788
  const positionless = positionIndependentAssignments(assignments);
@@ -139791,14 +139845,14 @@ function isDerivedOnlyRefresh(change, stateRecords) {
139791
139845
  if (!isObjectRecord(base.data)) return false;
139792
139846
  return canonicalStringify(comparisonData(change.recordKind, change.nextData)) === canonicalStringify(comparisonData(change.recordKind, base.data));
139793
139847
  }
139794
- function auditAuthoredSeedRowIdentities(seeds, stateRecords, assignments) {
139848
+ function auditAuthoredSeedRowIdentities(seeds, stateRecords, assignments, derivedRowIds = /* @__PURE__ */ new Set()) {
139795
139849
  const mintedIds = new Set(assignments.values());
139796
139850
  const authoredCreates = /* @__PURE__ */ new Set();
139797
139851
  for (const [memberId, seed] of seeds) {
139798
139852
  for (const row of seed.values ?? []) {
139799
139853
  if (isPendingId(row.id)) continue;
139800
139854
  if (stateRecords[`value:${row.id}`] !== void 0) continue;
139801
- if (!isUuidV4Id(row.id)) {
139855
+ if (!isUuidV4Id(row.id) && !derivedRowIds.has(row.id)) {
139802
139856
  throw new ProjectSourceCommitVerificationError(
139803
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.`
139804
139858
  );
@@ -139817,6 +139871,19 @@ function auditAuthoredSeedRowIdentities(seeds, stateRecords, assignments) {
139817
139871
  }
139818
139872
  }
139819
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
+ }
139820
139887
  function validateAssignments(value) {
139821
139888
  const assignments = /* @__PURE__ */ new Map();
139822
139889
  const assignedIds = /* @__PURE__ */ new Set();
@@ -142269,6 +142336,9 @@ function emitStoredConstructorExpression(context, member, valueId, visited = /*
142269
142336
  targetTyped
142270
142337
  );
142271
142338
  if (constructor2 !== null) return constructor2;
142339
+ if (hasStoredConstruction && value.instanceConstructorId === null) {
142340
+ return targetTyped ? "new()" : `new ${className}`;
142341
+ }
142272
142342
  if (projection === null || projection.arguments.length === 0 && schemaClass2.requiredConstructorId === void 0) {
142273
142343
  throw new Error(
142274
142344
  `Stored materialized value ${valueId} has no constructor arguments.`
@@ -149817,6 +149887,9 @@ function classValueBody(context, member, value, visited, targetTyped, outerEnvir
149817
149887
  }
149818
149888
  continue;
149819
149889
  }
149890
+ const storedBase = context.storedValueBase;
149891
+ if (storedBase !== void 0 && isDerivedNewValueId(childId, (id2) => storedBase.has(id2)))
149892
+ continue;
149820
149893
  const preservesBinding = context.collectionBindingValueIds.has(childId) || context.localValues?.byValueId.has(childId) === true;
149821
149894
  const baseChildBody = context.storedValueBase?.get(childId)?.value;
149822
149895
  const clearedStoredClassOverrides = isObjectRecord(baseChildBody) && Object.keys(baseChildBody).length > 0;
@@ -151990,6 +152063,7 @@ var init_value_sources = __esm({
151990
152063
  "src/project-source/value-sources.ts"() {
151991
152064
  "use strict";
151992
152065
  init_immutable_json3();
152066
+ init_lower_support();
151993
152067
  init_record_fields();
151994
152068
  init_source_syntax_cache();
151995
152069
  init_lexer();
@@ -153261,8 +153335,7 @@ function materializeInitializersLocallyV4(args) {
153261
153335
  const sourceRoots = initializerSourceRootIds(
153262
153336
  args.changes,
153263
153337
  args.authoredValueSeeds,
153264
- records3,
153265
- args.workspace.state.records
153338
+ records3
153266
153339
  );
153267
153340
  const written = [...args.changes];
153268
153341
  for (const seed of args.authoredValueSeeds) {
@@ -153660,28 +153733,23 @@ function initializerCode(records3, valueId) {
153660
153733
  }
153661
153734
  return row.init.code;
153662
153735
  }
153663
- function initializerSourceRootIds(changes, seeds, records3, baseRecords) {
153736
+ function initializerSourceRootIds(changes, seeds, records3) {
153664
153737
  const ids = /* @__PURE__ */ new Set();
153665
- const needsFirstMaterialization = (valueId) => {
153666
- const base = baseRecords[`value:${valueId}`]?.data;
153667
- return base === void 0 || isObjectRecord(base) && isObjectRecord(base.init);
153668
- };
153669
153738
  for (const change of changes) {
153670
153739
  if (change.recordKind !== "value") continue;
153671
153740
  if (!isObjectRecord(change.nextData)) continue;
153672
153741
  if (!isObjectRecord(change.nextData.init)) continue;
153673
- if (!needsFirstMaterialization(change.recordId)) continue;
153674
153742
  ids.add(change.recordId);
153675
153743
  }
153676
153744
  for (const seed of seeds) {
153677
153745
  const member = records3.get(`member:${seed.memberId}`)?.data;
153678
153746
  const instanceBinding = isObjectRecord(member) && (member.modifier === 3 || member.valueId === seed.valueId);
153679
153747
  if (!instanceBinding) continue;
153680
- if (seed.nodeType === "initializer" && typeof seed.valueId === "string" && needsFirstMaterialization(seed.valueId)) {
153748
+ if (seed.nodeType === "initializer" && typeof seed.valueId === "string") {
153681
153749
  ids.add(seed.valueId);
153682
153750
  }
153683
153751
  for (const row of seed.values ?? []) {
153684
- if (row.nodeType === "initializer" && needsFirstMaterialization(row.id)) {
153752
+ if (row.nodeType === "initializer") {
153685
153753
  ids.add(row.id);
153686
153754
  }
153687
153755
  }
@@ -157015,6 +157083,13 @@ function walkValueSegments(walk, startId, segments, path, subject, fail2) {
157015
157083
  return null;
157016
157084
  }
157017
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
+ }
157018
157093
  fail2(
157019
157094
  `${subject} ${path} stops before segment ${segment}: the row it reaches stores no single-valued members.`
157020
157095
  );
@@ -157112,6 +157187,7 @@ var init_root_source = __esm({
157112
157187
  "use strict";
157113
157188
  init_project_root();
157114
157189
  init_value_comparison();
157190
+ init_members();
157115
157191
  init_value_sources();
157116
157192
  init_source_format();
157117
157193
  init_stored_value_placements();
@@ -197351,12 +197427,36 @@ var init_export = __esm({
197351
197427
 
197352
197428
  // src/project-source/evaluation-workspace.ts
197353
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) {
197354
197453
  const memberIds = /* @__PURE__ */ new Set();
197355
197454
  const constructorIds = /* @__PURE__ */ new Set();
197356
197455
  const pending = /* @__PURE__ */ new Map();
197357
197456
  const scriptSources = /* @__PURE__ */ new Map();
197358
- for (const [key, record7] of Object.entries(workspace.state.records)) {
197457
+ for (const [key, record7] of entries) {
197359
197458
  const kind = record7.recordKind;
197459
+ if (record7.deleted === true) continue;
197360
197460
  if (kind !== "member" && kind !== "constructor") continue;
197361
197461
  const stale = firstRejectedNeoScriptCompiledBody(record7.data, null);
197362
197462
  if (stale !== null) {
@@ -197367,34 +197467,27 @@ function workspaceForLocalEvaluation(workspace) {
197367
197467
  } else if (!hasPendingNeoScriptDerivation(kind, record7.data)) continue;
197368
197468
  (kind === "member" ? memberIds : constructorIds).add(record7.recordId);
197369
197469
  scriptSources.set(key, neoScriptRecordSources(record7.data));
197370
- pending.set(key, {
197371
- ...record7,
197372
- deleted: false,
197373
- data: stripClientDerivedBodies(kind, record7.data)
197374
- });
197470
+ pending.set(key, stripClientDerivedBodies(kind, record7.data));
197375
197471
  }
197376
- if (pending.size === 0) return workspace;
197377
- const records3 = /* @__PURE__ */ new Map();
197378
- for (const [key, record7] of Object.entries(workspace.state.records))
197379
- records3.set(key, pending.get(key) ?? { ...record7, deleted: false });
197380
- 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);
197381
197477
  compilePulledProjectDocumentForEvaluationV4(document, void 0, {
197382
197478
  memberIds,
197383
197479
  constructorIds,
197384
197480
  scriptSources
197385
197481
  });
197386
- const refreshed = { ...workspace.state.records };
197482
+ const bodies = /* @__PURE__ */ new Map();
197387
197483
  for (const member of document.members) {
197388
- if (!memberIds.has(member.id)) continue;
197389
- const key = `member:${member.id}`;
197390
- refreshed[key] = { ...refreshed[key], data: member };
197484
+ if (memberIds.has(member.id)) bodies.set(`member:${member.id}`, member);
197391
197485
  }
197392
197486
  for (const constructor2 of document.constructors ?? []) {
197393
- if (!constructorIds.has(constructor2.id)) continue;
197394
- const key = `constructor:${constructor2.id}`;
197395
- refreshed[key] = { ...refreshed[key], data: constructor2 };
197487
+ if (constructorIds.has(constructor2.id))
197488
+ bodies.set(`constructor:${constructor2.id}`, constructor2);
197396
197489
  }
197397
- return { ...workspace, state: { ...workspace.state, records: refreshed } };
197490
+ return { records: compilable, bodies };
197398
197491
  }
197399
197492
  var init_evaluation_workspace = __esm({
197400
197493
  "src/project-source/evaluation-workspace.ts"() {
@@ -198710,11 +198803,7 @@ async function prepareLocalPushArtifactsV4(workspace, status, onPhase = () => vo
198710
198803
  } : void 0;
198711
198804
  onPhase("Hashing project source\u2026");
198712
198805
  const source = projectSourceIdentityForStatus(status);
198713
- const verificationSource = options.fullValidation ? createPendingProjectSourceIdentityV4(
198714
- workspace,
198715
- status,
198716
- status.authoredValueSeeds
198717
- ) : null;
198806
+ const verificationSource = options.fullValidation ? locatedPendingProjectSourceIdentity(workspace, status) : null;
198718
198807
  onPhase("Assigning pending value identities\u2026");
198719
198808
  const pendingAssignment = assignPendingIds(
198720
198809
  status.changes,
@@ -198846,6 +198935,17 @@ function locatePreparationError(error, status, assigned) {
198846
198935
  if (source === void 0) return error;
198847
198936
  return new Error(`${source.file}:${source.line} \u2014 ${error.message}`);
198848
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
+ }
198849
198949
  async function prepareLocalCandidateV4(workspace, options = {}) {
198850
198950
  const pushOptions = {
198851
198951
  dryRun: options.dryRun ?? true,
@@ -199210,19 +199310,22 @@ function createPendingProjectSourceIdentityV4(workspace, status, authoredValueSe
199210
199310
  }
199211
199311
  }
199212
199312
  materializePendingSourceLocalization(records3, status);
199213
- const emission = emitProjectDocumentFilesV4(records3, {
199214
- dialogueGroupSymbols: authoredDialogueGroupSymbols(
199215
- status.sourceSnapshot?.analysis
199216
- ),
199217
- storedValueBase: storedValueRowsByIdV4(
199218
- Object.values(workspace.state.records)
199219
- ),
199220
- recordFiles: projectRecordFilesV4(
199221
- Object.values(workspace.state.records),
199222
- status.reconstructed.values()
199223
- ),
199224
- localValues: status.localValues
199225
- });
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
+ );
199226
199329
  const files = emission.files.map((file) => {
199227
199330
  const kind = neoProjectSourceKind(file.path, file.content);
199228
199331
  if (kind === null || !isNeoProjectProductionSourceKind(kind)) {
@@ -202242,7 +202345,7 @@ async function finishFormat4Pull(args) {
202242
202345
  const formatSource = createWorkspaceSourceFormatter(workspace.root);
202243
202346
  const localResult = emitProjectDocumentFilesV4(
202244
202347
  candidateValueRecordsForEmissionV4(
202245
- localRecords,
202348
+ recordsForLocalEvaluation(localRecords),
202246
202349
  workspace.state.records,
202247
202350
  workspace.config.projectId
202248
202351
  ),
@@ -202725,17 +202828,19 @@ function buildEmitRecordSet(document, plans, side) {
202725
202828
  resolvedRecordKind,
202726
202829
  resolvedRecordId,
202727
202830
  data,
202728
- 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 })
202729
202834
  ) : data
202730
202835
  });
202731
202836
  }
202732
202837
  return records3;
202733
202838
  }
202734
- function composeProspectivePullRecord(recordKind, recordId, data, serverRecord) {
202839
+ function composeProspectivePullRecord(recordKind, recordId, data, base) {
202735
202840
  if (!isSchemaRecordKindV4(recordKind) || !isObjectRecord(data)) return data;
202736
202841
  let baseRecord = null;
202737
- if (serverRecord !== void 0) {
202738
- if (!isObjectRecord(serverRecord.data)) {
202842
+ if (base !== void 0) {
202843
+ if (!isObjectRecord(base.data)) {
202739
202844
  throw new Error(
202740
202845
  `Cannot compose pulled ${recordKind} record ${JSON.stringify(recordId)} because its server payload is not an object.`
202741
202846
  );
@@ -202743,7 +202848,7 @@ function composeProspectivePullRecord(recordKind, recordId, data, serverRecord)
202743
202848
  baseRecord = {
202744
202849
  recordKind,
202745
202850
  recordId,
202746
- data: serverRecord.data
202851
+ data: base.data
202747
202852
  };
202748
202853
  }
202749
202854
  return composeDocumentRecord(
@@ -202784,6 +202889,7 @@ var init_pull = __esm({
202784
202889
  init_static_member_ownership_recovery();
202785
202890
  init_value_base_desync();
202786
202891
  init_packed_value_parity();
202892
+ init_evaluation_workspace();
202787
202893
  init_compiler_metadata();
202788
202894
  }
202789
202895
  });
@@ -215703,7 +215809,7 @@ var releaseWorkspaceLock = () => void 0;
215703
215809
  async function main() {
215704
215810
  const args = parseArgs(process.argv.slice(2));
215705
215811
  if (args.command === "--version") {
215706
- console.log("0.84.0");
215812
+ console.log("0.84.1");
215707
215813
  return;
215708
215814
  }
215709
215815
  if (args.command === null || args.command === "help" || args.command === "--help" || args.command === "-h") {