@neocompose/cli 0.22.4 → 0.22.6

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
@@ -8954,7 +8954,8 @@ var init_strict_resolver = __esm({
8954
8954
  className,
8955
8955
  expression,
8956
8956
  scope,
8957
- expression.pos
8957
+ expression.pos,
8958
+ expected
8958
8959
  );
8959
8960
  }
8960
8961
  if (expression.argumentNames && !projectionCall) {
@@ -10588,7 +10589,7 @@ var init_strict_resolver = __esm({
10588
10589
  * the call site's initializer block is carried through to be applied last
10589
10590
  * (§6.1 step 4).
10590
10591
  */
10591
- resolveDeclaredConstructor(className, expression, scope, pos) {
10592
+ resolveDeclaredConstructor(className, expression, scope, pos, expected) {
10592
10593
  const schemaClass2 = this.project.typeByName.get(className);
10593
10594
  if (!schemaClass2 || schemaClass2.kind !== "class") {
10594
10595
  throw new CompileError(
@@ -10608,7 +10609,24 @@ var init_strict_resolver = __esm({
10608
10609
  pos
10609
10610
  );
10610
10611
  }
10611
- const declared = schemaClass2.declaredConstructors ?? [];
10612
+ const targetType = this.constructorTargetType(
10613
+ schemaClass2,
10614
+ expression,
10615
+ expected
10616
+ );
10617
+ const declared = (schemaClass2.declaredConstructors ?? []).map(
10618
+ (constructor2) => ({
10619
+ ...constructor2,
10620
+ parameters: constructor2.parameters.map((parameter3) => ({
10621
+ ...parameter3,
10622
+ type: substituteTypeParameters(
10623
+ parameter3.type,
10624
+ targetType,
10625
+ schemaClass2
10626
+ )
10627
+ }))
10628
+ })
10629
+ );
10612
10630
  const argumentNames = expression.args.map(
10613
10631
  (_, index) => expression.argumentNames?.[index] ?? null
10614
10632
  );
@@ -10649,10 +10667,7 @@ var init_strict_resolver = __esm({
10649
10667
  expression,
10650
10668
  scope
10651
10669
  );
10652
- const classType = {
10653
- kind: "named",
10654
- typeId: schemaClass2.id
10655
- };
10670
+ const classType = targetType;
10656
10671
  const schemaClassInfo = toWireType(classType, this.project);
10657
10672
  if (schemaClassInfo.type !== 7 /* Class */) {
10658
10673
  throw new Error(
@@ -38855,8 +38870,145 @@ function substituteMember(member, env, members) {
38855
38870
  };
38856
38871
  return substituted;
38857
38872
  }
38873
+ if (isMemberDelegateBase(resolved)) {
38874
+ const returnTypeInfo = substituteNestedTypeInfo(
38875
+ resolved.returnTypeInfo,
38876
+ env,
38877
+ members
38878
+ );
38879
+ let argumentsChanged = false;
38880
+ const argumentTypes = resolved.argumentTypes.map((argument2) => {
38881
+ const substituted2 = substituteNestedTypeInfo(argument2, env, members);
38882
+ if (substituted2 === argument2) return argument2;
38883
+ argumentsChanged = true;
38884
+ return { ...substituted2, name: argument2.name };
38885
+ });
38886
+ if (returnTypeInfo === resolved.returnTypeInfo && !argumentsChanged) {
38887
+ return resolved;
38888
+ }
38889
+ const substituted = {
38890
+ ...resolved,
38891
+ returnTypeInfo,
38892
+ argumentTypes
38893
+ };
38894
+ return substituted;
38895
+ }
38858
38896
  return resolved;
38859
38897
  }
38898
+ function substituteNestedTypeInfo(typeInfo, env, members) {
38899
+ if (typeInfo.type === 21 /* Generic */) {
38900
+ const entry = env.get(typeInfo.genericParamId);
38901
+ if (entry === void 0) {
38902
+ throw new Error(
38903
+ `substituteMember: callable type references generic param "${typeInfo.genericParamId}", which is not present in the binding environment.`
38904
+ );
38905
+ }
38906
+ if (entry.kind === "unbound") return typeInfo;
38907
+ const binding = members.find(
38908
+ (candidate) => candidate.id === entry.memberId
38909
+ );
38910
+ if (binding === void 0) {
38911
+ throw new Error(
38912
+ `substituteMember: callable type binding member "${entry.memberId}" for generic param "${typeInfo.genericParamId}" does not exist in the document.`
38913
+ );
38914
+ }
38915
+ return genericBindingTypeInfo(binding, env, members);
38916
+ }
38917
+ if (typeInfo.type === 6 /* List */ || typeInfo.type === 5 /* Dictionary */ || typeInfo.type === 9 /* Lookup */) {
38918
+ return {
38919
+ ...typeInfo,
38920
+ entryTypeInfo: substituteNestedTypeInfo(
38921
+ typeInfo.entryTypeInfo,
38922
+ env,
38923
+ members
38924
+ )
38925
+ };
38926
+ }
38927
+ if (typeInfo.type === 7 /* Class */) {
38928
+ const typeArguments = typeInfo.typeArguments;
38929
+ if (typeArguments === void 0) return typeInfo;
38930
+ return {
38931
+ ...typeInfo,
38932
+ typeArguments: Object.fromEntries(
38933
+ Object.entries(typeArguments).map(([parameterId, argument2]) => [
38934
+ parameterId,
38935
+ substituteNestedTypeInfo(argument2, env, members)
38936
+ ])
38937
+ )
38938
+ };
38939
+ }
38940
+ if (typeInfo.type === 25 /* NSDelegate */) {
38941
+ return {
38942
+ ...typeInfo,
38943
+ returnTypeInfo: substituteNestedTypeInfo(
38944
+ typeInfo.returnTypeInfo,
38945
+ env,
38946
+ members
38947
+ ),
38948
+ argumentTypes: typeInfo.argumentTypes.map(
38949
+ (argument2) => substituteNestedTypeInfo(argument2, env, members)
38950
+ )
38951
+ };
38952
+ }
38953
+ return typeInfo;
38954
+ }
38955
+ function genericBindingTypeInfo(rawMember, env, members) {
38956
+ return typeInfoFromArgumentSignature(
38957
+ typeArgumentSignatureOfMember(rawMember, env, members)
38958
+ );
38959
+ }
38960
+ function typeInfoFromArgumentSignature(signature) {
38961
+ if (signature.type === 7 /* Class */) {
38962
+ const classSignature = signature;
38963
+ return {
38964
+ type: 7 /* Class */,
38965
+ required: classSignature.required,
38966
+ classId: classSignature.classId,
38967
+ ...Object.keys(classSignature.args).length === 0 ? {} : {
38968
+ typeArguments: Object.fromEntries(
38969
+ Object.entries(classSignature.args).map(
38970
+ ([parameterId, argument2]) => [
38971
+ parameterId,
38972
+ typeInfoFromArgumentSignature(argument2)
38973
+ ]
38974
+ )
38975
+ )
38976
+ }
38977
+ };
38978
+ }
38979
+ if (signature.type === 8 /* Enum */) {
38980
+ const enumSignature = signature;
38981
+ return {
38982
+ type: 8 /* Enum */,
38983
+ required: enumSignature.required,
38984
+ enumId: enumSignature.enumId
38985
+ };
38986
+ }
38987
+ if (signature.type === 6 /* List */) {
38988
+ const listSignature = signature;
38989
+ return {
38990
+ type: 6 /* List */,
38991
+ required: listSignature.required,
38992
+ entryTypeInfo: typeInfoFromArgumentSignature(listSignature.entry)
38993
+ };
38994
+ }
38995
+ if (signature.type === 5 /* Dictionary */) {
38996
+ const dictionarySignature = signature;
38997
+ return {
38998
+ type: 5 /* Dictionary */,
38999
+ required: dictionarySignature.required,
39000
+ entryTypeInfo: typeInfoFromArgumentSignature(dictionarySignature.entry),
39001
+ ...dictionarySignature.keyEnumId === void 0 ? {} : { keyEnumId: dictionarySignature.keyEnumId }
39002
+ };
39003
+ }
39004
+ const typeInfo = { type: signature.type, required: signature.required };
39005
+ if (!isNSTypeInfo(typeInfo)) {
39006
+ throw new Error(
39007
+ `substituteMember: generic binding kind ${signature.type} cannot appear in a NeoScript callable type.`
39008
+ );
39009
+ }
39010
+ return typeInfo;
39011
+ }
38860
39012
  function resolveTerminalBinding(genericParamId, slotName, env, members) {
38861
39013
  const entry = env.get(genericParamId);
38862
39014
  if (entry === void 0) {
@@ -39137,6 +39289,7 @@ var init_generics = __esm({
39137
39289
  "../src/models/classes/generics.ts"() {
39138
39290
  "use strict";
39139
39291
  init_member_kinds();
39292
+ init_neoscript();
39140
39293
  init_world_system_classes();
39141
39294
  init_structural_narrow();
39142
39295
  init_inheritance();
@@ -40781,7 +40934,11 @@ function evaluateLiteralContainer(args) {
40781
40934
  `Cannot materialize member "${args.member.name}": its value is a NeoScript initializer, which this builder cannot evaluate. Supply an initEvaluator.`
40782
40935
  );
40783
40936
  }
40784
- const evaluated = args.initEvaluator(args.member, body.init);
40937
+ const evaluated = args.initEvaluator(
40938
+ args.member,
40939
+ body.init,
40940
+ args.sourceValueId
40941
+ );
40785
40942
  return {
40786
40943
  literal: {
40787
40944
  value: evaluated.value,
@@ -41139,7 +41296,8 @@ function cloneDefaultValueForMember(args) {
41139
41296
  const evaluated = evaluateLiteralContainer({
41140
41297
  body: sourceValue,
41141
41298
  member,
41142
- initEvaluator: args.initEvaluator
41299
+ initEvaluator: args.initEvaluator,
41300
+ sourceValueId: args.sourceValueId
41143
41301
  });
41144
41302
  if (evaluated === void 0) {
41145
41303
  throw new Error(
@@ -54070,14 +54228,18 @@ var init_NSGetterRuntimeError = __esm({
54070
54228
  }
54071
54229
  };
54072
54230
  UncompiledInitializerRuntimeError = class extends NSGetterRuntimeError {
54073
- constructor(memberId, memberName) {
54231
+ constructor(memberId, memberName, initializer = null, valueId = null) {
54074
54232
  super(
54075
54233
  `Initializer for '${memberName}' has no compiled body; push the project so the server compiles it.`
54076
54234
  );
54077
54235
  this.memberId = memberId;
54236
+ this.initializer = initializer;
54237
+ this.valueId = valueId;
54078
54238
  this.name = "UncompiledInitializerRuntimeError";
54079
54239
  }
54080
54240
  memberId;
54241
+ initializer;
54242
+ valueId;
54081
54243
  };
54082
54244
  }
54083
54245
  });
@@ -55203,6 +55365,14 @@ function trackedRowForValueReference(value, ctx) {
55203
55365
  const indexes = evaluatorIndexes(ctx);
55204
55366
  return indexes.rowByValueReference.get(value) ?? indexes.baseRowByValueReference?.get(value) ?? null;
55205
55367
  }
55368
+ function assertStoredReplayMutableValue(value, ctx, label) {
55369
+ if (ctx.storedConstructionReplay !== true) return;
55370
+ const row = trackedRowForValueReference(value, ctx);
55371
+ if (row === null || ctx.__runtimeSessionValues?.has(row.id) === true) return;
55372
+ throw new NSGetterRuntimeError(
55373
+ `Stored construction replay cannot mutate persisted ${label}.`
55374
+ );
55375
+ }
55206
55376
  function pushConstructionFrame(ctx, label) {
55207
55377
  const state = ctx.__executionState;
55208
55378
  if (state === void 0) {
@@ -55367,7 +55537,7 @@ function withEvaluationRuntime(ctx, writes) {
55367
55537
  if (ctx.__runtimeSessionValues !== void 0 && ctx.__executionState !== void 0 && ctx.__valueOverlay !== void 0) {
55368
55538
  return ctx;
55369
55539
  }
55370
- const overlay = ctx.__valueOverlay ?? buildValueOverlay(ctx.vm);
55540
+ const overlay = ctx.__valueOverlay ?? (ctx.storedConstructionReplay === true ? /* @__PURE__ */ new Map() : buildValueOverlay(ctx.vm));
55371
55541
  const referenceRemap = ctx.__runtimeReferenceRemap ?? /* @__PURE__ */ new Map();
55372
55542
  const runtimeReferences = runtimeSessionValueReferences(
55373
55543
  ctx.__runtimeSessionValues
@@ -56375,6 +56545,11 @@ function evalInstructions(instructions, scope, ctx, options) {
56375
56545
  }
56376
56546
  function applyOverlayAssignment(target, targetTypeInfo, value, scope, ctx) {
56377
56547
  if (target.type === "staticMember" /* staticMember */) {
56548
+ if (ctx.storedConstructionReplay === true) {
56549
+ throw new NSGetterRuntimeError(
56550
+ "Stored construction replay cannot assign persisted static values."
56551
+ );
56552
+ }
56378
56553
  applyOverlayStaticAssignment(target.memberId, value, ctx);
56379
56554
  return;
56380
56555
  }
@@ -56384,6 +56559,7 @@ function applyOverlayAssignment(target, targetTypeInfo, value, scope, ctx) {
56384
56559
  );
56385
56560
  }
56386
56561
  const receiver = evalPointer(target.keyOf.pointer, scope, ctx);
56562
+ assertStoredReplayMutableValue(receiver, ctx, "assignment target");
56387
56563
  const key = evalPointer(target.keyOf.key, scope, ctx);
56388
56564
  const referenceValueId = targetTypeInfo.type === 7 /* Class */ || targetTypeInfo.type === 6 /* List */ || targetTypeInfo.type === 5 /* Dictionary */ ? findKnownRowIdByValueReference(value, ctx) : null;
56389
56565
  if (Array.isArray(receiver)) {
@@ -56692,6 +56868,11 @@ function resolveCompiledSetter(memberId, ctx) {
56692
56868
  }
56693
56869
  function evalCollectionMutationInstruction(ins, scope, ctx, options) {
56694
56870
  if (ins.target.pointer.type === "staticMember" /* staticMember */) {
56871
+ if (ctx.storedConstructionReplay === true) {
56872
+ throw new NSGetterRuntimeError(
56873
+ "Stored construction replay cannot mutate persisted static collections."
56874
+ );
56875
+ }
56695
56876
  const member = evalMemberById(ctx.vm, ins.target.pointer.memberId);
56696
56877
  if (member === null) {
56697
56878
  throw new NSGetterRuntimeError(
@@ -56701,6 +56882,13 @@ function evalCollectionMutationInstruction(ins, scope, ctx, options) {
56701
56882
  writableStaticBindingMap(member, ctx);
56702
56883
  }
56703
56884
  const targetValue = evalPointer(ins.target.pointer, scope, ctx);
56885
+ if (ins.target.pointer.type !== "variable" /* variable */) {
56886
+ assertStoredReplayMutableValue(
56887
+ targetValue,
56888
+ ctx,
56889
+ "collection mutation target"
56890
+ );
56891
+ }
56704
56892
  const args = ins.args.map((arg) => evalPointer(arg, scope, ctx));
56705
56893
  const isLookupSet = ins.target.typeInfo.type === 9 /* Lookup */;
56706
56894
  if (ins.mutation === "Add" /* Add */) {
@@ -58936,7 +59124,14 @@ function validateClassConstructorDescriptor(info, ctx, requireEveryRequiredField
58936
59124
  `Cannot construct abstract Class '${schemaClass2.name}'.`
58937
59125
  );
58938
59126
  }
58939
- if (!isClosedClass(classId, ctx.vm.classes)) {
59127
+ const replaySlot = ctx.__storedConstructionReplayNestedSlots?.toReversed().find((slot) => slot.classId === classId) ?? ctx.__storedConstructionReplaySlot;
59128
+ const classArguments2 = replaySlot?.classId === classId ? replaySlot.classArguments : void 0;
59129
+ const instanceEnv = resolveInstanceEnv(
59130
+ classId,
59131
+ classArguments2,
59132
+ ctx.vm.classes
59133
+ );
59134
+ if (firstUnboundParamId(instanceEnv) !== null) {
58940
59135
  throw new NSGetterRuntimeError(
58941
59136
  `Cannot construct open generic Class '${schemaClass2.name}'.`
58942
59137
  );
@@ -58961,7 +59156,6 @@ function validateClassConstructorDescriptor(info, ctx, requireEveryRequiredField
58961
59156
  const schemaByKey = new Map(
58962
59157
  mergedSchema.map((entry) => [entry.schemaKey, entry])
58963
59158
  );
58964
- const instanceEnv = resolveInstanceEnv(classId, void 0, ctx.vm.classes);
58965
59159
  const seenSchemaKeys = /* @__PURE__ */ new Set();
58966
59160
  const seenMemberIds = /* @__PURE__ */ new Set();
58967
59161
  const fields = [];
@@ -59012,7 +59206,7 @@ function validateClassConstructorDescriptor(info, ctx, requireEveryRequiredField
59012
59206
  );
59013
59207
  }
59014
59208
  if (!requireEveryRequiredField) {
59015
- return { schemaClass: schemaClass2, fields, instanceEnv };
59209
+ return { schemaClass: schemaClass2, fields, instanceEnv, classArguments: classArguments2 };
59016
59210
  }
59017
59211
  for (const entry of mergedSchema) {
59018
59212
  const rawMember = evalMemberById(ctx.vm, entry.memberId);
@@ -59035,7 +59229,7 @@ function validateClassConstructorDescriptor(info, ctx, requireEveryRequiredField
59035
59229
  );
59036
59230
  }
59037
59231
  }
59038
- return { schemaClass: schemaClass2, fields, instanceEnv };
59232
+ return { schemaClass: schemaClass2, fields, instanceEnv, classArguments: classArguments2 };
59039
59233
  }
59040
59234
  function assertConstructorFieldSlotWritable(args) {
59041
59235
  const surfaceEntry = mergeInstanceSchema(
@@ -59118,11 +59312,12 @@ function evaluateConstructorFields(descriptor, scope, ctx) {
59118
59312
  return { validated, value };
59119
59313
  });
59120
59314
  }
59121
- function syntheticConstructorMember(schemaClass2) {
59315
+ function syntheticConstructorMember(schemaClass2, classArguments2) {
59122
59316
  return {
59123
59317
  name: `new ${schemaClass2.name}`,
59124
59318
  kind: 7 /* Class */,
59125
59319
  classId: schemaClass2.id,
59320
+ ...classArguments2 === void 0 ? {} : { classArguments: classArguments2 },
59126
59321
  locked: false,
59127
59322
  required: true,
59128
59323
  isStatic: false,
@@ -59353,7 +59548,10 @@ function constructClassValueWithinFrame(descriptor, scope, ctx) {
59353
59548
  const schemaClass2 = descriptor.schemaClass;
59354
59549
  const classId = schemaClass2.id;
59355
59550
  const supplied = evaluateConstructorFields(descriptor, scope, ctx);
59356
- const syntheticMember = syntheticConstructorMember(schemaClass2);
59551
+ const syntheticMember = syntheticConstructorMember(
59552
+ schemaClass2,
59553
+ descriptor.classArguments
59554
+ );
59357
59555
  const createdValues = [];
59358
59556
  const storageKeyDeclarations = /* @__PURE__ */ new Map();
59359
59557
  let root;
@@ -59775,9 +59973,41 @@ function constructionInitEvaluator(ctx, createdValues, argumentScopes, construct
59775
59973
  }
59776
59974
  return null;
59777
59975
  };
59778
- return (member, init) => {
59976
+ return (member, init, sourceValueId) => {
59977
+ const evaluate = (argumentValues = []) => {
59978
+ if (ctx.storedConstructionReplay !== true || !isMemberClassBase(member) || Object.keys(member.classArguments ?? {}).length === 0) {
59979
+ return evaluateInitializerInContext(
59980
+ init,
59981
+ member,
59982
+ ctx,
59983
+ createdValues,
59984
+ argumentValues,
59985
+ sourceValueId ?? null
59986
+ );
59987
+ }
59988
+ const previousSlots = ctx.__storedConstructionReplayNestedSlots;
59989
+ ctx.__storedConstructionReplayNestedSlots = [
59990
+ ...previousSlots ?? [],
59991
+ {
59992
+ classId: member.classId,
59993
+ classArguments: member.classArguments ?? {}
59994
+ }
59995
+ ];
59996
+ try {
59997
+ return evaluateInitializerInContext(
59998
+ init,
59999
+ member,
60000
+ ctx,
60001
+ createdValues,
60002
+ argumentValues,
60003
+ sourceValueId ?? null
60004
+ );
60005
+ } finally {
60006
+ ctx.__storedConstructionReplayNestedSlots = previousSlots;
60007
+ }
60008
+ };
59779
60009
  if (init.compiled === void 0) {
59780
- return evaluateInitializerInContext(init, member, ctx, createdValues);
60010
+ return evaluate();
59781
60011
  }
59782
60012
  const memberId = Reflect.get(member, "id");
59783
60013
  const scopeMemberId = indexes.initializerScopeMemberIds.get(init) ?? (typeof memberId === "string" ? memberId : "");
@@ -59789,12 +60019,12 @@ function constructionInitEvaluator(ctx, createdValues, argumentScopes, construct
59789
60019
  `Member initializer '${member.name}' has ${expectedArgumentCount} constructor parameter(s), but its declaring class scope could not be resolved.`
59790
60020
  );
59791
60021
  }
59792
- return evaluateInitializerInContext(init, member, ctx, createdValues);
60022
+ return evaluate();
59793
60023
  }
59794
60024
  const scopedArguments = argumentScopes.valuesByClassId.get(ownerClassId);
59795
60025
  if (scopedArguments === void 0) {
59796
60026
  if (expectedArgumentCount === 0) {
59797
- return evaluateInitializerInContext(init, member, ctx, createdValues);
60027
+ return evaluate();
59798
60028
  }
59799
60029
  if (argumentScopes.missingScopeReason === "no-constructor") {
59800
60030
  throw new NSGetterRuntimeError(
@@ -59810,13 +60040,7 @@ function constructionInitEvaluator(ctx, createdValues, argumentScopes, construct
59810
60040
  `Member initializer '${member.name}' on '${ownerClassId}' expected ${expectedArgumentCount} constructor argument(s), got ${scopedArguments.length}.`
59811
60041
  );
59812
60042
  }
59813
- return evaluateInitializerInContext(
59814
- init,
59815
- member,
59816
- ctx,
59817
- createdValues,
59818
- scopedArguments
59819
- );
60043
+ return evaluate(scopedArguments);
59820
60044
  };
59821
60045
  }
59822
60046
  function constructorInitializerIndexes(ctx) {
@@ -59931,14 +60155,16 @@ function runtimeValueReferencesVariable(value, variableId, visited = /* @__PURE_
59931
60155
  (child) => runtimeValueReferencesVariable(child, variableId, visited)
59932
60156
  );
59933
60157
  }
59934
- function evaluateInitializerInContext(init, member, ctx, createdValues, argumentValues = []) {
60158
+ function evaluateInitializerInContext(init, member, ctx, createdValues, argumentValues = [], sourceValueId = null) {
59935
60159
  ctx.__constructedArgumentsByValue ??= /* @__PURE__ */ new WeakMap();
59936
60160
  const compiled = init.compiled;
59937
60161
  if (compiled === void 0) {
59938
60162
  const memberId = Reflect.get(member, "id");
59939
60163
  throw new UncompiledInitializerRuntimeError(
59940
60164
  typeof memberId === "string" ? memberId : null,
59941
- member.name
60165
+ member.name,
60166
+ init,
60167
+ sourceValueId
59942
60168
  );
59943
60169
  }
59944
60170
  const closeFrame = pushConstructionFrame(ctx, `${member.name} initializer`);
@@ -60137,7 +60363,10 @@ function constructDeclaredClassValueWithinFrame(descriptor, record3, info, scope
60137
60363
  textureTemplates: ctx.vm.textureTemplates ?? []
60138
60364
  },
60139
60365
  projectId: ctx.vm.project.id,
60140
- member: syntheticConstructorMember(schemaClass2),
60366
+ member: syntheticConstructorMember(
60367
+ schemaClass2,
60368
+ descriptor.classArguments
60369
+ ),
60141
60370
  topLevelClassId: classId,
60142
60371
  createdValues,
60143
60372
  storageKeyDeclarations,
@@ -61381,7 +61610,8 @@ function evaluateMemberInitializer(args) {
61381
61610
  if (compiled === void 0) {
61382
61611
  throw new UncompiledInitializerRuntimeError(
61383
61612
  typeof Reflect.get(args.member, "id") === "string" ? Reflect.get(args.member, "id") : null,
61384
- args.member.name
61613
+ args.member.name,
61614
+ args.init
61385
61615
  );
61386
61616
  }
61387
61617
  const ctx = {
@@ -61403,7 +61633,15 @@ function evaluateMemberInitializer(args) {
61403
61633
  rootValue: buildInitializerRootValue(args.document),
61404
61634
  saveStaticBindings: args.saveStaticBindings,
61405
61635
  sessionStaticBindings: args.sessionStaticBindings,
61406
- ...args.storedConstructionReplay === true ? { storedConstructionReplay: true } : {},
61636
+ ...args.storedConstructionReplay === true ? {
61637
+ storedConstructionReplay: true,
61638
+ ...isMemberClassBase(args.member) ? {
61639
+ __storedConstructionReplaySlot: {
61640
+ classId: args.member.classId,
61641
+ classArguments: args.member.classArguments ?? {}
61642
+ }
61643
+ } : {}
61644
+ } : {},
61407
61645
  __constructedArgumentsByValue: /* @__PURE__ */ new WeakMap(),
61408
61646
  __createdStorageKeyDeclarations: args.storageKeyDeclarations ?? /* @__PURE__ */ new Map()
61409
61647
  };
@@ -61426,6 +61664,7 @@ var evaluatorLookupsByDocument;
61426
61664
  var init_evaluateInitializer = __esm({
61427
61665
  "../src/view-models/neoscript-evaluator/evaluateInitializer.ts"() {
61428
61666
  "use strict";
61667
+ init_members();
61429
61668
  init_project2();
61430
61669
  init_NSGetterRuntimeError();
61431
61670
  init_evaluateNSGetter();
@@ -69696,7 +69935,7 @@ function materializedInitializerReconciliationFailuresV4(args) {
69696
69935
  candidateValueIds
69697
69936
  );
69698
69937
  const currentRecords = reconciliationRecords(args.workspace, []);
69699
- const cachedExpressions = readMaterializedConstructionBuildCacheV1(
69938
+ const cachedExpressions = args.useBuildCaches === false ? null : readMaterializedConstructionBuildCacheV1(
69700
69939
  args.workspace.root,
69701
69940
  args.workspace.state
69702
69941
  );
@@ -69720,11 +69959,13 @@ function materializedInitializerReconciliationFailuresV4(args) {
69720
69959
  )) {
69721
69960
  canonicalExpressions.set(valueId, expression);
69722
69961
  }
69723
- writeMaterializedConstructionBuildCacheV1(
69724
- args.workspace.root,
69725
- args.workspace.state,
69726
- canonicalExpressions
69727
- );
69962
+ if (args.useBuildCaches !== false) {
69963
+ writeMaterializedConstructionBuildCacheV1(
69964
+ args.workspace.root,
69965
+ args.workspace.state,
69966
+ canonicalExpressions
69967
+ );
69968
+ }
69728
69969
  }
69729
69970
  }
69730
69971
  const replayableValueIds = /* @__PURE__ */ new Set();
@@ -69738,7 +69979,7 @@ function materializedInitializerReconciliationFailuresV4(args) {
69738
69979
  }
69739
69980
  }
69740
69981
  const owners = resolveOwnerMembersForValues(document, replayableValueIds);
69741
- const compilationProject = replayableValueIds.size === 0 ? void 0 : loadOrBuildNeoScriptProjectV1(args.workspace.root, document);
69982
+ const compilationProject = replayableValueIds.size === 0 ? void 0 : args.useBuildCaches === false ? createNeoScriptCompilationProject(document) : loadOrBuildNeoScriptProjectV1(args.workspace.root, document);
69742
69983
  const failures = [];
69743
69984
  for (const reconciliation of args.reconciliations.values()) {
69744
69985
  if (reconciliation.storedConstructorArgs === null) continue;
@@ -70078,6 +70319,7 @@ var init_local_initializer_materialization = __esm({
70078
70319
  init_value_row_owner_members();
70079
70320
  init_neo_script_recompile_scope();
70080
70321
  init_neoscript_build_cache();
70322
+ init_compiler_adapter();
70081
70323
  }
70082
70324
  });
70083
70325
 
@@ -70716,6 +70958,7 @@ function computeWorkspaceStatus(workspace, options) {
70716
70958
  reconciliations: valueLowerRegistry.initializerReconciliations,
70717
70959
  manifest,
70718
70960
  forceRecompile: options.forceRecompile,
70961
+ useBuildCaches: options.useBuildCaches,
70719
70962
  sourceTextByUri: new Map(
70720
70963
  sourceEntries.map((entry) => [entry.relPath, entry.source])
70721
70964
  )
@@ -70786,13 +71029,15 @@ function computeWorkspaceStatus(workspace, options) {
70786
71029
  parseErrors.push(new SchemaSourceError(message, "<project-files>", 1, 1));
70787
71030
  }
70788
71031
  try {
71032
+ const animationRecords = prospectiveAnimationRecords(
71033
+ workspace.state.records,
71034
+ reconstructed3,
71035
+ changes,
71036
+ authoredValueSeeds
71037
+ );
70789
71038
  validateProspectiveAnimationRecordsV4(
70790
- prospectiveAnimationRecords(
70791
- workspace.state.records,
70792
- reconstructed3,
70793
- changes,
70794
- authoredValueSeeds
70795
- )
71039
+ animationRecords,
71040
+ animationRecordsFromState(workspace.state.records)
70796
71041
  );
70797
71042
  } catch (error) {
70798
71043
  parseErrors.push(
@@ -70860,17 +71105,19 @@ function computeWorkspaceStatus(workspace, options) {
70860
71105
  )
70861
71106
  };
70862
71107
  }
70863
- function validateProspectiveAnimationRecordsV4(records2) {
71108
+ function validateProspectiveAnimationRecordsV4(records2, fallbackRecords = []) {
70864
71109
  const candidates = [...records2];
70865
71110
  const document = prospectiveAnimationDocumentV4(candidates);
70866
71111
  if (document === null) return;
71112
+ const fallbackDocument = prospectiveAnimationDocumentV4(fallbackRecords);
70867
71113
  const replayed = replayAnimationDeclarationInitializersV4(
70868
71114
  candidates,
70869
- document
71115
+ document,
71116
+ fallbackDocument
70870
71117
  );
70871
71118
  assertAnimationClipDocumentValid(replayed);
70872
71119
  }
70873
- function replayAnimationDeclarationInitializersV4(records2, document) {
71120
+ function replayAnimationDeclarationInitializersV4(records2, document, fallbackDocument) {
70874
71121
  const initializers = document.values.flatMap((row) => {
70875
71122
  const init = Reflect.get(row, "init");
70876
71123
  return isObjectRecord2(init) && typeof init.code === "string" ? [{ row, code: init.code }] : [];
@@ -70897,7 +71144,24 @@ function replayAnimationDeclarationInitializersV4(records2, document) {
70897
71144
  data: record3.data
70898
71145
  });
70899
71146
  }
70900
- const values = new Map(document.values.map((row) => [row.id, row]));
71147
+ const replayDocument = readPulledProjectDocumentV4(pulled);
71148
+ const compilationProject = createNeoScriptCompilationProject({
71149
+ project: replayDocument.project,
71150
+ projectFiles: replayDocument.projectFiles,
71151
+ members: replayDocument.members,
71152
+ classes: replayDocument.classes,
71153
+ enums: replayDocument.enums,
71154
+ interfaces: replayDocument.interfaces,
71155
+ constructors: replayDocument.constructors ?? []
71156
+ });
71157
+ let documentBodiesCompiled = false;
71158
+ const fallbackValues = new Map(
71159
+ (fallbackDocument?.values ?? []).map((row) => [row.id, row])
71160
+ );
71161
+ const values = new Map([
71162
+ ...fallbackValues,
71163
+ ...document.values.map((row) => [row.id, row])
71164
+ ]);
70901
71165
  for (const { row, code } of initializers) {
70902
71166
  if (rootKinds.get(row.id) !== "declaration") continue;
70903
71167
  const owner = owners.get(row.id);
@@ -70910,26 +71174,34 @@ function replayAnimationDeclarationInitializersV4(records2, document) {
70910
71174
  const rootOwner = rootOwners.get(row.id);
70911
71175
  const rootOwnerId = Reflect.get(rootOwner ?? {}, "id");
70912
71176
  const initializerOwnerClass = typeof rootOwnerId !== "string" ? null : findSchemaPlacement(rootOwnerId, document.classes)?.ownerClass ?? null;
71177
+ const evaluate = initializerOwnerClass?.requiredConstructorId === void 0 || initializerOwnerClass.requiredConstructorId === null;
70913
71178
  let replay;
70914
71179
  try {
70915
71180
  replay = replayStoredConstructionV4({
70916
71181
  records: pulled,
71182
+ document: replayDocument,
70917
71183
  valueId: row.id,
70918
71184
  code,
70919
71185
  member: owner,
70920
- compileDocumentBodies: true,
71186
+ compileDocumentBodies: !documentBodiesCompiled,
71187
+ compilationProject,
70921
71188
  initializerOwnerClass,
70922
71189
  // A parameterized declaration is a template. Its arguments exist only
70923
71190
  // at concrete construction sites, so validate the authored body here
70924
71191
  // without fabricating values for the class header parameters.
70925
- evaluate: initializerOwnerClass?.requiredConstructorId === void 0 || initializerOwnerClass.requiredConstructorId === null
71192
+ evaluate
70926
71193
  });
71194
+ documentBodiesCompiled = true;
70927
71195
  } catch (error) {
70928
71196
  throw new Error(
70929
71197
  `Animation declaration replay failed for value "${row.id}": ${error instanceof Error ? error.message : String(error)}`,
70930
71198
  { cause: error }
70931
71199
  );
70932
71200
  }
71201
+ if (!evaluate) {
71202
+ const fallback = fallbackValues.get(row.id);
71203
+ if (fallback !== void 0) values.set(row.id, fallback);
71204
+ }
70933
71205
  for (const [id2, value] of replay) {
70934
71206
  if (!isMemberValue(value)) {
70935
71207
  throw new Error(
@@ -70941,6 +71213,12 @@ function replayAnimationDeclarationInitializersV4(records2, document) {
70941
71213
  }
70942
71214
  return { ...document, values: [...values.values()] };
70943
71215
  }
71216
+ function animationRecordsFromState(records2) {
71217
+ return Object.values(records2).flatMap((record3) => {
71218
+ const data = record3.conflictServerHash !== void 0 && isObjectRecord2(record3.conflictServerData) ? record3.conflictServerData : record3.data;
71219
+ return isObjectRecord2(data) ? [{ recordKind: record3.recordKind, data }] : [];
71220
+ });
71221
+ }
70944
71222
  function classBelongsToAnimationFamily(classes, classId) {
70945
71223
  const classesById = new Map(
70946
71224
  classes.map((schemaClass2) => [schemaClass2.id, schemaClass2])
@@ -71314,6 +71592,7 @@ var init_workspace_status_core = __esm({
71314
71592
  init_local_initializer_materialization();
71315
71593
  init_push_change_intent();
71316
71594
  init_initializer_replay();
71595
+ init_compiler_adapter();
71317
71596
  IGNORED_SCHEMA_DIRECTORIES = /* @__PURE__ */ new Set([
71318
71597
  ".git",
71319
71598
  ".neo",
@@ -71364,6 +71643,7 @@ function verifyProjectSourceCommitAgainstStateV4(args) {
71364
71643
  }
71365
71644
  const status = computeWorkspaceStatus(workspace, {
71366
71645
  skipProjectBinaryInspection: true,
71646
+ useBuildCaches: false,
71367
71647
  writeProjectAnalysisCache: () => void 0,
71368
71648
  trustedPendingProjectFiles,
71369
71649
  virtualSourceFiles: args.files,
@@ -74901,13 +75181,14 @@ function materializePreparedInstanceInitializers(args) {
74901
75181
  `Value "${valueId}" carries an initializer but no instance ownership path resolves its declared member.`
74902
75182
  );
74903
75183
  }
75184
+ const existingRoot = existingValueById.get(valueId);
75185
+ const existingConstructedRoot = existingRoot !== void 0 && isLiteralValueContent(existingRoot) && (typeof existingRoot.classId === "string" || existingRoot.constructorArgs !== void 0 && existingRoot.constructorArgs !== null);
74904
75186
  const materialized = materializeInitializerValue({
74905
75187
  document: compiledDocument,
74906
75188
  member,
74907
- row: site.row
75189
+ row: site.row,
75190
+ ...existingConstructedRoot ? { storedConstructionReplay: true } : {}
74908
75191
  });
74909
- const existingRoot = existingValueById.get(valueId);
74910
- const existingConstructedRoot = existingRoot !== void 0 && isLiteralValueContent(existingRoot) && (typeof existingRoot.classId === "string" || existingRoot.constructorArgs !== void 0 && existingRoot.constructorArgs !== null);
74911
75192
  if (existingConstructedRoot) {
74912
75193
  if (!isLiteralValueContent(materialized.root) || existingRoot.classId !== materialized.root.classId || !replayedCreationDataMatches({
74913
75194
  currentDocument: args.document,
@@ -77091,6 +77372,9 @@ function prepareServerOwnedValueInitializerBodies(args) {
77091
77372
  void 0,
77092
77373
  rootOwnerByValueId
77093
77374
  );
77375
+ const currentValueById = new Map(
77376
+ args.document.values.map((value) => [value.id, value])
77377
+ );
77094
77378
  const compileOne = (document, row) => {
77095
77379
  const member = ownerByValueId.get(row.id);
77096
77380
  if (member === void 0) {
@@ -77098,6 +77382,8 @@ function prepareServerOwnedValueInitializerBodies(args) {
77098
77382
  `Value "${row.id}" carries an initializer but no member in this project version stores it, so its declared type is unknown.`
77099
77383
  );
77100
77384
  }
77385
+ const currentValue = currentValueById.get(row.id);
77386
+ const replaysStoredConstruction = isLiteralValueContent(currentValue) && (typeof currentValue.classId === "string" || currentValue.constructorArgs !== void 0);
77101
77387
  compileValueRowInitializerBody({
77102
77388
  project: document.project,
77103
77389
  projectFiles: document.projectFiles,
@@ -77112,7 +77398,8 @@ function prepareServerOwnedValueInitializerBodies(args) {
77112
77398
  initializerOwnerClass: findSchemaPlacement(
77113
77399
  rootOwnerByValueId.get(row.id)?.id ?? "",
77114
77400
  document.classes
77115
- )?.ownerClass ?? null
77401
+ )?.ownerClass ?? null,
77402
+ ...replaysStoredConstruction ? { storedConstructionReplay: true } : {}
77116
77403
  });
77117
77404
  };
77118
77405
  for (const [index, row] of explicitRows) {
@@ -77210,22 +77497,29 @@ function prepareServerOwnedDelegateValueBodies(args) {
77210
77497
  `Value "${row.id}" carries a NeoDelegate closure but no NeoDelegate member in this project version stores it.`
77211
77498
  );
77212
77499
  }
77213
- row.value = compileDelegateClosureValue(row.value.code, {
77214
- project: document.project,
77215
- projectFiles: document.projectFiles,
77216
- members: document.members,
77217
- classes: document.classes,
77218
- enums: document.enums,
77219
- interfaces: document.interfaces,
77220
- constructors: document.constructors ?? [],
77221
- thisClass: findSchemaPlacement(
77222
- rootOwnerByValueId.get(row.id)?.id ?? "",
77223
- document.classes
77224
- )?.ownerClass ?? null,
77225
- returnTypeInfo: member.returnTypeInfo,
77226
- argumentTypes: member.argumentTypes,
77227
- name: `${member.name} value`
77228
- });
77500
+ const rootOwner = rootOwnerByValueId.get(row.id);
77501
+ const thisClass = findSchemaPlacement(rootOwner?.id ?? "", document.classes)?.ownerClass ?? null;
77502
+ try {
77503
+ row.value = compileDelegateClosureValue(row.value.code, {
77504
+ project: document.project,
77505
+ projectFiles: document.projectFiles,
77506
+ members: document.members,
77507
+ classes: document.classes,
77508
+ enums: document.enums,
77509
+ interfaces: document.interfaces,
77510
+ constructors: document.constructors ?? [],
77511
+ thisClass,
77512
+ returnTypeInfo: member.returnTypeInfo,
77513
+ argumentTypes: member.argumentTypes,
77514
+ name: `${member.name} value`
77515
+ });
77516
+ } catch (error) {
77517
+ const detail = error instanceof Error ? error.message : String(error);
77518
+ throw new Error(
77519
+ `Value "${row.id}" NeoDelegate closure failed under member "${member.name}" (${getOptionalString(member, "id") ?? "unknown"}), root owner "${rootOwner?.name ?? "unknown"}" (${getOptionalString(rootOwner, "id") ?? "unknown"}), lexical class "${thisClass?.name ?? "none"}" (${thisClass?.id ?? "none"}), and return type ${canonicalJsonStringify(member.returnTypeInfo)}: ${detail}`,
77520
+ { cause: error }
77521
+ );
77522
+ }
77229
77523
  };
77230
77524
  for (const [index, row] of explicitRows) {
77231
77525
  const compiled = { ...row, value: { ...row.value } };
@@ -77780,6 +78074,7 @@ var init_project_version_schema_commit = __esm({
77780
78074
  init_members();
77781
78075
  init_inheritance();
77782
78076
  init_generics();
78077
+ init_core();
77783
78078
  init_world_content_sidecar_validation();
77784
78079
  init_project_document_value_overlay();
77785
78080
  init_project2();
@@ -81147,8 +81442,22 @@ var init_server_preparation_preflight = __esm({
81147
81442
  // src/project-source/initializer-replay.ts
81148
81443
  function replayStoredConstructionV4(args) {
81149
81444
  const document = args.document ?? readPulledProjectDocumentV4(args.records);
81445
+ const compilationProject = args.compilationProject ?? (args.compileDocumentBodies === true ? createNeoScriptCompilationProject({
81446
+ project: document.project,
81447
+ projectFiles: document.projectFiles,
81448
+ members: document.members,
81449
+ classes: document.classes,
81450
+ enums: document.enums,
81451
+ interfaces: document.interfaces,
81452
+ constructors: document.constructors ?? []
81453
+ }) : void 0);
81150
81454
  if (args.compileDocumentBodies === true) {
81151
- compilePulledProjectDocumentBodiesV4(document);
81455
+ if (compilationProject === void 0) {
81456
+ throw new Error(
81457
+ "Construction replay cannot compile document bodies without a compiler project."
81458
+ );
81459
+ }
81460
+ compilePulledProjectDocumentBodiesV4(document, compilationProject);
81152
81461
  }
81153
81462
  const root = document.values.find((value) => value.id === args.valueId);
81154
81463
  if (root === void 0) {
@@ -81201,7 +81510,7 @@ function replayStoredConstructionV4(args) {
81201
81510
  // header parameters that are in lexical scope at their source site.
81202
81511
  initializerOwnerClass: args.initializerOwnerClass ?? null,
81203
81512
  storedConstructionReplay: true,
81204
- ...args.compilationProject === void 0 ? {} : { compilationProject: args.compilationProject }
81513
+ ...compilationProject === void 0 ? {} : { compilationProject }
81205
81514
  });
81206
81515
  if (!isMemberValue(candidate) || !isInitValueContent(candidate)) {
81207
81516
  throw new Error(
@@ -81224,11 +81533,24 @@ function replayStoredConstructionV4(args) {
81224
81533
  });
81225
81534
  break;
81226
81535
  } catch (error) {
81227
- if (!(error instanceof UncompiledInitializerRuntimeError) || error.memberId === null || compiledDependencies.has(error.memberId)) {
81536
+ const dependencyKey = error instanceof UncompiledInitializerRuntimeError && error.valueId !== null ? error.valueId : error instanceof UncompiledInitializerRuntimeError && error.initializer !== null ? error.initializer : error instanceof UncompiledInitializerRuntimeError ? error.memberId : null;
81537
+ if (!(error instanceof UncompiledInitializerRuntimeError) || error.memberId === null || dependencyKey === null || compiledDependencies.has(dependencyKey)) {
81228
81538
  throw error;
81229
81539
  }
81230
- compilePulledMemberInitializerBodyV4(document, error.memberId);
81231
- compiledDependencies.add(error.memberId);
81540
+ if (error.valueId !== null) {
81541
+ compilePulledValueInitializerBodyV4(
81542
+ document,
81543
+ error.valueId,
81544
+ compilationProject
81545
+ );
81546
+ } else {
81547
+ compilePulledMemberInitializerBodyV4(
81548
+ document,
81549
+ error.memberId,
81550
+ compilationProject
81551
+ );
81552
+ }
81553
+ compiledDependencies.add(dependencyKey);
81232
81554
  }
81233
81555
  }
81234
81556
  return new Map(
@@ -81238,7 +81560,55 @@ function replayStoredConstructionV4(args) {
81238
81560
  ])
81239
81561
  );
81240
81562
  }
81241
- function compilePulledProjectDocumentBodiesV4(document) {
81563
+ function valueInitializerCompilationSites(document) {
81564
+ const cached = pulledValueInitializerCompilationSites.get(document);
81565
+ if (cached !== void 0) return cached;
81566
+ const rows = document.values.filter(isInitValueContent);
81567
+ const rootOwners = /* @__PURE__ */ new Map();
81568
+ const owners = resolveOwnerMembersForValues(
81569
+ document,
81570
+ new Set(rows.map((row) => row.id)),
81571
+ void 0,
81572
+ rootOwners
81573
+ );
81574
+ const sites = /* @__PURE__ */ new Map();
81575
+ for (const row of rows) {
81576
+ const member = owners.get(row.id);
81577
+ if (member === void 0) continue;
81578
+ const rootOwnerId = Reflect.get(rootOwners.get(row.id) ?? {}, "id");
81579
+ sites.set(row.id, {
81580
+ row,
81581
+ member,
81582
+ ownerClass: typeof rootOwnerId !== "string" ? null : findSchemaPlacement(rootOwnerId, document.classes)?.ownerClass ?? null
81583
+ });
81584
+ }
81585
+ pulledValueInitializerCompilationSites.set(document, sites);
81586
+ return sites;
81587
+ }
81588
+ function compilePulledValueInitializerBodyV4(document, valueId, compilationProject) {
81589
+ const site = valueInitializerCompilationSites(document).get(valueId);
81590
+ if (site === void 0) {
81591
+ throw new Error(
81592
+ "Cannot compile initializer dependency because its source value row is unresolved."
81593
+ );
81594
+ }
81595
+ compileValueRowInitializerBody({
81596
+ project: document.project,
81597
+ projectFiles: document.projectFiles,
81598
+ members: document.members,
81599
+ classes: document.classes,
81600
+ enums: document.enums,
81601
+ interfaces: document.interfaces,
81602
+ constructors: document.constructors ?? [],
81603
+ member: site.member,
81604
+ valueRow: site.row,
81605
+ valueId: String(Reflect.get(site.row, "id")),
81606
+ initializerOwnerClass: site.ownerClass,
81607
+ storedConstructionReplay: true,
81608
+ ...compilationProject === void 0 ? {} : { compilationProject }
81609
+ });
81610
+ }
81611
+ function compilePulledProjectDocumentBodiesV4(document, compilationProject) {
81242
81612
  const compileArgs = {
81243
81613
  project: document.project,
81244
81614
  projectFiles: document.projectFiles,
@@ -81246,7 +81616,8 @@ function compilePulledProjectDocumentBodiesV4(document) {
81246
81616
  classes: document.classes,
81247
81617
  enums: document.enums,
81248
81618
  interfaces: document.interfaces,
81249
- constructors: document.constructors ?? []
81619
+ constructors: document.constructors ?? [],
81620
+ compilationProject
81250
81621
  };
81251
81622
  for (const constructor2 of compileArgs.constructors) {
81252
81623
  compileConstructorRecord({ ...compileArgs, constructor: constructor2 });
@@ -81277,7 +81648,7 @@ function assertPulledConstructorsCompiled(document) {
81277
81648
  );
81278
81649
  }
81279
81650
  }
81280
- function compilePulledMemberInitializerBodyV4(document, memberId) {
81651
+ function compilePulledMemberInitializerBodyV4(document, memberId, compilationProject) {
81281
81652
  const compileArgs = {
81282
81653
  project: document.project,
81283
81654
  projectFiles: document.projectFiles,
@@ -81299,12 +81670,16 @@ function compilePulledMemberInitializerBodyV4(document, memberId) {
81299
81670
  compileMemberInitializerBody({
81300
81671
  ...compileArgs,
81301
81672
  member,
81302
- thisClass
81673
+ thisClass,
81674
+ ...compilationProject === void 0 ? {} : { compilationProject }
81303
81675
  });
81304
81676
  }
81305
81677
  function readPulledProjectDocumentV4(records2) {
81306
81678
  return readProjectDocument(
81307
- pulledProjectDocumentRaw(replayWorkspace(records2)),
81679
+ // Replay compilation mutates authored `init` envelopes with transient IR.
81680
+ // Keep that evaluator-local: the input records are also the source commit
81681
+ // payload, where compiled bodies are deliberately absent.
81682
+ structuredClone(pulledProjectDocumentRaw(replayWorkspace(records2))),
81308
81683
  { constructors: "authored-or-compiled" }
81309
81684
  );
81310
81685
  }
@@ -81335,6 +81710,7 @@ function replayWorkspace(records2) {
81335
81710
  state: { records: stateRecords }
81336
81711
  };
81337
81712
  }
81713
+ var pulledValueInitializerCompilationSites;
81338
81714
  var init_initializer_replay = __esm({
81339
81715
  "src/project-source/initializer-replay.ts"() {
81340
81716
  "use strict";
@@ -81342,11 +81718,14 @@ var init_initializer_replay = __esm({
81342
81718
  init_compile_ns_property();
81343
81719
  init_init_backed_value_materialization();
81344
81720
  init_value_row_owner_members();
81721
+ init_inheritance();
81345
81722
  init_project_document_read();
81346
81723
  init_server_preparation_preflight();
81347
81724
  init_projection();
81348
81725
  init_constructors2();
81349
81726
  init_neoscript_evaluator();
81727
+ init_compiler_adapter();
81728
+ pulledValueInitializerCompilationSites = /* @__PURE__ */ new WeakMap();
81350
81729
  }
81351
81730
  });
81352
81731
 
@@ -81373,10 +81752,13 @@ function buildValueEmitContext(records2, manifest) {
81373
81752
  const symbolsByValueId = staticSymbols(classes, members);
81374
81753
  let document;
81375
81754
  const readDocument = () => document ??= readPulledProjectDocumentV4(records2);
81755
+ let compilationProject;
81756
+ const readCompilationProject = () => compilationProject ??= createNeoScriptCompilationProject(readDocument());
81376
81757
  let materializedGraph;
81377
81758
  return {
81378
81759
  records: records2,
81379
81760
  readDocument,
81761
+ readCompilationProject,
81380
81762
  readMaterializedGraph: () => {
81381
81763
  if (materializedGraph !== void 0) return materializedGraph;
81382
81764
  materializedGraph = new MaterializedValueGraphContext(
@@ -81524,8 +81906,10 @@ function animationConstructorProjectionTargetValueIds(context, classId, value) {
81524
81906
  return [];
81525
81907
  }
81526
81908
  const targetIds = [];
81527
- for (const projection of inheritedConstructorProjections2(
81909
+ for (const projection of effectiveConstructorProjections(
81528
81910
  context.manifestClasses,
81911
+ context.manifestConstructors,
81912
+ context.manifestMembers,
81529
81913
  classId
81530
81914
  )) {
81531
81915
  const schemaKey = inheritedProjectionSchemaKey(
@@ -82503,9 +82887,10 @@ function lowerRowBackedDefault(context, member, backed, baseData3, binding) {
82503
82887
  const assignmentSlices = objectInitializerSlices(binding.initializer);
82504
82888
  for (const assignment of expression.initializer ?? []) {
82505
82889
  const childMember = classMemberByName(context, classId, assignment.name);
82506
- if (inheritedConstructorProjections2(context.classes, schemaClass2.id).some(
82507
- (projection) => projection.memberId === childMember.id
82508
- )) {
82890
+ if (inheritedLegacyConstructorProjections(
82891
+ context.classes,
82892
+ schemaClass2.id
82893
+ ).some((projection) => projection.memberId === childMember.id)) {
82509
82894
  throw new Error(
82510
82895
  `Default value ${binding.label}.${assignment.name} is constructor-projected and must be set through its named constructor argument.`
82511
82896
  );
@@ -82916,7 +83301,7 @@ function lowerSeedRow(context, member, sourceExpression, source, valueId, path,
82916
83301
  effectiveClass.id,
82917
83302
  assignment.name
82918
83303
  );
82919
- if (inheritedConstructorProjections2(
83304
+ if (inheritedLegacyConstructorProjections(
82920
83305
  context.classes,
82921
83306
  effectiveClass.id
82922
83307
  ).some((projection) => projection.memberId === childMember.id)) {
@@ -83419,9 +83804,10 @@ function lowerClassValue(context, member, expression, base, source, outerEnviron
83419
83804
  }
83420
83805
  for (const assignment of expression.initializer ?? []) {
83421
83806
  const childMember = classMemberByName(context, classId, assignment.name);
83422
- if (inheritedConstructorProjections2(context.classes, schemaClass2.id).some(
83423
- (projection) => projection.memberId === childMember.id
83424
- )) {
83807
+ if (inheritedLegacyConstructorProjections(
83808
+ context.classes,
83809
+ schemaClass2.id
83810
+ ).some((projection) => projection.memberId === childMember.id)) {
83425
83811
  throw new Error(
83426
83812
  `Class value ${String(base.id)}.${assignment.name} is constructor-projected and must be set through its named constructor argument.`
83427
83813
  );
@@ -83601,7 +83987,7 @@ function classInheritanceChain(classes, classId) {
83601
83987
  }
83602
83988
  return chain;
83603
83989
  }
83604
- function inheritedConstructorProjections2(classes, classId) {
83990
+ function inheritedLegacyConstructorProjections(classes, classId) {
83605
83991
  const resolved = [];
83606
83992
  const claimed = /* @__PURE__ */ new Set();
83607
83993
  for (const schemaClass2 of classInheritanceChain(classes, classId)) {
@@ -83613,6 +83999,67 @@ function inheritedConstructorProjections2(classes, classId) {
83613
83999
  }
83614
84000
  return resolved;
83615
84001
  }
84002
+ function effectiveConstructorProjections(classes, constructors, members, classId) {
84003
+ const schemaClass2 = classes.get(classId);
84004
+ const requiredId = schemaClass2?.requiredConstructorId;
84005
+ if (schemaClass2 === void 0 || requiredId === void 0) {
84006
+ return inheritedLegacyConstructorProjections(classes, classId);
84007
+ }
84008
+ const required2 = constructors.get(requiredId);
84009
+ if (required2 === void 0) return [];
84010
+ const projected = requiredConstructorProjectionMap(
84011
+ classes,
84012
+ constructors,
84013
+ members,
84014
+ classId,
84015
+ /* @__PURE__ */ new Set()
84016
+ );
84017
+ if (required2.arguments.some((parameter3) => !projected.has(parameter3.name))) {
84018
+ return [];
84019
+ }
84020
+ return required2.arguments.map((parameter3) => ({
84021
+ parameterName: parameter3.name,
84022
+ memberId: projected.get(parameter3.name)
84023
+ }));
84024
+ }
84025
+ function requiredConstructorProjectionMap(classes, constructors, members, classId, visited) {
84026
+ if (visited.has(classId)) return /* @__PURE__ */ new Map();
84027
+ const schemaClass2 = classes.get(classId);
84028
+ const requiredId = schemaClass2?.requiredConstructorId;
84029
+ const required2 = requiredId === void 0 ? void 0 : constructors.get(requiredId);
84030
+ if (schemaClass2 === void 0 || required2 === void 0) return /* @__PURE__ */ new Map();
84031
+ const result = /* @__PURE__ */ new Map();
84032
+ for (const memberId of Object.values(schemaClass2.schema)) {
84033
+ const initializer = members.get(memberId)?.defaultValue;
84034
+ if (initializer === null || initializer === void 0 || !("init" in initializer)) {
84035
+ continue;
84036
+ }
84037
+ const parameterName = initializer.init.code.trim();
84038
+ if (required2.arguments.some((parameter3) => parameter3.name === parameterName)) {
84039
+ result.set(parameterName, memberId);
84040
+ }
84041
+ }
84042
+ const baseClassId = schemaClass2.extendsClassId;
84043
+ if (baseClassId === null) return result;
84044
+ const base = requiredConstructorProjectionMap(
84045
+ classes,
84046
+ constructors,
84047
+ members,
84048
+ baseClassId,
84049
+ /* @__PURE__ */ new Set([...visited, classId])
84050
+ );
84051
+ for (const forwarded of required2.baseArguments ?? []) {
84052
+ const sourceName = forwarded.code.trim();
84053
+ if (!required2.arguments.some((parameter3) => parameter3.name === sourceName)) {
84054
+ continue;
84055
+ }
84056
+ const memberId = base.get(forwarded.name);
84057
+ if (memberId !== void 0 && !result.has(sourceName)) {
84058
+ result.set(sourceName, memberId);
84059
+ }
84060
+ }
84061
+ return result;
84062
+ }
83616
84063
  function inheritedProjectionSchemaKey(classes, classId, memberId) {
83617
84064
  for (const schemaClass2 of classInheritanceChain(classes, classId)) {
83618
84065
  for (const [schemaKey, declared] of Object.entries(schemaClass2.schema)) {
@@ -83622,8 +84069,10 @@ function inheritedProjectionSchemaKey(classes, classId, memberId) {
83622
84069
  return null;
83623
84070
  }
83624
84071
  function resolveConstructorProjectionArguments(context, schemaClass2, expression, ownerValueId, environment, source) {
83625
- const projections = inheritedConstructorProjections2(
84072
+ const projections = effectiveConstructorProjections(
83626
84073
  context.classes,
84074
+ context.manifestConstructors,
84075
+ context.members,
83627
84076
  schemaClass2.id
83628
84077
  );
83629
84078
  const signature = describeProjectedConstructor(schemaClass2.name, projections);
@@ -85277,13 +85726,37 @@ function classValue(context, member, value, visited, targetTyped, outerEnvironme
85277
85726
  if (!isObjectRecord2(value.value))
85278
85727
  return targetTyped ? "new()" : `new ${classValueTypeName(context, classId, member, storedEnvironment)}()`;
85279
85728
  const schema = isObjectRecord2(schemaClass2.schema) ? schemaClass2.schema : {};
85280
- const projection = constructorProjectionSource(
85281
- context,
85282
- classId,
85283
- value.value,
85284
- visited,
85285
- storedEnvironment
85286
- );
85729
+ const hasStoredConstruction = isObjectRecord2(value.constructorArgs);
85730
+ let projection;
85731
+ try {
85732
+ projection = hasStoredConstruction ? {
85733
+ arguments: [],
85734
+ memberIds: new Set(
85735
+ effectiveConstructorProjections(
85736
+ context.manifestClasses,
85737
+ context.manifestConstructors,
85738
+ context.manifestMembers,
85739
+ classId
85740
+ ).map((entry) => entry.memberId)
85741
+ ),
85742
+ targetValueIds: animationConstructorProjectionTargetValueIds(
85743
+ context,
85744
+ classId,
85745
+ value
85746
+ )
85747
+ } : constructorProjectionSource(
85748
+ context,
85749
+ classId,
85750
+ value.value,
85751
+ visited,
85752
+ storedEnvironment
85753
+ );
85754
+ } catch (error) {
85755
+ throw new Error(
85756
+ `Constructor projection for value "${String(value.id ?? "unknown")}" of class "${schemaClass2.name}" cannot be emitted: ${error instanceof Error ? error.message : String(error)}`,
85757
+ { cause: error }
85758
+ );
85759
+ }
85287
85760
  const environment = inferAnimationChildOverrideEmitEnvironment(
85288
85761
  context,
85289
85762
  classId,
@@ -85291,15 +85764,23 @@ function classValue(context, member, value, visited, targetTyped, outerEnvironme
85291
85764
  storedEnvironment
85292
85765
  );
85293
85766
  const name = classValueTypeName(context, classId, member, environment);
85294
- const storedConstruction = storedConstructorCallSource(
85295
- context,
85296
- schemaClass2,
85297
- value,
85298
- name,
85299
- environment,
85300
- visited,
85301
- targetTyped
85302
- );
85767
+ let storedConstruction;
85768
+ try {
85769
+ storedConstruction = storedConstructorCallSource(
85770
+ context,
85771
+ schemaClass2,
85772
+ value,
85773
+ name,
85774
+ environment,
85775
+ visited,
85776
+ targetTyped
85777
+ );
85778
+ } catch (error) {
85779
+ throw new Error(
85780
+ `Stored construction for value "${String(value.id ?? "unknown")}" of class "${name}" cannot be emitted: ${error instanceof Error ? error.message : String(error)}`,
85781
+ { cause: error }
85782
+ );
85783
+ }
85303
85784
  if (storedConstruction !== null && typeof value.id === "string") {
85304
85785
  context.materializedConstructors.set(value.id, storedConstruction);
85305
85786
  }
@@ -85317,7 +85798,7 @@ function classValue(context, member, value, visited, targetTyped, outerEnvironme
85317
85798
  context,
85318
85799
  value.id,
85319
85800
  replayConstruction,
85320
- member
85801
+ concreteClassMemberForReplay(member, environment)
85321
85802
  );
85322
85803
  const replayRoot = replayRows === null || typeof value.id !== "string" ? void 0 : replayRows.get(value.id);
85323
85804
  const replayGraph = replayRows === null || typeof value.id !== "string" ? null : context.readMaterializedGraph().withRowOverrides(
@@ -85403,11 +85884,27 @@ function storedConstructionReplayRows(context, valueId, code, member) {
85403
85884
  document: context.readDocument(),
85404
85885
  valueId,
85405
85886
  code,
85406
- member
85887
+ member,
85888
+ compilationProject: context.readCompilationProject()
85407
85889
  });
85408
85890
  context.constructionReplays.set(valueId, replay);
85409
85891
  return replay;
85410
85892
  }
85893
+ function concreteClassMemberForReplay(member, environment) {
85894
+ if (numberField(member, "kind") !== 7 /* Class */) return member;
85895
+ const classArguments2 = isObjectRecord2(member.classArguments) ? member.classArguments : {};
85896
+ let changed = false;
85897
+ const concreteArguments = Object.fromEntries(
85898
+ Object.entries(classArguments2).map(([genericParamId, binding]) => {
85899
+ const forwardedParamId = isObjectRecord2(binding) && binding.kind === "generic" && typeof binding.genericParamId === "string" ? binding.genericParamId : null;
85900
+ const bindingMemberId = environment.get(genericParamId) ?? (forwardedParamId === null ? void 0 : environment.get(forwardedParamId));
85901
+ if (bindingMemberId === void 0) return [genericParamId, binding];
85902
+ changed = true;
85903
+ return [genericParamId, { kind: "member", memberId: bindingMemberId }];
85904
+ })
85905
+ );
85906
+ return changed ? { ...member, classArguments: concreteArguments } : member;
85907
+ }
85411
85908
  function materializedValueSubgraphsEqual(context, currentGraph, replayGraph, currentId, replayId, member, environment) {
85412
85909
  const resolvedMember = resolveGenericValueMember(
85413
85910
  context,
@@ -85579,8 +86076,30 @@ function storedConstructorArgumentSource(context, type, value, environment, visi
85579
86076
  false
85580
86077
  );
85581
86078
  }
86079
+ case "generic": {
86080
+ const bindingId = environment.get(type.genericParamId);
86081
+ const inferredClassId = inferredGenericClassId(bindingId);
86082
+ const resolvedType = inferredClassId === null ? bindingId === void 0 ? null : schemaTypeForBindingMember(context, bindingId, environment) : {
86083
+ kind: "class",
86084
+ nullable: type.nullable,
86085
+ classId: inferredClassId,
86086
+ classArguments: {}
86087
+ };
86088
+ if (resolvedType === null) {
86089
+ throw new Error(
86090
+ `Stored Generic constructor argument cannot resolve parameter ${type.genericParamId}.`
86091
+ );
86092
+ }
86093
+ return storedConstructorArgumentSource(
86094
+ context,
86095
+ { ...resolvedType, nullable: type.nullable || resolvedType.nullable },
86096
+ value,
86097
+ environment,
86098
+ visited,
86099
+ cloneAggregateArguments
86100
+ );
86101
+ }
85582
86102
  case "interface":
85583
- case "generic":
85584
86103
  case "list":
85585
86104
  case "dictionary":
85586
86105
  if (typeof value !== "string") {
@@ -85631,6 +86150,147 @@ function storedConstructorArgumentSource(context, type, value, environment, visi
85631
86150
  );
85632
86151
  }
85633
86152
  }
86153
+ function schemaTypeForBindingMember(context, memberId, environment, visited = /* @__PURE__ */ new Set()) {
86154
+ if (visited.has(memberId)) {
86155
+ throw new Error(
86156
+ `Stored constructor argument generic binding contains a member cycle at ${memberId}.`
86157
+ );
86158
+ }
86159
+ const member = context.manifestMembers.get(memberId);
86160
+ if (member === void 0) {
86161
+ throw new Error(
86162
+ `Stored constructor argument generic binding names missing member ${memberId}.`
86163
+ );
86164
+ }
86165
+ const nullable = !member.required;
86166
+ const nextVisited = /* @__PURE__ */ new Set([...visited, memberId]);
86167
+ switch (member.kind) {
86168
+ case "null":
86169
+ case "bool":
86170
+ case "int":
86171
+ case "string":
86172
+ case "float":
86173
+ case "decimal":
86174
+ case "sprite":
86175
+ case "audio":
86176
+ case "vector2":
86177
+ case "vector2Int":
86178
+ case "vector3":
86179
+ case "vector3Int":
86180
+ case "color":
86181
+ return { kind: member.kind, nullable };
86182
+ case "class":
86183
+ return {
86184
+ kind: "class",
86185
+ nullable,
86186
+ classId: member.classId,
86187
+ classArguments: Object.fromEntries(
86188
+ Object.entries(member.classArguments).map(
86189
+ ([parameterId, binding]) => [
86190
+ parameterId,
86191
+ binding.kind === "member" ? schemaTypeForBindingMember(
86192
+ context,
86193
+ binding.memberId,
86194
+ environment,
86195
+ nextVisited
86196
+ ) : schemaTypeForBindingMember(
86197
+ context,
86198
+ requiredGenericBindingMemberId(
86199
+ environment,
86200
+ binding.genericParamId
86201
+ ),
86202
+ environment,
86203
+ nextVisited
86204
+ )
86205
+ ]
86206
+ )
86207
+ )
86208
+ };
86209
+ case "enum":
86210
+ return { kind: "enum", nullable, enumId: member.enumId };
86211
+ case "list":
86212
+ return {
86213
+ kind: "list",
86214
+ nullable,
86215
+ entryType: schemaTypeForBindingMember(
86216
+ context,
86217
+ member.entryMemberId,
86218
+ environment,
86219
+ nextVisited
86220
+ ),
86221
+ listMemberId: member.id,
86222
+ readOnly: member.isReadOnly
86223
+ };
86224
+ case "dictionary":
86225
+ return {
86226
+ kind: "dictionary",
86227
+ nullable,
86228
+ entryType: schemaTypeForBindingMember(
86229
+ context,
86230
+ member.entryMemberId,
86231
+ environment,
86232
+ nextVisited
86233
+ ),
86234
+ keyEnumId: member.key.kind === "enum" ? member.key.enumId : null,
86235
+ readOnly: member.isReadOnly
86236
+ };
86237
+ case "lookup": {
86238
+ if (member.declaredType !== null) {
86239
+ return { ...member.declaredType, nullable };
86240
+ }
86241
+ const collection = context.manifestMembers.get(member.collectionMemberId);
86242
+ if (collection?.kind !== "list" && collection?.kind !== "dictionary") {
86243
+ throw new Error(
86244
+ `Stored constructor argument Lookup binding ${member.id} has no collection entry type.`
86245
+ );
86246
+ }
86247
+ return {
86248
+ kind: "lookup",
86249
+ nullable,
86250
+ entryType: schemaTypeForBindingMember(
86251
+ context,
86252
+ collection.entryMemberId,
86253
+ environment,
86254
+ nextVisited
86255
+ ),
86256
+ collectionMemberId: member.collectionMemberId,
86257
+ collectionValueId: member.collectionValueId
86258
+ };
86259
+ }
86260
+ case "dialogueLookup":
86261
+ return { kind: "dialogueLookup", nullable };
86262
+ case "delegate":
86263
+ return {
86264
+ kind: "delegate",
86265
+ nullable,
86266
+ returnType: member.returnType,
86267
+ argumentTypes: member.arguments.map((argument2) => argument2.type)
86268
+ };
86269
+ case "generic":
86270
+ return schemaTypeForBindingMember(
86271
+ context,
86272
+ requiredGenericBindingMemberId(environment, member.genericParamId),
86273
+ environment,
86274
+ nextVisited
86275
+ );
86276
+ case "computed":
86277
+ case "function":
86278
+ case "scriptFunction":
86279
+ case "functionRef":
86280
+ throw new Error(
86281
+ `Stored constructor argument cannot use ${member.kind} member ${member.id} as a generic type binding.`
86282
+ );
86283
+ }
86284
+ }
86285
+ function requiredGenericBindingMemberId(environment, genericParamId) {
86286
+ const bindingId = environment.get(genericParamId);
86287
+ if (bindingId === void 0 || inferredGenericClassId(bindingId) !== null) {
86288
+ throw new Error(
86289
+ `Stored constructor argument cannot resolve generic binding ${genericParamId} to a member.`
86290
+ );
86291
+ }
86292
+ return bindingId;
86293
+ }
85634
86294
  function storedAggregateCloneSource(context, type, valueId, environment) {
85635
86295
  if (!context.values.has(valueId)) {
85636
86296
  throw new Error(
@@ -85930,8 +86590,10 @@ function manifestMemberTypeName(context, member) {
85930
86590
  return fixedSourceTypeNameForKind(member.kind) ?? member.kind;
85931
86591
  }
85932
86592
  function constructorProjectionSource(context, classId, body, visited, environment) {
85933
- const projections = inheritedConstructorProjections2(
86593
+ const projections = effectiveConstructorProjections(
85934
86594
  context.manifestClasses,
86595
+ context.manifestConstructors,
86596
+ context.manifestMembers,
85935
86597
  classId
85936
86598
  );
85937
86599
  const argumentsValue = [];
@@ -86525,6 +87187,7 @@ var init_value_sources = __esm({
86525
87187
  init_member_value_id();
86526
87188
  init_members();
86527
87189
  init_compile_ns_property();
87190
+ init_compile();
86528
87191
  init_constructor_argument_ownership();
86529
87192
  init_structured_leaf_source();
86530
87193
  init_member_kind_type_names();
@@ -88762,6 +89425,10 @@ async function runPull(workspace, options) {
88762
89425
  async function runNormalPull(workspace, options, progress) {
88763
89426
  const destructive = options.force;
88764
89427
  const hasBaseline = Object.keys(workspace.state.records).length > 0;
89428
+ const mainLocale = workspaceMainLocale(workspace.state.records);
89429
+ if (acceptSourceEquivalentConflictBases(workspace, mainLocale) > 0) {
89430
+ writeWorkspaceState(workspace.root, workspace.state);
89431
+ }
88765
89432
  let localByKey = /* @__PURE__ */ new Map();
88766
89433
  let localStatus = null;
88767
89434
  if (hasBaseline && !destructive) {
@@ -88854,10 +89521,11 @@ ${blockingErrors.map((error) => ` ${error.message}`).join("\n")}`
88854
89521
  continue;
88855
89522
  }
88856
89523
  const serverChanged = serverRecord.contentHash !== baseState.contentHash;
88857
- const localChanged = local !== void 0 && baseState.file !== void 0 && !authoredRecordsSemanticallyEqual(
89524
+ const localChanged = local !== void 0 && baseState.file !== void 0 && !sourceAuthoredRecordsSemanticallyEqual(
88858
89525
  serverRecord.recordKind,
88859
89526
  local,
88860
- baseState.data
89527
+ baseState.data,
89528
+ mainLocale
88861
89529
  );
88862
89530
  const locallyDeleted = hasBaseline && baseState.file !== void 0 && local === void 0;
88863
89531
  if (!serverChanged) {
@@ -88866,7 +89534,8 @@ ${blockingErrors.map((error) => ` ${error.message}`).join("\n")}`
88866
89534
  serverRecord.recordKind,
88867
89535
  baseState.data,
88868
89536
  serverRecord.data,
88869
- local
89537
+ local,
89538
+ mainLocale
88870
89539
  ).merged,
88871
89540
  serverHash: baseState.contentHash,
88872
89541
  serverData: baseState.data,
@@ -88888,7 +89557,8 @@ ${blockingErrors.map((error) => ` ${error.message}`).join("\n")}`
88888
89557
  serverRecord.recordKind,
88889
89558
  baseState.data,
88890
89559
  serverRecord.data,
88891
- localSide
89560
+ localSide,
89561
+ mainLocale
88892
89562
  );
88893
89563
  if (locallyDeleted || conflictFields.length > 0) {
88894
89564
  conflictCount += 1;
@@ -88921,10 +89591,11 @@ ${blockingErrors.map((error) => ` ${error.message}`).join("\n")}`
88921
89591
  if (baseState !== void 0 && !document.records.has(key)) {
88922
89592
  const binary = localBinaryById.get(baseState.recordId);
88923
89593
  const binaryChanged = binary !== void 0 && binary.action !== "unchanged" && binary.action !== "converged";
88924
- if (authoredRecordsSemanticallyEqual(
89594
+ if (sourceAuthoredRecordsSemanticallyEqual(
88925
89595
  baseState.recordKind,
88926
89596
  local,
88927
- baseState.data
89597
+ baseState.data,
89598
+ mainLocale
88928
89599
  ) && !binaryChanged) {
88929
89600
  continue;
88930
89601
  }
@@ -89385,6 +90056,30 @@ function sourceComparableRecord(recordKind, value, mainLocale) {
89385
90056
  }
89386
90057
  return result;
89387
90058
  }
90059
+ function acceptSourceEquivalentConflictBases(workspace, mainLocale) {
90060
+ let accepted = 0;
90061
+ for (const [key, record3] of Object.entries(workspace.state.records)) {
90062
+ if (typeof record3.conflictServerHash !== "string") continue;
90063
+ if (!sourceAuthoredRecordsSemanticallyEqual(
90064
+ record3.recordKind,
90065
+ record3.data,
90066
+ record3.conflictServerData,
90067
+ mainLocale
90068
+ )) {
90069
+ continue;
90070
+ }
90071
+ const next = {
90072
+ ...record3,
90073
+ contentHash: record3.conflictServerHash,
90074
+ data: record3.conflictServerData
90075
+ };
90076
+ delete next.conflictServerHash;
90077
+ delete next.conflictServerData;
90078
+ workspace.state.records[key] = next;
90079
+ accepted += 1;
90080
+ }
90081
+ return accepted;
90082
+ }
89388
90083
  function workspaceMainLocale(records2) {
89389
90084
  const config = Object.values(records2).find(
89390
90085
  (record3) => record3.recordKind === "localization-config"
@@ -89392,11 +90087,27 @@ function workspaceMainLocale(records2) {
89392
90087
  const data = config?.data;
89393
90088
  return isObjectRecord2(data) && typeof data.mainLocale === "string" ? data.mainLocale : "en-US";
89394
90089
  }
89395
- function authoredRecordsSemanticallyEqual(recordKind, left, right) {
89396
- return isSchemaRecordKindV4(recordKind) ? schemaDocumentAuthoredSemanticallyEqual(recordKind, left, right) : canonicallyEqual(left, right);
90090
+ function mergeProjectDocumentRecord(recordKind, base, server, local, mainLocale) {
90091
+ if (isSchemaRecordKindV4(recordKind)) {
90092
+ return mergeSchemaDocumentRecord(recordKind, base, server, local);
90093
+ }
90094
+ return threeWayMergeRecord(base, server, local, {
90095
+ recursive: true,
90096
+ comparison: {
90097
+ base: sourceComparableObjectRecord(recordKind, base, mainLocale),
90098
+ server: sourceComparableObjectRecord(recordKind, server, mainLocale),
90099
+ local: sourceComparableObjectRecord(recordKind, local, mainLocale)
90100
+ }
90101
+ });
89397
90102
  }
89398
- function mergeProjectDocumentRecord(recordKind, base, server, local) {
89399
- return isSchemaRecordKindV4(recordKind) ? mergeSchemaDocumentRecord(recordKind, base, server, local) : threeWayMergeRecord(base, server, local, { recursive: true });
90103
+ function sourceComparableObjectRecord(recordKind, value, mainLocale) {
90104
+ const comparable = sourceComparableRecord(recordKind, value, mainLocale);
90105
+ if (!isObjectRecord2(comparable)) {
90106
+ throw new Error(
90107
+ `Cannot merge ${recordKind} record because its source-comparable payload is not an object.`
90108
+ );
90109
+ }
90110
+ return comparable;
89400
90111
  }
89401
90112
  function buildEmitRecordSet(document, plans, side) {
89402
90113
  const records2 = /* @__PURE__ */ new Map();