@neocompose/cli 0.48.3 → 0.49.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
@@ -20094,16 +20094,8 @@ var init_project_source_construction_diagnostics = __esm({
20094
20094
  "parameter-default-type-mismatch": "error",
20095
20095
  /** §2.5 g. An initializer key naming no member of the constructed class. */
20096
20096
  "unknown-initializer-member": "error",
20097
- /**
20098
- * §2.5 f. A construction site leaving a required member unsettled.
20099
- *
20100
- * Ships as a warning for this release (§5 step 1). A value seed whose
20101
- * members are supplied by stored value rows rather than by initializer text
20102
- * reads as unsettled to an analysis that only sees source, so promoting this
20103
- * to an error would reject the existing corpus. Every other rule below is
20104
- * decidable from source alone and is already an error.
20105
- */
20106
- "unsettled-required-member": "warning",
20097
+ /** §2.5 f. Every construction must settle its required members. */
20098
+ "unsettled-required-member": "error",
20107
20099
  /** §2.4. A declared constructor that is not a complete construction path. */
20108
20100
  "constructor-unsettled-member": "error",
20109
20101
  /** §2.4. An S1 header plus `init` block that is not a complete path. */
@@ -20989,19 +20981,34 @@ function buildNeoConstructionIndex(documents) {
20989
20981
  }
20990
20982
  return { classes, interfaceNames, requiredMemberCache: /* @__PURE__ */ new Map() };
20991
20983
  }
20992
- function requiredMembersForClass(index, className) {
20993
- const cached = index.requiredMemberCache.get(className);
20984
+ function requiredMembersForClass(index, className, typeArguments = []) {
20985
+ const cacheKey = JSON.stringify([className, typeArguments]);
20986
+ const cached = index.requiredMemberCache.get(cacheKey);
20994
20987
  if (cached) return cached;
20995
20988
  const entry = index.classes.get(className);
20996
20989
  if (!entry) return [];
20997
20990
  const required2 = [];
20998
20991
  const seen = /* @__PURE__ */ new Set();
20999
- for (const hop of baseChain(index, entry).hops) {
20992
+ const hops = baseChain(index, entry, typeArguments).hops;
20993
+ const defaults = /* @__PURE__ */ new Map();
20994
+ for (const hop of hops) {
20995
+ for (const member of hop.entry.declaration.members) {
20996
+ if (member.kind !== "field") continue;
20997
+ const key = member.name.toLowerCase();
20998
+ if (defaults.has(key)) continue;
20999
+ if (member.initializer !== void 0 || member.flowInitializer !== void 0)
21000
+ defaults.set(key, member);
21001
+ }
21002
+ }
21003
+ for (const hop of hops) {
21000
21004
  for (const member of hop.entry.declaration.members) {
21001
21005
  const key = member.name.toLowerCase();
21002
21006
  if (seen.has(key)) continue;
21003
21007
  seen.add(key);
21004
21008
  if (!isRequiredMember(member, hop.bindings)) continue;
21009
+ const declaredDefault = defaults.get(key);
21010
+ if (declaredDefault !== void 0 && declaredDefault.initializer?.text.trim() !== "null")
21011
+ continue;
21005
21012
  required2.push({
21006
21013
  name: member.name,
21007
21014
  declaringClassName: hop.entry.declaration.name,
@@ -21010,16 +21017,16 @@ function requiredMembersForClass(index, className) {
21010
21017
  });
21011
21018
  }
21012
21019
  }
21013
- index.requiredMemberCache.set(className, required2);
21020
+ index.requiredMemberCache.set(cacheKey, required2);
21014
21021
  return required2;
21015
21022
  }
21016
- function unsettledRequiredMembers(index, className, settledNames) {
21023
+ function unsettledRequiredMembers(index, className, settledNames, typeArguments = []) {
21017
21024
  const entry = index.classes.get(className);
21018
21025
  if (!entry) return [];
21019
21026
  const settled = /* @__PURE__ */ new Set();
21020
21027
  for (const name of settledNames) settled.add(name.toLowerCase());
21021
21028
  for (const name of declarationSettledMembers(index, entry)) settled.add(name);
21022
- return requiredMembersForClass(index, className).filter(
21029
+ return requiredMembersForClass(index, className, typeArguments).filter(
21023
21030
  (member) => !settled.has(member.name.toLowerCase())
21024
21031
  );
21025
21032
  }
@@ -21046,7 +21053,8 @@ function validateNeoConstructionSite(index, call) {
21046
21053
  const unsettled = unsettledRequiredMembers(
21047
21054
  index,
21048
21055
  call.className,
21049
- call.initializerNames
21056
+ call.initializerNames,
21057
+ call.typeArguments
21050
21058
  );
21051
21059
  if (unsettled.length > 0) {
21052
21060
  diagnostics.push({
@@ -21080,6 +21088,7 @@ function validateBaseConstruction(index, entry, diagnostics) {
21080
21088
  }
21081
21089
  for (const diagnostic of validateNeoConstructionSite(index, {
21082
21090
  className: baseClause.type.name,
21091
+ typeArguments: baseClause.type.typeArguments.map(typeShape),
21083
21092
  argumentNames: (baseClause.arguments ?? []).map(
21084
21093
  (argument2) => argument2.name ?? null
21085
21094
  ),
@@ -21354,11 +21363,16 @@ function stripOuterBraces(text) {
21354
21363
  const trimmed = text.trim();
21355
21364
  return trimmed.startsWith("{") && trimmed.endsWith("}") ? trimmed.slice(1, -1) : text;
21356
21365
  }
21357
- function baseChain(index, start) {
21366
+ function baseChain(index, start, typeArguments = []) {
21358
21367
  const hops = [];
21359
21368
  const visited = /* @__PURE__ */ new Set();
21360
21369
  let current = start;
21361
- let bindings = /* @__PURE__ */ new Map();
21370
+ let bindings = new Map(
21371
+ start.declaration.genericParameters.flatMap((parameter4, position) => {
21372
+ const argument2 = typeArguments[position];
21373
+ return argument2 === void 0 ? [] : [[parameter4.name, argument2]];
21374
+ })
21375
+ );
21362
21376
  let complete2 = true;
21363
21377
  while (current !== void 0 && !visited.has(current.declaration.name)) {
21364
21378
  visited.add(current.declaration.name);
@@ -21412,12 +21426,17 @@ function typeShape(type) {
21412
21426
  }
21413
21427
  function substitute(type, bindings) {
21414
21428
  const bound = bindings.get(type.name);
21415
- if (bound !== void 0 && type.arguments.length === 0) {
21416
- return { ...bound, nullable: bound.nullable || type.nullable };
21429
+ if (bound !== void 0 && (type.arguments?.length ?? 0) === 0) {
21430
+ return {
21431
+ ...bound,
21432
+ nullable: bound.nullable === true || type.nullable === true
21433
+ };
21417
21434
  }
21418
21435
  return {
21419
21436
  ...type,
21420
- arguments: type.arguments.map((argument2) => substitute(argument2, bindings))
21437
+ arguments: (type.arguments ?? []).map(
21438
+ (argument2) => substitute(argument2, bindings)
21439
+ )
21421
21440
  };
21422
21441
  }
21423
21442
  function describeParameterList(className, parameters) {
@@ -23086,6 +23105,7 @@ function validateExpression(expression, expected, scope, environment, uri, range
23086
23105
  environment.construction,
23087
23106
  {
23088
23107
  className: declaration.name,
23108
+ typeArguments: expression.typeArguments?.map(semanticAstType) ?? (expression.className === null ? expected?.arguments : void 0) ?? [],
23089
23109
  argumentNames: variantSite?.argumentNames ?? siteArgumentNames,
23090
23110
  initializerNames: variantSite?.initializerNames ?? siteInitializerNames
23091
23111
  }
@@ -38022,7 +38042,7 @@ function memberToDocumentFields(member, baseData3) {
38022
38042
  }
38023
38043
  function preserveOverrideNulls(fields, member, baseData3) {
38024
38044
  if (member.overrideOf === null || baseData3 === void 0) return;
38025
- for (const field of CHAIN_RESOLVED_OPTIONAL_MEMBER_FIELDS) {
38045
+ for (const field of NULLABLE_OVERRIDE_MEMBER_FIELDS) {
38026
38046
  if (Object.hasOwn(baseData3, field) && baseData3[field] === null) {
38027
38047
  fields[field] = null;
38028
38048
  }
@@ -38782,7 +38802,7 @@ function invalidDocument(record4, path, message) {
38782
38802
  `${record4.recordKind}:${record4.recordId}.${path} ${message}.`
38783
38803
  );
38784
38804
  }
38785
- var MEMBER_KIND, MEMBER_MODIFIERS, MEMBER_ACCESS, MEMBER_STORAGE, MEMBER_DISTRIBUTION, STRING_FORMAT, MEMBER_SEARCH_BY, MEMBER_SELECTION, FUNCTION_DISPATCH, FUNCTION_BODY, MEMBER_PAYLOAD, DICTIONARY_KEY, LIST_KIND, LIST_INDEX, COLUMN_VISIBILITY, COLUMN_PIN, COLUMN_OVERFLOW, GENERIC_BINDING, TYPE_KIND_BY_MEMBER_KIND, SIMPLE_MEMBER_KIND_BY_KIND, MEMBER_KIND_BY_KIND, TYPE_MEMBER_KIND_BY_KIND, MEMBER_IDENTITY_FIELDS, INHERITED_MEMBER_ORDINAL_FIELDS, CHAIN_RESOLVED_OPTIONAL_MEMBER_FIELDS;
38805
+ var MEMBER_KIND, MEMBER_MODIFIERS, MEMBER_ACCESS, MEMBER_STORAGE, MEMBER_DISTRIBUTION, STRING_FORMAT, MEMBER_SEARCH_BY, MEMBER_SELECTION, FUNCTION_DISPATCH, FUNCTION_BODY, MEMBER_PAYLOAD, DICTIONARY_KEY, LIST_KIND, LIST_INDEX, COLUMN_VISIBILITY, COLUMN_PIN, COLUMN_OVERFLOW, GENERIC_BINDING, TYPE_KIND_BY_MEMBER_KIND, SIMPLE_MEMBER_KIND_BY_KIND, MEMBER_KIND_BY_KIND, TYPE_MEMBER_KIND_BY_KIND, MEMBER_IDENTITY_FIELDS, INHERITED_MEMBER_ORDINAL_FIELDS, NULLABLE_OVERRIDE_MEMBER_FIELDS;
38786
38806
  var init_codecs = __esm({
38787
38807
  "src/project-manifest/record-adapters/codecs.ts"() {
38788
38808
  "use strict";
@@ -38925,7 +38945,7 @@ var init_codecs = __esm({
38925
38945
  "dispatch",
38926
38946
  "bodyMode"
38927
38947
  ]);
38928
- CHAIN_RESOLVED_OPTIONAL_MEMBER_FIELDS = [
38948
+ NULLABLE_OVERRIDE_MEMBER_FIELDS = [
38929
38949
  "defaultValue",
38930
38950
  "storageKey",
38931
38951
  "minValue",
@@ -44162,36 +44182,36 @@ var MemberKind;
44162
44182
  var init_member_kind_enum = __esm({
44163
44183
  "../src/models/members/member-kind-enum.ts"() {
44164
44184
  "use strict";
44165
- MemberKind = /* @__PURE__ */ ((MemberKind14) => {
44166
- MemberKind14[MemberKind14["Null"] = 0] = "Null";
44167
- MemberKind14[MemberKind14["Bool"] = 1] = "Bool";
44168
- MemberKind14[MemberKind14["Int"] = 2] = "Int";
44169
- MemberKind14[MemberKind14["String"] = 3] = "String";
44170
- MemberKind14[MemberKind14["Float"] = 4] = "Float";
44171
- MemberKind14[MemberKind14["Dictionary"] = 5] = "Dictionary";
44172
- MemberKind14[MemberKind14["List"] = 6] = "List";
44173
- MemberKind14[MemberKind14["Class"] = 7] = "Class";
44174
- MemberKind14[MemberKind14["Enum"] = 8] = "Enum";
44175
- MemberKind14[MemberKind14["Lookup"] = 9] = "Lookup";
44176
- MemberKind14[MemberKind14["NSProperty"] = 10] = "NSProperty";
44177
- MemberKind14[MemberKind14["Sprite"] = 11] = "Sprite";
44178
- MemberKind14[MemberKind14["Audio"] = 12] = "Audio";
44179
- MemberKind14[MemberKind14["Function"] = 13] = "Function";
44180
- MemberKind14[MemberKind14["Vector2"] = 14] = "Vector2";
44181
- MemberKind14[MemberKind14["Vector2Int"] = 15] = "Vector2Int";
44182
- MemberKind14[MemberKind14["Vector3"] = 16] = "Vector3";
44183
- MemberKind14[MemberKind14["Vector3Int"] = 17] = "Vector3Int";
44184
- MemberKind14[MemberKind14["DialogueLookup"] = 18] = "DialogueLookup";
44185
- MemberKind14[MemberKind14["Color"] = 19] = "Color";
44186
- MemberKind14[MemberKind14["Decimal"] = 20] = "Decimal";
44187
- MemberKind14[MemberKind14["Generic"] = 21] = "Generic";
44188
- MemberKind14[MemberKind14["Interface"] = 22] = "Interface";
44189
- MemberKind14[MemberKind14["NSFunction"] = 23] = "NSFunction";
44190
- MemberKind14[MemberKind14["FunctionRef"] = 24] = "FunctionRef";
44191
- MemberKind14[MemberKind14["NSDelegate"] = 25] = "NSDelegate";
44192
- MemberKind14[MemberKind14["NSAction"] = 26] = "NSAction";
44193
- MemberKind14[MemberKind14["Variant"] = 27] = "Variant";
44194
- return MemberKind14;
44185
+ MemberKind = /* @__PURE__ */ ((MemberKind15) => {
44186
+ MemberKind15[MemberKind15["Null"] = 0] = "Null";
44187
+ MemberKind15[MemberKind15["Bool"] = 1] = "Bool";
44188
+ MemberKind15[MemberKind15["Int"] = 2] = "Int";
44189
+ MemberKind15[MemberKind15["String"] = 3] = "String";
44190
+ MemberKind15[MemberKind15["Float"] = 4] = "Float";
44191
+ MemberKind15[MemberKind15["Dictionary"] = 5] = "Dictionary";
44192
+ MemberKind15[MemberKind15["List"] = 6] = "List";
44193
+ MemberKind15[MemberKind15["Class"] = 7] = "Class";
44194
+ MemberKind15[MemberKind15["Enum"] = 8] = "Enum";
44195
+ MemberKind15[MemberKind15["Lookup"] = 9] = "Lookup";
44196
+ MemberKind15[MemberKind15["NSProperty"] = 10] = "NSProperty";
44197
+ MemberKind15[MemberKind15["Sprite"] = 11] = "Sprite";
44198
+ MemberKind15[MemberKind15["Audio"] = 12] = "Audio";
44199
+ MemberKind15[MemberKind15["Function"] = 13] = "Function";
44200
+ MemberKind15[MemberKind15["Vector2"] = 14] = "Vector2";
44201
+ MemberKind15[MemberKind15["Vector2Int"] = 15] = "Vector2Int";
44202
+ MemberKind15[MemberKind15["Vector3"] = 16] = "Vector3";
44203
+ MemberKind15[MemberKind15["Vector3Int"] = 17] = "Vector3Int";
44204
+ MemberKind15[MemberKind15["DialogueLookup"] = 18] = "DialogueLookup";
44205
+ MemberKind15[MemberKind15["Color"] = 19] = "Color";
44206
+ MemberKind15[MemberKind15["Decimal"] = 20] = "Decimal";
44207
+ MemberKind15[MemberKind15["Generic"] = 21] = "Generic";
44208
+ MemberKind15[MemberKind15["Interface"] = 22] = "Interface";
44209
+ MemberKind15[MemberKind15["NSFunction"] = 23] = "NSFunction";
44210
+ MemberKind15[MemberKind15["FunctionRef"] = 24] = "FunctionRef";
44211
+ MemberKind15[MemberKind15["NSDelegate"] = 25] = "NSDelegate";
44212
+ MemberKind15[MemberKind15["NSAction"] = 26] = "NSAction";
44213
+ MemberKind15[MemberKind15["Variant"] = 27] = "Variant";
44214
+ return MemberKind15;
44195
44215
  })(MemberKind || {});
44196
44216
  }
44197
44217
  });
@@ -46054,6 +46074,7 @@ function isGenericParamDeclaration(value) {
46054
46074
  function isGenericBinding(value) {
46055
46075
  const v = value;
46056
46076
  if (!v || typeof v !== "object") return false;
46077
+ if (Object.hasOwn(v, "defaultValue")) return false;
46057
46078
  if (v.kind === void 0 || v.kind === 0 /* Generic */) {
46058
46079
  if (typeof v.genericParamId !== "string") return false;
46059
46080
  if (v.genericParamId.length === 0) return false;
@@ -47370,7 +47391,7 @@ function isAnyMember(value) {
47370
47391
  function isAnyMemberAuthoredOrCompiled(value) {
47371
47392
  return isAnyMember(value) || isUncompiledMemberNSFunctionOverride(value);
47372
47393
  }
47373
- var FunctionArgumentReservedNames, NSFunctionArgumentReservedNames, ListKind, CHAIN_RESOLVED_OPTIONAL_MEMBER_FIELDS2, MEMBER_ACCESS_KINDS, DECIMAL_STRING_PATTERN, DECIMAL_MAX_SIGNIFICANT_DIGITS, DECIMAL_MAX_SCALE;
47394
+ var FunctionArgumentReservedNames, NSFunctionArgumentReservedNames, ListKind, CHAIN_RESOLVED_OPTIONAL_MEMBER_FIELDS, MEMBER_ACCESS_KINDS, DECIMAL_STRING_PATTERN, DECIMAL_MAX_SIGNIFICANT_DIGITS, DECIMAL_MAX_SCALE;
47374
47395
  var init_member_kinds = __esm({
47375
47396
  "../src/models/members/member-kinds.ts"() {
47376
47397
  "use strict";
@@ -47400,8 +47421,7 @@ var init_member_kinds = __esm({
47400
47421
  ListKind3[ListKind3["Unordered"] = 1] = "Unordered";
47401
47422
  return ListKind3;
47402
47423
  })(ListKind || {});
47403
- CHAIN_RESOLVED_OPTIONAL_MEMBER_FIELDS2 = [
47404
- "defaultValue",
47424
+ CHAIN_RESOLVED_OPTIONAL_MEMBER_FIELDS = [
47405
47425
  "storageKey",
47406
47426
  "minValue",
47407
47427
  "maxValue",
@@ -47884,6 +47904,7 @@ function resolveMemberWithIndex(member, memberIndex) {
47884
47904
  for (const link of chain) {
47885
47905
  for (const [key, value] of Object.entries(link)) {
47886
47906
  if (value === void 0) continue;
47907
+ if (key === "defaultValue" && value === null) continue;
47887
47908
  merged[key] = value;
47888
47909
  }
47889
47910
  if (getField(link, "code") === null) {
@@ -47896,7 +47917,7 @@ function resolveMemberWithIndex(member, memberIndex) {
47896
47917
  }
47897
47918
  }
47898
47919
  delete merged.extendsMemberId;
47899
- for (const field of CHAIN_RESOLVED_OPTIONAL_MEMBER_FIELDS2) {
47920
+ for (const field of CHAIN_RESOLVED_OPTIONAL_MEMBER_FIELDS) {
47900
47921
  if (merged[field] === null) delete merged[field];
47901
47922
  }
47902
47923
  if (member.mutability === void 0) {
@@ -47911,7 +47932,6 @@ function resolveMemberWithIndex(member, memberIndex) {
47911
47932
  }
47912
47933
  if (member.kind === 21 /* Generic */) {
47913
47934
  if (member.requirement === void 0) delete merged.requirement;
47914
- if (member.defaultValue === void 0) delete merged.defaultValue;
47915
47935
  }
47916
47936
  return Object.freeze(merged);
47917
47937
  }
@@ -50054,8 +50074,10 @@ function substituteMember(member, env, members, preResolvedMember) {
50054
50074
  access: resolved.access,
50055
50075
  system: resolved.system ?? void 0
50056
50076
  };
50057
- if (resolved.defaultValue !== void 0) {
50077
+ if (resolved.defaultValue != null) {
50058
50078
  substituted.defaultValue = resolved.defaultValue;
50079
+ } else {
50080
+ delete substituted.defaultValue;
50059
50081
  }
50060
50082
  const slotId = getOptionalString(member, "id");
50061
50083
  if (slotId !== void 0) {
@@ -51021,9 +51043,9 @@ function assertReadOnlyMembersValid(document) {
51021
51043
  );
51022
51044
  }
51023
51045
  if (isAbstractMember(member) === true) continue;
51024
- if (effective.defaultValue === void 0) {
51046
+ if (effective.defaultValue == null) {
51025
51047
  throw new Error(
51026
- `Read-only member "${member.name}" (${member.id}) requires an explicit defaultValue from every closed Generic binding; ${ownerContext}.`
51048
+ `Read-only member "${member.name}" (${member.id}) requires an explicit field defaultValue in every closed Generic placement; ${ownerContext}.`
51027
51049
  );
51028
51050
  }
51029
51051
  if (isMemberStringBase(effective) && effective.searchBy === 1 /* MemberKey */) {
@@ -51910,6 +51932,403 @@ var init_storage_partitions = __esm({
51910
51932
  }
51911
51933
  });
51912
51934
 
51935
+ // ../src/models/constructors/constructors.ts
51936
+ function hasRejectedConstructorKey(value) {
51937
+ return REJECTED_CONSTRUCTOR_KEYS.some((key) => value[key] !== void 0);
51938
+ }
51939
+ function isNamedBaseClauseEntry(value, nameIsValid) {
51940
+ if (typeof value !== "object" || value === null) return false;
51941
+ if (Array.isArray(value)) return false;
51942
+ const candidate = value;
51943
+ if (!Object.keys(candidate).every((key) => key === "name" || key === "code")) {
51944
+ return false;
51945
+ }
51946
+ if (!nameIsValid(candidate.name)) return false;
51947
+ if (typeof candidate.code !== "string") return false;
51948
+ return candidate.code.length > 0;
51949
+ }
51950
+ function isNeoConstructorBaseArgument(value) {
51951
+ return isNamedBaseClauseEntry(value, isValidCallableArgumentIdentifier);
51952
+ }
51953
+ function isNeoConstructorBaseInitializerField(value) {
51954
+ return isNamedBaseClauseEntry(value, isValidSchemaMemberIdentifier);
51955
+ }
51956
+ function isNeoClassConstructorBase(value) {
51957
+ if (typeof value !== "object" || value === null) return false;
51958
+ if (Array.isArray(value)) return false;
51959
+ const v = value;
51960
+ if (hasRejectedConstructorKey(v)) return false;
51961
+ if (!isValidDocsText(v.docsText)) return false;
51962
+ if (typeof v.classId !== "string") return false;
51963
+ if (v.classId.length === 0) return false;
51964
+ if (typeof v.code !== "string" && v.code !== null) return false;
51965
+ if (!Array.isArray(v.argumentTypes)) return false;
51966
+ const parameterNames = /* @__PURE__ */ new Set();
51967
+ const argumentTypes = [];
51968
+ for (const argument2 of v.argumentTypes) {
51969
+ if (!isNSFunctionArgumentTypeInfo(argument2)) return false;
51970
+ if (!isValidCallableArgumentIdentifier(argument2.name)) return false;
51971
+ if (parameterNames.has(argument2.name)) return false;
51972
+ parameterNames.add(argument2.name);
51973
+ argumentTypes.push(argument2);
51974
+ }
51975
+ if (validateParameterDefaults(argumentTypes).length > 0) return false;
51976
+ if (v.baseArguments !== void 0 && v.baseArguments !== null) {
51977
+ if (!Array.isArray(v.baseArguments)) return false;
51978
+ const baseNames = /* @__PURE__ */ new Set();
51979
+ for (const baseArgument of v.baseArguments) {
51980
+ if (!isNeoConstructorBaseArgument(baseArgument)) return false;
51981
+ if (baseNames.has(baseArgument.name)) return false;
51982
+ baseNames.add(baseArgument.name);
51983
+ }
51984
+ }
51985
+ if (v.baseInitializerFields !== void 0 && v.baseInitializerFields !== null) {
51986
+ if (!Array.isArray(v.baseInitializerFields)) return false;
51987
+ const fieldNames = /* @__PURE__ */ new Set();
51988
+ for (const field of v.baseInitializerFields) {
51989
+ if (!isNeoConstructorBaseInitializerField(field)) return false;
51990
+ if (fieldNames.has(field.name)) return false;
51991
+ fieldNames.add(field.name);
51992
+ }
51993
+ }
51994
+ if (v.action !== void 0 && v.action !== null) return false;
51995
+ if (v.compiledBaseArguments !== void 0 && v.compiledBaseArguments !== null) {
51996
+ return false;
51997
+ }
51998
+ return v.compiledBaseInitializerFields === void 0 || v.compiledBaseInitializerFields === null;
51999
+ }
52000
+ function isUncompiledNeoClassConstructor(value) {
52001
+ if (!isNeoClassConstructorBase(value)) return false;
52002
+ const v = value;
52003
+ if (typeof v.id !== "string" || v.id.length === 0) return false;
52004
+ if (typeof v.projectId !== "string" || v.projectId.length === 0) return false;
52005
+ if (!isEpochMillis(v.createdAt)) return false;
52006
+ return isEpochMillis(v.updatedAt);
52007
+ }
52008
+ function hasValidConstructorAction(action, argumentTypes) {
52009
+ if (!isNSFunctionWithReturnType(action)) return false;
52010
+ if (action.typeInfo.type !== 0 /* Null */) return false;
52011
+ if (action.typeInfo.required !== true) return false;
52012
+ if (action.parameters.length !== argumentTypes.length + 2) return false;
52013
+ if (action.parameters[0]?.id !== "__this__") return false;
52014
+ if (action.parameters[1]?.id !== "__root__") return false;
52015
+ for (let index = 0; index < argumentTypes.length; index += 1) {
52016
+ const parameter4 = action.parameters[index + 2];
52017
+ if (parameter4?.id !== `__arg_${index}__`) return false;
52018
+ const declared = argumentTypes[index];
52019
+ if (declared === void 0) return false;
52020
+ if (!typeInfosInvariantlyEqual(parameter4.typeInfo, declared)) return false;
52021
+ }
52022
+ return true;
52023
+ }
52024
+ function compiledBaseClauseGettersAlign(compiled, authored) {
52025
+ const authoredCount = Array.isArray(authored) ? authored.length : 0;
52026
+ if (compiled === void 0 || compiled === null) return authoredCount === 0;
52027
+ if (!Array.isArray(compiled)) return false;
52028
+ if (!compiled.every(isNSGetter)) return false;
52029
+ return compiled.length === authoredCount;
52030
+ }
52031
+ function isNeoClassConstructorProps(value) {
52032
+ if (typeof value !== "object" || value === null) return false;
52033
+ const v = value;
52034
+ const {
52035
+ action: _action,
52036
+ compiledBaseArguments: _compiledBaseArguments,
52037
+ compiledBaseInitializerFields: _compiledBaseInitializerFields,
52038
+ ...authored
52039
+ } = v;
52040
+ void _action;
52041
+ void _compiledBaseArguments;
52042
+ void _compiledBaseInitializerFields;
52043
+ if (!isNeoClassConstructorBase(authored)) return false;
52044
+ if (typeof v.id !== "string") return false;
52045
+ if (v.id.length === 0) return false;
52046
+ if (typeof v.projectId !== "string") return false;
52047
+ if (!isEpochMillis(v.createdAt)) return false;
52048
+ if (!isEpochMillis(v.updatedAt)) return false;
52049
+ const argumentTypes = v.argumentTypes;
52050
+ if (!hasValidConstructorAction(v.action, argumentTypes)) return false;
52051
+ if (!compiledBaseClauseGettersAlign(v.compiledBaseArguments, v.baseArguments)) {
52052
+ return false;
52053
+ }
52054
+ return compiledBaseClauseGettersAlign(
52055
+ v.compiledBaseInitializerFields,
52056
+ v.baseInitializerFields
52057
+ );
52058
+ }
52059
+ function isNeoClassConstructor(value) {
52060
+ return isNeoClassConstructorProps(value);
52061
+ }
52062
+ function constructorActionParameterId(constructor2, index) {
52063
+ const action = "action" in constructor2 ? constructor2.action : void 0;
52064
+ if (action !== null && typeof action === "object") {
52065
+ const parameters = action.parameters;
52066
+ if (Array.isArray(parameters)) {
52067
+ const parameter4 = parameters[index + 2];
52068
+ if (parameter4 !== null && typeof parameter4 === "object" && typeof parameter4.id === "string") {
52069
+ return parameter4.id;
52070
+ }
52071
+ }
52072
+ }
52073
+ return `__arg_${index}__`;
52074
+ }
52075
+ var REJECTED_CONSTRUCTOR_KEYS;
52076
+ var init_constructors = __esm({
52077
+ "../src/models/constructors/constructors.ts"() {
52078
+ "use strict";
52079
+ init_core();
52080
+ init_docs_text2();
52081
+ init_member_kinds();
52082
+ init_schema_identifiers();
52083
+ init_neoscript();
52084
+ REJECTED_CONSTRUCTOR_KEYS = [
52085
+ "bodyMode",
52086
+ "uiAction",
52087
+ "returnTypeInfo",
52088
+ "deferred"
52089
+ ];
52090
+ }
52091
+ });
52092
+
52093
+ // ../src/models/constructors/index.ts
52094
+ var init_constructors2 = __esm({
52095
+ "../src/models/constructors/index.ts"() {
52096
+ "use strict";
52097
+ init_constructors();
52098
+ }
52099
+ });
52100
+
52101
+ // ../src/models/classes/construction-requirements.ts
52102
+ function requiredMembersForConstruction(classId, document, classArguments2) {
52103
+ return unsettledMembers(
52104
+ classId,
52105
+ contextFor(document),
52106
+ classArguments2,
52107
+ /* @__PURE__ */ new Set()
52108
+ );
52109
+ }
52110
+ function contextFor(document, env = /* @__PURE__ */ new Map()) {
52111
+ return {
52112
+ document,
52113
+ membersById: new Map(document.members.map((member) => [member.id, member])),
52114
+ env
52115
+ };
52116
+ }
52117
+ function unsettledMembers(classId, context, classArguments2, path) {
52118
+ const previousEnv = context.env;
52119
+ context.env = resolveInstanceEnv(
52120
+ classId,
52121
+ classArguments2,
52122
+ context.document.classes
52123
+ );
52124
+ try {
52125
+ return constructionMembers(classId, context).filter(
52126
+ ({ member }) => isRequiredMember2(member) && !defaultSettlesConstruction(member, context, path)
52127
+ );
52128
+ } finally {
52129
+ context.env = previousEnv;
52130
+ }
52131
+ }
52132
+ function constructionMembers(classId, context) {
52133
+ const { document, membersById, env } = context;
52134
+ if (firstUnboundParamId(env) !== null) return [];
52135
+ const result = [];
52136
+ for (const entry of mergeStoredInstanceSchema(
52137
+ classId,
52138
+ document.classes,
52139
+ document.members
52140
+ )) {
52141
+ const raw = membersById.get(entry.memberId);
52142
+ if (raw === void 0) continue;
52143
+ const member = {
52144
+ ...raw,
52145
+ ...substituteMember(
52146
+ raw,
52147
+ env,
52148
+ document.members,
52149
+ resolveMember2(raw, document.members)
52150
+ ),
52151
+ id: raw.id
52152
+ };
52153
+ if (isAbstractMember(member)) continue;
52154
+ if (isReadOnlyMember(member)) continue;
52155
+ if (!memberKindOwnsStoredValue(member.kind)) continue;
52156
+ if ("payload" in member && member.payload === 1 /* Partial */)
52157
+ continue;
52158
+ result.push({ schemaKey: entry.schemaKey, member });
52159
+ }
52160
+ return result;
52161
+ }
52162
+ function storedValueSettlesConstruction(member, sourceValue, document, genericEnv) {
52163
+ return valueSettlesConstruction(
52164
+ member,
52165
+ sourceValue,
52166
+ contextFor(document, genericEnv),
52167
+ /* @__PURE__ */ new Set(),
52168
+ true
52169
+ );
52170
+ }
52171
+ function defaultSettlesConstruction(member, context, path) {
52172
+ const body = member.defaultValue;
52173
+ if (body == null) return false;
52174
+ return valueSettlesConstruction(member, body, context, path);
52175
+ }
52176
+ function valueSettlesConstruction(member, body, context, path, storedRow = false) {
52177
+ if (isInitValueContent(body)) return true;
52178
+ const value = body.value;
52179
+ if (value == null) return !isRequiredMember2(member);
52180
+ const isClass = isMemberClassBase(member);
52181
+ const isCollection = isMemberListBase(member) || isMemberDictionaryBase(member);
52182
+ if (!isClass && !isCollection) return true;
52183
+ if (isClass && member.payload === 1 /* Partial */) return true;
52184
+ if (typeof value !== "object") return false;
52185
+ if (path.has(value)) return false;
52186
+ path.add(value);
52187
+ const previousEnv = context.env;
52188
+ try {
52189
+ if (isCollection) {
52190
+ if (body.genericBindings != null)
52191
+ context.env = envFromStamp(body.genericBindings);
52192
+ const entry = context.membersById.get(member.entryMemberId);
52193
+ if (entry === void 0) return false;
52194
+ const resolvedEntry = substituteMember(
52195
+ entry,
52196
+ context.env,
52197
+ context.document.members
52198
+ );
52199
+ const entries = Array.isArray(value) ? value : Object.values(value);
52200
+ return entries.every(
52201
+ (entryValue) => suppliedValueSettlesConstruction(
52202
+ resolvedEntry,
52203
+ entryValue,
52204
+ context,
52205
+ path
52206
+ )
52207
+ );
52208
+ }
52209
+ if (!isClass || Array.isArray(value)) return false;
52210
+ const classId = body.classId ?? member.classId;
52211
+ const constructor2 = typeof body.instanceConstructorId === "string" ? context.document.constructors.find(
52212
+ (record4) => record4.id === body.instanceConstructorId && record4.classId === classId
52213
+ ) : void 0;
52214
+ if (typeof body.instanceConstructorId === "string" && constructor2 === void 0)
52215
+ return false;
52216
+ if (constructor2 !== void 0 && constructor2.argumentTypes.some(
52217
+ (argument2, index) => !parameterHasDefault(argument2) && !Object.hasOwn(
52218
+ body.constructorArgs ?? {},
52219
+ constructorActionParameterId(constructor2, index)
52220
+ )
52221
+ ))
52222
+ return false;
52223
+ const requiredConstructorId2 = context.document.classes.find(
52224
+ (schemaClass2) => schemaClass2.id === classId
52225
+ )?.requiredConstructorId;
52226
+ if (typeof requiredConstructorId2 === "string" && constructor2?.id !== requiredConstructorId2 && !(storedRow && body.instanceConstructorId == null))
52227
+ return false;
52228
+ const classArguments2 = { ...member.classArguments };
52229
+ for (const [parameterId, memberId] of Object.entries(
52230
+ body.genericBindings ?? {}
52231
+ )) {
52232
+ classArguments2[parameterId] = {
52233
+ kind: 1 /* Member */,
52234
+ memberId
52235
+ };
52236
+ }
52237
+ context.env = resolveInstanceEnv(
52238
+ classId,
52239
+ classArguments2,
52240
+ context.document.classes
52241
+ );
52242
+ if (firstUnboundParamId(context.env) !== null) return false;
52243
+ const members = constructionMembers(classId, context);
52244
+ for (const entry of members) {
52245
+ if (Object.hasOwn(value, entry.schemaKey)) {
52246
+ if (!suppliedValueSettlesConstruction(
52247
+ entry.member,
52248
+ Reflect.get(value, entry.schemaKey),
52249
+ context,
52250
+ path
52251
+ ))
52252
+ return false;
52253
+ continue;
52254
+ }
52255
+ if (!isRequiredMember2(entry.member)) continue;
52256
+ if (constructor2 !== void 0 || typeof body.instanceVariantId === "string")
52257
+ continue;
52258
+ if (!defaultSettlesConstruction(entry.member, context, path))
52259
+ return false;
52260
+ }
52261
+ return true;
52262
+ } finally {
52263
+ path.delete(value);
52264
+ context.env = previousEnv;
52265
+ }
52266
+ }
52267
+ function suppliedValueSettlesConstruction(member, value, context, path) {
52268
+ if (typeof value === "string") {
52269
+ let row;
52270
+ if (context.document.valueById !== void 0) {
52271
+ row = context.document.valueById(value);
52272
+ } else {
52273
+ context.valuesById ??= new Map(
52274
+ context.document.values?.map((entry) => [entry.id, entry]) ?? []
52275
+ );
52276
+ row = context.valuesById.get(value);
52277
+ }
52278
+ if (row !== void 0 && row !== null)
52279
+ return valueSettlesConstruction(member, row, context, path, true);
52280
+ return false;
52281
+ }
52282
+ return valueSettlesConstruction(member, { value }, context, path);
52283
+ }
52284
+ function resolveConstructionTypeArguments(typeArguments, document) {
52285
+ if (typeArguments === void 0) return void 0;
52286
+ const bindings = {};
52287
+ const projected = /* @__PURE__ */ new Map();
52288
+ for (const [parameterId, typeInfo] of Object.entries(typeArguments)) {
52289
+ let binding;
52290
+ for (const member of document.members) {
52291
+ if (!projected.has(member.id)) {
52292
+ try {
52293
+ projected.set(
52294
+ member.id,
52295
+ genericBindingTypeInfo(member, /* @__PURE__ */ new Map(), document.members)
52296
+ );
52297
+ } catch {
52298
+ projected.set(member.id, null);
52299
+ }
52300
+ }
52301
+ const candidate = projected.get(member.id);
52302
+ if (candidate != null && typeInfosInvariantlyEqual(candidate, typeInfo)) {
52303
+ binding = member;
52304
+ break;
52305
+ }
52306
+ }
52307
+ if (binding === void 0) {
52308
+ throw new Error(
52309
+ `Construction type argument "${parameterId}" has no matching type descriptor in the document.`
52310
+ );
52311
+ }
52312
+ bindings[parameterId] = {
52313
+ kind: 1 /* Member */,
52314
+ memberId: binding.id
52315
+ };
52316
+ }
52317
+ return bindings;
52318
+ }
52319
+ var init_construction_requirements = __esm({
52320
+ "../src/models/classes/construction-requirements.ts"() {
52321
+ "use strict";
52322
+ init_type_info_compatibility();
52323
+ init_classes();
52324
+ init_inheritance();
52325
+ init_generics();
52326
+ init_constructors2();
52327
+ init_parameter_defaults();
52328
+ init_members();
52329
+ }
52330
+ });
52331
+
51913
52332
  // ../src/models/unity/unity-import-settings.ts
51914
52333
  function buildDefaultUnityTexture2DImportSettings() {
51915
52334
  return {
@@ -53113,13 +53532,10 @@ function directScalarDefaultBody(document, member) {
53113
53532
  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 */) {
53114
53533
  return void 0;
53115
53534
  }
53116
- if (!isRequiredMember2(member) && (member.defaultValue === void 0 || member.defaultValue === null)) {
53117
- return void 0;
53118
- }
53119
- if (documentHasInitValueContent(document, member.defaultValue)) {
53535
+ if (member.defaultValue == null) return void 0;
53536
+ if (documentHasInitValueContent(document, member.defaultValue))
53120
53537
  return void 0;
53121
- }
53122
- const body = member.defaultValue ?? primitiveFallbackValue(document, member);
53538
+ const body = member.defaultValue;
53123
53539
  if (!isLiteralValueContent(body)) return void 0;
53124
53540
  if (body.value !== null && typeof body.value !== "boolean" && typeof body.value !== "number" && typeof body.value !== "string") {
53125
53541
  return void 0;
@@ -53292,6 +53708,11 @@ function buildDefaultMemberValue(args) {
53292
53708
  `Cannot create a value of missing class "${effectiveClassId}".`
53293
53709
  );
53294
53710
  }
53711
+ if (member.payload !== 1 /* Partial */ && typeof effectiveClass.requiredConstructorId === "string" && args.constructorRoot === void 0 && args.authoredRoot === void 0) {
53712
+ throw new Error(
53713
+ `Class "${effectiveClass.name}" declares a required constructor; provide its constructor arguments.`
53714
+ );
53715
+ }
53295
53716
  if (isAbstractClass(effectiveClass)) {
53296
53717
  throw new Error(
53297
53718
  `Cannot create a value of abstract class "${effectiveClass.name}".`
@@ -53373,6 +53794,13 @@ function buildDefaultMemberValue(args) {
53373
53794
  )) {
53374
53795
  continue;
53375
53796
  }
53797
+ if (isRequiredMember2(resolvedChildMember) && resolvedChildMember.defaultValue == null && !(isMemberClassBase(resolvedChildMember) && resolvedChildMember.payload === 1 /* Partial */)) {
53798
+ if (args.constructorRoot?.runsMemberInitializers === true) continue;
53799
+ if (args.constructorRoot?.omitMissingRequired === true) continue;
53800
+ throw new Error(
53801
+ `Class "${effectiveClass.name}" cannot be constructed without required member "${schemaKey}"; supply it or declare a member default.`
53802
+ );
53803
+ }
53376
53804
  if (!shouldMaterializeChildDefaultForRoot(
53377
53805
  args.constructorRoot,
53378
53806
  resolvedChildMember,
@@ -53383,7 +53811,6 @@ function buildDefaultMemberValue(args) {
53383
53811
  )) {
53384
53812
  continue;
53385
53813
  }
53386
- if (shouldSkipRequiredChildDefault(resolvedChildMember)) continue;
53387
53814
  const childValue = directScalarBody === void 0 ? buildDefaultMemberValue({
53388
53815
  document: args.document,
53389
53816
  projectId: args.projectId,
@@ -53716,15 +54143,43 @@ function cloneDefaultValueForMember(args) {
53716
54143
  );
53717
54144
  return evaluatedRow;
53718
54145
  }
54146
+ if (args.path.size === 0 && !storedValueSettlesConstruction(
54147
+ member,
54148
+ sourceValue,
54149
+ {
54150
+ classes: args.document.classes,
54151
+ members: args.document.members,
54152
+ constructors: args.document.constructors ?? [],
54153
+ values: args.document.values,
54154
+ valueById: args.document.valueById
54155
+ },
54156
+ args.genericEnv
54157
+ )) {
54158
+ throw new Error(
54159
+ `Default value "${args.sourceValueId}" in ${args.referenceLocation} does not satisfy its construction requirements.`
54160
+ );
54161
+ }
53719
54162
  let body;
53720
- if (isMemberClassBase(member)) {
54163
+ if (isMemberClassBase(member) && sourceValue.value === null) {
54164
+ body = cloneMemberValueBase(sourceValue);
54165
+ } else if (isMemberClassBase(member)) {
53721
54166
  const effectiveClassId = typeof sourceValue.classId === "string" ? sourceValue.classId : member.classId;
53722
- const childEnv = args.document.instanceEnv?.(effectiveClassId, member.classArguments) ?? resolveInstanceEnv(
54167
+ const classArguments2 = { ...member.classArguments };
54168
+ for (const [parameterId, memberId] of Object.entries(
54169
+ sourceValue.genericBindings ?? {}
54170
+ )) {
54171
+ classArguments2[parameterId] = {
54172
+ kind: 1 /* Member */,
54173
+ memberId
54174
+ };
54175
+ }
54176
+ const childEnv = args.document.instanceEnv?.(effectiveClassId, classArguments2) ?? resolveInstanceEnv(
53723
54177
  effectiveClassId,
53724
- member.classArguments,
54178
+ classArguments2,
53725
54179
  args.document.classes
53726
54180
  );
53727
54181
  body = {
54182
+ ...cloneMemberValueBase(sourceValue),
53728
54183
  value: cloneDefaultClassRecord({
53729
54184
  document: args.document,
53730
54185
  projectId: args.projectId,
@@ -53738,7 +54193,7 @@ function cloneDefaultValueForMember(args) {
53738
54193
  path: nextPath,
53739
54194
  position: args.position
53740
54195
  }),
53741
- classId: effectiveClassId !== member.classId ? effectiveClassId : void 0
54196
+ classId: effectiveClassId !== member.classId || sourceValue.constructorArgs != null ? effectiveClassId : void 0
53742
54197
  };
53743
54198
  } else if (isMemberListBase(member)) {
53744
54199
  body = cloneDefaultListRecord({
@@ -53749,7 +54204,7 @@ function cloneDefaultValueForMember(args) {
53749
54204
  createdValues: args.createdValues,
53750
54205
  storageKeyDeclarations: args.storageKeyDeclarations,
53751
54206
  initEvaluator: args.initEvaluator,
53752
- genericEnv: args.genericEnv,
54207
+ genericEnv: sourceValue.genericBindings == null ? args.genericEnv : envFromStamp(sourceValue.genericBindings),
53753
54208
  path: nextPath,
53754
54209
  position: args.position
53755
54210
  });
@@ -53762,7 +54217,7 @@ function cloneDefaultValueForMember(args) {
53762
54217
  createdValues: args.createdValues,
53763
54218
  storageKeyDeclarations: args.storageKeyDeclarations,
53764
54219
  initEvaluator: args.initEvaluator,
53765
- genericEnv: args.genericEnv,
54220
+ genericEnv: sourceValue.genericBindings == null ? args.genericEnv : envFromStamp(sourceValue.genericBindings),
53766
54221
  path: nextPath,
53767
54222
  position: args.position
53768
54223
  });
@@ -53779,7 +54234,9 @@ function cloneDefaultValueForMember(args) {
53779
54234
  }
53780
54235
  const value = createDocumentValueRow(args.document, args.projectId, body);
53781
54236
  value.sourceValueId = sourceValue.sourceValueId ?? sourceValue.id;
53782
- if (isMemberListBase(member) || isMemberDictionaryBase(member)) {
54237
+ if (sourceValue.genericBindings != null) {
54238
+ value.genericBindings = { ...sourceValue.genericBindings };
54239
+ } else if (isMemberListBase(member) || isMemberDictionaryBase(member)) {
53783
54240
  stampGenericBindings(value, member, args);
53784
54241
  }
53785
54242
  args.createdValues.push(value);
@@ -53837,10 +54294,6 @@ function stampGenericBindings(value, member, args) {
53837
54294
  if (stamp === void 0) return;
53838
54295
  value.genericBindings = stamp;
53839
54296
  }
53840
- function shouldSkipRequiredChildDefault(member) {
53841
- if (member.defaultValue !== void 0) return false;
53842
- return isMemberAudioBase(member);
53843
- }
53844
54297
  function shouldMaterializeChildDefault(member) {
53845
54298
  if (isMemberClassBase(member) && member.payload === 1 /* Partial */)
53846
54299
  return false;
@@ -53862,7 +54315,7 @@ function skipProvidedConstructorSchemaKey(constructorRoot, schemaKey, member, is
53862
54315
  if (constructorRoot.runsMemberInitializers !== true) {
53863
54316
  return !isInitializer;
53864
54317
  }
53865
- return member.defaultValue === void 0;
54318
+ return member.defaultValue == null;
53866
54319
  }
53867
54320
  function shouldMaterializeChildDefaultForRoot(constructorRoot, member, isInitializer = isInitValueContent(member.defaultValue)) {
53868
54321
  if (constructorRoot === void 0)
@@ -54118,6 +54571,7 @@ var DECLARATION_DEFAULT_POSITION, SPRITE_FILE_ID_KEY;
54118
54571
  var init_build_default_member_value = __esm({
54119
54572
  "../src/models/members/build-default-member-value.ts"() {
54120
54573
  "use strict";
54574
+ init_construction_requirements();
54121
54575
  init_deep_clone_plain_data();
54122
54576
  init_dist_node();
54123
54577
  init_inheritance();
@@ -65601,172 +66055,6 @@ var init_lower_variants = __esm({
65601
66055
  }
65602
66056
  });
65603
66057
 
65604
- // ../src/models/constructors/constructors.ts
65605
- function hasRejectedConstructorKey(value) {
65606
- return REJECTED_CONSTRUCTOR_KEYS.some((key) => value[key] !== void 0);
65607
- }
65608
- function isNamedBaseClauseEntry(value, nameIsValid) {
65609
- if (typeof value !== "object" || value === null) return false;
65610
- if (Array.isArray(value)) return false;
65611
- const candidate = value;
65612
- if (!Object.keys(candidate).every((key) => key === "name" || key === "code")) {
65613
- return false;
65614
- }
65615
- if (!nameIsValid(candidate.name)) return false;
65616
- if (typeof candidate.code !== "string") return false;
65617
- return candidate.code.length > 0;
65618
- }
65619
- function isNeoConstructorBaseArgument(value) {
65620
- return isNamedBaseClauseEntry(value, isValidCallableArgumentIdentifier);
65621
- }
65622
- function isNeoConstructorBaseInitializerField(value) {
65623
- return isNamedBaseClauseEntry(value, isValidSchemaMemberIdentifier);
65624
- }
65625
- function isNeoClassConstructorBase(value) {
65626
- if (typeof value !== "object" || value === null) return false;
65627
- if (Array.isArray(value)) return false;
65628
- const v = value;
65629
- if (hasRejectedConstructorKey(v)) return false;
65630
- if (!isValidDocsText(v.docsText)) return false;
65631
- if (typeof v.classId !== "string") return false;
65632
- if (v.classId.length === 0) return false;
65633
- if (typeof v.code !== "string" && v.code !== null) return false;
65634
- if (!Array.isArray(v.argumentTypes)) return false;
65635
- const parameterNames = /* @__PURE__ */ new Set();
65636
- const argumentTypes = [];
65637
- for (const argument2 of v.argumentTypes) {
65638
- if (!isNSFunctionArgumentTypeInfo(argument2)) return false;
65639
- if (!isValidCallableArgumentIdentifier(argument2.name)) return false;
65640
- if (parameterNames.has(argument2.name)) return false;
65641
- parameterNames.add(argument2.name);
65642
- argumentTypes.push(argument2);
65643
- }
65644
- if (validateParameterDefaults(argumentTypes).length > 0) return false;
65645
- if (v.baseArguments !== void 0 && v.baseArguments !== null) {
65646
- if (!Array.isArray(v.baseArguments)) return false;
65647
- const baseNames = /* @__PURE__ */ new Set();
65648
- for (const baseArgument of v.baseArguments) {
65649
- if (!isNeoConstructorBaseArgument(baseArgument)) return false;
65650
- if (baseNames.has(baseArgument.name)) return false;
65651
- baseNames.add(baseArgument.name);
65652
- }
65653
- }
65654
- if (v.baseInitializerFields !== void 0 && v.baseInitializerFields !== null) {
65655
- if (!Array.isArray(v.baseInitializerFields)) return false;
65656
- const fieldNames = /* @__PURE__ */ new Set();
65657
- for (const field of v.baseInitializerFields) {
65658
- if (!isNeoConstructorBaseInitializerField(field)) return false;
65659
- if (fieldNames.has(field.name)) return false;
65660
- fieldNames.add(field.name);
65661
- }
65662
- }
65663
- if (v.action !== void 0 && v.action !== null) return false;
65664
- if (v.compiledBaseArguments !== void 0 && v.compiledBaseArguments !== null) {
65665
- return false;
65666
- }
65667
- return v.compiledBaseInitializerFields === void 0 || v.compiledBaseInitializerFields === null;
65668
- }
65669
- function isUncompiledNeoClassConstructor(value) {
65670
- if (!isNeoClassConstructorBase(value)) return false;
65671
- const v = value;
65672
- if (typeof v.id !== "string" || v.id.length === 0) return false;
65673
- if (typeof v.projectId !== "string" || v.projectId.length === 0) return false;
65674
- if (!isEpochMillis(v.createdAt)) return false;
65675
- return isEpochMillis(v.updatedAt);
65676
- }
65677
- function hasValidConstructorAction(action, argumentTypes) {
65678
- if (!isNSFunctionWithReturnType(action)) return false;
65679
- if (action.typeInfo.type !== 0 /* Null */) return false;
65680
- if (action.typeInfo.required !== true) return false;
65681
- if (action.parameters.length !== argumentTypes.length + 2) return false;
65682
- if (action.parameters[0]?.id !== "__this__") return false;
65683
- if (action.parameters[1]?.id !== "__root__") return false;
65684
- for (let index = 0; index < argumentTypes.length; index += 1) {
65685
- const parameter4 = action.parameters[index + 2];
65686
- if (parameter4?.id !== `__arg_${index}__`) return false;
65687
- const declared = argumentTypes[index];
65688
- if (declared === void 0) return false;
65689
- if (!typeInfosInvariantlyEqual(parameter4.typeInfo, declared)) return false;
65690
- }
65691
- return true;
65692
- }
65693
- function compiledBaseClauseGettersAlign(compiled, authored) {
65694
- const authoredCount = Array.isArray(authored) ? authored.length : 0;
65695
- if (compiled === void 0 || compiled === null) return authoredCount === 0;
65696
- if (!Array.isArray(compiled)) return false;
65697
- if (!compiled.every(isNSGetter)) return false;
65698
- return compiled.length === authoredCount;
65699
- }
65700
- function isNeoClassConstructorProps(value) {
65701
- if (typeof value !== "object" || value === null) return false;
65702
- const v = value;
65703
- const {
65704
- action: _action,
65705
- compiledBaseArguments: _compiledBaseArguments,
65706
- compiledBaseInitializerFields: _compiledBaseInitializerFields,
65707
- ...authored
65708
- } = v;
65709
- void _action;
65710
- void _compiledBaseArguments;
65711
- void _compiledBaseInitializerFields;
65712
- if (!isNeoClassConstructorBase(authored)) return false;
65713
- if (typeof v.id !== "string") return false;
65714
- if (v.id.length === 0) return false;
65715
- if (typeof v.projectId !== "string") return false;
65716
- if (!isEpochMillis(v.createdAt)) return false;
65717
- if (!isEpochMillis(v.updatedAt)) return false;
65718
- const argumentTypes = v.argumentTypes;
65719
- if (!hasValidConstructorAction(v.action, argumentTypes)) return false;
65720
- if (!compiledBaseClauseGettersAlign(v.compiledBaseArguments, v.baseArguments)) {
65721
- return false;
65722
- }
65723
- return compiledBaseClauseGettersAlign(
65724
- v.compiledBaseInitializerFields,
65725
- v.baseInitializerFields
65726
- );
65727
- }
65728
- function isNeoClassConstructor(value) {
65729
- return isNeoClassConstructorProps(value);
65730
- }
65731
- function constructorActionParameterId(constructor2, index) {
65732
- const action = "action" in constructor2 ? constructor2.action : void 0;
65733
- if (action !== null && typeof action === "object") {
65734
- const parameters = action.parameters;
65735
- if (Array.isArray(parameters)) {
65736
- const parameter4 = parameters[index + 2];
65737
- if (parameter4 !== null && typeof parameter4 === "object" && typeof parameter4.id === "string") {
65738
- return parameter4.id;
65739
- }
65740
- }
65741
- }
65742
- return `__arg_${index}__`;
65743
- }
65744
- var REJECTED_CONSTRUCTOR_KEYS;
65745
- var init_constructors = __esm({
65746
- "../src/models/constructors/constructors.ts"() {
65747
- "use strict";
65748
- init_core();
65749
- init_docs_text2();
65750
- init_member_kinds();
65751
- init_schema_identifiers();
65752
- init_neoscript();
65753
- REJECTED_CONSTRUCTOR_KEYS = [
65754
- "bodyMode",
65755
- "uiAction",
65756
- "returnTypeInfo",
65757
- "deferred"
65758
- ];
65759
- }
65760
- });
65761
-
65762
- // ../src/models/constructors/index.ts
65763
- var init_constructors2 = __esm({
65764
- "../src/models/constructors/index.ts"() {
65765
- "use strict";
65766
- init_constructors();
65767
- }
65768
- });
65769
-
65770
66058
  // ../src/models/classes/constructor-parameter-settlement.ts
65771
66059
  function createConstructorSettlementResolver(view) {
65772
66060
  const classesById = new Map(
@@ -76750,16 +77038,35 @@ function validateClassConstructorDescriptor(info, ctx, requireEveryRequiredField
76750
77038
  );
76751
77039
  }
76752
77040
  const genericSlot = ctx.__constructionGenericSlots?.toReversed().find((slot) => slot.classId === classId) ?? ctx.__storedConstructionReplaySlot;
76753
- const classArguments2 = genericSlot?.classId === classId ? genericSlot.classArguments : void 0;
77041
+ const slotArguments = genericSlot?.classId === classId ? genericSlot.classArguments : void 0;
76754
77042
  const descriptorCache = evaluatorResolutionCache(ctx).validatedConstructorDescriptorByInfo;
76755
- const descriptorCacheKey = `${requireEveryRequiredField}:${ctx.storedConstructionReplay === true}:${JSON.stringify(classArguments2 ?? null)}`;
77043
+ const descriptorCacheKey = `${requireEveryRequiredField}:${ctx.storedConstructionReplay === true}:${JSON.stringify(slotArguments ?? info.schemaClassInfo.typeArguments ?? null)}`;
76756
77044
  const cachedDescriptor = descriptorCache.get(info)?.get(descriptorCacheKey);
76757
77045
  if (cachedDescriptor !== void 0) return cachedDescriptor;
77046
+ const constructionDocument = {
77047
+ classes: ctx.vm.classes,
77048
+ members: ctx.vm.members,
77049
+ constructors: ctx.vm.constructors ?? [],
77050
+ values: ctx.vm.values,
77051
+ valueById: ctx.vm.databaseVM?.valueById
77052
+ };
77053
+ const classArguments2 = slotArguments ?? resolveConstructionTypeArguments(
77054
+ info.schemaClassInfo.typeArguments,
77055
+ constructionDocument
77056
+ );
76758
77057
  const cacheDescriptor = (descriptor) => {
77058
+ const complete2 = {
77059
+ ...descriptor,
77060
+ requiredSchemaKeys: requiredMembersForConstruction(
77061
+ classId,
77062
+ constructionDocument,
77063
+ classArguments2
77064
+ ).map((entry) => entry.schemaKey)
77065
+ };
76759
77066
  const variants = descriptorCache.get(info) ?? /* @__PURE__ */ new Map();
76760
- variants.set(descriptorCacheKey, descriptor);
77067
+ variants.set(descriptorCacheKey, complete2);
76761
77068
  descriptorCache.set(info, variants);
76762
- return descriptor;
77069
+ return complete2;
76763
77070
  };
76764
77071
  const instanceEnv = cachedInstanceEnv(classId, classArguments2, ctx);
76765
77072
  if (firstUnboundParamId(instanceEnv) !== null) {
@@ -77375,6 +77682,7 @@ function constructClassValueWithinFrame(descriptor, scope, ctx) {
77375
77682
  project: ctx.vm.project,
77376
77683
  members: ctx.vm.members,
77377
77684
  classes: ctx.vm.classes,
77685
+ constructors: ctx.vm.constructors,
77378
77686
  enums: ctx.vm.enums,
77379
77687
  // Declaration defaults only reference durable rows. Supplying the
77380
77688
  // immutable base plus its indexes avoids copying and linearly scanning
@@ -77461,6 +77769,15 @@ function constructClassValueWithinFrame(descriptor, scope, ctx) {
77461
77769
  `Failed to construct '${schemaClass2.name}': ${error instanceof Error ? error.message : String(error)}`
77462
77770
  );
77463
77771
  }
77772
+ if (ctx.constructionBaselineReplay !== true) {
77773
+ for (const schemaKey of descriptor.requiredSchemaKeys) {
77774
+ if (typeof root.value === "object" && root.value !== null && Reflect.get(root.value, schemaKey) != null)
77775
+ continue;
77776
+ throw new NSGetterRuntimeError(
77777
+ `Class '${schemaClass2.name}' was constructed without settling required member '${schemaKey}'.`
77778
+ );
77779
+ }
77780
+ }
77464
77781
  publishConstructedRows({
77465
77782
  root,
77466
77783
  classId,
@@ -78957,6 +79274,7 @@ function constructDeclaredClassValueWithinFrame(descriptor, record4, info, scope
78957
79274
  project: ctx.vm.project,
78958
79275
  members: ctx.vm.members,
78959
79276
  classes: ctx.vm.classes,
79277
+ constructors: ctx.vm.constructors,
78960
79278
  enums: ctx.vm.enums,
78961
79279
  values: ctx.vm.values,
78962
79280
  memberById: ctx.vm.databaseVM?.memberById,
@@ -79117,6 +79435,15 @@ function constructDeclaredClassValueWithinFrame(descriptor, record4, info, scope
79117
79435
  `Failed to construct '${schemaClass2.name}': ${error instanceof Error ? error.message : String(error)}`
79118
79436
  );
79119
79437
  }
79438
+ if (ctx.constructionBaselineReplay !== true) {
79439
+ for (const schemaKey of descriptor.requiredSchemaKeys) {
79440
+ if (typeof root.value === "object" && root.value !== null && Reflect.get(root.value, schemaKey) != null)
79441
+ continue;
79442
+ throw new NSGetterRuntimeError(
79443
+ `Class '${schemaClass2.name}' was constructed without settling required member '${schemaKey}'.`
79444
+ );
79445
+ }
79446
+ }
79120
79447
  publishConstructedRows({
79121
79448
  root,
79122
79449
  classId,
@@ -80241,6 +80568,7 @@ var DELEGATE_LEXICAL_THIS, DELEGATE_LEXICAL_ROOT, NonCatchableNSGetterRuntimeErr
80241
80568
  var init_evaluateNSGetter = __esm({
80242
80569
  "../src/runtime/neoscript/evaluateNSGetter.ts"() {
80243
80570
  "use strict";
80571
+ init_construction_requirements();
80244
80572
  init_deep_clone_plain_data();
80245
80573
  init_instance_provenance();
80246
80574
  init_NeoScriptScope();
@@ -107077,7 +107405,7 @@ function materializeDeclarationInitializersForAnimationValidation(document) {
107077
107405
  return deferredMember;
107078
107406
  }
107079
107407
  const materialized = materializeInitializerValue2({
107080
- document: { ...document, members, values: [...valuesById.values()] },
107408
+ document: { ...document, values: [...valuesById.values()] },
107081
107409
  member,
107082
107410
  row: {
107083
107411
  id: `animation-validation-default:${member.id}`,
@@ -107111,7 +107439,7 @@ function materializeDeclarationInitializersForAnimationValidation(document) {
107111
107439
  continue;
107112
107440
  }
107113
107441
  const materialized = materializeInitializerValue2({
107114
- document: { ...document, members, values: [...valuesById.values()] },
107442
+ document: { ...document, values: [...valuesById.values()] },
107115
107443
  member,
107116
107444
  row
107117
107445
  });
@@ -113289,7 +113617,6 @@ function buildValueEmitContext(records2, manifest) {
113289
113617
  },
113290
113618
  members,
113291
113619
  classes,
113292
- implicitGenericMembersByClassId: /* @__PURE__ */ new Map(),
113293
113620
  manifestMembers,
113294
113621
  manifestClasses: new Map(
113295
113622
  manifest.classes.map((schemaClass2) => [schemaClass2.id, schemaClass2])
@@ -118954,41 +119281,6 @@ function classValue(context, member, value, visited, targetTyped, outerEnvironme
118954
119281
  );
118955
119282
  overrideKeys.add(key);
118956
119283
  }
118957
- if (!partial && value.instanceVariantId == null && value.instanceVariantRowValueId == null) {
118958
- for (const [key, genericMember] of implicitGenericMembers(
118959
- context,
118960
- classId
118961
- )) {
118962
- if (key in value.value) continue;
118963
- const parameterId = stringField3(genericMember, "genericParamId");
118964
- if (!environment.has(parameterId)) continue;
118965
- const binding = resolveGenericValueMember(
118966
- context,
118967
- genericMember,
118968
- environment
118969
- );
118970
- const kind = numberField(binding, "kind");
118971
- if (!IMPLICIT_GENERIC_DEFAULT_KINDS.has(kind)) continue;
118972
- if (kind === 3 /* String */ && isLocalizedStringMember(binding))
118973
- continue;
118974
- if (binding.payload === 1 /* Partial */) continue;
118975
- const defaultValue = binding.defaultValue;
118976
- if (!isObjectRecord2(defaultValue) || !("value" in defaultValue)) continue;
118977
- const body = defaultValue.value;
118978
- if (body === null) continue;
118979
- if (Array.isArray(body) && body.length > 0) continue;
118980
- if (isObjectRecord2(body) && Object.keys(body).length > 0) continue;
118981
- const expression = emitValueBody(
118982
- context,
118983
- binding,
118984
- defaultValue,
118985
- /* @__PURE__ */ new Set(),
118986
- (defaultValue.classId ?? binding.classId) === binding.classId,
118987
- environment
118988
- );
118989
- fields.push(`${key} = ${expression}`);
118990
- }
118991
- }
118992
119284
  if (partial) {
118993
119285
  return fields.length === 0 ? "new { }" : `new {
118994
119286
  ${fields.map((field) => indentNeoSourceNonEmptyLines(field, 2)).join(",\n")}
@@ -119007,33 +119299,6 @@ ${fields.map((field) => indentNeoSourceNonEmptyLines(field, 2)).join(",\n")}
119007
119299
  ${fields.map((field) => indentNeoSourceNonEmptyLines(field, 2)).join(",\n")}
119008
119300
  }`;
119009
119301
  }
119010
- function implicitGenericMembers(context, classId) {
119011
- const cached = context.implicitGenericMembersByClassId.get(classId);
119012
- if (cached !== void 0) return cached;
119013
- const result = /* @__PURE__ */ new Map();
119014
- const seenKeys = /* @__PURE__ */ new Set();
119015
- const seenClasses = /* @__PURE__ */ new Set();
119016
- let current = context.manifestClasses.get(classId);
119017
- while (current !== void 0 && !seenClasses.has(current.id)) {
119018
- seenClasses.add(current.id);
119019
- if (current.requiredConstructorId || current.constructorIds?.length) {
119020
- result.clear();
119021
- context.implicitGenericMembersByClassId.set(classId, result);
119022
- return result;
119023
- }
119024
- for (const [key, memberId] of Object.entries(current.schema)) {
119025
- if (seenKeys.has(key)) continue;
119026
- seenKeys.add(key);
119027
- const member = context.members.get(memberId);
119028
- if (member?.kind === 21 /* Generic */ && !isObjectRecord2(member.init)) {
119029
- result.set(key, member);
119030
- }
119031
- }
119032
- current = current.extendsClassId === null ? void 0 : context.manifestClasses.get(current.extendsClassId);
119033
- }
119034
- context.implicitGenericMembersByClassId.set(classId, result);
119035
- return result;
119036
- }
119037
119302
  function emitsAsMemberDefaultDerivedAbsence(context, member, valueId) {
119038
119303
  const value = context.values.get(valueId);
119039
119304
  if (value === void 0) return false;
@@ -120031,7 +120296,13 @@ function resolveGenericValueMember(context, member, environment) {
120031
120296
  `Stored Generic member ${String(member.name ?? member.id)} resolves to missing binding member ${bindingMemberId}.`
120032
120297
  );
120033
120298
  }
120034
- return member.payload === 1 /* Partial */ ? { ...bindingMember, payload: 1 /* Partial */ } : bindingMember;
120299
+ return {
120300
+ ...bindingMember,
120301
+ id: member.id,
120302
+ name: member.name,
120303
+ defaultValue: member.defaultValue,
120304
+ ...member.payload === 1 /* Partial */ ? { payload: 1 /* Partial */ } : {}
120305
+ };
120035
120306
  }
120036
120307
  function declaringClassGenericEnvironment(context, member) {
120037
120308
  const classId = context.ownerClassIds.get(stringField3(member, "id")) ?? memberRecordOwnerClassId(member);
@@ -120103,11 +120374,17 @@ function resolveGenericSchemaMember(context, member, environment) {
120103
120374
  `Stored Generic member ${member.name} resolves to missing binding member ${bindingMemberId}.`
120104
120375
  );
120105
120376
  }
120106
- if (member.partial !== true) return bindingMember;
120107
- if (bindingMember.kind === "class" || bindingMember.kind === "generic") {
120108
- return { ...bindingMember, partial: true };
120377
+ const resolved = {
120378
+ ...bindingMember,
120379
+ id: member.id,
120380
+ name: member.name,
120381
+ defaultValue: member.defaultValue
120382
+ };
120383
+ if (member.partial !== true) return resolved;
120384
+ if (resolved.kind === "class" || resolved.kind === "generic") {
120385
+ return { ...resolved, partial: true };
120109
120386
  }
120110
- return structuredLeafPartialChild(true, bindingMember);
120387
+ return structuredLeafPartialChild(true, resolved);
120111
120388
  }
120112
120389
  function lowerInstanceGenericEnvironment(context, classId, member, outerEnvironment) {
120113
120390
  const bindings = classGenericBindings(context.classes, classId);
@@ -120569,7 +120846,7 @@ function memberDefaultBody(member) {
120569
120846
  if (!("value" in defaultValue)) return null;
120570
120847
  return defaultValue.value;
120571
120848
  }
120572
- var INFERRED_GENERIC_CLASS_PREFIX, MEMBER_KIND_DICTIONARY2, MEMBER_KIND_LIST2, MEMBER_KIND_CLASS2, IMPLICIT_GENERIC_DEFAULT_KINDS, LEADING_AUTHORED_ROW_ID, CANONICAL_CONSTRUCTOR_INLINE_WIDTH;
120849
+ var INFERRED_GENERIC_CLASS_PREFIX, MEMBER_KIND_DICTIONARY2, MEMBER_KIND_LIST2, MEMBER_KIND_CLASS2, LEADING_AUTHORED_ROW_ID, CANONICAL_CONSTRUCTOR_INLINE_WIDTH;
120573
120850
  var init_value_sources = __esm({
120574
120851
  "src/project-source/value-sources.ts"() {
120575
120852
  "use strict";
@@ -120609,16 +120886,6 @@ var init_value_sources = __esm({
120609
120886
  MEMBER_KIND_DICTIONARY2 = 5;
120610
120887
  MEMBER_KIND_LIST2 = 6;
120611
120888
  MEMBER_KIND_CLASS2 = 7;
120612
- IMPLICIT_GENERIC_DEFAULT_KINDS = /* @__PURE__ */ new Set([
120613
- 1 /* Bool */,
120614
- 2 /* Int */,
120615
- 4 /* Float */,
120616
- 20 /* Decimal */,
120617
- 3 /* String */,
120618
- 7 /* Class */,
120619
- 6 /* List */,
120620
- 5 /* Dictionary */
120621
- ]);
120622
120889
  LEADING_AUTHORED_ROW_ID = /^@id\(\s*"((?:[^"\\]|\\.)*)"\s*\)/;
120623
120890
  CANONICAL_CONSTRUCTOR_INLINE_WIDTH = 88;
120624
120891
  }
@@ -120831,7 +121098,9 @@ function emitProjectDocumentFilesV4(records2, options = {}) {
120831
121098
  })
120832
121099
  );
120833
121100
  const errors = analysis.diagnostics.filter(
120834
- (diagnostic) => diagnostic.severity === "error" && !isPullRecoveryDiagnosticCode(diagnostic.code)
121101
+ (diagnostic) => diagnostic.severity === "error" && // Pull must expose incomplete stored objects so source can repair them.
121102
+ // Status, tests, and push still reject these construction errors.
121103
+ diagnostic.code !== "unsettled-required-member" && !isPullRecoveryDiagnosticCode(diagnostic.code)
120835
121104
  );
120836
121105
  if (errors.length > 0) {
120837
121106
  throw new Error(
@@ -131577,7 +131846,7 @@ var init_registry2 = __esm({
131577
131846
  "schema-contract/registry.mjs"() {
131578
131847
  "use strict";
131579
131848
  PROJECT_SCHEMA_CONTRACT = Object.freeze({
131580
- cliVersion: "0.48.3",
131849
+ cliVersion: "0.49.0",
131581
131850
  projectFileUploadBatchSize: 32,
131582
131851
  documentRecords: {
131583
131852
  member: {
@@ -138627,7 +138896,7 @@ There is no --keep-current: preserving current semantic state defines flatten.
138627
138896
  async function main() {
138628
138897
  const args = parseArgs(process.argv.slice(2));
138629
138898
  if (args.command === "--version") {
138630
- console.log("0.48.3");
138899
+ console.log("0.49.0");
138631
138900
  return;
138632
138901
  }
138633
138902
  if (args.command === null || args.command === "help" || args.command === "--help" || args.command === "-h") {