@neocompose/cli 0.26.4 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/neo.mjs CHANGED
@@ -44,7 +44,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
44
44
  // src/token-store.ts
45
45
  var token_store_exports = {};
46
46
  __export(token_store_exports, {
47
+ NEO_CONFIG_HOME_ENV_VAR: () => NEO_CONFIG_HOME_ENV_VAR,
48
+ NEO_CREDENTIAL_NAMESPACE_ENV_VAR: () => NEO_CREDENTIAL_NAMESPACE_ENV_VAR,
47
49
  NEO_TOKEN_ENV_VAR: () => NEO_TOKEN_ENV_VAR,
50
+ credentialsDir: () => credentialsDir,
51
+ deleteCredential: () => deleteCredential,
52
+ keychainAccount: () => keychainAccount,
48
53
  loadCredential: () => loadCredential,
49
54
  loadToken: () => loadToken,
50
55
  saveCredential: () => saveCredential
@@ -54,12 +59,22 @@ import {
54
59
  existsSync,
55
60
  mkdirSync,
56
61
  readFileSync,
62
+ rmSync,
57
63
  writeFileSync
58
64
  } from "node:fs";
59
65
  import { execFileSync } from "node:child_process";
60
66
  import { homedir } from "node:os";
61
- import { join } from "node:path";
67
+ import { isAbsolute, join } from "node:path";
62
68
  function credentialsDir() {
69
+ const configHome = process.env[NEO_CONFIG_HOME_ENV_VAR];
70
+ if (configHome !== void 0 && configHome !== "") {
71
+ if (!isAbsolute(configHome)) {
72
+ throw new Error(
73
+ `${NEO_CONFIG_HOME_ENV_VAR} must be an absolute directory path, got "${configHome}".`
74
+ );
75
+ }
76
+ return configHome;
77
+ }
63
78
  const xdg = process.env.XDG_CONFIG_HOME;
64
79
  const base = xdg !== void 0 && xdg !== "" ? xdg : join(homedir(), ".config");
65
80
  return join(base, "neo-compose");
@@ -80,6 +95,11 @@ function readCredentialsFile() {
80
95
  }
81
96
  return file;
82
97
  }
98
+ function keychainAccount(apiBaseUrl) {
99
+ const namespace = process.env[NEO_CREDENTIAL_NAMESPACE_ENV_VAR];
100
+ if (namespace === void 0 || namespace === "") return apiBaseUrl;
101
+ return `${namespace}::${apiBaseUrl}`;
102
+ }
83
103
  function keychainSet(account, secret) {
84
104
  if (process.platform !== "darwin") return false;
85
105
  try {
@@ -116,8 +136,24 @@ function keychainGet(account) {
116
136
  return null;
117
137
  }
118
138
  }
139
+ function keychainDelete(account) {
140
+ if (process.platform !== "darwin") return false;
141
+ try {
142
+ execFileSync(
143
+ "security",
144
+ ["delete-generic-password", "-s", KEYCHAIN_SERVICE, "-a", account],
145
+ { stdio: "ignore" }
146
+ );
147
+ return true;
148
+ } catch {
149
+ return false;
150
+ }
151
+ }
119
152
  function saveCredential(credential) {
120
- const inKeychain = keychainSet(credential.apiBaseUrl, credential.token);
153
+ const inKeychain = keychainSet(
154
+ keychainAccount(credential.apiBaseUrl),
155
+ credential.token
156
+ );
121
157
  mkdirSync(credentialsDir(), { recursive: true, mode: 448 });
122
158
  const file = readCredentialsFile();
123
159
  file.credentials[credential.apiBaseUrl] = inKeychain ? { ...credential, token: "" } : credential;
@@ -132,7 +168,7 @@ function saveCredential(credential) {
132
168
  function loadToken(apiBaseUrl) {
133
169
  const envToken = process.env[NEO_TOKEN_ENV_VAR];
134
170
  if (envToken !== void 0 && envToken !== "") return envToken;
135
- const fromKeychain = keychainGet(apiBaseUrl);
171
+ const fromKeychain = keychainGet(keychainAccount(apiBaseUrl));
136
172
  if (fromKeychain !== null) return fromKeychain;
137
173
  const file = readCredentialsFile();
138
174
  const credential = file.credentials[apiBaseUrl];
@@ -143,11 +179,38 @@ function loadCredential(apiBaseUrl) {
143
179
  const file = readCredentialsFile();
144
180
  return file.credentials[apiBaseUrl] ?? null;
145
181
  }
146
- var NEO_TOKEN_ENV_VAR, KEYCHAIN_SERVICE;
182
+ function deleteCredential(apiBaseUrl) {
183
+ const account = keychainAccount(apiBaseUrl);
184
+ const fromKeychain = keychainGet(account);
185
+ const file = readCredentialsFile();
186
+ const fileEntry = file.credentials[apiBaseUrl];
187
+ const token = fromKeychain ?? (fileEntry !== void 0 && fileEntry.token !== "" ? fileEntry.token : null);
188
+ const deletedKeychainEntry = keychainDelete(account);
189
+ let deletedFileEntry = false;
190
+ if (fileEntry !== void 0) {
191
+ delete file.credentials[apiBaseUrl];
192
+ deletedFileEntry = true;
193
+ const path = credentialsPath();
194
+ if (Object.keys(file.credentials).length === 0) {
195
+ rmSync(path, { force: true });
196
+ } else {
197
+ writeFileSync(path, `${JSON.stringify(file, null, 2)}
198
+ `, {
199
+ encoding: "utf8",
200
+ mode: 384
201
+ });
202
+ chmodSync(path, 384);
203
+ }
204
+ }
205
+ return { token, deletedKeychainEntry, deletedFileEntry };
206
+ }
207
+ var NEO_TOKEN_ENV_VAR, NEO_CONFIG_HOME_ENV_VAR, NEO_CREDENTIAL_NAMESPACE_ENV_VAR, KEYCHAIN_SERVICE;
147
208
  var init_token_store = __esm({
148
209
  "src/token-store.ts"() {
149
210
  "use strict";
150
211
  NEO_TOKEN_ENV_VAR = "NEO_COMPOSE_TOKEN";
212
+ NEO_CONFIG_HOME_ENV_VAR = "NEO_COMPOSE_CONFIG_HOME";
213
+ NEO_CREDENTIAL_NAMESPACE_ENV_VAR = "NEO_COMPOSE_CREDENTIAL_NAMESPACE";
151
214
  KEYCHAIN_SERVICE = "neo-compose-cli";
152
215
  }
153
216
  });
@@ -427,6 +490,44 @@ async function runLogin(options) {
427
490
  return;
428
491
  }
429
492
  }
493
+ async function runLogout(apiBaseUrl) {
494
+ const { deleteCredential: deleteCredential2 } = await Promise.resolve().then(() => (init_token_store(), token_store_exports));
495
+ const deleted = deleteCredential2(apiBaseUrl);
496
+ if (deleted.token === null && !deleted.deletedKeychainEntry && !deleted.deletedFileEntry) {
497
+ console.log(`No credentials stored for "${apiBaseUrl}".`);
498
+ return;
499
+ }
500
+ if (deleted.token !== null) {
501
+ try {
502
+ const response = await fetch(new URL("/api/auth/sign-out", apiBaseUrl), {
503
+ body: "{}",
504
+ headers: {
505
+ Authorization: `Bearer ${deleted.token}`,
506
+ "Content-Type": "application/json"
507
+ },
508
+ method: "POST"
509
+ });
510
+ if (response.ok) {
511
+ console.log(`Revoked the server session at ${apiBaseUrl}.`);
512
+ } else {
513
+ console.log(
514
+ `Server session revocation returned ${response.status}; the local credential was still deleted.`
515
+ );
516
+ }
517
+ } catch {
518
+ console.log(
519
+ "Server session revocation was unreachable; the local credential was still deleted."
520
+ );
521
+ }
522
+ }
523
+ const surfaces = [
524
+ deleted.deletedKeychainEntry ? "Keychain entry" : null,
525
+ deleted.deletedFileEntry ? "credentials file entry" : null
526
+ ].filter((surface) => surface !== null);
527
+ console.log(
528
+ `Logged out of ${apiBaseUrl}${surfaces.length > 0 ? ` (removed ${surfaces.join(" and ")})` : ""}.`
529
+ );
530
+ }
430
531
  async function runWhoami(apiBaseUrl) {
431
532
  const { loadToken: loadToken2 } = await Promise.resolve().then(() => (init_token_store(), token_store_exports));
432
533
  const token = loadToken2(apiBaseUrl);
@@ -41382,8 +41483,8 @@ function envFromStamp(stamp) {
41382
41483
  }
41383
41484
  return env;
41384
41485
  }
41385
- function substituteMember(member, env, members) {
41386
- const resolved = resolveMember2(member, members);
41486
+ function substituteMember(member, env, members, preResolvedMember) {
41487
+ const resolved = preResolvedMember ?? resolveMember2(member, members);
41387
41488
  if (isMemberGenericBase(resolved)) {
41388
41489
  const binding = substituteMember(
41389
41490
  resolveTerminalBinding(
@@ -42342,6 +42443,12 @@ function stampCreatedValuesMapKey(values, mapKey) {
42342
42443
  }
42343
42444
  }
42344
42445
  function applyDeclaredStorageKeyOverrides(args) {
42446
+ const boundaryValues = args.createdValues.filter(
42447
+ (value) => normalizeStorageKeyDeclaration(
42448
+ args.declarationByValueId.get(value.id)
42449
+ ) !== STORAGE_KEY_INHERIT
42450
+ );
42451
+ if (boundaryValues.length === 0) return;
42345
42452
  const createdById = new Map(
42346
42453
  args.createdValues.map((value) => [value.id, value])
42347
42454
  );
@@ -42367,12 +42474,7 @@ function applyDeclaredStorageKeyOverrides(args) {
42367
42474
  }
42368
42475
  return depth;
42369
42476
  };
42370
- const boundaries = args.createdValues.filter((value) => {
42371
- const declaration = normalizeStorageKeyDeclaration(
42372
- args.declarationByValueId.get(value.id)
42373
- );
42374
- return declaration !== STORAGE_KEY_INHERIT;
42375
- }).sort((left, right) => depthOf(left) - depthOf(right));
42477
+ const boundaries = boundaryValues.sort((left, right) => depthOf(left) - depthOf(right));
42376
42478
  for (const boundary of boundaries) {
42377
42479
  const parentCreated = parentOf.get(boundary.id);
42378
42480
  const parent = parentCreated !== void 0 ? {
@@ -43567,7 +43669,59 @@ function descendPositionThroughMember(position, memberId) {
43567
43669
  }
43568
43670
  function recordStorageKeyDeclaration(sink, valueId, member) {
43569
43671
  if (sink === void 0) return;
43570
- sink.set(valueId, normalizeStorageKeyDeclaration(member.storageKey));
43672
+ const declaration = normalizeStorageKeyDeclaration(member.storageKey);
43673
+ if (declaration === STORAGE_KEY_INHERIT) return;
43674
+ sink.set(valueId, declaration);
43675
+ }
43676
+ function documentHasInitValueContent(document, value) {
43677
+ return document.isInitValueContent?.(value) ?? isInitValueContent(value);
43678
+ }
43679
+ function createDocumentValueRow(document, projectId, body) {
43680
+ return document.createValueRow?.(projectId, body) ?? buildNewValue(projectId, body);
43681
+ }
43682
+ function directScalarDefaultBody(document, member) {
43683
+ if (member.kind !== 1 /* Bool */ && member.kind !== 2 /* Int */ && member.kind !== 4 /* Float */ && member.kind !== 3 /* String */ && member.kind !== 20 /* Decimal */ && member.kind !== 8 /* Enum */ && member.kind !== 0 /* Null */) {
43684
+ return void 0;
43685
+ }
43686
+ if (!member.required && (member.defaultValue === void 0 || member.defaultValue === null)) {
43687
+ return void 0;
43688
+ }
43689
+ if (documentHasInitValueContent(document, member.defaultValue)) {
43690
+ return void 0;
43691
+ }
43692
+ const body = member.defaultValue ?? primitiveFallbackValue(document, member);
43693
+ if (!isLiteralValueContent(body)) return void 0;
43694
+ if (body.value !== null && typeof body.value !== "boolean" && typeof body.value !== "number" && typeof body.value !== "string") {
43695
+ return void 0;
43696
+ }
43697
+ validateProjectDocumentFileMemberValue(
43698
+ document,
43699
+ member,
43700
+ body,
43701
+ DECLARATION_DEFAULT_POSITION
43702
+ );
43703
+ return { value: body.value, classId: body.classId };
43704
+ }
43705
+ function buildDefaultClassMaterializationPlan(document, classId, instanceEnv) {
43706
+ const merged = document.storedInstanceSchema?.(classId) ?? mergeStoredInstanceSchema(classId, document.classes, document.members);
43707
+ return merged.flatMap((entry) => {
43708
+ if (entry.memberId === null) return [];
43709
+ const childMember = findMemberInDocument(document, entry.memberId);
43710
+ if (!memberKindOwnsStoredValue(childMember.kind)) return [];
43711
+ const member = substituteMember(
43712
+ childMember,
43713
+ instanceEnv,
43714
+ document.members,
43715
+ document.resolvedMember?.(childMember)
43716
+ );
43717
+ return [
43718
+ {
43719
+ schemaKey: entry.schemaKey,
43720
+ member,
43721
+ directScalarBody: directScalarDefaultBody(document, member)
43722
+ }
43723
+ ];
43724
+ });
43571
43725
  }
43572
43726
  function assertLookupInitializerLiteral(member, literal2) {
43573
43727
  if (!isMemberLookupBase(member)) return;
@@ -43589,7 +43743,6 @@ function assertLookupInitializerLiteral(member, literal2) {
43589
43743
  function evaluateLiteralContainer(args) {
43590
43744
  const body = args.body;
43591
43745
  if (body === void 0) return void 0;
43592
- if (!isInitValueContent(body)) return { literal: body };
43593
43746
  if (args.initEvaluator === void 0) {
43594
43747
  throw new Error(
43595
43748
  `Cannot materialize member "${args.member.name}": its value is a NeoScript initializer, which this builder cannot evaluate. Supply an initEvaluator.`
@@ -43621,9 +43774,16 @@ function evaluateLiteralContainer(args) {
43621
43774
  };
43622
43775
  }
43623
43776
  function buildDefaultMemberValue(args) {
43624
- const member = args.genericEnv !== void 0 ? substituteMember(args.member, args.genericEnv, args.document.members) : resolveMember2(args.member, args.document.members);
43777
+ const resolvedMember = args.document.resolvedMember?.(args.member) ?? resolveMember2(args.member, args.document.members);
43778
+ const member = args.genericEnv !== void 0 ? substituteMember(
43779
+ args.member,
43780
+ args.genericEnv,
43781
+ args.document.members,
43782
+ resolvedMember
43783
+ ) : resolvedMember;
43625
43784
  const declaredDefault = member.defaultValue;
43626
- if (isInitValueContent(declaredDefault)) {
43785
+ if (documentHasInitValueContent(args.document, declaredDefault)) {
43786
+ const initializerCreatedValuesStart = args.createdValues.length;
43627
43787
  const evaluated = evaluateLiteralContainer({
43628
43788
  body: declaredDefault,
43629
43789
  member,
@@ -43637,13 +43797,17 @@ function buildDefaultMemberValue(args) {
43637
43797
  if (evaluated.existingValueRow !== void 0) {
43638
43798
  return evaluated.existingValueRow;
43639
43799
  }
43640
- const value2 = buildNewValue(args.projectId, evaluated.literal);
43800
+ const value2 = createDocumentValueRow(
43801
+ args.document,
43802
+ args.projectId,
43803
+ evaluated.literal
43804
+ );
43641
43805
  if (evaluated.genericBindings !== void 0) {
43642
43806
  value2.genericBindings = { ...evaluated.genericBindings };
43643
43807
  }
43644
43808
  if (evaluated.provisionalRootId !== void 0) {
43645
43809
  retargetDelegateReceiverValueIds(
43646
- [value2, ...args.createdValues],
43810
+ [value2, ...args.createdValues.slice(initializerCreatedValuesStart)],
43647
43811
  evaluated.provisionalRootId,
43648
43812
  value2.id
43649
43813
  );
@@ -43659,7 +43823,11 @@ function buildDefaultMemberValue(args) {
43659
43823
  `Required Class member "${member.name}" cannot have a null default.`
43660
43824
  );
43661
43825
  }
43662
- const value3 = buildNewValue(args.projectId, declaredDefault);
43826
+ const value3 = createDocumentValueRow(
43827
+ args.document,
43828
+ args.projectId,
43829
+ declaredDefault
43830
+ );
43663
43831
  args.createdValues.push(value3);
43664
43832
  recordStorageKeyDeclaration(
43665
43833
  args.storageKeyDeclarations,
@@ -43685,7 +43853,7 @@ function buildDefaultMemberValue(args) {
43685
43853
  `Cannot create a value of abstract class "${effectiveClass.name}".`
43686
43854
  );
43687
43855
  }
43688
- const childEnv = resolveInstanceEnv(
43856
+ const childEnv = args.document.instanceEnv?.(effectiveClassId, member.classArguments) ?? resolveInstanceEnv(
43689
43857
  effectiveClassId,
43690
43858
  member.classArguments,
43691
43859
  args.document.classes
@@ -43710,10 +43878,13 @@ function buildDefaultMemberValue(args) {
43710
43878
  );
43711
43879
  }
43712
43880
  }
43713
- const merged = mergeStoredInstanceSchema(
43881
+ const materializationPlan = args.document.storedInstanceMaterializationPlan?.(
43714
43882
  effectiveClassId,
43715
- args.document.classes,
43716
- args.document.members
43883
+ childEnv
43884
+ ) ?? buildDefaultClassMaterializationPlan(
43885
+ args.document,
43886
+ effectiveClassId,
43887
+ childEnv
43717
43888
  );
43718
43889
  const record3 = member.partial === true ? {} : cloneDefaultClassRecord({
43719
43890
  document: args.document,
@@ -43733,39 +43904,43 @@ function buildDefaultMemberValue(args) {
43733
43904
  position: DECLARATION_DEFAULT_POSITION
43734
43905
  });
43735
43906
  let anchorsParentClassPartition = false;
43736
- for (const entry of member.partial === true ? [] : merged) {
43737
- if (entry.memberId === null) continue;
43738
- const childMember = findMemberInDocument(args.document, entry.memberId);
43739
- if (!memberKindOwnsStoredValue(childMember.kind)) continue;
43740
- const resolvedChildMember = substituteMember(
43741
- childMember,
43742
- childEnv,
43743
- args.document.members
43744
- );
43907
+ for (const {
43908
+ schemaKey,
43909
+ member: resolvedChildMember,
43910
+ directScalarBody
43911
+ } of member.partial === true ? [] : materializationPlan) {
43745
43912
  if (storageKeyReferencesParentClass(
43746
43913
  normalizeStorageKeyDeclaration(resolvedChildMember.storageKey)
43747
43914
  )) {
43748
43915
  anchorsParentClassPartition = true;
43749
43916
  }
43750
- if (record3[entry.schemaKey] !== void 0) continue;
43751
- if (args.authoredRoot?.suppliedSchemaKeys.has(entry.schemaKey) === true) {
43917
+ if (record3[schemaKey] !== void 0) continue;
43918
+ if (args.authoredRoot?.suppliedSchemaKeys.has(schemaKey) === true) {
43752
43919
  continue;
43753
43920
  }
43754
43921
  if (skipProvidedConstructorSchemaKey(
43755
43922
  args.constructorRoot,
43756
- entry.schemaKey,
43757
- resolvedChildMember
43923
+ schemaKey,
43924
+ resolvedChildMember,
43925
+ documentHasInitValueContent(
43926
+ args.document,
43927
+ resolvedChildMember.defaultValue
43928
+ )
43758
43929
  )) {
43759
43930
  continue;
43760
43931
  }
43761
43932
  if (!shouldMaterializeChildDefaultForRoot(
43762
43933
  args.constructorRoot,
43763
- resolvedChildMember
43934
+ resolvedChildMember,
43935
+ documentHasInitValueContent(
43936
+ args.document,
43937
+ resolvedChildMember.defaultValue
43938
+ )
43764
43939
  )) {
43765
43940
  continue;
43766
43941
  }
43767
43942
  if (shouldSkipRequiredChildDefault(resolvedChildMember)) continue;
43768
- const childValue = buildDefaultMemberValue({
43943
+ const childValue = directScalarBody === void 0 ? buildDefaultMemberValue({
43769
43944
  document: args.document,
43770
43945
  projectId: args.projectId,
43771
43946
  member: resolvedChildMember,
@@ -43773,13 +43948,29 @@ function buildDefaultMemberValue(args) {
43773
43948
  storageKeyDeclarations: args.storageKeyDeclarations,
43774
43949
  initEvaluator: args.initEvaluator,
43775
43950
  genericEnv: childEnv
43776
- });
43777
- record3[entry.schemaKey] = childValue.id;
43951
+ }) : createDocumentValueRow(
43952
+ args.document,
43953
+ args.projectId,
43954
+ directScalarBody
43955
+ );
43956
+ if (directScalarBody !== void 0) {
43957
+ args.createdValues.push(childValue);
43958
+ recordStorageKeyDeclaration(
43959
+ args.storageKeyDeclarations,
43960
+ childValue.id,
43961
+ resolvedChildMember
43962
+ );
43963
+ }
43964
+ record3[schemaKey] = childValue.id;
43778
43965
  }
43779
- const value2 = buildNewValue(args.projectId, {
43780
- value: record3,
43781
- classId: member.partial === true || effectiveClassId !== member.classId || anchorsParentClassPartition ? effectiveClassId : void 0
43782
- });
43966
+ const value2 = createDocumentValueRow(
43967
+ args.document,
43968
+ args.projectId,
43969
+ {
43970
+ value: record3,
43971
+ classId: member.partial === true || effectiveClassId !== member.classId || anchorsParentClassPartition ? effectiveClassId : void 0
43972
+ }
43973
+ );
43783
43974
  args.createdValues.push(value2);
43784
43975
  recordStorageKeyDeclaration(args.storageKeyDeclarations, value2.id, member);
43785
43976
  return value2;
@@ -43797,7 +43988,11 @@ function buildDefaultMemberValue(args) {
43797
43988
  path: /* @__PURE__ */ new Set(),
43798
43989
  position: DECLARATION_DEFAULT_POSITION
43799
43990
  });
43800
- const value2 = buildNewValue(args.projectId, record3);
43991
+ const value2 = createDocumentValueRow(
43992
+ args.document,
43993
+ args.projectId,
43994
+ record3
43995
+ );
43801
43996
  stampGenericBindings(value2, member, args);
43802
43997
  args.createdValues.push(value2);
43803
43998
  recordStorageKeyDeclaration(args.storageKeyDeclarations, value2.id, member);
@@ -43816,14 +44011,20 @@ function buildDefaultMemberValue(args) {
43816
44011
  path: /* @__PURE__ */ new Set(),
43817
44012
  position: DECLARATION_DEFAULT_POSITION
43818
44013
  });
43819
- const value2 = buildNewValue(args.projectId, list);
44014
+ const value2 = createDocumentValueRow(
44015
+ args.document,
44016
+ args.projectId,
44017
+ list
44018
+ );
43820
44019
  stampGenericBindings(value2, member, args);
43821
44020
  args.createdValues.push(value2);
43822
44021
  recordStorageKeyDeclaration(args.storageKeyDeclarations, value2.id, member);
43823
44022
  return value2;
43824
44023
  }
43825
44024
  if (isMemberNullBase(member)) {
43826
- const value2 = buildNewValue(args.projectId, { value: null });
44025
+ const value2 = createDocumentValueRow(args.document, args.projectId, {
44026
+ value: null
44027
+ });
43827
44028
  args.createdValues.push(value2);
43828
44029
  recordStorageKeyDeclaration(args.storageKeyDeclarations, value2.id, member);
43829
44030
  return value2;
@@ -43843,30 +44044,33 @@ function buildDefaultMemberValue(args) {
43843
44044
  DECLARATION_DEFAULT_POSITION
43844
44045
  );
43845
44046
  }
43846
- const value = buildNewValue(args.projectId, clonedBody);
44047
+ const value = createDocumentValueRow(
44048
+ args.document,
44049
+ args.projectId,
44050
+ clonedBody
44051
+ );
43847
44052
  args.createdValues.push(value);
43848
44053
  recordStorageKeyDeclaration(args.storageKeyDeclarations, value.id, member);
43849
44054
  return value;
43850
44055
  }
43851
- function buildNewValue(projectId, body) {
44056
+ function buildNewValue(projectId, body, timestamp = Date.now()) {
43852
44057
  if (isInitValueContent(body)) {
43853
44058
  throw new Error(
43854
44059
  "Cannot build a value row from an initializer-backed container: the initializer must be evaluated into a literal value first."
43855
44060
  );
43856
44061
  }
43857
- const now = Date.now();
43858
44062
  const id2 = v4_default();
43859
44063
  const props = {
43860
44064
  id: id2,
43861
44065
  projectId,
43862
44066
  value: body.value,
43863
44067
  classId: body.classId ?? void 0,
43864
- ...body.constructorArgs === void 0 || body.constructorArgs === null ? {} : {
43865
- constructorArgs: cloneJsonValue(body.constructorArgs)
43866
- },
43867
- createdAt: now,
43868
- updatedAt: now
44068
+ createdAt: timestamp,
44069
+ updatedAt: timestamp
43869
44070
  };
44071
+ if (body.constructorArgs !== void 0 && body.constructorArgs !== null) {
44072
+ props.constructorArgs = cloneJsonValue(body.constructorArgs);
44073
+ }
43870
44074
  return props;
43871
44075
  }
43872
44076
  function retargetDelegateReceiverValueIds(rows, fromValueId, toValueId) {
@@ -44009,9 +44213,11 @@ function cloneDefaultValueForMember(args) {
44009
44213
  const member = substituteMember(
44010
44214
  args.member,
44011
44215
  args.genericEnv,
44012
- args.document.members
44216
+ args.document.members,
44217
+ args.document.resolvedMember?.(args.member)
44013
44218
  );
44014
- if (isInitValueContent(sourceValue)) {
44219
+ if (documentHasInitValueContent(args.document, sourceValue)) {
44220
+ const initializerCreatedValuesStart = args.createdValues.length;
44015
44221
  const evaluated = evaluateLiteralContainer({
44016
44222
  body: sourceValue,
44017
44223
  member,
@@ -44026,13 +44232,20 @@ function cloneDefaultValueForMember(args) {
44026
44232
  if (evaluated.existingValueRow !== void 0) {
44027
44233
  return evaluated.existingValueRow;
44028
44234
  }
44029
- const evaluatedRow = buildNewValue(args.projectId, evaluated.literal);
44235
+ const evaluatedRow = createDocumentValueRow(
44236
+ args.document,
44237
+ args.projectId,
44238
+ evaluated.literal
44239
+ );
44030
44240
  if (evaluated.genericBindings !== void 0) {
44031
44241
  evaluatedRow.genericBindings = { ...evaluated.genericBindings };
44032
44242
  }
44033
44243
  if (evaluated.provisionalRootId !== void 0) {
44034
44244
  retargetDelegateReceiverValueIds(
44035
- [evaluatedRow, ...args.createdValues],
44245
+ [
44246
+ evaluatedRow,
44247
+ ...args.createdValues.slice(initializerCreatedValuesStart)
44248
+ ],
44036
44249
  evaluated.provisionalRootId,
44037
44250
  evaluatedRow.id
44038
44251
  );
@@ -44049,7 +44262,7 @@ function cloneDefaultValueForMember(args) {
44049
44262
  let body;
44050
44263
  if (isMemberClassBase(member)) {
44051
44264
  const effectiveClassId = typeof sourceValue.classId === "string" ? sourceValue.classId : member.classId;
44052
- const childEnv = resolveInstanceEnv(
44265
+ const childEnv = args.document.instanceEnv?.(effectiveClassId, member.classArguments) ?? resolveInstanceEnv(
44053
44266
  effectiveClassId,
44054
44267
  member.classArguments,
44055
44268
  args.document.classes
@@ -44107,7 +44320,7 @@ function cloneDefaultValueForMember(args) {
44107
44320
  args.position
44108
44321
  );
44109
44322
  }
44110
- const value = buildNewValue(args.projectId, body);
44323
+ const value = createDocumentValueRow(args.document, args.projectId, body);
44111
44324
  value.sourceValueId = sourceValue.sourceValueId ?? sourceValue.id;
44112
44325
  if (isMemberListBase(member) || isMemberDictionaryBase(member)) {
44113
44326
  stampGenericBindings(value, member, args);
@@ -44130,9 +44343,7 @@ function formatDefaultReferenceLocation(memberName, key) {
44130
44343
  }
44131
44344
  function getSchemaEntryMap(document, classId) {
44132
44345
  return new Map(
44133
- mergeStoredInstanceSchema(classId, document.classes, document.members).map(
44134
- (entry) => [entry.schemaKey, entry]
44135
- )
44346
+ (document.storedInstanceSchema?.(classId) ?? mergeStoredInstanceSchema(classId, document.classes, document.members)).map((entry) => [entry.schemaKey, entry])
44136
44347
  );
44137
44348
  }
44138
44349
  function cloneMemberValueBase(body) {
@@ -44189,26 +44400,26 @@ function shouldMaterializeChildDefault(member) {
44189
44400
  }
44190
44401
  return member.defaultValue !== void 0;
44191
44402
  }
44192
- function shouldMaterializeConstructorChildDefault(member) {
44193
- if (isInitValueContent(member.defaultValue)) return true;
44403
+ function shouldMaterializeConstructorChildDefault(member, isInitializer = isInitValueContent(member.defaultValue)) {
44404
+ if (isInitializer) return true;
44194
44405
  if (!member.required) return false;
44195
44406
  return shouldMaterializeChildDefault(member);
44196
44407
  }
44197
- function skipProvidedConstructorSchemaKey(constructorRoot, schemaKey, member) {
44408
+ function skipProvidedConstructorSchemaKey(constructorRoot, schemaKey, member, isInitializer = isInitValueContent(member.defaultValue)) {
44198
44409
  if (constructorRoot === void 0) return false;
44199
44410
  if (!constructorRoot.providedSchemaKeys.has(schemaKey)) return false;
44200
44411
  if (constructorRoot.runsMemberInitializers !== true) {
44201
- return !isInitValueContent(member.defaultValue);
44412
+ return !isInitializer;
44202
44413
  }
44203
44414
  return member.defaultValue === void 0;
44204
44415
  }
44205
- function shouldMaterializeChildDefaultForRoot(constructorRoot, member) {
44416
+ function shouldMaterializeChildDefaultForRoot(constructorRoot, member, isInitializer = isInitValueContent(member.defaultValue)) {
44206
44417
  if (constructorRoot === void 0)
44207
44418
  return shouldMaterializeChildDefault(member);
44208
44419
  if (constructorRoot.runsMemberInitializers === true) {
44209
44420
  return shouldMaterializeChildDefault(member);
44210
44421
  }
44211
- return shouldMaterializeConstructorChildDefault(member);
44422
+ return shouldMaterializeConstructorChildDefault(member, isInitializer);
44212
44423
  }
44213
44424
  function primitiveFallbackValue(document, member) {
44214
44425
  if (isMemberBoolBase(member)) return { value: false };
@@ -58443,6 +58654,7 @@ function buildEvaluatorBaseIndexes(members, values, valueById = new Map(
58443
58654
  ownershipRootIdsByRowId: /* @__PURE__ */ new Map(),
58444
58655
  ownershipDistancesByRowId: /* @__PURE__ */ new Map(),
58445
58656
  ownedValueAttachmentsByValueId: /* @__PURE__ */ new Map(),
58657
+ constructorOwnershipDirtyValueIds: /* @__PURE__ */ new Set(),
58446
58658
  memberByRowId: /* @__PURE__ */ new Map()
58447
58659
  };
58448
58660
  const membersByValueId = /* @__PURE__ */ new Map();
@@ -58454,7 +58666,7 @@ function buildEvaluatorBaseIndexes(members, values, valueById = new Map(
58454
58666
  membersByValueId.set(member.valueId, bucket);
58455
58667
  }
58456
58668
  }
58457
- for (const row of values) indexEvaluatorRow(indexes, row);
58669
+ indexEvaluatorRows(indexes, values);
58458
58670
  return {
58459
58671
  rows: values,
58460
58672
  valueById,
@@ -58498,6 +58710,7 @@ function evaluatorIndexes(ctx) {
58498
58710
  ownershipRootIdsByRowId: sharedOwnershipCaches?.ownershipRootIdsByRowId ?? /* @__PURE__ */ new Map(),
58499
58711
  ownershipDistancesByRowId: sharedOwnershipCaches?.ownershipDistancesByRowId ?? /* @__PURE__ */ new Map(),
58500
58712
  ownedValueAttachmentsByValueId: /* @__PURE__ */ new Map(),
58713
+ constructorOwnershipDirtyValueIds: /* @__PURE__ */ new Set(),
58501
58714
  memberByRowId: /* @__PURE__ */ new Map()
58502
58715
  };
58503
58716
  if (base === void 0) {
@@ -58506,18 +58719,21 @@ function evaluatorIndexes(ctx) {
58506
58719
  indexes.memberByValueId.set(member.valueId, member);
58507
58720
  }
58508
58721
  }
58509
- for (const row of evaluatorValues(ctx)) indexEvaluatorRow(indexes, row);
58722
+ indexEvaluatorRows(indexes, evaluatorValues(ctx));
58510
58723
  } else {
58724
+ const localRows = [];
58511
58725
  for (const row of ctx.__runtimeSessionValues?.values() ?? []) {
58512
58726
  indexes.shadowedBaseRowIds.add(row.id);
58513
- indexEvaluatorRow(indexes, row, true);
58727
+ localRows.push(row);
58514
58728
  }
58515
58729
  for (const row of ctx.__valueOverlay?.values() ?? []) {
58516
58730
  indexes.shadowedBaseRowIds.add(row.id);
58517
- indexEvaluatorRow(indexes, row, true);
58731
+ localRows.push(row);
58518
58732
  }
58733
+ indexEvaluatorRows(indexes, localRows, true);
58519
58734
  }
58520
58735
  syncLazyOverlayReferences(indexes, ctx.__valueOverlay);
58736
+ indexes.constructorOwnershipDirtyValueIds.clear();
58521
58737
  ctx.__indexes = indexes;
58522
58738
  return indexes;
58523
58739
  }
@@ -58534,27 +58750,32 @@ function syncLazyOverlayReferences(indexes, overlay) {
58534
58750
  }
58535
58751
  indexes.indexedOverlayRowCount += materializedRows.length;
58536
58752
  }
58537
- function indexEvaluatorRow(indexes, row, allowBaseShadow = false) {
58753
+ function indexEvaluatorRow(indexes, row, allowBaseShadow = false, sharedCachesAlreadyInvalidated = false) {
58754
+ if (indexes.indexedRowIds.has(row.id) || !allowBaseShadow && indexes.baseIndexedRowIds?.has(row.id) === true) {
58755
+ return;
58756
+ }
58757
+ if (!sharedCachesAlreadyInvalidated) {
58758
+ indexes.ownershipRootIdsByRowId.clear();
58759
+ indexes.ownershipDistancesByRowId.clear();
58760
+ indexes.memberByRowId.clear();
58761
+ }
58538
58762
  indexes.ownedValueAttachmentsByValueId.delete(row.id);
58763
+ indexes.constructorOwnershipDirtyValueIds.add(row.id);
58539
58764
  if (Array.isArray(row.value)) {
58540
58765
  for (const childId of row.value) {
58541
58766
  if (typeof childId === "string") {
58542
58767
  indexes.ownedValueAttachmentsByValueId.delete(childId);
58768
+ indexes.constructorOwnershipDirtyValueIds.add(childId);
58543
58769
  }
58544
58770
  }
58545
58771
  } else if (typeof row.value === "object" && row.value !== null) {
58546
58772
  for (const childId of Object.values(row.value)) {
58547
58773
  if (typeof childId === "string") {
58548
58774
  indexes.ownedValueAttachmentsByValueId.delete(childId);
58775
+ indexes.constructorOwnershipDirtyValueIds.add(childId);
58549
58776
  }
58550
58777
  }
58551
58778
  }
58552
- indexes.ownershipRootIdsByRowId.clear();
58553
- indexes.ownershipDistancesByRowId.clear();
58554
- indexes.memberByRowId.clear();
58555
- if (indexes.indexedRowIds.has(row.id) || !allowBaseShadow && indexes.baseIndexedRowIds?.has(row.id) === true) {
58556
- return;
58557
- }
58558
58779
  indexes.indexedRowIds.add(row.id);
58559
58780
  if (typeof row.sourceValueId === "string") {
58560
58781
  const rows = indexes.rowsBySourceValueId.get(row.sourceValueId) ?? [];
@@ -58582,6 +58803,55 @@ function indexEvaluatorRow(indexes, row, allowBaseShadow = false) {
58582
58803
  }
58583
58804
  }
58584
58805
  }
58806
+ function indexEvaluatorRows(indexes, rows, allowBaseShadow = false) {
58807
+ let sharedCachesInvalidated = false;
58808
+ for (const row of rows) {
58809
+ const alreadyIndexed = indexes.indexedRowIds.has(row.id) || !allowBaseShadow && indexes.baseIndexedRowIds?.has(row.id) === true;
58810
+ if (alreadyIndexed) continue;
58811
+ if (!sharedCachesInvalidated) {
58812
+ indexes.ownershipRootIdsByRowId.clear();
58813
+ indexes.ownershipDistancesByRowId.clear();
58814
+ indexes.memberByRowId.clear();
58815
+ sharedCachesInvalidated = true;
58816
+ }
58817
+ indexEvaluatorRow(indexes, row, allowBaseShadow, true);
58818
+ }
58819
+ }
58820
+ function unindexEvaluatorRow(indexes, row) {
58821
+ indexes.indexedRowIds.delete(row.id);
58822
+ indexes.ownedValueAttachmentsByValueId.delete(row.id);
58823
+ indexes.constructorOwnershipDirtyValueIds.delete(row.id);
58824
+ indexes.parentLinksByChildId.delete(row.id);
58825
+ if (typeof row.value === "object" && row.value !== null && indexes.rowByValueReference.get(row.value) === row) {
58826
+ indexes.rowByValueReference.delete(row.value);
58827
+ }
58828
+ if (typeof row.sourceValueId === "string") {
58829
+ const sourceRows = indexes.rowsBySourceValueId.get(row.sourceValueId);
58830
+ if (sourceRows !== void 0) {
58831
+ const retained = sourceRows.filter((candidate) => candidate !== row);
58832
+ if (retained.length === 0) {
58833
+ indexes.rowsBySourceValueId.delete(row.sourceValueId);
58834
+ } else {
58835
+ indexes.rowsBySourceValueId.set(row.sourceValueId, retained);
58836
+ }
58837
+ }
58838
+ }
58839
+ const childIds = Array.isArray(row.value) ? row.value : typeof row.value === "object" && row.value !== null ? Object.values(row.value) : [];
58840
+ for (const childId of childIds) {
58841
+ if (typeof childId !== "string") continue;
58842
+ const links = indexes.parentLinksByChildId.get(childId);
58843
+ if (links !== void 0) {
58844
+ const retained = links.filter((link) => link.parentId !== row.id);
58845
+ if (retained.length === 0) indexes.parentLinksByChildId.delete(childId);
58846
+ else indexes.parentLinksByChildId.set(childId, retained);
58847
+ }
58848
+ indexes.ownedValueAttachmentsByValueId.delete(childId);
58849
+ indexes.constructorOwnershipDirtyValueIds.add(childId);
58850
+ }
58851
+ indexes.ownershipRootIdsByRowId.clear();
58852
+ indexes.ownershipDistancesByRowId.clear();
58853
+ indexes.memberByRowId.clear();
58854
+ }
58585
58855
  function addEvaluatorParentLink(indexes, childId, parentId, key) {
58586
58856
  const links = indexes.parentLinksByChildId.get(childId) ?? [];
58587
58857
  links.push({ parentId, key });
@@ -58751,6 +59021,12 @@ function evaluatorResolutionCache(ctx) {
58751
59021
  compiledFunctionByMemberId: /* @__PURE__ */ new Map(),
58752
59022
  compiledGetterByMemberId: /* @__PURE__ */ new Map(),
58753
59023
  compiledSetterByMemberId: /* @__PURE__ */ new Map(),
59024
+ resolvedMemberById: /* @__PURE__ */ new Map(),
59025
+ storedInstanceSchemaByClassId: /* @__PURE__ */ new Map(),
59026
+ instanceEnvByKey: /* @__PURE__ */ new Map(),
59027
+ validatedConstructorDescriptorByInfo: /* @__PURE__ */ new WeakMap(),
59028
+ validatedInitValueContents: /* @__PURE__ */ new WeakSet(),
59029
+ storedInstanceMaterializationPlanByClassAndEnv: /* @__PURE__ */ new Map(),
58754
59030
  effectiveStorageResolver: void 0
58755
59031
  };
58756
59032
  resolutionCacheByMembers.set(members, {
@@ -58762,10 +59038,139 @@ function evaluatorResolutionCache(ctx) {
58762
59038
  ctx.__resolutionCache = cache;
58763
59039
  return cache;
58764
59040
  }
58765
- function createdSessionValuesSince(session, existingIds) {
59041
+ function cachedResolvedMember(member, ctx) {
59042
+ const memberId = member.id;
59043
+ if (typeof memberId !== "string") {
59044
+ return resolveMember2(member, ctx.vm.members);
59045
+ }
59046
+ const cache = evaluatorResolutionCache(ctx).resolvedMemberById;
59047
+ const cached = cache.get(memberId);
59048
+ if (cached !== void 0) return cached;
59049
+ const resolved = resolveMember2(member, ctx.vm.members);
59050
+ cache.set(memberId, resolved);
59051
+ return resolved;
59052
+ }
59053
+ function cachedStoredInstanceSchema(classId, ctx) {
59054
+ const cache = evaluatorResolutionCache(ctx).storedInstanceSchemaByClassId;
59055
+ const cached = cache.get(classId);
59056
+ if (cached !== void 0) return cached;
59057
+ const merged = mergeStoredInstanceSchema(
59058
+ classId,
59059
+ ctx.vm.classes,
59060
+ ctx.vm.members
59061
+ );
59062
+ cache.set(classId, merged);
59063
+ return merged;
59064
+ }
59065
+ function cachedStoredInstanceMaterializationPlan(classId, instanceEnv, ctx) {
59066
+ const cache = evaluatorResolutionCache(
59067
+ ctx
59068
+ ).storedInstanceMaterializationPlanByClassAndEnv;
59069
+ let byEnvironment = cache.get(classId);
59070
+ const cached = byEnvironment?.get(instanceEnv);
59071
+ if (cached !== void 0) return cached;
59072
+ const plan = buildDefaultClassMaterializationPlan(
59073
+ {
59074
+ project: ctx.vm.project,
59075
+ members: ctx.vm.members,
59076
+ classes: ctx.vm.classes,
59077
+ enums: ctx.vm.enums,
59078
+ values: ctx.vm.values,
59079
+ memberById: ctx.vm.databaseVM?.memberById,
59080
+ valueById: ctx.vm.databaseVM?.valueById,
59081
+ resolvedMember: (member) => cachedResolvedMember(member, ctx),
59082
+ storedInstanceSchema: (nestedClassId) => cachedStoredInstanceSchema(nestedClassId, ctx),
59083
+ instanceEnv: (nestedClassId, classArguments2) => cachedInstanceEnv(nestedClassId, classArguments2, ctx),
59084
+ isInitValueContent: (value) => cachedIsInitValueContent(value, ctx),
59085
+ projectFiles: ctx.vm.projectFiles ?? [],
59086
+ textureTemplates: ctx.vm.textureTemplates ?? []
59087
+ },
59088
+ classId,
59089
+ instanceEnv
59090
+ );
59091
+ byEnvironment ??= /* @__PURE__ */ new WeakMap();
59092
+ byEnvironment.set(instanceEnv, plan);
59093
+ cache.set(classId, byEnvironment);
59094
+ return plan;
59095
+ }
59096
+ function cachedInstanceEnv(classId, classArguments2, ctx) {
59097
+ const key = `${classId}:${JSON.stringify(classArguments2 ?? null)}`;
59098
+ const cache = evaluatorResolutionCache(ctx).instanceEnvByKey;
59099
+ const cached = cache.get(key);
59100
+ if (cached !== void 0) return cached;
59101
+ const resolved = resolveInstanceEnv(classId, classArguments2, ctx.vm.classes);
59102
+ cache.set(key, resolved);
59103
+ return resolved;
59104
+ }
59105
+ function cachedIsInitValueContent(value, ctx) {
59106
+ if (typeof value !== "object" || value === null) return false;
59107
+ const cache = evaluatorResolutionCache(ctx).validatedInitValueContents;
59108
+ if (cache.has(value)) return true;
59109
+ if (!isInitValueContent(value)) return false;
59110
+ cache.add(value);
59111
+ return true;
59112
+ }
59113
+ function sessionCreationCheckpoint(ctx) {
59114
+ if (ctx.__sessionCreationStrategy === "snapshot") {
59115
+ return new Set(ctx.__runtimeSessionValues?.keys());
59116
+ }
59117
+ const state = ctx.__executionState;
59118
+ if (state === void 0) {
59119
+ throw new NSGetterRuntimeError(
59120
+ "Created Session values require an effect-capable evaluator scope."
59121
+ );
59122
+ }
59123
+ return state.sessionCreationJournal.length;
59124
+ }
59125
+ function registerRuntimeSessionValue(ctx, row) {
59126
+ const session = ctx.__runtimeSessionValues;
59127
+ const state = ctx.__executionState;
59128
+ if (session === void 0 || state === void 0) {
59129
+ throw new NSGetterRuntimeError(
59130
+ "Session publication requires an effect-capable evaluator scope."
59131
+ );
59132
+ }
59133
+ if (!state.knownSessionValueIds.has(row.id)) {
59134
+ state.knownSessionValueIds.add(row.id);
59135
+ state.sessionCreationJournal.push(row.id);
59136
+ }
59137
+ session.set(row.id, row);
59138
+ }
59139
+ function deleteRuntimeSessionValue(ctx, rowId) {
59140
+ const session = ctx.__runtimeSessionValues;
59141
+ if (session === void 0) return;
59142
+ const row = session.get(rowId);
59143
+ if (row !== void 0 && ctx.__indexes !== void 0) {
59144
+ unindexEvaluatorRow(ctx.__indexes, row);
59145
+ }
59146
+ session.delete(rowId);
59147
+ }
59148
+ function createdSessionValuesSince(ctx, checkpoint) {
59149
+ const session = ctx.__runtimeSessionValues;
59150
+ const state = ctx.__executionState;
59151
+ if (session === void 0 || state === void 0) {
59152
+ throw new NSGetterRuntimeError(
59153
+ "Created Session values require an effect-capable evaluator scope."
59154
+ );
59155
+ }
58766
59156
  const created = [];
58767
- for (const row of session.values()) {
58768
- if (existingIds.has(row.id)) continue;
59157
+ if (typeof checkpoint !== "number") {
59158
+ for (const row of session.values()) {
59159
+ if (checkpoint.has(row.id)) continue;
59160
+ if (!isLiteralValueContent(row)) {
59161
+ throw new NSGetterRuntimeError(
59162
+ `Evaluator Session row ${row.id} carries an unevaluated initializer instead of a value.`
59163
+ );
59164
+ }
59165
+ created.push(row);
59166
+ }
59167
+ return created;
59168
+ }
59169
+ for (let index = checkpoint; index < state.sessionCreationJournal.length; index += 1) {
59170
+ const rowId = state.sessionCreationJournal[index];
59171
+ if (rowId === void 0) continue;
59172
+ const row = session.get(rowId);
59173
+ if (row === void 0) continue;
58769
59174
  if (!isLiteralValueContent(row)) {
58770
59175
  throw new NSGetterRuntimeError(
58771
59176
  `Evaluator Session row '${row.id}' carries an unevaluated initializer instead of a value.`
@@ -58784,7 +59189,7 @@ function evaluateNSGetterWithEffects(getter, ctx, argumentValues = []) {
58784
59189
  const runtimeCtx = withEvaluationRuntime(ctx, requestedWrites);
58785
59190
  consumeBudget(runtimeCtx, "workUnits", 1, "work unit");
58786
59191
  const writes = runtimeCtx.__executionState?.writes ?? requestedWrites;
58787
- const existingIds = new Set(runtimeCtx.__runtimeSessionValues.keys());
59192
+ const creationCheckpoint = sessionCreationCheckpoint(runtimeCtx);
58788
59193
  const scope = createTopLevelScope(runtimeCtx);
58789
59194
  const parameters = getter.parameters.slice(2);
58790
59195
  if (parameters.length !== argumentValues.length) {
@@ -58816,8 +59221,8 @@ function evaluateNSGetterWithEffects(getter, ctx, argumentValues = []) {
58816
59221
  );
58817
59222
  result.value = preserveReadOnlyReturnIdentity(result.value, runtimeCtx);
58818
59223
  const createdSessionValues = createdSessionValuesSince(
58819
- runtimeCtx.__runtimeSessionValues,
58820
- existingIds
59224
+ runtimeCtx,
59225
+ creationCheckpoint
58821
59226
  );
58822
59227
  return createdSessionValues.length === 0 ? { value: result.value, writes } : { value: result.value, writes, createdSessionValues };
58823
59228
  }
@@ -58834,7 +59239,7 @@ function evaluateNSVoidBody(action, ctx) {
58834
59239
  const writes = [];
58835
59240
  const runtimeCtx = withEvaluationRuntime(ctx, writes);
58836
59241
  consumeBudget(runtimeCtx, "workUnits", 1, "work unit");
58837
- const existingIds = new Set(runtimeCtx.__runtimeSessionValues.keys());
59242
+ const creationCheckpoint = sessionCreationCheckpoint(runtimeCtx);
58838
59243
  const scope = createTopLevelScope(runtimeCtx);
58839
59244
  try {
58840
59245
  const result = evalInstructions(action.instructions, scope, runtimeCtx, {
@@ -58855,8 +59260,8 @@ function evaluateNSVoidBody(action, ctx) {
58855
59260
  throw error;
58856
59261
  }
58857
59262
  const createdSessionValues = createdSessionValuesSince(
58858
- runtimeCtx.__runtimeSessionValues,
58859
- existingIds
59263
+ runtimeCtx,
59264
+ creationCheckpoint
58860
59265
  );
58861
59266
  return createdSessionValues.length === 0 ? { writes } : { writes, createdSessionValues };
58862
59267
  }
@@ -58865,7 +59270,7 @@ function evaluateNSFunction(action, ctx, args) {
58865
59270
  const writes = [];
58866
59271
  const runtimeCtx = withEvaluationRuntime(ctx, writes);
58867
59272
  consumeBudget(runtimeCtx, "workUnits", 1, "work unit");
58868
- const existingIds = new Set(runtimeCtx.__runtimeSessionValues.keys());
59273
+ const creationCheckpoint = sessionCreationCheckpoint(runtimeCtx);
58869
59274
  const runtimeArgs = remapRuntimeArguments(args, runtimeCtx);
58870
59275
  let value;
58871
59276
  try {
@@ -58886,8 +59291,8 @@ function evaluateNSFunction(action, ctx, args) {
58886
59291
  throw error;
58887
59292
  }
58888
59293
  const createdSessionValues = createdSessionValuesSince(
58889
- runtimeCtx.__runtimeSessionValues,
58890
- existingIds
59294
+ runtimeCtx,
59295
+ creationCheckpoint
58891
59296
  );
58892
59297
  return createdSessionValues.length === 0 ? { value, writes } : { value, writes, createdSessionValues };
58893
59298
  }
@@ -58912,6 +59317,7 @@ function withEvaluationRuntime(ctx, writes) {
58912
59317
  }
58913
59318
  const overlay = ctx.__valueOverlay ?? (ctx.storedConstructionReplay === true ? /* @__PURE__ */ new Map() : buildValueOverlay(ctx.vm));
58914
59319
  const referenceRemap = ctx.__runtimeReferenceRemap ?? /* @__PURE__ */ new Map();
59320
+ const runtimeSessionValues = ctx.__runtimeSessionValues ?? /* @__PURE__ */ new Map();
58915
59321
  const runtimeReferences = runtimeSessionValueReferences(
58916
59322
  ctx.__runtimeSessionValues
58917
59323
  );
@@ -58930,7 +59336,7 @@ function withEvaluationRuntime(ctx, writes) {
58930
59336
  primary: remap(ctx.dialogueContext.primary),
58931
59337
  trigger: remap(ctx.dialogueContext.trigger)
58932
59338
  },
58933
- __runtimeSessionValues: ctx.__runtimeSessionValues ?? /* @__PURE__ */ new Map(),
59339
+ __runtimeSessionValues: runtimeSessionValues,
58934
59340
  __saveStaticBindings: ctx.__saveStaticBindings ?? staticBindingMap(ctx.saveStaticBindings),
58935
59341
  __sessionStaticBindings: ctx.__sessionStaticBindings ?? staticBindingMap(ctx.sessionStaticBindings),
58936
59342
  __valueOverlay: overlay,
@@ -58939,7 +59345,12 @@ function withEvaluationRuntime(ctx, writes) {
58939
59345
  writes,
58940
59346
  functionStack: [],
58941
59347
  delegateStack: [],
59348
+ knownSessionValueIds: new Set(runtimeSessionValues.keys()),
59349
+ sessionCreationJournal: [],
58942
59350
  constructorGroups: /* @__PURE__ */ new Map(),
59351
+ constructorGroupByRowId: /* @__PURE__ */ new Map(),
59352
+ constructorGroupDependencies: /* @__PURE__ */ new Map(),
59353
+ constructionTimestamp: Date.now(),
58943
59354
  ownedValueAttachments: /* @__PURE__ */ new Map(),
58944
59355
  constructionStack: [],
58945
59356
  loopIterations: 0,
@@ -59098,10 +59509,22 @@ function finalizeConstructorAllocations(ctx, returnValue, ownsInvocationState, r
59098
59509
  }
59099
59510
  const escapedRoots = /* @__PURE__ */ new Set();
59100
59511
  const scannedRows = /* @__PURE__ */ new Set();
59512
+ const markConstructorGroupEscaped = (rootId) => {
59513
+ if (escapedRoots.has(rootId)) return;
59514
+ escapedRoots.add(rootId);
59515
+ for (const dependencyRootId of state.constructorGroupDependencies.get(
59516
+ rootId
59517
+ ) ?? []) {
59518
+ markConstructorGroupEscaped(dependencyRootId);
59519
+ }
59520
+ };
59101
59521
  const isOwnedRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
59102
59522
  const scanOwnedRow = (valueId, hintedMember) => {
59103
59523
  const groupRoot = groupByRowId.get(valueId);
59104
- if (groupRoot !== void 0) escapedRoots.add(groupRoot);
59524
+ if (groupRoot !== void 0) {
59525
+ markConstructorGroupEscaped(groupRoot);
59526
+ return;
59527
+ }
59105
59528
  if (scannedRows.has(valueId)) return;
59106
59529
  scannedRows.add(valueId);
59107
59530
  const row = evalValueById(
@@ -59213,7 +59636,10 @@ function finalizeConstructorAllocations(ctx, returnValue, ownsInvocationState, r
59213
59636
  const scanReturnedValue = (value, typeInfo) => {
59214
59637
  if (typeof value === "object" && value !== null) {
59215
59638
  const direct = groupByValueReference.get(value);
59216
- if (direct !== void 0) escapedRoots.add(direct);
59639
+ if (direct !== void 0) {
59640
+ markConstructorGroupEscaped(direct);
59641
+ return;
59642
+ }
59217
59643
  const tracked = trackedRowForValueReference(value, ctx);
59218
59644
  if (tracked !== null) {
59219
59645
  scanOwnedRow(tracked.id);
@@ -59261,7 +59687,7 @@ function finalizeConstructorAllocations(ctx, returnValue, ownsInvocationState, r
59261
59687
  if (typeof row?.value === "object" && row.value !== null) {
59262
59688
  collectedReferences.add(row.value);
59263
59689
  }
59264
- session.delete(rowId);
59690
+ deleteRuntimeSessionValue(ctx, rowId);
59265
59691
  collectedIds.add(rowId);
59266
59692
  }
59267
59693
  }
@@ -59285,6 +59711,8 @@ function finalizeConstructorAllocations(ctx, returnValue, ownsInvocationState, r
59285
59711
  invalidateEvaluatorIndexes(ctx);
59286
59712
  }
59287
59713
  state.constructorGroups.clear();
59714
+ state.constructorGroupByRowId.clear();
59715
+ state.constructorGroupDependencies.clear();
59288
59716
  }
59289
59717
  function buildValueOverlay(vm) {
59290
59718
  return new LazyValueOverlay(vm);
@@ -60149,9 +60577,11 @@ function applyOverlayStaticAssignment(memberId, value, ctx) {
60149
60577
  "Static assignment requires an evaluator Session row registry."
60150
60578
  );
60151
60579
  }
60580
+ if (ctx.__indexes !== void 0) {
60581
+ indexEvaluatorRows(ctx.__indexes, createdValues);
60582
+ }
60152
60583
  for (const created of createdValues) {
60153
- destination.set(created.id, created);
60154
- if (ctx.__indexes !== void 0) indexEvaluatorRow(ctx.__indexes, created);
60584
+ registerRuntimeSessionValue(ctx, created);
60155
60585
  }
60156
60586
  bindings.set(member.id, row.id);
60157
60587
  invalidateEvaluatorIndexes(ctx);
@@ -62940,11 +63370,17 @@ function validateClassConstructorDescriptor(info, ctx, requireEveryRequiredField
62940
63370
  }
62941
63371
  const genericSlot = ctx.__constructionGenericSlots?.toReversed().find((slot) => slot.classId === classId) ?? ctx.__storedConstructionReplaySlot;
62942
63372
  const classArguments2 = genericSlot?.classId === classId ? genericSlot.classArguments : void 0;
62943
- const instanceEnv = resolveInstanceEnv(
62944
- classId,
62945
- classArguments2,
62946
- ctx.vm.classes
62947
- );
63373
+ const descriptorCache = evaluatorResolutionCache(ctx).validatedConstructorDescriptorByInfo;
63374
+ const descriptorCacheKey = `${requireEveryRequiredField}:${ctx.storedConstructionReplay === true}:${JSON.stringify(classArguments2 ?? null)}`;
63375
+ const cachedDescriptor = descriptorCache.get(info)?.get(descriptorCacheKey);
63376
+ if (cachedDescriptor !== void 0) return cachedDescriptor;
63377
+ const cacheDescriptor = (descriptor) => {
63378
+ const variants = descriptorCache.get(info) ?? /* @__PURE__ */ new Map();
63379
+ variants.set(descriptorCacheKey, descriptor);
63380
+ descriptorCache.set(info, variants);
63381
+ return descriptor;
63382
+ };
63383
+ const instanceEnv = cachedInstanceEnv(classId, classArguments2, ctx);
62948
63384
  if (firstUnboundParamId(instanceEnv) !== null) {
62949
63385
  throw new NSGetterRuntimeError(
62950
63386
  `Cannot construct open generic Class '${schemaClass2.name}'.`
@@ -62957,11 +63393,7 @@ function validateClassConstructorDescriptor(info, ctx, requireEveryRequiredField
62957
63393
  }
62958
63394
  let mergedSchema;
62959
63395
  try {
62960
- mergedSchema = mergeStoredInstanceSchema(
62961
- classId,
62962
- ctx.vm.classes,
62963
- ctx.vm.members
62964
- );
63396
+ mergedSchema = [...cachedStoredInstanceSchema(classId, ctx)];
62965
63397
  } catch (error) {
62966
63398
  throw new NSGetterRuntimeError(
62967
63399
  `Cannot validate constructor for '${schemaClass2.name}': ${error instanceof Error ? error.message : String(error)}`
@@ -63020,7 +63452,12 @@ function validateClassConstructorDescriptor(info, ctx, requireEveryRequiredField
63020
63452
  );
63021
63453
  }
63022
63454
  if (!requireEveryRequiredField) {
63023
- return { schemaClass: schemaClass2, fields, instanceEnv, classArguments: classArguments2 };
63455
+ return cacheDescriptor({
63456
+ schemaClass: schemaClass2,
63457
+ fields,
63458
+ instanceEnv,
63459
+ classArguments: classArguments2
63460
+ });
63024
63461
  }
63025
63462
  for (const entry of mergedSchema) {
63026
63463
  const rawMember = evalMemberById(ctx.vm, entry.memberId);
@@ -63032,7 +63469,8 @@ function validateClassConstructorDescriptor(info, ctx, requireEveryRequiredField
63032
63469
  const member = substituteMember(
63033
63470
  rawMember,
63034
63471
  instanceEnv,
63035
- ctx.vm.members
63472
+ ctx.vm.members,
63473
+ cachedResolvedMember(rawMember, ctx)
63036
63474
  );
63037
63475
  if (member.isStatic || !memberKindSupportsStorage(member.kind) || member.kind === 21 /* Generic */) {
63038
63476
  continue;
@@ -63043,7 +63481,7 @@ function validateClassConstructorDescriptor(info, ctx, requireEveryRequiredField
63043
63481
  );
63044
63482
  }
63045
63483
  }
63046
- return { schemaClass: schemaClass2, fields, instanceEnv, classArguments: classArguments2 };
63484
+ return cacheDescriptor({ schemaClass: schemaClass2, fields, instanceEnv, classArguments: classArguments2 });
63047
63485
  }
63048
63486
  function assertConstructorFieldSlotWritable(args) {
63049
63487
  const surfaceEntry = mergeInstanceSchema(
@@ -63070,7 +63508,8 @@ function validateConstructorFieldSlot(args) {
63070
63508
  const member = substituteMember(
63071
63509
  rawMember,
63072
63510
  args.instanceEnv,
63073
- ctx.vm.members
63511
+ ctx.vm.members,
63512
+ cachedResolvedMember(rawMember, ctx)
63074
63513
  );
63075
63514
  if (member.isStatic || !memberKindSupportsStorage(member.kind) || member.kind === 21 /* Generic */) {
63076
63515
  throw new NSGetterRuntimeError(
@@ -63112,7 +63551,7 @@ function constructionGenericSlotsForMember(rawMember, ctx, instanceEnv, visitedM
63112
63551
  const entryMember = evalMemberById(ctx.vm, member.entryMemberId);
63113
63552
  if (entryMember === null) return [];
63114
63553
  return constructionGenericSlotsForMember(
63115
- resolveMember2(entryMember, ctx.vm.members),
63554
+ cachedResolvedMember(entryMember, ctx),
63116
63555
  ctx,
63117
63556
  instanceEnv,
63118
63557
  nextVisited
@@ -63130,6 +63569,9 @@ function withConstructionGenericSlots(member, ctx, instanceEnv, evaluate) {
63130
63569
  }
63131
63570
  }
63132
63571
  function evaluateConstructorFields(descriptor, scope, ctx) {
63572
+ if (descriptor.fields.length === 0) {
63573
+ return EMPTY_SUPPLIED_CONSTRUCTOR_FIELDS;
63574
+ }
63133
63575
  const schemaClass2 = descriptor.schemaClass;
63134
63576
  const evaluatedValues = descriptor.fields.map((validated) => {
63135
63577
  if (validated.valuePointer === null) {
@@ -63170,16 +63612,17 @@ function evaluateConstructorFields(descriptor, scope, ctx) {
63170
63612
  });
63171
63613
  }
63172
63614
  function syntheticConstructorMember(schemaClass2, classArguments2) {
63173
- return {
63615
+ const member = {
63174
63616
  name: `new ${schemaClass2.name}`,
63175
63617
  kind: 7 /* Class */,
63176
63618
  classId: schemaClass2.id,
63177
- ...classArguments2 === void 0 ? {} : { classArguments: classArguments2 },
63178
63619
  locked: false,
63179
63620
  required: true,
63180
63621
  isStatic: false,
63181
63622
  accessModifierKind: "public"
63182
63623
  };
63624
+ if (classArguments2 !== void 0) member.classArguments = classArguments2;
63625
+ return member;
63183
63626
  }
63184
63627
  function stampConstructedRootGenericBindings(root, descriptor) {
63185
63628
  const stamp = {};
@@ -63316,37 +63759,19 @@ function stageConstructedRows(createdValues, ctx) {
63316
63759
  );
63317
63760
  }
63318
63761
  for (const row of createdValues) {
63319
- destination.set(row.id, row);
63320
- if (ctx.__indexes !== void 0) indexEvaluatorRow(ctx.__indexes, row);
63762
+ registerRuntimeSessionValue(ctx, row);
63763
+ }
63764
+ if (ctx.__indexes !== void 0) {
63765
+ indexEvaluatorRows(ctx.__indexes, createdValues);
63321
63766
  }
63322
63767
  }
63323
- function bindConstructedDelegateTargets(rootId, ctx) {
63324
- const indexes = evaluatorIndexes(ctx);
63325
- const pending = [rootId];
63326
- const visited = /* @__PURE__ */ new Set();
63327
- while (pending.length > 0) {
63328
- const rowId = pending.pop();
63329
- if (rowId === void 0 || visited.has(rowId)) continue;
63330
- visited.add(rowId);
63331
- const row = evalValueById(
63332
- ctx,
63333
- rowId,
63334
- ctx.__runtimeSessionValues,
63335
- ctx.__valueOverlay
63336
- );
63337
- if (row === null) continue;
63338
- if (Array.isArray(row.value)) {
63339
- for (const childId of row.value) {
63340
- if (typeof childId === "string") pending.push(childId);
63341
- }
63342
- } else if (typeof row.value === "object" && row.value !== null) {
63343
- for (const childId of Object.values(row.value)) {
63344
- if (typeof childId === "string") pending.push(childId);
63345
- }
63346
- }
63768
+ function bindConstructedDelegateTargets(createdValues, ctx) {
63769
+ let indexes;
63770
+ for (const row of createdValues) {
63347
63771
  if (!isMemberDelegateTarget(row.value) || row.value.valueId !== null) {
63348
63772
  continue;
63349
63773
  }
63774
+ indexes ??= evaluatorIndexes(ctx);
63350
63775
  const target = evalMemberById(ctx.vm, row.value.memberId);
63351
63776
  if (target === null || target.isStatic === true) continue;
63352
63777
  const placement = findSchemaPlacement(target.id, ctx.vm.classes);
@@ -63391,8 +63816,10 @@ function bindConstructedDelegateTargets(rootId, ctx) {
63391
63816
  function publishConstructedRows(args) {
63392
63817
  const { root, createdValues, ctx } = args;
63393
63818
  assertConstructorRowsHaveSingleStructuralOwner(createdValues, ctx);
63394
- const beforeRetain = new Set(createdValues.map((row) => row.id));
63395
- retainOnlyCreatedRowsReachableFrom(root.id, createdValues, ctx);
63819
+ const beforeRetain = args.mayHaveOrphanedRows === false ? null : new Set(createdValues.map((row) => row.id));
63820
+ if (beforeRetain !== null) {
63821
+ retainOnlyCreatedRowsReachableFrom(root.id, createdValues, ctx);
63822
+ }
63396
63823
  stampCreatedValuesMapKey(createdValues, null);
63397
63824
  applyDeclaredStorageKeyOverrides({
63398
63825
  createdValues,
@@ -63441,29 +63868,84 @@ function publishConstructedRows(args) {
63441
63868
  "produced collection entry"
63442
63869
  );
63443
63870
  const retained = retainedIds;
63444
- for (const rowId of beforeRetain) {
63445
- if (retained.has(rowId)) continue;
63446
- destination.delete(rowId);
63871
+ if (beforeRetain !== null) {
63872
+ for (const rowId of beforeRetain) {
63873
+ if (retained.has(rowId)) continue;
63874
+ deleteRuntimeSessionValue(ctx, rowId);
63875
+ }
63447
63876
  }
63448
63877
  for (const row of createdValues) {
63449
- destination.set(row.id, row);
63450
- if (ctx.__indexes !== void 0) indexEvaluatorRow(ctx.__indexes, row);
63878
+ registerRuntimeSessionValue(ctx, row);
63879
+ }
63880
+ if (ctx.__indexes !== void 0) {
63881
+ indexEvaluatorRows(ctx.__indexes, createdValues);
63882
+ }
63883
+ bindConstructedDelegateTargets(createdValues, ctx);
63884
+ let rootDependencies = state.constructorGroupDependencies.get(root.id);
63885
+ for (const rowId of retained) {
63886
+ if (rowId === root.id) continue;
63887
+ const nestedDependencies = state.constructorGroupDependencies.get(rowId);
63888
+ if (nestedDependencies === void 0) continue;
63889
+ rootDependencies ??= /* @__PURE__ */ new Set();
63890
+ for (const dependencyRootId of nestedDependencies) {
63891
+ if (dependencyRootId !== root.id) {
63892
+ rootDependencies.add(dependencyRootId);
63893
+ }
63894
+ }
63895
+ state.constructorGroupDependencies.delete(rowId);
63896
+ }
63897
+ if (rootDependencies !== void 0) {
63898
+ state.constructorGroupDependencies.set(root.id, rootDependencies);
63451
63899
  }
63452
- bindConstructedDelegateTargets(root.id, ctx);
63453
63900
  state.constructorGroups.set(root.id, retained);
63901
+ for (const rowId of retained) {
63902
+ state.constructorGroupByRowId.set(rowId, root.id);
63903
+ }
63904
+ if (ctx.__indexes !== void 0) {
63905
+ for (const rowId of retained) {
63906
+ ctx.__indexes.constructorOwnershipDirtyValueIds.delete(rowId);
63907
+ }
63908
+ }
63454
63909
  state.ownedValueAttachments.clear();
63455
63910
  }
63456
63911
  function assertConstructorRowsHaveSingleStructuralOwner(createdValues, ctx) {
63457
- const candidateIds = new Set(createdValues.map((row) => row.id));
63458
- for (const rowIds of ctx.__executionState?.constructorGroups.values() ?? []) {
63459
- for (const rowId of rowIds) candidateIds.add(rowId);
63912
+ let indexes = ctx.__indexes;
63913
+ const candidateIds = /* @__PURE__ */ new Set();
63914
+ if (ctx.__constructorOwnershipStrategy === "cumulative") {
63915
+ indexes ??= evaluatorIndexes(ctx);
63916
+ for (const row of createdValues) candidateIds.add(row.id);
63917
+ for (const rowIds of ctx.__executionState?.constructorGroups.values() ?? []) {
63918
+ for (const rowId of rowIds) candidateIds.add(rowId);
63919
+ }
63920
+ } else if (indexes !== void 0) {
63921
+ const state = ctx.__executionState;
63922
+ for (const rowId of indexes.constructorOwnershipDirtyValueIds) {
63923
+ if (ctx.__constructorPerformanceMetrics !== void 0) {
63924
+ ctx.__constructorPerformanceMetrics.ownershipDirtyRowsVisited += 1;
63925
+ }
63926
+ const rootId = state?.constructorGroupByRowId.get(rowId);
63927
+ if (rootId !== void 0 && state?.constructorGroups.has(rootId)) {
63928
+ candidateIds.add(rowId);
63929
+ } else {
63930
+ indexes.constructorOwnershipDirtyValueIds.delete(rowId);
63931
+ }
63932
+ }
63933
+ }
63934
+ if (candidateIds.size === 0) return;
63935
+ indexes ??= evaluatorIndexes(ctx);
63936
+ if (ctx.__constructorPerformanceMetrics !== void 0) {
63937
+ ctx.__constructorPerformanceMetrics.ownershipCandidateRowsValidated += candidateIds.size;
63460
63938
  }
63461
63939
  for (const valueId of candidateIds) {
63462
63940
  const owners = currentOwnedValueAttachments(valueId, ctx);
63463
- if (owners.length <= 1) continue;
63464
- throw new NSGetterRuntimeError(
63465
- `Constructed value '${valueId}' has multiple structural parents (${owners.map((owner) => owner.label).join(", ")}). Reuse its row in one field or call Clone() explicitly.`
63466
- );
63941
+ if (owners.length > 1) {
63942
+ throw new NSGetterRuntimeError(
63943
+ `Constructed value '${valueId}' has multiple structural parents (${owners.map((owner) => owner.label).join(
63944
+ ", "
63945
+ )}). Reuse its row in one field or call Clone() explicitly.`
63946
+ );
63947
+ }
63948
+ indexes.constructorOwnershipDirtyValueIds.delete(valueId);
63467
63949
  }
63468
63950
  }
63469
63951
  function assertImplicitConstructionAllowed(schemaClass2) {
@@ -63508,6 +63990,20 @@ function constructClassValueWithinFrame(descriptor, scope, ctx) {
63508
63990
  values: ctx.vm.values,
63509
63991
  memberById: ctx.vm.databaseVM?.memberById,
63510
63992
  valueById: ctx.vm.databaseVM?.valueById,
63993
+ resolvedMember: (member) => member === syntheticMember ? syntheticMember : cachedResolvedMember(member, ctx),
63994
+ storedInstanceSchema: (nestedClassId) => cachedStoredInstanceSchema(nestedClassId, ctx),
63995
+ storedInstanceMaterializationPlan: (nestedClassId, instanceEnv) => cachedStoredInstanceMaterializationPlan(
63996
+ nestedClassId,
63997
+ instanceEnv,
63998
+ ctx
63999
+ ),
64000
+ instanceEnv: (nestedClassId, classArguments2) => cachedInstanceEnv(nestedClassId, classArguments2, ctx),
64001
+ isInitValueContent: (value) => cachedIsInitValueContent(value, ctx),
64002
+ createValueRow: (projectId, body) => buildNewValue(
64003
+ projectId,
64004
+ body,
64005
+ ctx.__executionState?.constructionTimestamp
64006
+ ),
63511
64007
  projectFiles: ctx.vm.projectFiles ?? [],
63512
64008
  textureTemplates: ctx.vm.textureTemplates ?? []
63513
64009
  },
@@ -63543,19 +64039,21 @@ function constructClassValueWithinFrame(descriptor, scope, ctx) {
63543
64039
  );
63544
64040
  }
63545
64041
  const rootRecord = root.value;
63546
- applyConstructorFields({
63547
- supplied,
63548
- root,
63549
- rootRecord,
63550
- schemaClass: schemaClass2,
63551
- instanceEnv: descriptor.instanceEnv,
63552
- createdValues,
63553
- createdById: new Map(createdValues.map((row) => [row.id, row])),
63554
- storageKeyDeclarations,
63555
- // Generated C# factories pass null for an omitted optional parameter.
63556
- nullMeansOmit: true,
63557
- ctx
63558
- });
64042
+ if (supplied.length > 0) {
64043
+ applyConstructorFields({
64044
+ supplied,
64045
+ root,
64046
+ rootRecord,
64047
+ schemaClass: schemaClass2,
64048
+ instanceEnv: descriptor.instanceEnv,
64049
+ createdValues,
64050
+ createdById: new Map(createdValues.map((row) => [row.id, row])),
64051
+ storageKeyDeclarations,
64052
+ // Generated C# factories pass null for an omitted optional parameter.
64053
+ nullMeansOmit: true,
64054
+ ctx
64055
+ });
64056
+ }
63559
64057
  } catch (error) {
63560
64058
  if (error instanceof NSGetterRuntimeError) throw error;
63561
64059
  throw new NSGetterRuntimeError(
@@ -63567,6 +64065,7 @@ function constructClassValueWithinFrame(descriptor, scope, ctx) {
63567
64065
  classId,
63568
64066
  createdValues,
63569
64067
  storageKeyDeclarations,
64068
+ mayHaveOrphanedRows: supplied.some((entry) => entry.value !== null),
63570
64069
  ctx
63571
64070
  });
63572
64071
  return root.value;
@@ -64095,9 +64594,12 @@ function evaluateInitializerInContext(init, member, ctx, createdValues, argument
64095
64594
  const closeFrame = pushConstructionFrame(ctx, `${member.name} initializer`);
64096
64595
  let result;
64097
64596
  try {
64597
+ const initializerCtx = ctx.thisValue === null ? ctx : Object.assign({}, ctx, {
64598
+ thisValue: null
64599
+ });
64098
64600
  result = evaluateNSGetterWithEffects(
64099
64601
  compiled,
64100
- { ...ctx, thisValue: null },
64602
+ initializerCtx,
64101
64603
  argumentValues
64102
64604
  );
64103
64605
  } finally {
@@ -64125,9 +64627,8 @@ function evaluateInitializerInContext(init, member, ctx, createdValues, argument
64125
64627
  }
64126
64628
  return { value: result.value, classId: existingRuntimeClassId };
64127
64629
  }
64128
- ctx.__runtimeSessionValues?.delete(rootRow.id);
64630
+ deleteRuntimeSessionValue(ctx, rootRow.id);
64129
64631
  ctx.__executionState?.constructorGroups.delete(rootRow.id);
64130
- invalidateEvaluatorIndexes(ctx);
64131
64632
  const constructorArgs = typeof result.value === "object" && result.value !== null ? ctx.__constructedArgumentsByValue.get(result.value) : void 0;
64132
64633
  return {
64133
64634
  value: result.value,
@@ -64146,10 +64647,9 @@ function encodeLookupInitializerResult(member, value, created, ctx) {
64146
64647
  );
64147
64648
  if (created.length > 0) {
64148
64649
  for (const row of created) {
64149
- ctx.__runtimeSessionValues?.delete(row.id);
64650
+ deleteRuntimeSessionValue(ctx, row.id);
64150
64651
  ctx.__executionState?.constructorGroups.delete(row.id);
64151
64652
  }
64152
- invalidateEvaluatorIndexes(ctx);
64153
64653
  }
64154
64654
  return { value: selection, classId: null };
64155
64655
  }
@@ -64205,10 +64705,25 @@ function initializerRootRow(value, created) {
64205
64705
  return created.find((row) => row.value === value) ?? null;
64206
64706
  }
64207
64707
  function constructorGroupForRow(valueId, ctx) {
64208
- for (const [rootId, rowIds] of ctx.__executionState?.constructorGroups ?? []) {
64209
- if (rowIds.has(valueId)) return rootId;
64210
- }
64211
- return null;
64708
+ const state = ctx.__executionState;
64709
+ if (state === void 0) return null;
64710
+ const rootId = state.constructorGroupByRowId.get(valueId);
64711
+ return rootId !== void 0 && state.constructorGroups.has(rootId) ? rootId : null;
64712
+ }
64713
+ function recordConstructorGroupDependency(valueId, destination, ctx) {
64714
+ if (!destination.identity.startsWith("value:")) return;
64715
+ const state = ctx.__executionState;
64716
+ if (state === void 0) return;
64717
+ const dependencyRootId = constructorGroupForRow(valueId, ctx);
64718
+ if (dependencyRootId === null) return;
64719
+ const ownerRootId = constructorGroupForRow(destination.label, ctx) ?? destination.label;
64720
+ if (ownerRootId === dependencyRootId) return;
64721
+ let dependencies = state.constructorGroupDependencies.get(ownerRootId);
64722
+ if (dependencies === void 0) {
64723
+ dependencies = /* @__PURE__ */ new Set();
64724
+ state.constructorGroupDependencies.set(ownerRootId, dependencies);
64725
+ }
64726
+ dependencies.add(dependencyRootId);
64212
64727
  }
64213
64728
  function encodeRequiredConstructorArgument(args) {
64214
64729
  const trackedId = findKnownRowIdByValueReference(args.value, args.ctx);
@@ -64342,6 +64857,10 @@ function constructDeclaredClassValueWithinFrame(descriptor, record3, info, scope
64342
64857
  );
64343
64858
  const createdValues = [];
64344
64859
  const storageKeyDeclarations = /* @__PURE__ */ new Map();
64860
+ const syntheticMember = syntheticConstructorMember(
64861
+ schemaClass2,
64862
+ descriptor.classArguments
64863
+ );
64345
64864
  let root;
64346
64865
  try {
64347
64866
  root = buildDefaultMemberValue({
@@ -64353,14 +64872,25 @@ function constructDeclaredClassValueWithinFrame(descriptor, record3, info, scope
64353
64872
  values: ctx.vm.values,
64354
64873
  memberById: ctx.vm.databaseVM?.memberById,
64355
64874
  valueById: ctx.vm.databaseVM?.valueById,
64875
+ resolvedMember: (member) => member === syntheticMember ? syntheticMember : cachedResolvedMember(member, ctx),
64876
+ storedInstanceSchema: (nestedClassId) => cachedStoredInstanceSchema(nestedClassId, ctx),
64877
+ storedInstanceMaterializationPlan: (nestedClassId, instanceEnv) => cachedStoredInstanceMaterializationPlan(
64878
+ nestedClassId,
64879
+ instanceEnv,
64880
+ ctx
64881
+ ),
64882
+ instanceEnv: (nestedClassId, classArguments2) => cachedInstanceEnv(nestedClassId, classArguments2, ctx),
64883
+ isInitValueContent: (value) => cachedIsInitValueContent(value, ctx),
64884
+ createValueRow: (projectId, body) => buildNewValue(
64885
+ projectId,
64886
+ body,
64887
+ ctx.__executionState?.constructionTimestamp
64888
+ ),
64356
64889
  projectFiles: ctx.vm.projectFiles ?? [],
64357
64890
  textureTemplates: ctx.vm.textureTemplates ?? []
64358
64891
  },
64359
64892
  projectId: ctx.vm.project.id,
64360
- member: syntheticConstructorMember(
64361
- schemaClass2,
64362
- descriptor.classArguments
64363
- ),
64893
+ member: syntheticMember,
64364
64894
  topLevelClassId: classId,
64365
64895
  createdValues,
64366
64896
  storageKeyDeclarations,
@@ -64427,7 +64957,7 @@ function constructDeclaredClassValueWithinFrame(descriptor, record3, info, scope
64427
64957
  root.constructorArgs = structuredClone(encoded);
64428
64958
  }
64429
64959
  stageConstructedRows(createdValues, ctx);
64430
- bindConstructedDelegateTargets(root.id, ctx);
64960
+ bindConstructedDelegateTargets(createdValues, ctx);
64431
64961
  if (record3 !== null) {
64432
64962
  runDeclaredConstructorChain({
64433
64963
  record: record3,
@@ -64465,20 +64995,22 @@ function constructDeclaredClassValueWithinFrame(descriptor, record3, info, scope
64465
64995
  }
64466
64996
  const supplied = evaluateConstructorFields(descriptor, scope, ctx);
64467
64997
  try {
64468
- applyConstructorFields({
64469
- supplied,
64470
- root,
64471
- rootRecord,
64472
- schemaClass: schemaClass2,
64473
- instanceEnv: descriptor.instanceEnv,
64474
- createdValues,
64475
- createdById: new Map(createdValues.map((row) => [row.id, row])),
64476
- storageKeyDeclarations,
64477
- // §6.1 step 4: these are initializer-block assignments, so an explicit
64478
- // null clears the slot rather than omitting the field.
64479
- nullMeansOmit: false,
64480
- ctx
64481
- });
64998
+ if (supplied.length > 0) {
64999
+ applyConstructorFields({
65000
+ supplied,
65001
+ root,
65002
+ rootRecord,
65003
+ schemaClass: schemaClass2,
65004
+ instanceEnv: descriptor.instanceEnv,
65005
+ createdValues,
65006
+ createdById: new Map(createdValues.map((row) => [row.id, row])),
65007
+ storageKeyDeclarations,
65008
+ // §6.1 step 4: these are initializer-block assignments, so an explicit
65009
+ // null clears the slot rather than omitting the field.
65010
+ nullMeansOmit: false,
65011
+ ctx
65012
+ });
65013
+ }
64482
65014
  } catch (error) {
64483
65015
  if (error instanceof NSGetterRuntimeError) throw error;
64484
65016
  throw new NSGetterRuntimeError(
@@ -64490,6 +65022,7 @@ function constructDeclaredClassValueWithinFrame(descriptor, record3, info, scope
64490
65022
  classId,
64491
65023
  createdValues,
64492
65024
  storageKeyDeclarations,
65025
+ mayHaveOrphanedRows: record3 !== null || supplied.length > 0,
64493
65026
  ctx
64494
65027
  });
64495
65028
  return root.value;
@@ -64523,6 +65056,7 @@ function assertOwnedValueAttachable(valueId, destination, destinationName2, ctx,
64523
65056
  );
64524
65057
  if (constructorArgumentReservation && (destination.label === reserved.label || destinationConstructorGroup === reserved.label)) {
64525
65058
  ctx.__executionState?.ownedValueAttachments.set(valueId, destination);
65059
+ recordConstructorGroupDependency(valueId, destination, ctx);
64526
65060
  return;
64527
65061
  }
64528
65062
  throw new NSGetterRuntimeError(
@@ -64532,11 +65066,15 @@ function assertOwnedValueAttachable(valueId, destination, destinationName2, ctx,
64532
65066
  if (reserveUntilPublished) {
64533
65067
  ctx.__executionState?.ownedValueAttachments.set(valueId, destination);
64534
65068
  }
65069
+ recordConstructorGroupDependency(valueId, destination, ctx);
64535
65070
  }
64536
65071
  function currentOwnedValueAttachments(valueId, ctx) {
64537
65072
  const indexes = evaluatorIndexes(ctx);
64538
65073
  const cached = indexes.ownedValueAttachmentsByValueId.get(valueId);
64539
65074
  if (cached !== void 0) return [...cached];
65075
+ if (ctx.__constructorPerformanceMetrics !== void 0) {
65076
+ ctx.__constructorPerformanceMetrics.ownershipAttachmentCacheMisses += 1;
65077
+ }
64540
65078
  const found = /* @__PURE__ */ new Map();
64541
65079
  const add = (attachment) => {
64542
65080
  found.set(attachment.identity, attachment);
@@ -65156,11 +65694,11 @@ function cloneClassValueGraph(receiver, expectedClassId, ctx) {
65156
65694
  `Class.Clone source value '${sourceId3}' has runtime Class '${runtimeClassId}', which is not assignable to '${expectedClassId}'.`
65157
65695
  );
65158
65696
  }
65159
- const destination = ctx.__runtimeSessionValues ?? (() => {
65697
+ if (ctx.__runtimeSessionValues === void 0) {
65160
65698
  throw new NSGetterRuntimeError(
65161
65699
  "Class.Clone requires an evaluator Session value registry."
65162
65700
  );
65163
- })();
65701
+ }
65164
65702
  const active = /* @__PURE__ */ new Set();
65165
65703
  const clonedBySourceId = /* @__PURE__ */ new Map();
65166
65704
  const constructorArgumentReferenceCounts = /* @__PURE__ */ new Map();
@@ -65190,7 +65728,7 @@ function cloneClassValueGraph(receiver, expectedClassId, ctx) {
65190
65728
  // parent explicitly supplies its fresh id.
65191
65729
  containerId: clonedContainerId ?? null
65192
65730
  };
65193
- destination.set(id2, clone);
65731
+ registerRuntimeSessionValue(ctx, clone);
65194
65732
  clonedBySourceId.set(sourceRow.id, clone);
65195
65733
  if (typeof sourceRow.value === "object" && sourceRow.value !== null && !Array.isArray(sourceRow.value)) {
65196
65734
  const sourceRecord = sourceRow.value;
@@ -65459,7 +65997,7 @@ function iterateCollection(c, ctx, callback) {
65459
65997
  return callback(entry, key, valueId);
65460
65998
  });
65461
65999
  }
65462
- var DELEGATE_LEXICAL_THIS, DELEGATE_LEXICAL_ROOT, NonCatchableNSGetterRuntimeError, NativeFunctionDelegateUnavailableError, CorruptNeoScriptIRError, NeoScriptResourceLimitError, NeoScriptWallClockTimeoutError, DEFAULT_NEO_SCRIPT_EXECUTION_BUDGET_LIMITS, liveListIndexesByProject, evaluatorOwnershipCachesByBase, MAX_CONSTRUCTION_DEPTH, MAX_LOOP_ITERATIONS, resolutionCacheByMembers, NO_SCHEMA_REVISION, LazyValueOverlay, READONLY_FOREACH_BINDING_ERROR, READONLY_CATCH_BINDING_ERROR;
66000
+ var DELEGATE_LEXICAL_THIS, DELEGATE_LEXICAL_ROOT, NonCatchableNSGetterRuntimeError, NativeFunctionDelegateUnavailableError, CorruptNeoScriptIRError, NeoScriptResourceLimitError, NeoScriptWallClockTimeoutError, DEFAULT_NEO_SCRIPT_EXECUTION_BUDGET_LIMITS, liveListIndexesByProject, evaluatorOwnershipCachesByBase, MAX_CONSTRUCTION_DEPTH, MAX_LOOP_ITERATIONS, resolutionCacheByMembers, NO_SCHEMA_REVISION, LazyValueOverlay, READONLY_FOREACH_BINDING_ERROR, READONLY_CATCH_BINDING_ERROR, EMPTY_SUPPLIED_CONSTRUCTOR_FIELDS;
65463
66001
  var init_evaluateNSGetter = __esm({
65464
66002
  "../src/view-models/neoscript-evaluator/evaluateNSGetter.ts"() {
65465
66003
  "use strict";
@@ -65603,6 +66141,7 @@ var init_evaluateNSGetter = __esm({
65603
66141
  };
65604
66142
  READONLY_FOREACH_BINDING_ERROR = "Cannot assign to a read-only foreach iterator binding.";
65605
66143
  READONLY_CATCH_BINDING_ERROR = "Cannot assign to a read-only catch message binding.";
66144
+ EMPTY_SUPPLIED_CONSTRUCTOR_FIELDS = [];
65606
66145
  }
65607
66146
  });
65608
66147
 
@@ -87437,10 +87976,28 @@ function emitMemberDefaultSourcesV4(records2, manifest) {
87437
87976
  continue;
87438
87977
  }
87439
87978
  const member = record3.data;
87979
+ const manifestMember = context.manifestMembers.get(record3.recordId);
87980
+ const defaultValue = isObjectRecord2(member.defaultValue) ? member.defaultValue : {};
87981
+ const linkedLocalizedTextId = defaultValue.value;
87982
+ if (manifestMember?.kind === "string" && manifestMember.localizable && typeof linkedLocalizedTextId === "string" && context.localizedTexts.has(linkedLocalizedTextId)) {
87983
+ const localizedText = context.localizedTexts.get(linkedLocalizedTextId);
87984
+ const localeValues = isObjectRecord2(localizedText?.localeValues) ? localizedText.localeValues : {};
87985
+ const mainLocale = localeValues[context.mainLocale];
87986
+ const mainLocaleValue = isObjectRecord2(mainLocale) ? mainLocale.value : void 0;
87987
+ initializers.set(
87988
+ record3.recordId,
87989
+ mainLocaleValue === null ? quote5(linkedLocalizedTextId) : quote5(localizedString(context, member, linkedLocalizedTextId))
87990
+ );
87991
+ recordKeysByMember.set(
87992
+ record3.recordId,
87993
+ /* @__PURE__ */ new Set([`localized-text:${linkedLocalizedTextId}`])
87994
+ );
87995
+ context.localizedTextIds.clear();
87996
+ continue;
87997
+ }
87440
87998
  const backed = rowBackedDefaultBody(member, (id2) => context.values.has(id2));
87441
87999
  if (backed === null) continue;
87442
88000
  const visited = /* @__PURE__ */ new Set();
87443
- const defaultValue = isObjectRecord2(member.defaultValue) ? member.defaultValue : {};
87444
88001
  const environment = declaringClassGenericEnvironment(context, member);
87445
88002
  let expression;
87446
88003
  if (backed.kind === "class") {
@@ -87797,6 +88354,39 @@ function lowerMemberDefaultSourcesV4(state, analysis, manifest, options = {}) {
87797
88354
  bindingRuntimeIdentifiers(context, binding)
87798
88355
  );
87799
88356
  const baseData3 = stateData(context, "member", memberId);
88357
+ const annotatedExpression = annotatedValue(expression).expression;
88358
+ const storedDefault = isObjectRecord2(baseData3?.defaultValue) ? baseData3.defaultValue : null;
88359
+ const storedLocalizedTextId = storedDefault?.value;
88360
+ const storedDefaultClassId = storedDefault?.classId;
88361
+ const storedLocalizedText = typeof storedLocalizedTextId === "string" ? state[`localized-text:${storedLocalizedTextId}`]?.data : void 0;
88362
+ const authoredLocalizedValue = annotatedExpression.kind === "litString" ? annotatedExpression.value : annotatedExpression.kind === "litNull" ? null : void 0;
88363
+ if (member.kind === "string" && member.localizable && authoredLocalizedValue !== void 0 && typeof storedLocalizedTextId === "string" && isObjectRecord2(storedLocalizedText)) {
88364
+ if (annotatedExpression.kind === "litString" && annotatedExpression.value === storedLocalizedTextId) {
88365
+ addReconstructed(
88366
+ context,
88367
+ "localized-text",
88368
+ storedLocalizedTextId,
88369
+ nonVolatileFields(storedLocalizedText),
88370
+ binding.source
88371
+ );
88372
+ memberDefaultValues.set(memberId, {
88373
+ value: storedLocalizedTextId,
88374
+ classId: typeof storedDefaultClassId === "string" ? storedDefaultClassId : null
88375
+ });
88376
+ continue;
88377
+ }
88378
+ const preservedTextId = lowerLinkedLocalizedText(
88379
+ context,
88380
+ storedLocalizedTextId,
88381
+ authoredLocalizedValue,
88382
+ binding
88383
+ );
88384
+ memberDefaultValues.set(memberId, {
88385
+ value: preservedTextId,
88386
+ classId: typeof storedDefaultClassId === "string" ? storedDefaultClassId : null
88387
+ });
88388
+ continue;
88389
+ }
87800
88390
  const backed = baseData3 === null || requiresEvaluation ? null : rowBackedDefaultBody(baseData3, (id2) => pulledValueIds.has(id2));
87801
88391
  if (backed !== null && baseData3 !== null) {
87802
88392
  const existingReconstructedKeys = new Set(context.reconstructed.keys());
@@ -90300,6 +90890,18 @@ function lowerStringValue(context, member, expression, base, source) {
90300
90890
  if (!isObjectRecord2(textState?.data)) {
90301
90891
  return expression.value;
90302
90892
  }
90893
+ return lowerLinkedLocalizedText(
90894
+ context,
90895
+ base.value,
90896
+ expression.value,
90897
+ source
90898
+ );
90899
+ }
90900
+ function lowerLinkedLocalizedText(context, textId, value, source) {
90901
+ const textState = context.state[`localized-text:${textId}`];
90902
+ if (!isObjectRecord2(textState?.data)) {
90903
+ throw new Error(`Localized text ${textId} was not pulled.`);
90904
+ }
90303
90905
  const textBase = textState.data;
90304
90906
  const localeValues = isObjectRecord2(textBase.localeValues) ? textBase.localeValues : {};
90305
90907
  const currentValue = localeValues[context.mainLocale];
@@ -90307,17 +90909,17 @@ function lowerStringValue(context, member, expression, base, source) {
90307
90909
  addReconstructed(
90308
90910
  context,
90309
90911
  "localized-text",
90310
- base.value,
90912
+ textId,
90311
90913
  {
90312
90914
  ...nonVolatileFields(textBase),
90313
90915
  localeValues: {
90314
90916
  ...localeValues,
90315
- [context.mainLocale]: { ...current, value: expression.value }
90917
+ [context.mainLocale]: { ...current, value }
90316
90918
  }
90317
90919
  },
90318
90920
  source.source
90319
90921
  );
90320
- return base.value;
90922
+ return textId;
90321
90923
  }
90322
90924
  function lowerEnum2(context, member, expression) {
90323
90925
  const elements = member.multiselect ? expression.kind === "litList" ? expression.elements : null : [expression];
@@ -93378,7 +93980,7 @@ import {
93378
93980
  readFileSync as readFileSync6,
93379
93981
  readdirSync,
93380
93982
  renameSync as renameSync4,
93381
- rmSync,
93983
+ rmSync as rmSync2,
93382
93984
  writeFileSync as writeFileSync6
93383
93985
  } from "node:fs";
93384
93986
  import { basename, dirname as dirname5, extname, join as join6, relative, sep } from "node:path";
@@ -93658,7 +94260,7 @@ function writeVerifiedBinaryDownloadV4(destination, bytes, expectedSha256) {
93658
94260
  writeFileSync6(temporary, bytes);
93659
94261
  renameSync4(temporary, destination);
93660
94262
  } finally {
93661
- rmSync(temporary, { force: true });
94263
+ rmSync2(temporary, { force: true });
93662
94264
  }
93663
94265
  }
93664
94266
  function writeBinaryConflictArtifactV4(root, fileId, fileName2, bytes, expectedSha256) {
@@ -93989,16 +94591,28 @@ var init_workspace_status = __esm({
93989
94591
  // src/project-source/status-output.ts
93990
94592
  function groupProjectStatusChangesV4(status) {
93991
94593
  const groups = /* @__PURE__ */ new Map();
94594
+ const group = (source) => {
94595
+ const existing = groups.get(source);
94596
+ if (existing !== void 0) return existing;
94597
+ const created = { changes: [], authoredValueSeeds: [] };
94598
+ groups.set(source, created);
94599
+ return created;
94600
+ };
93992
94601
  for (const change of status.changes) {
93993
94602
  const reconstructed3 = status.reconstructed.get(
93994
94603
  recordStateKey(change.recordKind, change.recordId)
93995
94604
  );
93996
94605
  const source = reconstructed3?.sourceSpan?.path ?? change.file ?? "<unplaced>";
93997
- const entries = groups.get(source) ?? [];
93998
- entries.push(change);
93999
- groups.set(source, entries);
94606
+ group(source).changes.push(change);
94607
+ }
94608
+ for (const [memberId, seed] of status.authoredValueSeeds) {
94609
+ const reconstructed3 = status.reconstructed.get(
94610
+ recordStateKey("member", memberId)
94611
+ );
94612
+ const source = reconstructed3?.sourceSpan?.path ?? "<unplaced>";
94613
+ group(source).authoredValueSeeds.push({ memberId, seed });
94000
94614
  }
94001
- return [...groups].sort(([left], [right]) => compareCodePoints(left, right)).map(([source, changes]) => ({ source, changes }));
94615
+ return [...groups].sort(([left], [right]) => compareCodePoints(left, right)).map(([source, entries]) => ({ source, ...entries }));
94002
94616
  }
94003
94617
  function projectStatusJsonV4(status, options) {
94004
94618
  return {
@@ -94040,7 +94654,18 @@ function projectStatusJsonV4(status, options) {
94040
94654
  mimeType: binary.mimeType
94041
94655
  } : null,
94042
94656
  conflictArtifactPath: binary.conflictArtifactPath ?? null
94043
- }))
94657
+ })),
94658
+ authoredValueSeeds: [...status.authoredValueSeeds].sort(([left], [right]) => compareCodePoints(left, right)).map(([memberId, seed]) => {
94659
+ const reconstructed3 = status.reconstructed.get(
94660
+ recordStateKey("member", memberId)
94661
+ );
94662
+ return {
94663
+ operation: "create",
94664
+ memberId,
94665
+ valueId: seed.valueId ?? null,
94666
+ sourceSpan: reconstructed3?.sourceSpan ?? null
94667
+ };
94668
+ })
94044
94669
  };
94045
94670
  }
94046
94671
  function recordChangeJsonV4(change, status, options) {
@@ -94760,7 +95385,7 @@ import {
94760
95385
  mkdirSync as mkdirSync7,
94761
95386
  readFileSync as readFileSync8,
94762
95387
  readdirSync as readdirSync3,
94763
- rmSync as rmSync2,
95388
+ rmSync as rmSync3,
94764
95389
  writeFileSync as writeFileSync7,
94765
95390
  statSync
94766
95391
  } from "node:fs";
@@ -94772,14 +95397,14 @@ function resetWorkspaceToProjectSourcesV4(workspace, document, options = {}) {
94772
95397
  const previous = managedFilesBeforeReset(workspace.root);
94773
95398
  const preservedSpecs = preserveManagedSpecs(workspace.root);
94774
95399
  for (const directory of FORMAT_4_MANAGED_DIRECTORIES) {
94775
- rmSync2(join8(workspace.root, directory), { recursive: true, force: true });
95400
+ rmSync3(join8(workspace.root, directory), { recursive: true, force: true });
94776
95401
  }
94777
- rmSync2(join8(workspace.root, "Scripts"), { recursive: true, force: true });
95402
+ rmSync3(join8(workspace.root, "Scripts"), { recursive: true, force: true });
94778
95403
  for (const file of LEGACY_ROOT_FILES) {
94779
- rmSync2(join8(workspace.root, file), { force: true });
95404
+ rmSync3(join8(workspace.root, file), { force: true });
94780
95405
  }
94781
95406
  for (const privatePath of LEGACY_PRIVATE_PATHS) {
94782
- rmSync2(join8(workspace.root, privatePath), { recursive: true, force: true });
95407
+ rmSync3(join8(workspace.root, privatePath), { recursive: true, force: true });
94783
95408
  }
94784
95409
  for (const [path, bytes] of preservedSpecs) {
94785
95410
  const absolute = join8(workspace.root, path);
@@ -95035,7 +95660,7 @@ var init_http = __esm({
95035
95660
  });
95036
95661
 
95037
95662
  // src/project-source/project-file-pull.ts
95038
- import { existsSync as existsSync6, rmSync as rmSync3 } from "node:fs";
95663
+ import { existsSync as existsSync6, rmSync as rmSync4 } from "node:fs";
95039
95664
  import { join as join9 } from "node:path";
95040
95665
  async function pullProjectBinariesV4(args) {
95041
95666
  let client = args.client ?? null;
@@ -95164,7 +95789,7 @@ async function pullProjectBinariesV4(args) {
95164
95789
  conflicted += 1;
95165
95790
  continue;
95166
95791
  }
95167
- rmSync3(absolute, { force: true });
95792
+ rmSync4(absolute, { force: true });
95168
95793
  removePreviousConflict(args.workspace.root, previous.projectBinary);
95169
95794
  }
95170
95795
  return { states, downloaded, conflicted, conflicts };
@@ -95234,7 +95859,7 @@ function fileName(data) {
95234
95859
  }
95235
95860
  function removePreviousConflict(root, state) {
95236
95861
  if (state?.conflict?.artifactPath === void 0) return;
95237
- rmSync3(join9(root, state.conflict.artifactPath), { force: true });
95862
+ rmSync4(join9(root, state.conflict.artifactPath), { force: true });
95238
95863
  }
95239
95864
  var init_project_file_pull = __esm({
95240
95865
  "src/project-source/project-file-pull.ts"() {
@@ -95299,7 +95924,7 @@ __export(pull_exports, {
95299
95924
  import {
95300
95925
  mkdirSync as mkdirSync8,
95301
95926
  writeFileSync as writeFileSync8,
95302
- rmSync as rmSync4,
95927
+ rmSync as rmSync5,
95303
95928
  existsSync as existsSync7,
95304
95929
  readFileSync as readFileSync9
95305
95930
  } from "node:fs";
@@ -95688,7 +96313,7 @@ async function finishFormat4Pull(args) {
95688
96313
  if (previousPath === void 0 || emittedPaths.has(previousPath)) continue;
95689
96314
  const absolute = join10(workspace.root, previousPath);
95690
96315
  if (existsSync7(absolute)) {
95691
- rmSync4(absolute);
96316
+ rmSync5(absolute);
95692
96317
  removed += 1;
95693
96318
  }
95694
96319
  }
@@ -99854,7 +100479,7 @@ import { createHash as createHash10, randomUUID as randomUUID2 } from "node:cryp
99854
100479
  import {
99855
100480
  mkdirSync as mkdirSync10,
99856
100481
  writeFileSync as writeFileSync10,
99857
- rmSync as rmSync5,
100482
+ rmSync as rmSync6,
99858
100483
  existsSync as existsSync11,
99859
100484
  readFileSync as readFileSync15
99860
100485
  } from "node:fs";
@@ -100650,7 +101275,7 @@ async function runPush(workspace, options, preparationOverride) {
100650
101275
  });
100651
101276
  } finally {
100652
101277
  if (preparedBuildDir !== void 0) {
100653
- rmSync5(preparedBuildDir, { recursive: true, force: true });
101278
+ rmSync6(preparedBuildDir, { recursive: true, force: true });
100654
101279
  }
100655
101280
  }
100656
101281
  } else {
@@ -101863,7 +102488,7 @@ ${finalErrors.map(
101863
102488
  const previousPath = recordState.file;
101864
102489
  if (previousPath === void 0 || emittedPaths.has(previousPath)) continue;
101865
102490
  const absolute = join15(workspace.root, previousPath);
101866
- if (existsSync11(absolute)) rmSync5(absolute);
102491
+ if (existsSync11(absolute)) rmSync6(absolute);
101867
102492
  }
101868
102493
  for (const file of files) {
101869
102494
  const absolute = join15(workspace.root, file.path);
@@ -102673,7 +103298,7 @@ var init_registry2 = __esm({
102673
103298
  PROJECT_SCHEMA_CONTRACT = Object.freeze({
102674
103299
  formatVersion: 3,
102675
103300
  contractVersion: "3.9",
102676
- cliVersion: "0.26.4",
103301
+ cliVersion: "0.27.0",
102677
103302
  projectFileUploadBatchSize: 32,
102678
103303
  documentRecords: {
102679
103304
  member: {
@@ -103974,14 +104599,14 @@ import {
103974
104599
  readFileSync as readFileSync16,
103975
104600
  realpathSync,
103976
104601
  renameSync as renameSync5,
103977
- rmSync as rmSync6,
104602
+ rmSync as rmSync7,
103978
104603
  statSync as statSync2,
103979
104604
  writeFileSync as writeFileSync11
103980
104605
  } from "node:fs";
103981
104606
  import {
103982
104607
  basename as basename3,
103983
104608
  dirname as dirname9,
103984
- isAbsolute,
104609
+ isAbsolute as isAbsolute2,
103985
104610
  join as join16,
103986
104611
  relative as relative5,
103987
104612
  resolve as resolve3,
@@ -104182,7 +104807,7 @@ function preparedHookCandidate(workspace) {
104182
104807
  "test-build"
104183
104808
  );
104184
104809
  const pathFromRoot = relative5(cacheRoot, directory);
104185
- if (isAbsolute(pathFromRoot)) {
104810
+ if (isAbsolute2(pathFromRoot)) {
104186
104811
  throw new NeoTestPreparedCandidateError(
104187
104812
  "NEO_PREPARED_BUILD_DIR must not resolve to an absolute path outside this workspace's .neo/test-build directory."
104188
104813
  );
@@ -104382,7 +105007,7 @@ function selectedSpecPaths(workspace, selectors) {
104382
105007
  );
104383
105008
  for (const selector of normalizedSelectors) {
104384
105009
  if (/[*?]/u.test(selector)) continue;
104385
- if (isAbsolute(selector)) {
105010
+ if (isAbsolute2(selector)) {
104386
105011
  throw new Error(
104387
105012
  `Spec selector ${JSON.stringify(selector)} must be workspace-relative.`
104388
105013
  );
@@ -105167,16 +105792,16 @@ function maintainNeoTestBuildCache(root, maxBytes = TEST_BUILD_CACHE_LIMIT_BYTES
105167
105792
  const resolvedProtected = protectedDirectory === void 0 ? null : resolve3(protectedDirectory);
105168
105793
  const protectedInsideRoot = resolvedProtected !== null && (() => {
105169
105794
  const fromRoot = relative5(resolvedRoot, resolvedProtected);
105170
- return fromRoot === "" || !fromRoot.startsWith(`..${sep5}`) && fromRoot !== ".." && !isAbsolute(fromRoot);
105795
+ return fromRoot === "" || !fromRoot.startsWith(`..${sep5}`) && fromRoot !== ".." && !isAbsolute2(fromRoot);
105171
105796
  })();
105172
105797
  const isProtected = (path) => {
105173
105798
  if (!protectedInsideRoot || resolvedProtected === null) return false;
105174
105799
  const fromProtected = relative5(resolvedProtected, resolve3(path));
105175
- return fromProtected === "" || !fromProtected.startsWith(`..${sep5}`) && fromProtected !== ".." && !isAbsolute(fromProtected);
105800
+ return fromProtected === "" || !fromProtected.startsWith(`..${sep5}`) && fromProtected !== ".." && !isAbsolute2(fromProtected);
105176
105801
  };
105177
105802
  for (const file of testBuildFiles(root)) {
105178
105803
  if (!isProtected(file.path) && basename3(file.path).includes(".tmp-") && now - file.modifiedMs >= ABANDONED_TEMP_MAX_AGE_MS) {
105179
- rmSync6(file.path, { force: true });
105804
+ rmSync7(file.path, { force: true });
105180
105805
  }
105181
105806
  }
105182
105807
  const files = testBuildFiles(root);
@@ -105186,7 +105811,7 @@ function maintainNeoTestBuildCache(root, maxBytes = TEST_BUILD_CACHE_LIMIT_BYTES
105186
105811
  ).sort((left, right) => left.modifiedMs - right.modifiedMs);
105187
105812
  for (const file of removable) {
105188
105813
  if (total <= maxBytes) break;
105189
- rmSync6(file.path, { force: true });
105814
+ rmSync7(file.path, { force: true });
105190
105815
  total -= file.size;
105191
105816
  }
105192
105817
  }
@@ -105480,7 +106105,7 @@ async function runTest(workspace, options, dependencies = {}) {
105480
106105
  if (options.outputFile !== null) {
105481
106106
  try {
105482
106107
  atomicWrite(
105483
- isAbsolute(options.outputFile) ? options.outputFile : join16(workspace.root, options.outputFile),
106108
+ isAbsolute2(options.outputFile) ? options.outputFile : join16(workspace.root, options.outputFile),
105484
106109
  serialized
105485
106110
  );
105486
106111
  } catch (error) {
@@ -105693,7 +106318,7 @@ import {
105693
106318
  existsSync as existsSync13,
105694
106319
  readFileSync as readFileSync17
105695
106320
  } from "node:fs";
105696
- import { extname as extname2, isAbsolute as isAbsolute2, join as join17, relative as relative6, sep as sep6 } from "node:path";
106321
+ import { extname as extname2, isAbsolute as isAbsolute3, join as join17, relative as relative6, sep as sep6 } from "node:path";
105697
106322
  function inspectNeoDoctor(workspace) {
105698
106323
  const formatCompatible = workspace.config.formatVersion === CURRENT_FORMAT_VERSION;
105699
106324
  const compiler = inspectCompilerContract();
@@ -105873,7 +106498,7 @@ function inspectTrackedBinary(root, record3, errors) {
105873
106498
  const binary = record3.projectBinary;
105874
106499
  if (!binary) return;
105875
106500
  const path = binary.path.replaceAll("\\", "/");
105876
- if (isAbsolute2(path) || path.split("/").includes("..")) {
106501
+ if (isAbsolute3(path) || path.split("/").includes("..")) {
105877
106502
  errors.push(
105878
106503
  `Project file ${record3.recordId} has unsafe tracked path ${JSON.stringify(binary.path)}.`
105879
106504
  );
@@ -108950,7 +109575,7 @@ __export(resolve_exports, {
108950
109575
  runResolve: () => runResolve,
108951
109576
  workspaceFilePath: () => workspaceFilePath
108952
109577
  });
108953
- import { readFileSync as readFileSync19, rmSync as rmSync7, writeFileSync as writeFileSync14 } from "node:fs";
109578
+ import { readFileSync as readFileSync19, rmSync as rmSync8, writeFileSync as writeFileSync14 } from "node:fs";
108954
109579
  import { join as join21 } from "node:path";
108955
109580
  function runResolve(workspace, side) {
108956
109581
  let resolvedFiles = 0;
@@ -108976,12 +109601,12 @@ function runResolve(workspace, side) {
108976
109601
  );
108977
109602
  binary.sha256 = conflict2.remoteSha256;
108978
109603
  } else {
108979
- rmSync7(destination, { force: true });
109604
+ rmSync8(destination, { force: true });
108980
109605
  binary.sha256 = null;
108981
109606
  }
108982
109607
  }
108983
109608
  if (conflict2.artifactPath !== void 0) {
108984
- rmSync7(join21(workspace.root, conflict2.artifactPath), { force: true });
109609
+ rmSync8(join21(workspace.root, conflict2.artifactPath), { force: true });
108985
109610
  }
108986
109611
  delete binary.conflict;
108987
109612
  resolvedBinaries += 1;
@@ -109080,6 +109705,7 @@ ${h("Start")}
109080
109705
  login ${d("[--api <url>] [--profile editor|release] [--save-project <id>]")}
109081
109706
  init ${d("[--project <id>] [--version <id>] [--dir <path>] (interactive pickers)")}
109082
109707
  whoami ${d("[--api <url>]")}
109708
+ logout ${d("[--api <url>] delete the stored credential for one API origin")}
109083
109709
  help ${d("show this command overview")}
109084
109710
  --version ${d("print the installed CLI version")}
109085
109711
 
@@ -109238,7 +109864,7 @@ There is no --keep-current: preserving current semantic state defines flatten.
109238
109864
  async function main() {
109239
109865
  const args = parseArgs(process.argv.slice(2));
109240
109866
  if (args.command === "--version") {
109241
- console.log("0.26.4");
109867
+ console.log("0.27.0");
109242
109868
  return;
109243
109869
  }
109244
109870
  if (args.command === null || args.command === "help" || args.command === "--help" || args.command === "-h") {
@@ -109263,6 +109889,9 @@ async function main() {
109263
109889
  case "whoami":
109264
109890
  await runWhoami(apiBaseUrl);
109265
109891
  return;
109892
+ case "logout":
109893
+ await runLogout(apiBaseUrl);
109894
+ return;
109266
109895
  case "init":
109267
109896
  {
109268
109897
  const { runInit: runInit2 } = await Promise.resolve().then(() => (init_init(), init_exports));
@@ -109653,17 +110282,17 @@ async function main() {
109653
110282
  ` ${paintChangeKind(change.kind)} ${describeChange(change).replace(`${change.kind} `, "")}`
109654
110283
  );
109655
110284
  }
110285
+ if (group.authoredValueSeeds.length > 0) {
110286
+ console.log(
110287
+ ` ${paintChangeKind("create")} ${group.authoredValueSeeds.length} member value seed(s)`
110288
+ );
110289
+ }
109656
110290
  }
109657
110291
  for (const binary of status.binaryChanges ?? []) {
109658
110292
  console.log(
109659
110293
  `${paintChangeKind(binary.action === "create" ? "create" : "update")} project-file bytes ${binary.symbol} (${binary.path}) \u2014 ${binary.action}`
109660
110294
  );
109661
110295
  }
109662
- if (status.authoredValueSeeds.size > 0) {
109663
- console.log(
109664
- ` ${paintChangeKind("create")} ${status.authoredValueSeeds.size} member value seed(s)`
109665
- );
109666
- }
109667
110296
  if (status.conflictedFiles.length === 0 && status.parseErrors.length === 0 && status.changes.length === 0 && status.authoredValueSeeds.size === 0 && (status.binaryChanges?.length ?? 0) === 0) {
109668
110297
  console.log(`${sym.ok} Working copy is clean.`);
109669
110298
  }
@@ -109695,13 +110324,18 @@ async function main() {
109695
110324
  console.log(color.dim(` ${line}`));
109696
110325
  }
109697
110326
  }
110327
+ if (group.authoredValueSeeds.length > 0) {
110328
+ console.log(
110329
+ ` ${paintChangeKind("create")} ${group.authoredValueSeeds.length} member value seed(s)`
110330
+ );
110331
+ }
109698
110332
  }
109699
110333
  for (const binary of status.binaryChanges ?? []) {
109700
110334
  console.log(
109701
110335
  `${paintChangeKind(binary.action === "create" ? "create" : "update")} project-file bytes ${binary.symbol} (${binary.path}) \u2014 ${binary.action}`
109702
110336
  );
109703
110337
  }
109704
- if (status.changes.length === 0 && (status.binaryChanges?.length ?? 0) === 0) {
110338
+ if (status.changes.length === 0 && status.authoredValueSeeds.size === 0 && (status.binaryChanges?.length ?? 0) === 0) {
109705
110339
  console.log(`${sym.ok} No local changes.`);
109706
110340
  }
109707
110341
  return;