@neocompose/cli 0.75.1 → 0.76.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.
@@ -5601,11 +5601,8 @@ function resolvedClassSchemaFromIndexes(classId, classIndex, memberIndex) {
5601
5601
  if (cached !== void 0) return cached;
5602
5602
  const chain = resolveChainFromIndex(classId, classIndex);
5603
5603
  const surface = [];
5604
- const stored = [];
5605
- const readOnly = [];
5606
5604
  const statics = [];
5607
5605
  const surfaceByKey = /* @__PURE__ */ new Map();
5608
- const storedByKey = /* @__PURE__ */ new Map();
5609
5606
  for (const entry of mergeSchemas(chain)) {
5610
5607
  const member = memberIndex.get(entry.memberId);
5611
5608
  if (member !== void 0 && isStaticMember(member)) {
@@ -5614,20 +5611,8 @@ function resolvedClassSchemaFromIndexes(classId, classIndex, memberIndex) {
5614
5611
  }
5615
5612
  surface.push(entry);
5616
5613
  surfaceByKey.set(entry.schemaKey, entry);
5617
- if (member !== void 0 && isReadOnlyMember(member)) readOnly.push(entry);
5618
- else {
5619
- stored.push(entry);
5620
- storedByKey.set(entry.schemaKey, entry);
5621
- }
5622
5614
  }
5623
- const node = {
5624
- surface,
5625
- stored,
5626
- readOnly,
5627
- statics,
5628
- surfaceByKey,
5629
- storedByKey
5630
- };
5615
+ const node = { surface, statics, surfaceByKey };
5631
5616
  byClass.set(classId, node);
5632
5617
  return node;
5633
5618
  }
@@ -5647,9 +5632,6 @@ function mergeInstanceSurfaceSchemaFromIndexes(classId, classIndex, memberIndex)
5647
5632
  ...resolvedClassSchemaFromIndexes(classId, classIndex, memberIndex).surface
5648
5633
  ];
5649
5634
  }
5650
- function mergeStoredInstanceSchema(classId, classes, members) {
5651
- return [...resolvedClassSchema(classId, classes, members).stored];
5652
- }
5653
5635
  function findSchemaPlacement(memberId, classes) {
5654
5636
  return indexClasses(classes).firstSchemaPlacement(memberId);
5655
5637
  }
@@ -5766,6 +5748,46 @@ function descendantClassIdsInChildIndex(classId, childrenByClassId) {
5766
5748
  return result;
5767
5749
  }
5768
5750
 
5751
+ // ../packages/models/src/members/instance-provenance.ts
5752
+ var LITERAL_INSTANCE_IDENTITY_FIELDS = [
5753
+ "classId",
5754
+ "constructorArgs",
5755
+ "instanceConstructorId",
5756
+ "instanceVariantId",
5757
+ "instanceVariantRowValueId",
5758
+ "genericBindings"
5759
+ ];
5760
+ function replaceLiteralValueClass(value, classId) {
5761
+ const next = { ...value, classId };
5762
+ for (const field of LITERAL_INSTANCE_IDENTITY_FIELDS) {
5763
+ if (field !== "classId") Reflect.deleteProperty(next, field);
5764
+ }
5765
+ return next;
5766
+ }
5767
+ function overlayLiteralValueContent(base, override) {
5768
+ const merged = { ...base, ...override };
5769
+ if (!("value" in override) || override.value !== null) return merged;
5770
+ for (const field of LITERAL_INSTANCE_IDENTITY_FIELDS) {
5771
+ if (!Object.hasOwn(override, field)) Reflect.deleteProperty(merged, field);
5772
+ }
5773
+ return merged;
5774
+ }
5775
+ function pickInstanceProvenance(source) {
5776
+ return {
5777
+ ...source.constructorArgs === void 0 ? {} : { constructorArgs: source.constructorArgs },
5778
+ ...source.instanceConstructorId === void 0 ? {} : { instanceConstructorId: source.instanceConstructorId },
5779
+ ...source.instanceVariantId === void 0 ? {} : { instanceVariantId: source.instanceVariantId },
5780
+ ...source.instanceVariantRowValueId === void 0 ? {} : { instanceVariantRowValueId: source.instanceVariantRowValueId }
5781
+ };
5782
+ }
5783
+ function isVirtualInstanceRootShape(value) {
5784
+ if (value.instanceConstructorId !== void 0) return true;
5785
+ return typeof value.instanceVariantId === "string";
5786
+ }
5787
+ function isCollapseStampedInstanceRoot(value) {
5788
+ return isLiteralValueContent(value) && isVirtualInstanceRootShape(value);
5789
+ }
5790
+
5769
5791
  // ../packages/models/src/system-record-id.ts
5770
5792
  var SYSTEM_RECORD_ID_PREFIX = "system_";
5771
5793
  function isSystemRecordId(id) {
@@ -5806,52 +5828,644 @@ function inSystemRecordNamespaceOf(ownerId, derivedId) {
5806
5828
  return systemRecordId(derivedId);
5807
5829
  }
5808
5830
 
5809
- // ../packages/models/src/classes/world-system-classes.generated.ts
5810
- var WORLD_SPRITE_MASK_INTERACTION_ENUM_ID = "system_4e6c4d6f-1d0b-402a-ad3a-be92242dceec";
5811
- var WORLD_SPRITE_MASK_INTERACTION_NONE_OPTION_ID = "system_9d607a4f-60c3-4347-94fc-f24b538bf468";
5812
- var WORLD_SPRITE_MASK_INTERACTION_VISIBLE_INSIDE_OPTION_ID = "system_4c670ac9-78a4-44e9-9833-94e1c69dca97";
5813
- var WORLD_SPRITE_MASK_INTERACTION_VISIBLE_OUTSIDE_OPTION_ID = "system_a0aeb200-7216-49e2-aad2-e151ff35c336";
5814
- var WORLD_ANIMATION_CHILD_OVERRIDE_ENTRY_PARAM_ID = "system_de23448a-45be-4e3f-8965-072a545e08f0";
5815
- var WORLD_ANIMATION_FRAME_OVERRIDES_MEMBER_ID = "system_8ab7bb00-a475-43f0-8579-1b08f133d658";
5816
- var WORLD_ANIMATION_FRAME_CHILD_OVERRIDES_MEMBER_ID = "system_a5905750-c472-46a8-89e9-f04f0bf66696";
5817
- var WORLD_ANIMATION_FRAME_CHILD_OVERRIDES_ENTRY_MEMBER_ID = "system_86688965-6b26-529e-95f3-a4070f022582";
5818
- var WORLD_ANIMATION_CHILD_OVERRIDE_OVERRIDES_MEMBER_ID = "system_819b3743-0c3d-4896-b679-9aeeb73255f4";
5819
- var WORLD_PLAY_DIRECTION_ENUM_ID = "system_705ccc39-e46e-4c9f-af3e-3ec8fd818709";
5820
- var WORLD_PLAY_DIRECTION_FORWARD_OPTION_ID = "system_2e4ca40e-f305-49c6-a91b-b99d56239ba0";
5821
- var WORLD_PLAY_DIRECTION_REVERSE_OPTION_ID = "system_6478d195-3905-48db-befe-d276eb5478f0";
5822
- var WORLD_SYSTEM_CLASS_DEFINITIONS = [
5823
- {
5824
- classId: "system_fb9c4080-0148-530e-b9c0-8cd1c17ff8e7",
5825
- name: "NeoCellPattern",
5826
- docsText: "An immutable ordered pattern of cell offsets, relative to an origin.\nHand-built patterns preserve order and duplicates; factories order cells nearest first.",
5827
- modifier: 2 /* Sealed */,
5828
- constructorIds: ["system_f68684d6-6ea0-5d57-9f96-d544b17bf369"],
5829
- constructors: [
5830
- {
5831
- constructorId: "system_f68684d6-6ea0-5d57-9f96-d544b17bf369",
5832
- argumentTypes: [
5833
- {
5834
- name: "offsets",
5835
- type: 6,
5836
- required: true,
5837
- entryTypeInfo: { type: 15, required: true }
5838
- }
5839
- ],
5840
- code: "this._offsets = offsets.Select((offset) => { return Vector2Int(offset.x, offset.y); });"
5831
+ // ../packages/models/src/members/member-value-id.ts
5832
+ var NEO_MEMBER_VALUE_NAMESPACE = "7f2b9c14-58d6-5a07-b3e1-4c9d0a6f8b25";
5833
+ var NEO_VIRTUAL_VALUE_NAMESPACE = "3e8ca0b3-e3f1-5d5f-bf2f-6ab5ee3896d0";
5834
+ var virtualNamespaceBytes = parse_default(NEO_VIRTUAL_VALUE_NAMESPACE);
5835
+ var virtualIdentityEncoder = new TextEncoder();
5836
+ var SURROGATE_CODE_UNIT = /[\ud800-\udfff]/;
5837
+ function derivedMemberValueId(memberId) {
5838
+ return inSystemRecordNamespaceOf(
5839
+ memberId,
5840
+ v5_default(withoutSystemRecordIdPrefix(memberId), NEO_MEMBER_VALUE_NAMESPACE)
5841
+ );
5842
+ }
5843
+ function virtualValueId(instanceRootId, sourceIdentity2) {
5844
+ const identity = `${withoutSystemRecordIdPrefix(instanceRootId)}:${sourceIdentity2}`;
5845
+ const bytes = SURROGATE_CODE_UNIT.test(identity) ? identity : virtualIdentityEncoder.encode(identity);
5846
+ return inSystemRecordNamespaceOf(
5847
+ instanceRootId,
5848
+ v5_default(bytes, virtualNamespaceBytes)
5849
+ );
5850
+ }
5851
+ function virtualSourceIdentityHead(sourceIdentity2) {
5852
+ const pathStart = sourceIdentity2.indexOf(":$");
5853
+ return pathStart < 0 ? sourceIdentity2 : sourceIdentity2.slice(0, pathStart);
5854
+ }
5855
+ function hasPendingVirtualSourceIdentity(sourceIdentity2) {
5856
+ const head = virtualSourceIdentityHead(sourceIdentity2);
5857
+ return head.startsWith("path:__pending__:") || head.startsWith("__pending__:");
5858
+ }
5859
+ var PENDING_VIRTUAL_VALUE_PREFIX = "__pending__:virtual-value:";
5860
+ function pendingVirtualValueId(pendingInstanceRootId, sourceIdentity2) {
5861
+ return `${PENDING_VIRTUAL_VALUE_PREFIX}${encodeURIComponent(pendingInstanceRootId)}:${encodeURIComponent(sourceIdentity2)}`;
5862
+ }
5863
+
5864
+ // ../packages/models/src/members/packed-value-encoding.ts
5865
+ var PACKED_VALUE_ENTRY_KEY = "~packed";
5866
+ var PackedValueEncodingError = class extends Error {
5867
+ constructor(message) {
5868
+ super(message);
5869
+ this.name = "PackedValueEncodingError";
5870
+ }
5871
+ };
5872
+ var NO_CHILDREN = [];
5873
+ var NO_EDGES = /* @__PURE__ */ new Map();
5874
+ function isPackedValueEnvelope(value) {
5875
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
5876
+ return false;
5877
+ }
5878
+ return Object.hasOwn(value, PACKED_VALUE_ENTRY_KEY);
5879
+ }
5880
+ function rowCarriesPackedValueContent(content) {
5881
+ if (containerHoldsPackedEntry(content.value)) return true;
5882
+ return containerHoldsPackedEntry(content.constructorArgs);
5883
+ }
5884
+ function expandPackedValueRows(rows) {
5885
+ let firstPacked = -1;
5886
+ for (let index = 0; index < rows.length; index += 1) {
5887
+ const row = rows[index];
5888
+ if (row === void 0 || !rowCarriesPackedValueContent(row)) continue;
5889
+ firstPacked = index;
5890
+ break;
5891
+ }
5892
+ if (firstPacked < 0) return rows;
5893
+ const expanded = rows.slice(0, firstPacked);
5894
+ for (let index = firstPacked; index < rows.length; index += 1) {
5895
+ const row = rows[index];
5896
+ if (row === void 0) continue;
5897
+ const decoded = decodePackedValueRow(row);
5898
+ expanded.push(decoded.row, ...decoded.children);
5899
+ }
5900
+ return expanded;
5901
+ }
5902
+ function expandPackedDocumentValues(document2) {
5903
+ const stored = document2.values;
5904
+ const expanded = expandPackedValueRows(stored);
5905
+ if (expanded === stored) return document2;
5906
+ return { ...document2, values: expanded };
5907
+ }
5908
+ function decodePackedValueRow(row) {
5909
+ if (!rowCarriesPackedValueContent(row)) {
5910
+ return { row, children: NO_CHILDREN, packedChildIdsByParentId: NO_EDGES };
5911
+ }
5912
+ const state = {
5913
+ edges: /* @__PURE__ */ new Map(),
5914
+ seenIds: /* @__PURE__ */ new Set([row.id]),
5915
+ projectId: row.projectId,
5916
+ mapKey: row.mapKey
5917
+ };
5918
+ const children = [];
5919
+ const scope = {
5920
+ state,
5921
+ ownerId: row.id,
5922
+ ownerLabel: `value "${row.id}"`,
5923
+ constructionRootId: isCollapseStampedInstanceRoot(row) ? row.id : null
5924
+ };
5925
+ const value = decodeContentField(row.value, "value", scope, children);
5926
+ const constructorArgs = decodeContentField(
5927
+ isLiteralValueContent(row) ? row.constructorArgs : void 0,
5928
+ "constructorArgs",
5929
+ scope,
5930
+ children
5931
+ );
5932
+ return {
5933
+ row: withDecodedContent(row, value, constructorArgs),
5934
+ children,
5935
+ packedChildIdsByParentId: state.edges
5936
+ };
5937
+ }
5938
+ function canonicalPackedChildId(args) {
5939
+ if (args.constructionRootId === null) return null;
5940
+ if (typeof args.sourceValueId !== "string") return null;
5941
+ if (args.sourceValueId.length === 0) return null;
5942
+ return virtualValueId(args.constructionRootId, args.sourceValueId);
5943
+ }
5944
+ function decodeContentField(container, field, scope, children) {
5945
+ if (!containerHoldsPackedEntry(container)) return null;
5946
+ if (Array.isArray(container)) {
5947
+ return {
5948
+ content: container.map(
5949
+ (entry, index) => isPackedValueEnvelope(entry) ? decodeEnvelope(entry, `${field}[${index}]`, scope, children) : entry
5950
+ )
5951
+ };
5952
+ }
5953
+ const decoded = {};
5954
+ for (const [key, entry] of Object.entries(
5955
+ container
5956
+ )) {
5957
+ decoded[key] = isPackedValueEnvelope(entry) ? decodeEnvelope(
5958
+ entry,
5959
+ `${field}[${JSON.stringify(key)}]`,
5960
+ scope,
5961
+ children
5962
+ ) : entry;
5963
+ }
5964
+ return { content: decoded };
5965
+ }
5966
+ function decodeEnvelope(envelope, position, scope, children) {
5967
+ const label = `Packed value entry at ${scope.ownerLabel}.${position}`;
5968
+ const entry = envelope[PACKED_VALUE_ENTRY_KEY];
5969
+ assertDecodableEntry(entry, label);
5970
+ const id = packedEntryLogicalId(entry, label, scope.constructionRootId);
5971
+ if (scope.state.seenIds.has(id)) {
5972
+ throw new PackedValueEncodingError(
5973
+ `${label} resolves to id "${id}", which another row in the same packed payload already claims.`
5974
+ );
5975
+ }
5976
+ scope.state.seenIds.add(id);
5977
+ registerEdge(scope.state.edges, scope.ownerId, id);
5978
+ const childScope = {
5979
+ state: scope.state,
5980
+ ownerId: id,
5981
+ ownerLabel: `packed value "${id}"`,
5982
+ constructionRootId: isCollapseStampedInstanceRoot(entry) ? id : scope.constructionRootId
5983
+ };
5984
+ const nested = [];
5985
+ children.push(logicalChildRow(entry, id, childScope, nested));
5986
+ children.push(...nested);
5987
+ return id;
5988
+ }
5989
+ function logicalChildRow(entry, id, scope, children) {
5990
+ const rowFields = {
5991
+ id,
5992
+ projectId: scope.state.projectId,
5993
+ createdAt: entry.createdAt,
5994
+ updatedAt: entry.updatedAt,
5995
+ ...scope.state.mapKey === void 0 ? {} : { mapKey: scope.state.mapKey },
5996
+ ...entry.genericBindings === void 0 ? {} : { genericBindings: entry.genericBindings },
5997
+ ...entry.sourceValueId === void 0 ? {} : { sourceValueId: entry.sourceValueId }
5998
+ };
5999
+ if (isInitValueContent(entry)) return { ...rowFields, init: entry.init };
6000
+ const value = decodeContentField(entry.value, "value", scope, children);
6001
+ const constructorArgs = decodeContentField(
6002
+ entry.constructorArgs,
6003
+ "constructorArgs",
6004
+ scope,
6005
+ children
6006
+ );
6007
+ return {
6008
+ ...rowFields,
6009
+ ...literalContent(entry, value, constructorArgs)
6010
+ };
6011
+ }
6012
+ function packedEntryLogicalId(entry, label, constructionRootId) {
6013
+ const canonical = canonicalPackedChildId({
6014
+ constructionRootId,
6015
+ sourceValueId: entry.sourceValueId
6016
+ });
6017
+ const stored = entry.id;
6018
+ if (stored === void 0) {
6019
+ if (canonical === null) {
6020
+ throw new PackedValueEncodingError(
6021
+ `${label} stores no "id" and its position derives none: only a deterministic child of an enclosing construction root, stamped with a "sourceValueId", may omit its logical id.`
6022
+ );
6023
+ }
6024
+ return canonical;
6025
+ }
6026
+ if (typeof stored !== "string" || stored.length === 0) {
6027
+ throw new PackedValueEncodingError(
6028
+ `${label} stores an "id" that is not a non-empty string.`
6029
+ );
6030
+ }
6031
+ if (stored === canonical) {
6032
+ throw new PackedValueEncodingError(
6033
+ `${label} stores id "${stored}", which its position already derives; a derivable id must be omitted rather than repeated.`
6034
+ );
6035
+ }
6036
+ return stored;
6037
+ }
6038
+ var PACKED_ENTRY_FORBIDDEN_FIELDS = [
6039
+ "projectId",
6040
+ "containerId",
6041
+ "mapKey"
6042
+ ];
6043
+ function assertDecodableEntry(entry, label) {
6044
+ if (typeof entry !== "object" || entry === null || Array.isArray(entry)) {
6045
+ throw new PackedValueEncodingError(`${label} is not an object.`);
6046
+ }
6047
+ for (const field of PACKED_ENTRY_FORBIDDEN_FIELDS) {
6048
+ if (!Object.hasOwn(entry, field)) continue;
6049
+ throw new PackedValueEncodingError(
6050
+ `${label} stores "${field}", which decoding derives from its owning row.`
6051
+ );
6052
+ }
6053
+ if (!("createdAt" in entry) || typeof entry.createdAt !== "number") {
6054
+ throw new PackedValueEncodingError(
6055
+ `${label} stores no numeric "createdAt".`
6056
+ );
6057
+ }
6058
+ if (!("updatedAt" in entry) || typeof entry.updatedAt !== "number") {
6059
+ throw new PackedValueEncodingError(
6060
+ `${label} stores no numeric "updatedAt".`
6061
+ );
6062
+ }
6063
+ const hasValue = Object.hasOwn(entry, "value");
6064
+ const hasInit = Object.hasOwn(entry, "init");
6065
+ if (hasValue && hasInit) {
6066
+ throw new PackedValueEncodingError(
6067
+ `${label} stores both "value" and "init"; a value container holds exactly one.`
6068
+ );
6069
+ }
6070
+ if (!hasValue && !hasInit) {
6071
+ throw new PackedValueEncodingError(
6072
+ `${label} stores neither "value" nor "init"; a value container holds exactly one.`
6073
+ );
6074
+ }
6075
+ if (hasInit && !isInitValueContent(entry)) {
6076
+ throw new PackedValueEncodingError(
6077
+ `${label} stores an "init" that is not a valid initializer body.`
6078
+ );
6079
+ }
6080
+ if (hasValue && !isLiteralValueContent(entry)) {
6081
+ throw new PackedValueEncodingError(
6082
+ `${label} stores a "value" whose class or construction stamp is malformed.`
6083
+ );
6084
+ }
6085
+ }
6086
+ function literalContent(content, value, constructorArgs) {
6087
+ if (!isLiteralValueContent(content)) {
6088
+ throw new PackedValueEncodingError(
6089
+ `Value container has no literal "value" to encode.`
6090
+ );
6091
+ }
6092
+ const provenance = pickInstanceProvenance(content);
6093
+ return {
6094
+ value: value === null ? content.value : value.content,
6095
+ ...Object.hasOwn(content, "classId") ? { classId: content.classId } : {},
6096
+ ...provenance,
6097
+ ...constructorArgs === null ? {} : { constructorArgs: asConstructorArgs(constructorArgs.content) }
6098
+ };
6099
+ }
6100
+ function withDecodedContent(row, value, constructorArgs) {
6101
+ if (value === null && constructorArgs === null) return row;
6102
+ return { ...row, ...literalContent(row, value, constructorArgs) };
6103
+ }
6104
+ function asConstructorArgs(content) {
6105
+ if (content === null) return null;
6106
+ if (typeof content !== "object" || Array.isArray(content)) {
6107
+ throw new PackedValueEncodingError(
6108
+ `Value container stores "constructorArgs" that is not a record.`
6109
+ );
6110
+ }
6111
+ return content;
6112
+ }
6113
+ function containerHoldsPackedEntry(container) {
6114
+ if (Array.isArray(container)) {
6115
+ return container.some((entry) => isPackedValueEnvelope(entry));
6116
+ }
6117
+ if (typeof container !== "object" || container === null) return false;
6118
+ for (const entry of Object.values(container)) {
6119
+ if (isPackedValueEnvelope(entry)) return true;
6120
+ }
6121
+ return false;
6122
+ }
6123
+ function registerEdge(edges, ownerId, childId) {
6124
+ const existing = edges.get(ownerId);
6125
+ if (existing === void 0) edges.set(ownerId, [childId]);
6126
+ else existing.push(childId);
6127
+ }
6128
+
6129
+ // ../packages/models/src/members/unordered-list-membership.ts
6130
+ function buildUnorderedListMembershipIndex(values) {
6131
+ const membersByContainerId = /* @__PURE__ */ new Map();
6132
+ for (const candidate of values) {
6133
+ const containerId = candidate.containerId;
6134
+ if (typeof containerId !== "string") continue;
6135
+ const bucket = membersByContainerId.get(containerId);
6136
+ if (bucket === void 0) {
6137
+ membersByContainerId.set(containerId, [candidate.id]);
6138
+ } else {
6139
+ bucket.push(candidate.id);
6140
+ }
6141
+ }
6142
+ for (const bucket of membersByContainerId.values()) {
6143
+ bucket.sort();
6144
+ }
6145
+ return membersByContainerId;
6146
+ }
6147
+
6148
+ // ../packages/models/src/members/member-storage-key.ts
6149
+ var MAIN_STORAGE_PARTITION = "main";
6150
+ var STORAGE_KEY_INHERIT = "inherit";
6151
+ var STORAGE_KEY_ALL = "all";
6152
+ var PARENT_CLASS_TEMPLATE_TOKEN = "$parentClass";
6153
+ function normalizeStorageKeyDeclaration(declaration) {
6154
+ if (declaration === void 0 || declaration === null) {
6155
+ return STORAGE_KEY_INHERIT;
6156
+ }
6157
+ if (declaration.length === 0) return STORAGE_KEY_INHERIT;
6158
+ if (declaration === STORAGE_KEY_ALL) {
6159
+ throw new Error(
6160
+ 'Storage key "all" is reserved for partition-scoped reads and cannot be declared on a member.'
6161
+ );
6162
+ }
6163
+ return declaration;
6164
+ }
6165
+ function storageKeyReferencesParentClass(declaration) {
6166
+ return declaration.includes(PARENT_CLASS_TEMPLATE_TOKEN);
6167
+ }
6168
+ function resolveMapKeyForCreatedValue(args) {
6169
+ const declaration = normalizeStorageKeyDeclaration(args.declaration);
6170
+ if (declaration === STORAGE_KEY_INHERIT) return args.parentMapKey;
6171
+ if (declaration === MAIN_STORAGE_PARTITION) return null;
6172
+ if (storageKeyReferencesParentClass(declaration)) {
6173
+ if (args.parentClassId === void 0) {
6174
+ throw new Error(
6175
+ `Storage key "${declaration}" references ${PARENT_CLASS_TEMPLATE_TOKEN}, but the placement parent value has no classId (only class-valued parents can anchor a ${PARENT_CLASS_TEMPLATE_TOKEN} partition).`
6176
+ );
6177
+ }
6178
+ return declaration.replaceAll(
6179
+ PARENT_CLASS_TEMPLATE_TOKEN,
6180
+ args.parentClassId
6181
+ );
6182
+ }
6183
+ return declaration;
6184
+ }
6185
+
6186
+ // ../packages/models/src/members/storage-partitions.ts
6187
+ function stampCreatedValuesMapKey(values, mapKey) {
6188
+ const normalized = mapKey === void 0 || mapKey === null || mapKey.length === 0 || mapKey === MAIN_STORAGE_PARTITION ? null : mapKey;
6189
+ for (const value of values) {
6190
+ if (normalized === null) {
6191
+ delete value.mapKey;
6192
+ } else {
6193
+ value.mapKey = normalized;
6194
+ }
6195
+ }
6196
+ }
6197
+ function applyDeclaredStorageKeyOverrides(args) {
6198
+ const boundaryValues = args.createdValues.filter(
6199
+ (value) => normalizeStorageKeyDeclaration(
6200
+ args.declarationByValueId.get(value.id)
6201
+ ) !== STORAGE_KEY_INHERIT
6202
+ );
6203
+ if (boundaryValues.length === 0) return;
6204
+ const createdById = new Map(
6205
+ args.createdValues.map((value) => [value.id, value])
6206
+ );
6207
+ const parentOf = /* @__PURE__ */ new Map();
6208
+ for (const value of args.createdValues) {
6209
+ for (const childId of referencedValueIdCandidates(value.value)) {
6210
+ if (createdById.has(childId)) parentOf.set(childId, value);
6211
+ }
6212
+ }
6213
+ for (const value of args.createdValues) {
6214
+ if (typeof value.containerId !== "string") continue;
6215
+ const container = createdById.get(value.containerId);
6216
+ if (container !== void 0) parentOf.set(value.id, container);
6217
+ }
6218
+ const depthOf = (value) => {
6219
+ let depth = 0;
6220
+ let current = value;
6221
+ const seen = /* @__PURE__ */ new Set();
6222
+ while (current !== void 0 && !seen.has(current.id)) {
6223
+ seen.add(current.id);
6224
+ current = parentOf.get(current.id);
6225
+ if (current !== void 0) depth += 1;
6226
+ }
6227
+ return depth;
6228
+ };
6229
+ const boundaries = boundaryValues.sort((left, right) => depthOf(left) - depthOf(right));
6230
+ for (const boundary of boundaries) {
6231
+ const parentCreated = parentOf.get(boundary.id);
6232
+ const parent = parentCreated !== void 0 ? {
6233
+ mapKey: parentCreated.mapKey ?? null,
6234
+ classId: parentCreated.classId ?? void 0
6235
+ } : args.existingParentContextById?.get(boundary.id);
6236
+ if (parent === void 0) {
6237
+ throw new Error(
6238
+ `Cannot resolve storage partition for created value "${boundary.id}": its placement parent is neither a created value nor supplied in existingParentContextById.`
6239
+ );
6240
+ }
6241
+ const mapKey = resolveMapKeyForCreatedValue({
6242
+ declaration: args.declarationByValueId.get(boundary.id),
6243
+ parentMapKey: parent.mapKey,
6244
+ parentClassId: parent.classId
6245
+ });
6246
+ for (const member of collectCreatedSubtreeValues(
6247
+ boundary,
6248
+ args.createdValues
6249
+ )) {
6250
+ if (mapKey === null || mapKey === MAIN_STORAGE_PARTITION) {
6251
+ delete member.mapKey;
6252
+ } else {
6253
+ member.mapKey = mapKey;
5841
6254
  }
5842
- ],
5843
- schemaFields: [
5844
- {
5845
- memberId: "system_02a01003-41ff-531c-a63c-1e905ca88d7d",
5846
- memberKind: "list",
5847
- access: 2 /* Private */,
5848
- modifier: 1 /* Sealed */,
5849
- defaultValue: [],
5850
- entryMemberId: "system_1efcbead-df5b-5d09-b0ca-758039c06fca",
5851
- requirement: 1 /* Required */,
5852
- schemaKey: "_offsets"
5853
- },
5854
- {
6255
+ }
6256
+ }
6257
+ }
6258
+ function collectCreatedSubtreeValues(root, createdValues) {
6259
+ const createdById = new Map(createdValues.map((value) => [value.id, value]));
6260
+ const subtree = [];
6261
+ const visited = /* @__PURE__ */ new Set();
6262
+ const queue = [root];
6263
+ while (queue.length > 0) {
6264
+ const current = queue.shift();
6265
+ if (current === void 0) break;
6266
+ if (visited.has(current.id)) continue;
6267
+ visited.add(current.id);
6268
+ subtree.push(current);
6269
+ for (const childId of referencedValueIdCandidates(current.value)) {
6270
+ const child = createdById.get(childId);
6271
+ if (child !== void 0) queue.push(child);
6272
+ }
6273
+ for (const candidate of createdValues) {
6274
+ if (candidate.containerId === current.id) queue.push(candidate);
6275
+ }
6276
+ }
6277
+ return subtree;
6278
+ }
6279
+ function referencedValueIdCandidates(value) {
6280
+ if (Array.isArray(value)) {
6281
+ return value.filter((entry) => typeof entry === "string");
6282
+ }
6283
+ if (typeof value === "object" && value !== null) {
6284
+ return Object.values(value).filter(
6285
+ (entry) => typeof entry === "string"
6286
+ );
6287
+ }
6288
+ return [];
6289
+ }
6290
+
6291
+ // ../packages/models/src/core/auth-ownership-types.ts
6292
+ var ActorKind = {
6293
+ /**
6294
+ * `better-auth` user identities.
6295
+ */
6296
+ user: "user",
6297
+ /**
6298
+ * `better-auth` organization identities.
6299
+ */
6300
+ organization: "organization",
6301
+ /**
6302
+ * Used for denoting records created by a system.
6303
+ */
6304
+ system: "system"
6305
+ };
6306
+ function isActorIdentifier(value) {
6307
+ if (typeof value !== "object") return false;
6308
+ if (value === null) return false;
6309
+ const candidate = value;
6310
+ if (!isActorKind(candidate.kind)) return false;
6311
+ return typeof candidate.id === "string" && candidate.id.trim().length > 0;
6312
+ }
6313
+ function isActorKind(value) {
6314
+ return value === ActorKind.user || value === ActorKind.organization || value === ActorKind.system;
6315
+ }
6316
+
6317
+ // ../packages/models/src/members/member-change-listeners.ts
6318
+ function editChangeListenerSet(explicit, inherited, edit, options = { inheritedComplete: true }) {
6319
+ if (edit.kind === "reset") {
6320
+ return explicit === void 0 ? { changed: false } : { changed: true, targets: void 0 };
6321
+ }
6322
+ const current = explicit ?? inherited;
6323
+ let next;
6324
+ if (edit.kind === "replace") {
6325
+ next = edit.targets;
6326
+ } else {
6327
+ const identity = nsActionListenerIdentity(edit.target);
6328
+ const index = current.findIndex(
6329
+ (target) => nsActionListenerIdentity(target) === identity
6330
+ );
6331
+ if (edit.kind === "add") {
6332
+ if (index !== -1) return { changed: false };
6333
+ next = [...current, edit.target];
6334
+ } else {
6335
+ if (index === -1) return { changed: false };
6336
+ next = current.filter((_, i) => i !== index);
6337
+ }
6338
+ }
6339
+ const targets = [];
6340
+ const seen = /* @__PURE__ */ new Set();
6341
+ for (const target of next) {
6342
+ const identity = nsActionListenerIdentity(target);
6343
+ if (seen.has(identity))
6344
+ throw new Error("A listener set cannot repeat a handler identity.");
6345
+ seen.add(identity);
6346
+ targets.push({ memberId: target.memberId, valueId: target.valueId });
6347
+ }
6348
+ if (targets.length === 0 && inherited.length === 0 && options.inheritedComplete) {
6349
+ return explicit === void 0 ? { changed: false } : { changed: true, targets: void 0 };
6350
+ }
6351
+ if (explicit !== void 0 && sameChangeListeners(explicit, targets))
6352
+ return { changed: false };
6353
+ return { changed: true, targets };
6354
+ }
6355
+ function sameChangeListeners(left, right) {
6356
+ return left.length === right.length && left.every(
6357
+ (entry, index) => entry.memberId === right[index].memberId && entry.valueId === right[index].valueId
6358
+ );
6359
+ }
6360
+ function remapChangeListenerMap(map, identities, policy, internalEndpoints) {
6361
+ if (!map) return void 0;
6362
+ const result = {};
6363
+ for (const [ownerId, members] of Object.entries(map)) {
6364
+ const owner = identities.get(ownerId);
6365
+ if (owner === void 0) continue;
6366
+ const entry = {};
6367
+ for (const [memberId, targets] of Object.entries(members)) {
6368
+ const remapped = [];
6369
+ for (const target of targets) {
6370
+ const receiver = target.valueId === null ? null : identities.get(target.valueId);
6371
+ if (receiver === void 0 && (policy === "clone" || target.valueId !== null && internalEndpoints !== void 0 && internalEndpoints.has(target.valueId)))
6372
+ continue;
6373
+ remapped.push({
6374
+ memberId: target.memberId,
6375
+ valueId: receiver ?? target.valueId
6376
+ });
6377
+ }
6378
+ setOwnField(entry, memberId, remapped);
6379
+ }
6380
+ setOwnField(result, owner, entry);
6381
+ }
6382
+ return Object.keys(result).length === 0 ? void 0 : result;
6383
+ }
6384
+ var authoredListenerIndexes = /* @__PURE__ */ new WeakMap();
6385
+ function authoredChangeListenerOwners(rows) {
6386
+ const index = authoredListenerIndexes.get(rows);
6387
+ if (index !== void 0) return index;
6388
+ const owners = /* @__PURE__ */ new Map();
6389
+ for (const row of rows)
6390
+ for (const [ownerId, entry] of Object.entries(row.changeListeners ?? {})) {
6391
+ if (owners.has(ownerId))
6392
+ throw new Error(
6393
+ `Listener owner "${ownerId}" is declared on more than one binding root.`
6394
+ );
6395
+ owners.set(ownerId, entry);
6396
+ }
6397
+ authoredListenerIndexes.set(rows, owners);
6398
+ return owners;
6399
+ }
6400
+ var declarationListenerMetadata = /* @__PURE__ */ new WeakMap();
6401
+ function hasAuthoredChangeListenerMetadata(document2) {
6402
+ if (authoredChangeListenerOwners(document2.values).size !== 0) return true;
6403
+ let present = declarationListenerMetadata.get(document2.members);
6404
+ if (present === void 0) {
6405
+ present = document2.members.some(
6406
+ (member) => member.defaultValue?.changeListeners !== void 0
6407
+ );
6408
+ declarationListenerMetadata.set(document2.members, present);
6409
+ }
6410
+ return present;
6411
+ }
6412
+ function defaultSourceWithListeners(row, graph) {
6413
+ if (row === null || graph == null || graph.instanceRootId !== row.id)
6414
+ return row;
6415
+ const inherited = graph.listenerDefaultsByOwner;
6416
+ if (inherited === void 0 || inherited.size === 0) return row;
6417
+ const map = Object.fromEntries(inherited);
6418
+ for (const [id, entry] of Object.entries(row.changeListeners ?? {}))
6419
+ setOwnField(map, id, { ...map[id], ...entry });
6420
+ return { ...row, changeListeners: map };
6421
+ }
6422
+
6423
+ // ../packages/models/src/classes/world-system-classes.generated.ts
6424
+ var WORLD_SPRITE_MASK_INTERACTION_ENUM_ID = "system_4e6c4d6f-1d0b-402a-ad3a-be92242dceec";
6425
+ var WORLD_SPRITE_MASK_INTERACTION_NONE_OPTION_ID = "system_9d607a4f-60c3-4347-94fc-f24b538bf468";
6426
+ var WORLD_SPRITE_MASK_INTERACTION_VISIBLE_INSIDE_OPTION_ID = "system_4c670ac9-78a4-44e9-9833-94e1c69dca97";
6427
+ var WORLD_SPRITE_MASK_INTERACTION_VISIBLE_OUTSIDE_OPTION_ID = "system_a0aeb200-7216-49e2-aad2-e151ff35c336";
6428
+ var WORLD_ANIMATION_CHILD_OVERRIDE_ENTRY_PARAM_ID = "system_de23448a-45be-4e3f-8965-072a545e08f0";
6429
+ var WORLD_ANIMATION_FRAME_OVERRIDES_MEMBER_ID = "system_8ab7bb00-a475-43f0-8579-1b08f133d658";
6430
+ var WORLD_ANIMATION_FRAME_CHILD_OVERRIDES_MEMBER_ID = "system_a5905750-c472-46a8-89e9-f04f0bf66696";
6431
+ var WORLD_ANIMATION_FRAME_CHILD_OVERRIDES_ENTRY_MEMBER_ID = "system_86688965-6b26-529e-95f3-a4070f022582";
6432
+ var WORLD_ANIMATION_CHILD_OVERRIDE_OVERRIDES_MEMBER_ID = "system_819b3743-0c3d-4896-b679-9aeeb73255f4";
6433
+ var WORLD_PLAY_DIRECTION_ENUM_ID = "system_705ccc39-e46e-4c9f-af3e-3ec8fd818709";
6434
+ var WORLD_PLAY_DIRECTION_FORWARD_OPTION_ID = "system_2e4ca40e-f305-49c6-a91b-b99d56239ba0";
6435
+ var WORLD_PLAY_DIRECTION_REVERSE_OPTION_ID = "system_6478d195-3905-48db-befe-d276eb5478f0";
6436
+ var WORLD_SYSTEM_CLASS_DEFINITIONS = [
6437
+ {
6438
+ classId: "system_fb9c4080-0148-530e-b9c0-8cd1c17ff8e7",
6439
+ name: "NeoCellPattern",
6440
+ docsText: "An immutable ordered pattern of cell offsets, relative to an origin.\nHand-built patterns preserve order and duplicates; factories order cells nearest first.",
6441
+ modifier: 2 /* Sealed */,
6442
+ constructorIds: ["system_f68684d6-6ea0-5d57-9f96-d544b17bf369"],
6443
+ constructors: [
6444
+ {
6445
+ constructorId: "system_f68684d6-6ea0-5d57-9f96-d544b17bf369",
6446
+ argumentTypes: [
6447
+ {
6448
+ name: "offsets",
6449
+ type: 6,
6450
+ required: true,
6451
+ entryTypeInfo: { type: 15, required: true }
6452
+ }
6453
+ ],
6454
+ code: "this._offsets = offsets.Select((offset) => { return Vector2Int(offset.x, offset.y); });"
6455
+ }
6456
+ ],
6457
+ schemaFields: [
6458
+ {
6459
+ memberId: "system_02a01003-41ff-531c-a63c-1e905ca88d7d",
6460
+ memberKind: "list",
6461
+ access: 2 /* Private */,
6462
+ modifier: 1 /* Sealed */,
6463
+ defaultValue: [],
6464
+ entryMemberId: "system_1efcbead-df5b-5d09-b0ca-758039c06fca",
6465
+ requirement: 1 /* Required */,
6466
+ schemaKey: "_offsets"
6467
+ },
6468
+ {
5855
6469
  memberId: "system_51d883c9-d451-5747-bcf0-e314e44bffa8",
5856
6470
  memberKind: "computed",
5857
6471
  docsText: "Number of offsets, including any duplicates.",
@@ -7805,6 +8419,43 @@ function clonePlain(value, path, visiting) {
7805
8419
  }
7806
8420
  }
7807
8421
 
8422
+ // ../packages/models/src/classes/world-system-classes.ts
8423
+ var WORLD_SYSTEM_CLASS_DEFINITION_BY_KIND = new Map(
8424
+ WORLD_SYSTEM_CLASS_DEFINITIONS.map((definition) => [
8425
+ definition.worldKind,
8426
+ definition
8427
+ ])
8428
+ );
8429
+ function worldSystemSchemaFieldsForKind(worldKind) {
8430
+ return WORLD_SYSTEM_CLASS_DEFINITION_BY_KIND.get(worldKind)?.schemaFields ?? [];
8431
+ }
8432
+ var WORLD_SYSTEM_ANIMATION_KIND_MARKER = "animation";
8433
+ var WORLD_SYSTEM_ANIMATION_KINDS = new Set(
8434
+ WORLD_SYSTEM_CLASS_DEFINITIONS.map(
8435
+ (definition) => definition.worldKind
8436
+ ).filter(
8437
+ (worldKind) => worldKind.toLowerCase().includes(WORLD_SYSTEM_ANIMATION_KIND_MARKER)
8438
+ )
8439
+ );
8440
+ var GENERIC_WORLD_SYSTEM_CLASS_KINDS = new Set(
8441
+ WORLD_SYSTEM_CLASS_DEFINITIONS.filter(
8442
+ (definition) => (definition.genericParams?.length ?? 0) > 0
8443
+ ).map((definition) => definition.worldKind)
8444
+ );
8445
+ var WORLD_SYSTEM_ALL_KINDS = new Set(
8446
+ WORLD_SYSTEM_CLASS_DEFINITIONS.map((definition) => definition.worldKind)
8447
+ );
8448
+ var WORLD_SYSTEM_SCHEMA_FIELD_SITES_BY_MEMBER_ID = new Map(
8449
+ WORLD_SYSTEM_CLASS_DEFINITIONS.flatMap(
8450
+ (definition) => (definition.schemaFields ?? []).map(
8451
+ (field) => [
8452
+ field.memberId,
8453
+ { worldKind: definition.worldKind, schemaKey: field.schemaKey }
8454
+ ]
8455
+ )
8456
+ )
8457
+ );
8458
+
7808
8459
  // ../packages/models/src/classes/generics.ts
7809
8460
  var genericBindingsByClassIndex = /* @__PURE__ */ new WeakMap();
7810
8461
  function resolveGenericEnv(classId, classes, draft) {
@@ -8326,813 +8977,181 @@ function entrySignature(entryMemberId, env, members, seen) {
8326
8977
  if (!entryMember) {
8327
8978
  throw new Error(
8328
8979
  `typeArgumentSignatureOfMember: entry member "${entryMemberId}" does not exist in the document.`
8329
- );
8330
- }
8331
- return typeArgumentSignatureOfMember(entryMember, env, members, seen);
8332
- }
8333
- function typeArgumentSignatureOfBinding(binding, env, members, seen = /* @__PURE__ */ new Set()) {
8334
- if (isForwardedGenericBinding(binding)) {
8335
- const entry = env.get(binding.genericParamId);
8336
- if (entry === void 0) {
8337
- throw new Error(
8338
- `typeArgumentSignatureOfBinding: forwarded generic param "${binding.genericParamId}" is not present in the binding environment.`
8339
- );
8340
- }
8341
- if (entry.kind === "unbound") {
8342
- throw new Error(
8343
- `typeArgumentSignatureOfBinding: forwarded generic param "${binding.genericParamId}" is unbound \u2014 signatures exist only under closed environments.`
8344
- );
8345
- }
8346
- return typeArgumentSignatureOfBinding(
8347
- { kind: 1 /* Member */, memberId: entry.memberId },
8348
- env,
8349
- members,
8350
- seen
8351
- );
8352
- }
8353
- const member = memberIndexFor(members).get(binding.memberId);
8354
- if (!member) {
8355
- throw new Error(
8356
- `typeArgumentSignatureOfBinding: binding member "${binding.memberId}" does not exist in the document.`
8357
- );
8358
- }
8359
- return typeArgumentSignatureOfMember(member, env, members, seen);
8360
- }
8361
- function signaturesEqual(a, b) {
8362
- if (a.type !== b.type) return false;
8363
- if (a.required !== b.required) return false;
8364
- if (a.type === 3 /* String */ && b.type === 3 /* String */) {
8365
- const as = a;
8366
- const bs = b;
8367
- return as.localizable === bs.localizable;
8368
- }
8369
- if (a.type === 8 /* Enum */ && b.type === 8 /* Enum */) {
8370
- const ae = a;
8371
- const be = b;
8372
- return ae.enumId === be.enumId && ae.multiselect === be.multiselect;
8373
- }
8374
- if (a.type === 7 /* Class */ && b.type === 7 /* Class */) {
8375
- const ac = a;
8376
- const bc = b;
8377
- if (ac.classId !== bc.classId) return false;
8378
- const aKeys = Object.keys(ac.args).sort();
8379
- const bKeys = Object.keys(bc.args).sort();
8380
- if (aKeys.length !== bKeys.length) return false;
8381
- for (let i = 0; i < aKeys.length; i++) {
8382
- if (aKeys[i] !== bKeys[i]) return false;
8383
- if (!signaturesEqual(ac.args[aKeys[i]], bc.args[bKeys[i]])) return false;
8384
- }
8385
- return true;
8386
- }
8387
- if (a.type === 6 /* List */ && b.type === 6 /* List */) {
8388
- const al = a;
8389
- const bl = b;
8390
- if (al.listKind !== bl.listKind) return false;
8391
- return signaturesEqual(al.entry, bl.entry);
8392
- }
8393
- if (a.type === 5 /* Dictionary */ && b.type === 5 /* Dictionary */) {
8394
- const ad = a;
8395
- const bd = b;
8396
- if (ad.keyKind !== bd.keyKind) return false;
8397
- if (ad.keyEnumId !== bd.keyEnumId) return false;
8398
- return signaturesEqual(ad.entry, bd.entry);
8399
- }
8400
- return true;
8401
- }
8402
- function constructedSlotAccepts(slotMember, valueClassId, contextEnv, classes, members) {
8403
- const chain = resolveInheritanceChain(valueClassId, classes);
8404
- if (chain.length === 0) {
8405
- return {
8406
- ok: false,
8407
- reason: `class "${valueClassId}" does not exist in the document`
8408
- };
8409
- }
8410
- if (!chain.some((t) => t.id === slotMember.classId)) {
8411
- return {
8412
- ok: false,
8413
- reason: `class "${chain[0].name}" is not "${slotMember.classId}" or one of its descendants`
8414
- };
8415
- }
8416
- const valueEnv = resolveInstanceEnv(
8417
- valueClassId,
8418
- slotMember.classArguments,
8419
- classes
8420
- );
8421
- for (const entry of valueEnv.values()) {
8422
- if (entry.kind === "unbound") {
8423
- return {
8424
- ok: false,
8425
- reason: `class "${chain[0].name}" is open (generic param "${entry.paramId}" is unbound) and cannot be instantiated`
8426
- };
8427
- }
8428
- }
8429
- const args = slotMember.classArguments;
8430
- if (args === void 0 || args === null) return { ok: true };
8431
- for (const [targetParamId, arg] of Object.entries(args)) {
8432
- const valueBinding = valueEnv.get(targetParamId);
8433
- if (valueBinding === void 0) {
8434
- return {
8435
- ok: false,
8436
- reason: `class "${chain[0].name}" does not resolve generic param "${targetParamId}" anywhere in its chain`
8437
- };
8438
- }
8439
- if (valueBinding.kind === "unbound") {
8440
- return {
8441
- ok: false,
8442
- reason: `class "${chain[0].name}" leaves generic param "${targetParamId}" unbound`
8443
- };
8444
- }
8445
- const slotSignature = typeArgumentSignatureOfBinding(
8446
- arg,
8447
- contextEnv,
8448
- members
8449
- );
8450
- const valueSignature = typeArgumentSignatureOfBinding(
8451
- { kind: 1 /* Member */, memberId: valueBinding.memberId },
8452
- valueEnv,
8453
- members
8454
- );
8455
- if (!constructedSlotArgumentAccepts({
8456
- slotMember,
8457
- targetParamId,
8458
- slotSignature,
8459
- valueSignature,
8460
- classes,
8461
- members
8462
- })) {
8463
- return {
8464
- ok: false,
8465
- reason: `class-argument signature mismatch for param "${targetParamId}" (arguments compare invariantly)`
8466
- };
8467
- }
8468
- }
8469
- return { ok: true };
8470
- }
8471
- function constructedSlotArgumentAccepts(args) {
8472
- if (signaturesEqual(args.slotSignature, args.valueSignature)) return true;
8473
- if (!isAnimationChildOverrideEntrySlot(args.slotMember, args.members)) {
8474
- return false;
8475
- }
8476
- if (args.targetParamId !== WORLD_ANIMATION_CHILD_OVERRIDE_ENTRY_PARAM_ID) {
8477
- return false;
8478
- }
8479
- if (args.slotSignature.required !== args.valueSignature.required) {
8480
- return false;
8481
- }
8482
- if (args.slotSignature.type !== 7 /* Class */) return false;
8483
- if (args.valueSignature.type !== 7 /* Class */) return false;
8484
- const slotClass = args.slotSignature;
8485
- const valueClass = args.valueSignature;
8486
- return resolveInheritanceChain(valueClass.classId, args.classes).some(
8487
- (schemaClass2) => schemaClass2.id === slotClass.classId
8488
- );
8489
- }
8490
- function isAnimationChildOverrideEntrySlot(slotMember, members) {
8491
- const membersById = new Map(members.map((member) => [member.id, member]));
8492
- const visited = /* @__PURE__ */ new Set();
8493
- let current = slotMember;
8494
- while (current !== void 0) {
8495
- const id = getOptionalString(current, "id");
8496
- if (id === void 0 || visited.has(id)) return false;
8497
- visited.add(id);
8498
- if (id === WORLD_ANIMATION_FRAME_CHILD_OVERRIDES_MEMBER_ID || id === WORLD_ANIMATION_FRAME_CHILD_OVERRIDES_ENTRY_MEMBER_ID) {
8499
- return true;
8500
- }
8501
- current = typeof current.extendsMemberId === "string" ? membersById.get(current.extendsMemberId) : void 0;
8502
- }
8503
- return false;
8504
- }
8505
-
8506
- // ../packages/models/src/members/instance-provenance.ts
8507
- var LITERAL_INSTANCE_IDENTITY_FIELDS = [
8508
- "classId",
8509
- "constructorArgs",
8510
- "instanceConstructorId",
8511
- "instanceVariantId",
8512
- "instanceVariantRowValueId",
8513
- "genericBindings"
8514
- ];
8515
- function replaceLiteralValueClass(value, classId) {
8516
- const next = { ...value, classId };
8517
- for (const field of LITERAL_INSTANCE_IDENTITY_FIELDS) {
8518
- if (field !== "classId") Reflect.deleteProperty(next, field);
8519
- }
8520
- return next;
8521
- }
8522
- function overlayLiteralValueContent(base, override) {
8523
- const merged = { ...base, ...override };
8524
- if (!("value" in override) || override.value !== null) return merged;
8525
- for (const field of LITERAL_INSTANCE_IDENTITY_FIELDS) {
8526
- if (!Object.hasOwn(override, field)) Reflect.deleteProperty(merged, field);
8527
- }
8528
- return merged;
8529
- }
8530
- function pickInstanceProvenance(source) {
8531
- return {
8532
- ...source.constructorArgs === void 0 ? {} : { constructorArgs: source.constructorArgs },
8533
- ...source.instanceConstructorId === void 0 ? {} : { instanceConstructorId: source.instanceConstructorId },
8534
- ...source.instanceVariantId === void 0 ? {} : { instanceVariantId: source.instanceVariantId },
8535
- ...source.instanceVariantRowValueId === void 0 ? {} : { instanceVariantRowValueId: source.instanceVariantRowValueId }
8536
- };
8537
- }
8538
- function isVirtualInstanceRootShape(value) {
8539
- if (value.instanceConstructorId !== void 0) return true;
8540
- return typeof value.instanceVariantId === "string";
8541
- }
8542
- function isCollapseStampedInstanceRoot(value) {
8543
- return isLiteralValueContent(value) && isVirtualInstanceRootShape(value);
8544
- }
8545
-
8546
- // ../packages/models/src/members/unordered-list-membership.ts
8547
- function buildUnorderedListMembershipIndex(values) {
8548
- const membersByContainerId = /* @__PURE__ */ new Map();
8549
- for (const candidate of values) {
8550
- const containerId = candidate.containerId;
8551
- if (typeof containerId !== "string") continue;
8552
- const bucket = membersByContainerId.get(containerId);
8553
- if (bucket === void 0) {
8554
- membersByContainerId.set(containerId, [candidate.id]);
8555
- } else {
8556
- bucket.push(candidate.id);
8557
- }
8558
- }
8559
- for (const bucket of membersByContainerId.values()) {
8560
- bucket.sort();
8561
- }
8562
- return membersByContainerId;
8563
- }
8564
-
8565
- // ../packages/models/src/members/member-value-id.ts
8566
- var NEO_MEMBER_VALUE_NAMESPACE = "7f2b9c14-58d6-5a07-b3e1-4c9d0a6f8b25";
8567
- var NEO_VIRTUAL_VALUE_NAMESPACE = "3e8ca0b3-e3f1-5d5f-bf2f-6ab5ee3896d0";
8568
- var virtualNamespaceBytes = parse_default(NEO_VIRTUAL_VALUE_NAMESPACE);
8569
- var virtualIdentityEncoder = new TextEncoder();
8570
- var SURROGATE_CODE_UNIT = /[\ud800-\udfff]/;
8571
- function derivedMemberValueId(memberId) {
8572
- return inSystemRecordNamespaceOf(
8573
- memberId,
8574
- v5_default(withoutSystemRecordIdPrefix(memberId), NEO_MEMBER_VALUE_NAMESPACE)
8575
- );
8576
- }
8577
- function virtualValueId(instanceRootId, sourceIdentity2) {
8578
- const identity = `${withoutSystemRecordIdPrefix(instanceRootId)}:${sourceIdentity2}`;
8579
- const bytes = SURROGATE_CODE_UNIT.test(identity) ? identity : virtualIdentityEncoder.encode(identity);
8580
- return inSystemRecordNamespaceOf(
8581
- instanceRootId,
8582
- v5_default(bytes, virtualNamespaceBytes)
8583
- );
8584
- }
8585
- function virtualSourceIdentityHead(sourceIdentity2) {
8586
- const pathStart = sourceIdentity2.indexOf(":$");
8587
- return pathStart < 0 ? sourceIdentity2 : sourceIdentity2.slice(0, pathStart);
8588
- }
8589
- function hasPendingVirtualSourceIdentity(sourceIdentity2) {
8590
- const head = virtualSourceIdentityHead(sourceIdentity2);
8591
- return head.startsWith("path:__pending__:") || head.startsWith("__pending__:");
8592
- }
8593
- var PENDING_VIRTUAL_VALUE_PREFIX = "__pending__:virtual-value:";
8594
- function pendingVirtualValueId(pendingInstanceRootId, sourceIdentity2) {
8595
- return `${PENDING_VIRTUAL_VALUE_PREFIX}${encodeURIComponent(pendingInstanceRootId)}:${encodeURIComponent(sourceIdentity2)}`;
8596
- }
8597
-
8598
- // ../packages/models/src/members/packed-value-encoding.ts
8599
- var PACKED_VALUE_ENTRY_KEY = "~packed";
8600
- var PackedValueEncodingError = class extends Error {
8601
- constructor(message) {
8602
- super(message);
8603
- this.name = "PackedValueEncodingError";
8604
- }
8605
- };
8606
- var NO_CHILDREN = [];
8607
- var NO_EDGES = /* @__PURE__ */ new Map();
8608
- function isPackedValueEnvelope(value) {
8609
- if (typeof value !== "object" || value === null || Array.isArray(value)) {
8610
- return false;
8611
- }
8612
- return Object.hasOwn(value, PACKED_VALUE_ENTRY_KEY);
8613
- }
8614
- function rowCarriesPackedValueContent(content) {
8615
- if (containerHoldsPackedEntry(content.value)) return true;
8616
- return containerHoldsPackedEntry(content.constructorArgs);
8617
- }
8618
- function expandPackedValueRows(rows) {
8619
- let firstPacked = -1;
8620
- for (let index = 0; index < rows.length; index += 1) {
8621
- const row = rows[index];
8622
- if (row === void 0 || !rowCarriesPackedValueContent(row)) continue;
8623
- firstPacked = index;
8624
- break;
8625
- }
8626
- if (firstPacked < 0) return rows;
8627
- const expanded = rows.slice(0, firstPacked);
8628
- for (let index = firstPacked; index < rows.length; index += 1) {
8629
- const row = rows[index];
8630
- if (row === void 0) continue;
8631
- const decoded = decodePackedValueRow(row);
8632
- expanded.push(decoded.row, ...decoded.children);
8633
- }
8634
- return expanded;
8635
- }
8636
- function expandPackedDocumentValues(document2) {
8637
- const stored = document2.values;
8638
- const expanded = expandPackedValueRows(stored);
8639
- if (expanded === stored) return document2;
8640
- return { ...document2, values: expanded };
8641
- }
8642
- function decodePackedValueRow(row) {
8643
- if (!rowCarriesPackedValueContent(row)) {
8644
- return { row, children: NO_CHILDREN, packedChildIdsByParentId: NO_EDGES };
8645
- }
8646
- const state = {
8647
- edges: /* @__PURE__ */ new Map(),
8648
- seenIds: /* @__PURE__ */ new Set([row.id]),
8649
- projectId: row.projectId,
8650
- mapKey: row.mapKey
8651
- };
8652
- const children = [];
8653
- const scope = {
8654
- state,
8655
- ownerId: row.id,
8656
- ownerLabel: `value "${row.id}"`,
8657
- constructionRootId: isCollapseStampedInstanceRoot(row) ? row.id : null
8658
- };
8659
- const value = decodeContentField(row.value, "value", scope, children);
8660
- const constructorArgs = decodeContentField(
8661
- isLiteralValueContent(row) ? row.constructorArgs : void 0,
8662
- "constructorArgs",
8663
- scope,
8664
- children
8665
- );
8666
- return {
8667
- row: withDecodedContent(row, value, constructorArgs),
8668
- children,
8669
- packedChildIdsByParentId: state.edges
8670
- };
8671
- }
8672
- function canonicalPackedChildId(args) {
8673
- if (args.constructionRootId === null) return null;
8674
- if (typeof args.sourceValueId !== "string") return null;
8675
- if (args.sourceValueId.length === 0) return null;
8676
- return virtualValueId(args.constructionRootId, args.sourceValueId);
8677
- }
8678
- function decodeContentField(container, field, scope, children) {
8679
- if (!containerHoldsPackedEntry(container)) return null;
8680
- if (Array.isArray(container)) {
8681
- return {
8682
- content: container.map(
8683
- (entry, index) => isPackedValueEnvelope(entry) ? decodeEnvelope(entry, `${field}[${index}]`, scope, children) : entry
8684
- )
8685
- };
8686
- }
8687
- const decoded = {};
8688
- for (const [key, entry] of Object.entries(
8689
- container
8690
- )) {
8691
- decoded[key] = isPackedValueEnvelope(entry) ? decodeEnvelope(
8692
- entry,
8693
- `${field}[${JSON.stringify(key)}]`,
8694
- scope,
8695
- children
8696
- ) : entry;
8697
- }
8698
- return { content: decoded };
8699
- }
8700
- function decodeEnvelope(envelope, position, scope, children) {
8701
- const label = `Packed value entry at ${scope.ownerLabel}.${position}`;
8702
- const entry = envelope[PACKED_VALUE_ENTRY_KEY];
8703
- assertDecodableEntry(entry, label);
8704
- const id = packedEntryLogicalId(entry, label, scope.constructionRootId);
8705
- if (scope.state.seenIds.has(id)) {
8706
- throw new PackedValueEncodingError(
8707
- `${label} resolves to id "${id}", which another row in the same packed payload already claims.`
8708
- );
8709
- }
8710
- scope.state.seenIds.add(id);
8711
- registerEdge(scope.state.edges, scope.ownerId, id);
8712
- const childScope = {
8713
- state: scope.state,
8714
- ownerId: id,
8715
- ownerLabel: `packed value "${id}"`,
8716
- constructionRootId: isCollapseStampedInstanceRoot(entry) ? id : scope.constructionRootId
8717
- };
8718
- const nested = [];
8719
- children.push(logicalChildRow(entry, id, childScope, nested));
8720
- children.push(...nested);
8721
- return id;
8722
- }
8723
- function logicalChildRow(entry, id, scope, children) {
8724
- const rowFields = {
8725
- id,
8726
- projectId: scope.state.projectId,
8727
- createdAt: entry.createdAt,
8728
- updatedAt: entry.updatedAt,
8729
- ...scope.state.mapKey === void 0 ? {} : { mapKey: scope.state.mapKey },
8730
- ...entry.genericBindings === void 0 ? {} : { genericBindings: entry.genericBindings },
8731
- ...entry.sourceValueId === void 0 ? {} : { sourceValueId: entry.sourceValueId }
8732
- };
8733
- if (isInitValueContent(entry)) return { ...rowFields, init: entry.init };
8734
- const value = decodeContentField(entry.value, "value", scope, children);
8735
- const constructorArgs = decodeContentField(
8736
- entry.constructorArgs,
8737
- "constructorArgs",
8738
- scope,
8739
- children
8740
- );
8741
- return {
8742
- ...rowFields,
8743
- ...literalContent(entry, value, constructorArgs)
8744
- };
8745
- }
8746
- function packedEntryLogicalId(entry, label, constructionRootId) {
8747
- const canonical = canonicalPackedChildId({
8748
- constructionRootId,
8749
- sourceValueId: entry.sourceValueId
8750
- });
8751
- const stored = entry.id;
8752
- if (stored === void 0) {
8753
- if (canonical === null) {
8754
- throw new PackedValueEncodingError(
8755
- `${label} stores no "id" and its position derives none: only a deterministic child of an enclosing construction root, stamped with a "sourceValueId", may omit its logical id.`
8756
- );
8757
- }
8758
- return canonical;
8759
- }
8760
- if (typeof stored !== "string" || stored.length === 0) {
8761
- throw new PackedValueEncodingError(
8762
- `${label} stores an "id" that is not a non-empty string.`
8763
- );
8764
- }
8765
- if (stored === canonical) {
8766
- throw new PackedValueEncodingError(
8767
- `${label} stores id "${stored}", which its position already derives; a derivable id must be omitted rather than repeated.`
8768
- );
8769
- }
8770
- return stored;
8771
- }
8772
- var PACKED_ENTRY_FORBIDDEN_FIELDS = [
8773
- "projectId",
8774
- "containerId",
8775
- "mapKey"
8776
- ];
8777
- function assertDecodableEntry(entry, label) {
8778
- if (typeof entry !== "object" || entry === null || Array.isArray(entry)) {
8779
- throw new PackedValueEncodingError(`${label} is not an object.`);
8780
- }
8781
- for (const field of PACKED_ENTRY_FORBIDDEN_FIELDS) {
8782
- if (!Object.hasOwn(entry, field)) continue;
8783
- throw new PackedValueEncodingError(
8784
- `${label} stores "${field}", which decoding derives from its owning row.`
8785
- );
8786
- }
8787
- if (!("createdAt" in entry) || typeof entry.createdAt !== "number") {
8788
- throw new PackedValueEncodingError(
8789
- `${label} stores no numeric "createdAt".`
8790
- );
8791
- }
8792
- if (!("updatedAt" in entry) || typeof entry.updatedAt !== "number") {
8793
- throw new PackedValueEncodingError(
8794
- `${label} stores no numeric "updatedAt".`
8795
- );
8796
- }
8797
- const hasValue = Object.hasOwn(entry, "value");
8798
- const hasInit = Object.hasOwn(entry, "init");
8799
- if (hasValue && hasInit) {
8800
- throw new PackedValueEncodingError(
8801
- `${label} stores both "value" and "init"; a value container holds exactly one.`
8802
- );
8803
- }
8804
- if (!hasValue && !hasInit) {
8805
- throw new PackedValueEncodingError(
8806
- `${label} stores neither "value" nor "init"; a value container holds exactly one.`
8807
- );
8808
- }
8809
- if (hasInit && !isInitValueContent(entry)) {
8810
- throw new PackedValueEncodingError(
8811
- `${label} stores an "init" that is not a valid initializer body.`
8812
- );
8813
- }
8814
- if (hasValue && !isLiteralValueContent(entry)) {
8815
- throw new PackedValueEncodingError(
8816
- `${label} stores a "value" whose class or construction stamp is malformed.`
8817
- );
8818
- }
8819
- }
8820
- function literalContent(content, value, constructorArgs) {
8821
- if (!isLiteralValueContent(content)) {
8822
- throw new PackedValueEncodingError(
8823
- `Value container has no literal "value" to encode.`
8824
- );
8825
- }
8826
- const provenance = pickInstanceProvenance(content);
8827
- return {
8828
- value: value === null ? content.value : value.content,
8829
- ...Object.hasOwn(content, "classId") ? { classId: content.classId } : {},
8830
- ...provenance,
8831
- ...constructorArgs === null ? {} : { constructorArgs: asConstructorArgs(constructorArgs.content) }
8832
- };
8833
- }
8834
- function withDecodedContent(row, value, constructorArgs) {
8835
- if (value === null && constructorArgs === null) return row;
8836
- return { ...row, ...literalContent(row, value, constructorArgs) };
8837
- }
8838
- function asConstructorArgs(content) {
8839
- if (content === null) return null;
8840
- if (typeof content !== "object" || Array.isArray(content)) {
8841
- throw new PackedValueEncodingError(
8842
- `Value container stores "constructorArgs" that is not a record.`
8843
- );
8844
- }
8845
- return content;
8846
- }
8847
- function containerHoldsPackedEntry(container) {
8848
- if (Array.isArray(container)) {
8849
- return container.some((entry) => isPackedValueEnvelope(entry));
8850
- }
8851
- if (typeof container !== "object" || container === null) return false;
8852
- for (const entry of Object.values(container)) {
8853
- if (isPackedValueEnvelope(entry)) return true;
8854
- }
8855
- return false;
8856
- }
8857
- function registerEdge(edges, ownerId, childId) {
8858
- const existing = edges.get(ownerId);
8859
- if (existing === void 0) edges.set(ownerId, [childId]);
8860
- else existing.push(childId);
8861
- }
8862
-
8863
- // ../packages/models/src/members/member-storage-key.ts
8864
- var MAIN_STORAGE_PARTITION = "main";
8865
- var STORAGE_KEY_INHERIT = "inherit";
8866
- var STORAGE_KEY_ALL = "all";
8867
- var PARENT_CLASS_TEMPLATE_TOKEN = "$parentClass";
8868
- function normalizeStorageKeyDeclaration(declaration) {
8869
- if (declaration === void 0 || declaration === null) {
8870
- return STORAGE_KEY_INHERIT;
8871
- }
8872
- if (declaration.length === 0) return STORAGE_KEY_INHERIT;
8873
- if (declaration === STORAGE_KEY_ALL) {
8874
- throw new Error(
8875
- 'Storage key "all" is reserved for partition-scoped reads and cannot be declared on a member.'
8876
- );
8877
- }
8878
- return declaration;
8879
- }
8880
- function storageKeyReferencesParentClass(declaration) {
8881
- return declaration.includes(PARENT_CLASS_TEMPLATE_TOKEN);
8882
- }
8883
- function resolveMapKeyForCreatedValue(args) {
8884
- const declaration = normalizeStorageKeyDeclaration(args.declaration);
8885
- if (declaration === STORAGE_KEY_INHERIT) return args.parentMapKey;
8886
- if (declaration === MAIN_STORAGE_PARTITION) return null;
8887
- if (storageKeyReferencesParentClass(declaration)) {
8888
- if (args.parentClassId === void 0) {
8889
- throw new Error(
8890
- `Storage key "${declaration}" references ${PARENT_CLASS_TEMPLATE_TOKEN}, but the placement parent value has no classId (only class-valued parents can anchor a ${PARENT_CLASS_TEMPLATE_TOKEN} partition).`
8891
- );
8892
- }
8893
- return declaration.replaceAll(
8894
- PARENT_CLASS_TEMPLATE_TOKEN,
8895
- args.parentClassId
8896
- );
8897
- }
8898
- return declaration;
8899
- }
8900
-
8901
- // ../packages/models/src/members/storage-partitions.ts
8902
- function stampCreatedValuesMapKey(values, mapKey) {
8903
- const normalized = mapKey === void 0 || mapKey === null || mapKey.length === 0 || mapKey === MAIN_STORAGE_PARTITION ? null : mapKey;
8904
- for (const value of values) {
8905
- if (normalized === null) {
8906
- delete value.mapKey;
8907
- } else {
8908
- value.mapKey = normalized;
8909
- }
8910
- }
8911
- }
8912
- function applyDeclaredStorageKeyOverrides(args) {
8913
- const boundaryValues = args.createdValues.filter(
8914
- (value) => normalizeStorageKeyDeclaration(
8915
- args.declarationByValueId.get(value.id)
8916
- ) !== STORAGE_KEY_INHERIT
8917
- );
8918
- if (boundaryValues.length === 0) return;
8919
- const createdById = new Map(
8920
- args.createdValues.map((value) => [value.id, value])
8921
- );
8922
- const parentOf = /* @__PURE__ */ new Map();
8923
- for (const value of args.createdValues) {
8924
- for (const childId of referencedValueIdCandidates(value.value)) {
8925
- if (createdById.has(childId)) parentOf.set(childId, value);
8926
- }
8927
- }
8928
- for (const value of args.createdValues) {
8929
- if (typeof value.containerId !== "string") continue;
8930
- const container = createdById.get(value.containerId);
8931
- if (container !== void 0) parentOf.set(value.id, container);
8980
+ );
8932
8981
  }
8933
- const depthOf = (value) => {
8934
- let depth = 0;
8935
- let current = value;
8936
- const seen = /* @__PURE__ */ new Set();
8937
- while (current !== void 0 && !seen.has(current.id)) {
8938
- seen.add(current.id);
8939
- current = parentOf.get(current.id);
8940
- if (current !== void 0) depth += 1;
8941
- }
8942
- return depth;
8943
- };
8944
- const boundaries = boundaryValues.sort((left, right) => depthOf(left) - depthOf(right));
8945
- for (const boundary of boundaries) {
8946
- const parentCreated = parentOf.get(boundary.id);
8947
- const parent = parentCreated !== void 0 ? {
8948
- mapKey: parentCreated.mapKey ?? null,
8949
- classId: parentCreated.classId ?? void 0
8950
- } : args.existingParentContextById?.get(boundary.id);
8951
- if (parent === void 0) {
8982
+ return typeArgumentSignatureOfMember(entryMember, env, members, seen);
8983
+ }
8984
+ function typeArgumentSignatureOfBinding(binding, env, members, seen = /* @__PURE__ */ new Set()) {
8985
+ if (isForwardedGenericBinding(binding)) {
8986
+ const entry = env.get(binding.genericParamId);
8987
+ if (entry === void 0) {
8952
8988
  throw new Error(
8953
- `Cannot resolve storage partition for created value "${boundary.id}": its placement parent is neither a created value nor supplied in existingParentContextById.`
8989
+ `typeArgumentSignatureOfBinding: forwarded generic param "${binding.genericParamId}" is not present in the binding environment.`
8954
8990
  );
8955
8991
  }
8956
- const mapKey = resolveMapKeyForCreatedValue({
8957
- declaration: args.declarationByValueId.get(boundary.id),
8958
- parentMapKey: parent.mapKey,
8959
- parentClassId: parent.classId
8960
- });
8961
- for (const member of collectCreatedSubtreeValues(
8962
- boundary,
8963
- args.createdValues
8964
- )) {
8965
- if (mapKey === null || mapKey === MAIN_STORAGE_PARTITION) {
8966
- delete member.mapKey;
8967
- } else {
8968
- member.mapKey = mapKey;
8969
- }
8970
- }
8971
- }
8972
- }
8973
- function collectCreatedSubtreeValues(root, createdValues) {
8974
- const createdById = new Map(createdValues.map((value) => [value.id, value]));
8975
- const subtree = [];
8976
- const visited = /* @__PURE__ */ new Set();
8977
- const queue = [root];
8978
- while (queue.length > 0) {
8979
- const current = queue.shift();
8980
- if (current === void 0) break;
8981
- if (visited.has(current.id)) continue;
8982
- visited.add(current.id);
8983
- subtree.push(current);
8984
- for (const childId of referencedValueIdCandidates(current.value)) {
8985
- const child = createdById.get(childId);
8986
- if (child !== void 0) queue.push(child);
8987
- }
8988
- for (const candidate of createdValues) {
8989
- if (candidate.containerId === current.id) queue.push(candidate);
8992
+ if (entry.kind === "unbound") {
8993
+ throw new Error(
8994
+ `typeArgumentSignatureOfBinding: forwarded generic param "${binding.genericParamId}" is unbound \u2014 signatures exist only under closed environments.`
8995
+ );
8990
8996
  }
8997
+ return typeArgumentSignatureOfBinding(
8998
+ { kind: 1 /* Member */, memberId: entry.memberId },
8999
+ env,
9000
+ members,
9001
+ seen
9002
+ );
8991
9003
  }
8992
- return subtree;
8993
- }
8994
- function referencedValueIdCandidates(value) {
8995
- if (Array.isArray(value)) {
8996
- return value.filter((entry) => typeof entry === "string");
8997
- }
8998
- if (typeof value === "object" && value !== null) {
8999
- return Object.values(value).filter(
9000
- (entry) => typeof entry === "string"
9004
+ const member = memberIndexFor(members).get(binding.memberId);
9005
+ if (!member) {
9006
+ throw new Error(
9007
+ `typeArgumentSignatureOfBinding: binding member "${binding.memberId}" does not exist in the document.`
9001
9008
  );
9002
9009
  }
9003
- return [];
9004
- }
9005
-
9006
- // ../packages/models/src/core/auth-ownership-types.ts
9007
- var ActorKind = {
9008
- /**
9009
- * `better-auth` user identities.
9010
- */
9011
- user: "user",
9012
- /**
9013
- * `better-auth` organization identities.
9014
- */
9015
- organization: "organization",
9016
- /**
9017
- * Used for denoting records created by a system.
9018
- */
9019
- system: "system"
9020
- };
9021
- function isActorIdentifier(value) {
9022
- if (typeof value !== "object") return false;
9023
- if (value === null) return false;
9024
- const candidate = value;
9025
- if (!isActorKind(candidate.kind)) return false;
9026
- return typeof candidate.id === "string" && candidate.id.trim().length > 0;
9027
- }
9028
- function isActorKind(value) {
9029
- return value === ActorKind.user || value === ActorKind.organization || value === ActorKind.system;
9010
+ return typeArgumentSignatureOfMember(member, env, members, seen);
9030
9011
  }
9031
-
9032
- // ../packages/models/src/members/member-change-listeners.ts
9033
- function editChangeListenerSet(explicit, inherited, edit, options = { inheritedComplete: true }) {
9034
- if (edit.kind === "reset") {
9035
- return explicit === void 0 ? { changed: false } : { changed: true, targets: void 0 };
9012
+ function signaturesEqual(a, b) {
9013
+ if (a.type !== b.type) return false;
9014
+ if (a.required !== b.required) return false;
9015
+ if (a.type === 3 /* String */ && b.type === 3 /* String */) {
9016
+ const as = a;
9017
+ const bs = b;
9018
+ return as.localizable === bs.localizable;
9036
9019
  }
9037
- const current = explicit ?? inherited;
9038
- let next;
9039
- if (edit.kind === "replace") {
9040
- next = edit.targets;
9041
- } else {
9042
- const identity = nsActionListenerIdentity(edit.target);
9043
- const index = current.findIndex(
9044
- (target) => nsActionListenerIdentity(target) === identity
9045
- );
9046
- if (edit.kind === "add") {
9047
- if (index !== -1) return { changed: false };
9048
- next = [...current, edit.target];
9049
- } else {
9050
- if (index === -1) return { changed: false };
9051
- next = current.filter((_, i) => i !== index);
9020
+ if (a.type === 8 /* Enum */ && b.type === 8 /* Enum */) {
9021
+ const ae = a;
9022
+ const be = b;
9023
+ return ae.enumId === be.enumId && ae.multiselect === be.multiselect;
9024
+ }
9025
+ if (a.type === 7 /* Class */ && b.type === 7 /* Class */) {
9026
+ const ac = a;
9027
+ const bc = b;
9028
+ if (ac.classId !== bc.classId) return false;
9029
+ const aKeys = Object.keys(ac.args).sort();
9030
+ const bKeys = Object.keys(bc.args).sort();
9031
+ if (aKeys.length !== bKeys.length) return false;
9032
+ for (let i = 0; i < aKeys.length; i++) {
9033
+ if (aKeys[i] !== bKeys[i]) return false;
9034
+ if (!signaturesEqual(ac.args[aKeys[i]], bc.args[bKeys[i]])) return false;
9052
9035
  }
9036
+ return true;
9053
9037
  }
9054
- const targets = [];
9055
- const seen = /* @__PURE__ */ new Set();
9056
- for (const target of next) {
9057
- const identity = nsActionListenerIdentity(target);
9058
- if (seen.has(identity))
9059
- throw new Error("A listener set cannot repeat a handler identity.");
9060
- seen.add(identity);
9061
- targets.push({ memberId: target.memberId, valueId: target.valueId });
9038
+ if (a.type === 6 /* List */ && b.type === 6 /* List */) {
9039
+ const al = a;
9040
+ const bl = b;
9041
+ if (al.listKind !== bl.listKind) return false;
9042
+ return signaturesEqual(al.entry, bl.entry);
9062
9043
  }
9063
- if (targets.length === 0 && inherited.length === 0 && options.inheritedComplete) {
9064
- return explicit === void 0 ? { changed: false } : { changed: true, targets: void 0 };
9044
+ if (a.type === 5 /* Dictionary */ && b.type === 5 /* Dictionary */) {
9045
+ const ad = a;
9046
+ const bd = b;
9047
+ if (ad.keyKind !== bd.keyKind) return false;
9048
+ if (ad.keyEnumId !== bd.keyEnumId) return false;
9049
+ return signaturesEqual(ad.entry, bd.entry);
9065
9050
  }
9066
- if (explicit !== void 0 && sameChangeListeners(explicit, targets))
9067
- return { changed: false };
9068
- return { changed: true, targets };
9051
+ return true;
9069
9052
  }
9070
- function sameChangeListeners(left, right) {
9071
- return left.length === right.length && left.every(
9072
- (entry, index) => entry.memberId === right[index].memberId && entry.valueId === right[index].valueId
9053
+ function constructedSlotAccepts(slotMember, valueClassId, contextEnv, classes, members) {
9054
+ const chain = resolveInheritanceChain(valueClassId, classes);
9055
+ if (chain.length === 0) {
9056
+ return {
9057
+ ok: false,
9058
+ reason: `class "${valueClassId}" does not exist in the document`
9059
+ };
9060
+ }
9061
+ if (!chain.some((t) => t.id === slotMember.classId)) {
9062
+ return {
9063
+ ok: false,
9064
+ reason: `class "${chain[0].name}" is not "${slotMember.classId}" or one of its descendants`
9065
+ };
9066
+ }
9067
+ const valueEnv = resolveInstanceEnv(
9068
+ valueClassId,
9069
+ slotMember.classArguments,
9070
+ classes
9073
9071
  );
9074
- }
9075
- function remapChangeListenerMap(map, identities, policy, internalEndpoints) {
9076
- if (!map) return void 0;
9077
- const result = {};
9078
- for (const [ownerId, members] of Object.entries(map)) {
9079
- const owner = identities.get(ownerId);
9080
- if (owner === void 0) continue;
9081
- const entry = {};
9082
- for (const [memberId, targets] of Object.entries(members)) {
9083
- const remapped = [];
9084
- for (const target of targets) {
9085
- const receiver = target.valueId === null ? null : identities.get(target.valueId);
9086
- if (receiver === void 0 && (policy === "clone" || target.valueId !== null && internalEndpoints !== void 0 && internalEndpoints.has(target.valueId)))
9087
- continue;
9088
- remapped.push({
9089
- memberId: target.memberId,
9090
- valueId: receiver ?? target.valueId
9091
- });
9092
- }
9093
- setOwnField(entry, memberId, remapped);
9072
+ for (const entry of valueEnv.values()) {
9073
+ if (entry.kind === "unbound") {
9074
+ return {
9075
+ ok: false,
9076
+ reason: `class "${chain[0].name}" is open (generic param "${entry.paramId}" is unbound) and cannot be instantiated`
9077
+ };
9094
9078
  }
9095
- setOwnField(result, owner, entry);
9096
9079
  }
9097
- return Object.keys(result).length === 0 ? void 0 : result;
9098
- }
9099
- var authoredListenerIndexes = /* @__PURE__ */ new WeakMap();
9100
- function authoredChangeListenerOwners(rows) {
9101
- const index = authoredListenerIndexes.get(rows);
9102
- if (index !== void 0) return index;
9103
- const owners = /* @__PURE__ */ new Map();
9104
- for (const row of rows)
9105
- for (const [ownerId, entry] of Object.entries(row.changeListeners ?? {})) {
9106
- if (owners.has(ownerId))
9107
- throw new Error(
9108
- `Listener owner "${ownerId}" is declared on more than one binding root.`
9109
- );
9110
- owners.set(ownerId, entry);
9080
+ const args = slotMember.classArguments;
9081
+ if (args === void 0 || args === null) return { ok: true };
9082
+ for (const [targetParamId, arg] of Object.entries(args)) {
9083
+ const valueBinding = valueEnv.get(targetParamId);
9084
+ if (valueBinding === void 0) {
9085
+ return {
9086
+ ok: false,
9087
+ reason: `class "${chain[0].name}" does not resolve generic param "${targetParamId}" anywhere in its chain`
9088
+ };
9111
9089
  }
9112
- authoredListenerIndexes.set(rows, owners);
9113
- return owners;
9114
- }
9115
- var declarationListenerMetadata = /* @__PURE__ */ new WeakMap();
9116
- function hasAuthoredChangeListenerMetadata(document2) {
9117
- if (authoredChangeListenerOwners(document2.values).size !== 0) return true;
9118
- let present = declarationListenerMetadata.get(document2.members);
9119
- if (present === void 0) {
9120
- present = document2.members.some(
9121
- (member) => member.defaultValue?.changeListeners !== void 0
9090
+ if (valueBinding.kind === "unbound") {
9091
+ return {
9092
+ ok: false,
9093
+ reason: `class "${chain[0].name}" leaves generic param "${targetParamId}" unbound`
9094
+ };
9095
+ }
9096
+ const slotSignature = typeArgumentSignatureOfBinding(
9097
+ arg,
9098
+ contextEnv,
9099
+ members
9122
9100
  );
9123
- declarationListenerMetadata.set(document2.members, present);
9101
+ const valueSignature = typeArgumentSignatureOfBinding(
9102
+ { kind: 1 /* Member */, memberId: valueBinding.memberId },
9103
+ valueEnv,
9104
+ members
9105
+ );
9106
+ if (!constructedSlotArgumentAccepts({
9107
+ slotMember,
9108
+ targetParamId,
9109
+ slotSignature,
9110
+ valueSignature,
9111
+ classes,
9112
+ members
9113
+ })) {
9114
+ return {
9115
+ ok: false,
9116
+ reason: `class-argument signature mismatch for param "${targetParamId}" (arguments compare invariantly)`
9117
+ };
9118
+ }
9124
9119
  }
9125
- return present;
9120
+ return { ok: true };
9126
9121
  }
9127
- function defaultSourceWithListeners(row, graph) {
9128
- if (row === null || graph == null || graph.instanceRootId !== row.id)
9129
- return row;
9130
- const inherited = graph.listenerDefaultsByOwner;
9131
- if (inherited === void 0 || inherited.size === 0) return row;
9132
- const map = Object.fromEntries(inherited);
9133
- for (const [id, entry] of Object.entries(row.changeListeners ?? {}))
9134
- setOwnField(map, id, { ...map[id], ...entry });
9135
- return { ...row, changeListeners: map };
9122
+ function constructedSlotArgumentAccepts(args) {
9123
+ if (signaturesEqual(args.slotSignature, args.valueSignature)) return true;
9124
+ if (!isAnimationChildOverrideEntrySlot(args.slotMember, args.members)) {
9125
+ return false;
9126
+ }
9127
+ if (args.targetParamId !== WORLD_ANIMATION_CHILD_OVERRIDE_ENTRY_PARAM_ID) {
9128
+ return false;
9129
+ }
9130
+ if (args.slotSignature.required !== args.valueSignature.required) {
9131
+ return false;
9132
+ }
9133
+ if (args.slotSignature.type !== 7 /* Class */) return false;
9134
+ if (args.valueSignature.type !== 7 /* Class */) return false;
9135
+ const slotClass = args.slotSignature;
9136
+ const valueClass = args.valueSignature;
9137
+ return resolveInheritanceChain(valueClass.classId, args.classes).some(
9138
+ (schemaClass2) => schemaClass2.id === slotClass.classId
9139
+ );
9140
+ }
9141
+ function isAnimationChildOverrideEntrySlot(slotMember, members) {
9142
+ const membersById = new Map(members.map((member) => [member.id, member]));
9143
+ const visited = /* @__PURE__ */ new Set();
9144
+ let current = slotMember;
9145
+ while (current !== void 0) {
9146
+ const id = getOptionalString(current, "id");
9147
+ if (id === void 0 || visited.has(id)) return false;
9148
+ visited.add(id);
9149
+ if (id === WORLD_ANIMATION_FRAME_CHILD_OVERRIDES_MEMBER_ID || id === WORLD_ANIMATION_FRAME_CHILD_OVERRIDES_ENTRY_MEMBER_ID) {
9150
+ return true;
9151
+ }
9152
+ current = typeof current.extendsMemberId === "string" ? membersById.get(current.extendsMemberId) : void 0;
9153
+ }
9154
+ return false;
9136
9155
  }
9137
9156
 
9138
9157
  // ../packages/models/src/constructors/constructors.ts
@@ -9320,7 +9339,7 @@ function constructionMembers(classId, context) {
9320
9339
  const { document: document2, memberById, env } = context;
9321
9340
  if (firstUnboundParamId(env) !== null) return [];
9322
9341
  const result = [];
9323
- for (const entry of mergeStoredInstanceSchema(
9342
+ for (const entry of mergeInstanceSurfaceSchema(
9324
9343
  classId,
9325
9344
  document2.classes,
9326
9345
  document2.members
@@ -9338,7 +9357,6 @@ function constructionMembers(classId, context) {
9338
9357
  id: raw.id
9339
9358
  };
9340
9359
  if (isAbstractMember(member)) continue;
9341
- if (isReadOnlyMember(member)) continue;
9342
9360
  if (!memberKindOwnsStoredValue(member.kind)) continue;
9343
9361
  if ("payload" in member && member.payload === 1 /* Partial */)
9344
9362
  continue;
@@ -10569,7 +10587,7 @@ function withIndexedDefaultValueDocument(document2, options = {}) {
10569
10587
  classId,
10570
10588
  document2.classes,
10571
10589
  document2.members
10572
- ).stored;
10590
+ ).surface;
10573
10591
  cache.storedSchemaByClassId.set(classId, schema);
10574
10592
  return schema;
10575
10593
  },
@@ -10649,11 +10667,16 @@ function buildDefaultClassMaterializationPlan(document2, classId, instanceEnv) {
10649
10667
  ...document2,
10650
10668
  constructors: document2.constructors ?? []
10651
10669
  });
10652
- const merged = document2.storedInstanceSchema?.(classId) ?? mergeStoredInstanceSchema(classId, document2.classes, document2.members);
10670
+ const merged = document2.storedInstanceSchema?.(classId) ?? mergeInstanceSurfaceSchema(classId, document2.classes, document2.members);
10653
10671
  return merged.flatMap((entry) => {
10654
10672
  if (entry.memberId === null) return [];
10655
10673
  const childMember = findMemberInDocument(document2, entry.memberId);
10656
10674
  if (!memberKindOwnsStoredValue(childMember.kind)) return [];
10675
+ if (instanceEnv.size === 0 && isImmutableConstantMember(
10676
+ document2,
10677
+ document2.resolvedMember?.(childMember) ?? resolveMember(childMember, document2.members)
10678
+ ))
10679
+ return [];
10657
10680
  const member = substituteMember(
10658
10681
  childMember,
10659
10682
  instanceEnv,
@@ -10670,6 +10693,93 @@ function buildDefaultClassMaterializationPlan(document2, classId, instanceEnv) {
10670
10693
  ];
10671
10694
  });
10672
10695
  }
10696
+ function isImmutableConstantMember(document2, resolved) {
10697
+ if (resolved.storage !== 1 /* Immutable */) return false;
10698
+ if (isStaticMember(resolved)) return false;
10699
+ const declared = resolved.defaultValue;
10700
+ if (declared == null) return false;
10701
+ return !declarationReadsInstance(
10702
+ { document: document2, visited: /* @__PURE__ */ new Set() },
10703
+ resolved,
10704
+ declared,
10705
+ null
10706
+ );
10707
+ }
10708
+ function declarationReadsInstance(walk, member, body, rowId) {
10709
+ const { document: document2 } = walk;
10710
+ if (documentHasInitValueContent(document2, body)) {
10711
+ const compiled = body.init.compiled;
10712
+ if (compiled === void 0) return true;
10713
+ const instanceParameters = /* @__PURE__ */ new Set();
10714
+ for (const parameter3 of compiled.parameters) {
10715
+ if (parameter3.id !== "__root__") instanceParameters.add(parameter3.id);
10716
+ }
10717
+ return irReadsInstance(
10718
+ compiled.instructions,
10719
+ instanceParameters,
10720
+ /* @__PURE__ */ new Set()
10721
+ );
10722
+ }
10723
+ if (!isLiteralValueContent(body)) return true;
10724
+ if (irReadsInstance(body.constructorArgs, /* @__PURE__ */ new Set(), /* @__PURE__ */ new Set())) return true;
10725
+ const value = body.value;
10726
+ const ownedEntry = (entryMember) => (valueId) => typeof valueId !== "string" || rowReadsInstance(walk, entryMember, valueId);
10727
+ if (isMemberClassBase(member)) {
10728
+ if (value === null) return false;
10729
+ if (!isStringRecord(value)) return true;
10730
+ const classId = typeof body.classId === "string" ? body.classId : member.classId;
10731
+ const entries = getSchemaEntryMap(document2, classId);
10732
+ for (const [schemaKey, valueId] of Object.entries(value)) {
10733
+ const memberId = entries.get(schemaKey)?.memberId;
10734
+ if (memberId == null) return true;
10735
+ const child = findMemberInDocument(document2, memberId);
10736
+ if (ownedEntry(child)(valueId)) return true;
10737
+ }
10738
+ return false;
10739
+ }
10740
+ if (isMemberListBase(member)) {
10741
+ const entryMember = findMemberInDocument(document2, member.entryMemberId);
10742
+ const entryIds = listKindOf(member) !== 1 /* Unordered */ ? value : rowId === null ? [] : document2.unorderedListEntryIds?.(rowId) ?? (walk.membership ??= buildUnorderedListMembershipIndex(
10743
+ document2.values
10744
+ )).get(rowId) ?? [];
10745
+ if (entryIds === null) return false;
10746
+ return !Array.isArray(entryIds) || entryIds.some(ownedEntry(entryMember));
10747
+ }
10748
+ if (isMemberDictionaryBase(member)) {
10749
+ if (value === null) return false;
10750
+ if (!isStringRecord(value)) return true;
10751
+ const entryMember = findMemberInDocument(document2, member.entryMemberId);
10752
+ return Object.values(value).some(ownedEntry(entryMember));
10753
+ }
10754
+ if (member.kind === 21 /* Generic */) return true;
10755
+ return irReadsInstance(value, /* @__PURE__ */ new Set(), /* @__PURE__ */ new Set());
10756
+ }
10757
+ function rowReadsInstance(walk, member, valueId) {
10758
+ if (walk.visited.has(valueId)) return false;
10759
+ walk.visited.add(valueId);
10760
+ const { document: document2 } = walk;
10761
+ const row = document2.valueById?.(valueId) ?? (walk.rowById ??= new Map(
10762
+ document2.values.map((value) => [value.id, value])
10763
+ )).get(valueId);
10764
+ if (row === void 0 || row === null) return true;
10765
+ const resolved = document2.resolvedMember?.(member) ?? resolveMember(member, document2.members);
10766
+ return declarationReadsInstance(walk, resolved, row, row.id);
10767
+ }
10768
+ function irReadsInstance(value, instanceParameters, visited) {
10769
+ if (typeof value !== "object" || value === null) return false;
10770
+ if (visited.has(value)) return false;
10771
+ visited.add(value);
10772
+ if (isMemberDelegateTarget(value) && value.valueId === null) return true;
10773
+ if (Reflect.get(value, "type") === "variable" /* variable */) {
10774
+ const variableId = Reflect.get(value, "variableId");
10775
+ if (typeof variableId === "string" && instanceParameters.has(variableId))
10776
+ return true;
10777
+ }
10778
+ for (const child of Object.values(value)) {
10779
+ if (irReadsInstance(child, instanceParameters, visited)) return true;
10780
+ }
10781
+ return false;
10782
+ }
10673
10783
  function assertLookupInitializerLiteral(member, literal3) {
10674
10784
  if (!isMemberLookupBase(member)) return;
10675
10785
  const value = literal3.value;
@@ -11515,7 +11625,7 @@ function formatDefaultReferenceLocation(memberName, key) {
11515
11625
  function getSchemaEntryMap(document2, classId) {
11516
11626
  const node = resolvedClassSchema(classId, document2.classes, document2.members);
11517
11627
  const entries = document2.storedInstanceSchema?.(classId);
11518
- return entries === void 0 || entries === node.stored ? node.storedByKey : new Map(entries.map((entry) => [entry.schemaKey, entry]));
11628
+ return entries === void 0 || entries === node.surface ? node.surfaceByKey : new Map(entries.map((entry) => [entry.schemaKey, entry]));
11519
11629
  }
11520
11630
  function cloneMemberValueBase(body) {
11521
11631
  return {
@@ -12662,6 +12772,50 @@ function buildNeoScriptConstructorSignature(classId, members, memberDescriptor)
12662
12772
  parameters
12663
12773
  };
12664
12774
  }
12775
+ function buildNeoScriptConstructionSignatures(classId, members, memberDescriptor, immutableOnly) {
12776
+ const descriptors = /* @__PURE__ */ new Map();
12777
+ const describe = (memberId) => {
12778
+ let descriptor = descriptors.get(memberId);
12779
+ if (descriptor === void 0) {
12780
+ descriptor = memberDescriptor(memberId);
12781
+ descriptors.set(memberId, descriptor);
12782
+ }
12783
+ return descriptor;
12784
+ };
12785
+ const replay = buildNeoScriptConstructorSignature(classId, members, describe);
12786
+ if (immutableOnly) {
12787
+ return {
12788
+ storedConstructionReplaySignature: replay,
12789
+ constructorUnavailableReason: "immutableOnly"
12790
+ };
12791
+ }
12792
+ let hasImmutableMember = false;
12793
+ for (const descriptor of descriptors.values()) {
12794
+ if (descriptor?.immutable !== true) continue;
12795
+ if (constructorParameterIsRequired(
12796
+ descriptor.required,
12797
+ descriptor.defaultValue
12798
+ )) {
12799
+ return {
12800
+ storedConstructionReplaySignature: replay,
12801
+ constructorUnavailableReason: "requiredImmutableMember"
12802
+ };
12803
+ }
12804
+ hasImmutableMember = true;
12805
+ }
12806
+ if (!hasImmutableMember) return { constructorSignature: replay };
12807
+ return {
12808
+ constructorSignature: buildNeoScriptConstructorSignature(
12809
+ classId,
12810
+ members,
12811
+ (memberId) => {
12812
+ const descriptor = describe(memberId);
12813
+ return descriptor?.immutable === true ? null : descriptor;
12814
+ }
12815
+ ),
12816
+ storedConstructionReplaySignature: replay
12817
+ };
12818
+ }
12665
12819
  function isNeoScriptTypeAssignable(source, target, project) {
12666
12820
  if (isUnknownType(source) || isUnknownType(target)) return false;
12667
12821
  if (isNullType(source)) return isNullableType2(target);
@@ -13340,7 +13494,7 @@ function resolveOwnerMembersForValues(document2, targetValueIds, additionalRoots
13340
13494
  function storedSchema(classId) {
13341
13495
  const cached = storedSchemaByClassId.get(classId);
13342
13496
  if (cached !== void 0) return cached;
13343
- const created = mergeStoredInstanceSchema(
13497
+ const created = mergeInstanceSurfaceSchema(
13344
13498
  classId,
13345
13499
  document2.classes,
13346
13500
  document2.members
@@ -15308,8 +15462,6 @@ function classImplementsInterface(classId, interfaceId, classes, interfaces) {
15308
15462
  function readClassMember(args) {
15309
15463
  const { member, schemaKey } = args;
15310
15464
  const declaration = member.kind !== 10 /* NSProperty */ && member.defaultValue != null ? member.defaultValue : void 0;
15311
- if (args.mode !== "partial" && isReadOnlyMember(member) && declaration !== void 0)
15312
- return { kind: "declaration", content: declaration };
15313
15465
  if (Object.prototype.hasOwnProperty.call(args.record, schemaKey))
15314
15466
  return { kind: "value", value: Reflect.get(args.record, schemaKey) };
15315
15467
  if (args.mode === "partial") return { kind: "missing" };
@@ -18580,7 +18732,6 @@ function evalActionListenerInstruction(ins, scope, ctx, options) {
18580
18732
  scope,
18581
18733
  ctx,
18582
18734
  target.optional === true,
18583
- target.memberId,
18584
18735
  (resolved) => {
18585
18736
  destination = resolved;
18586
18737
  }
@@ -19580,13 +19731,7 @@ function evalPointerCore(pointer, scope, ctx, resultUsage = "value") {
19580
19731
  case "staticMember" /* staticMember */:
19581
19732
  return evalStaticMember(pointer.memberId, ctx);
19582
19733
  case "keyOf" /* keyOf */:
19583
- return evalKeyOf(
19584
- pointer.keyOf,
19585
- scope,
19586
- ctx,
19587
- pointer.optional === true,
19588
- pointer.memberId
19589
- );
19734
+ return evalKeyOf(pointer.keyOf, scope, ctx, pointer.optional === true);
19590
19735
  case "operation" /* operation */:
19591
19736
  return evalOperation(pointer.operation, scope, ctx);
19592
19737
  case "function" /* function */:
@@ -20217,7 +20362,6 @@ function readActionWithOwner(pointer, scope, ctx) {
20217
20362
  scope,
20218
20363
  ctx,
20219
20364
  pointer.optional === true,
20220
- pointer.memberId,
20221
20365
  (destination) => {
20222
20366
  owner = destination.receiver;
20223
20367
  }
@@ -21030,7 +21174,7 @@ function isRuntimeSpriteValue(value) {
21030
21174
  const sliceIndex = value.sliceIndex;
21031
21175
  return typeof sliceIndex === "number" && Number.isInteger(sliceIndex) && sliceIndex >= 0;
21032
21176
  }
21033
- function evalKeyOf(keyOf, scope, ctx, optional2 = false, memberId, onDestination) {
21177
+ function evalKeyOf(keyOf, scope, ctx, optional2 = false, onDestination) {
21034
21178
  const receiver = evalPointer(keyOf.pointer, scope, ctx);
21035
21179
  if (optional2 && (receiver === null || receiver === void 0)) {
21036
21180
  return null;
@@ -21089,11 +21233,6 @@ function evalKeyOf(keyOf, scope, ctx, optional2 = false, memberId, onDestination
21089
21233
  if (assetMember.kind === "ok") return assetMember.value;
21090
21234
  const dispatched = dispatchSchemaMember(receiver, k, ctx);
21091
21235
  if (dispatched.kind === "ok") return dispatched.value;
21092
- if (!dispatched.matchedMember && memberId !== void 0) {
21093
- const member = evalMemberById(ctx.vm, memberId);
21094
- const defaultValue = isReadOnlyMember(member) ? readDeclarationDefault(member, ctx) : { matched: false };
21095
- if (defaultValue.matched) return defaultValue.value;
21096
- }
21097
21236
  if (Object.prototype.hasOwnProperty.call(receiver, k)) {
21098
21237
  const at2 = receiver[k];
21099
21238
  return resolveValueIfId(at2, ctx);
@@ -21196,16 +21335,36 @@ function ensureVirtualExpansionIndexed(rows, ctx, existingIndexes) {
21196
21335
  );
21197
21336
  indexes3.indexedVirtualRowSets.add(rows);
21198
21337
  }
21338
+ var constantDeclarationRoots = /* @__PURE__ */ new WeakMap();
21199
21339
  function readDeclarationDefault(member, ctx) {
21200
21340
  if (member?.defaultValue === void 0 || member.defaultValue === null) {
21201
21341
  return { matched: false };
21202
21342
  }
21203
21343
  if (isInitValueContent(member.defaultValue) || isMemberClassBase(member) || isMemberListBase(member) || isMemberDictionaryBase(member)) {
21344
+ const session = ctx.__runtimeSessionValues;
21345
+ let shared;
21346
+ if (session !== void 0) {
21347
+ shared = constantDeclarationRoots.get(session);
21348
+ if (shared === void 0) {
21349
+ shared = /* @__PURE__ */ new Map();
21350
+ constantDeclarationRoots.set(session, shared);
21351
+ }
21352
+ }
21353
+ const known = shared?.get(member.id);
21354
+ if (typeof known === "string" && session?.has(known) === true) {
21355
+ return {
21356
+ matched: true,
21357
+ value: resolveValueIfIdForMember(known, member, ctx)
21358
+ };
21359
+ }
21360
+ const document2 = constructorDefaultValueDocument(ctx, member);
21361
+ const constant = shared !== void 0 && known !== false && (known !== void 0 || isImmutableConstantMember(document2, member));
21362
+ if (shared !== void 0 && !constant) shared.set(member.id, false);
21204
21363
  const created = [];
21205
21364
  const closeFrame = pushConstructionFrame(ctx, `${member.name} declaration`);
21206
21365
  try {
21207
21366
  const root = buildDefaultMemberValue({
21208
- document: constructorDefaultValueDocument(ctx, member),
21367
+ document: document2,
21209
21368
  projectId: ctx.vm.project.id,
21210
21369
  member,
21211
21370
  createdValues: created,
@@ -21226,6 +21385,7 @@ function readDeclarationDefault(member, ctx) {
21226
21385
  )
21227
21386
  });
21228
21387
  stageConstructedRows([root, ...created], ctx);
21388
+ if (constant) shared?.set(member.id, root.id);
21229
21389
  return {
21230
21390
  matched: true,
21231
21391
  value: resolveValueIfIdForMember(root.id, member, ctx)
@@ -23342,12 +23502,6 @@ function validateClassConstructorDescriptor(info, ctx, requireEveryRequiredField
23342
23502
  }
23343
23503
  seenSchemaKeys.add(field.schemaKey);
23344
23504
  seenMemberIds.add(field.memberId);
23345
- assertConstructorFieldSlotWritable({
23346
- schemaKey: field.schemaKey,
23347
- settledClassId: classId,
23348
- schemaClassName: schemaClass2.name,
23349
- ctx
23350
- });
23351
23505
  const schemaEntry = schemaByKey.get(field.schemaKey);
23352
23506
  if (schemaEntry === void 0) {
23353
23507
  throw new NSGetterRuntimeError(
@@ -23402,21 +23556,6 @@ function validateClassConstructorDescriptor(info, ctx, requireEveryRequiredField
23402
23556
  }
23403
23557
  return cacheDescriptor({ schemaClass: schemaClass2, fields, instanceEnv, classArguments: classArguments2 });
23404
23558
  }
23405
- function assertConstructorFieldSlotWritable(args) {
23406
- const index = evaluatorSchemaIndex(args.ctx);
23407
- const surfaceEntry = resolvedClassSchemaFromIndexes(
23408
- args.settledClassId,
23409
- index.classesById,
23410
- index.membersById
23411
- ).surfaceByKey.get(args.schemaKey);
23412
- if (surfaceEntry === void 0) return;
23413
- if (isReadOnlyMember(evalMemberById(args.ctx.vm, surfaceEntry.memberId)) !== true) {
23414
- return;
23415
- }
23416
- throw new NSGetterRuntimeError(
23417
- `Constructor field '${args.schemaKey}' on '${args.schemaClassName}' is a read-only declaration member and cannot have an instance value.`
23418
- );
23419
- }
23420
23559
  function validateConstructorFieldSlot(args) {
23421
23560
  const { schemaKey, ctx } = args;
23422
23561
  const rawMember = evalMemberById(ctx.vm, args.memberId);
@@ -23436,6 +23575,11 @@ function validateConstructorFieldSlot(args) {
23436
23575
  `Constructor field '${schemaKey}' on '${args.schemaClassName}' is not a stored concrete member.`
23437
23576
  );
23438
23577
  }
23578
+ if (member.storage === 1 /* Immutable */ && ctx.storedConstructionReplay !== true) {
23579
+ throw new NSGetterRuntimeError(
23580
+ `Constructor field '${schemaKey}' on '${args.schemaClassName}' is Immutable; runtime construction cannot set it.`
23581
+ );
23582
+ }
23439
23583
  const typeInfo = runtimeTypeInfoForMember(
23440
23584
  rawMember,
23441
23585
  args.instanceEnv,
@@ -24315,7 +24459,7 @@ function evaluateBaseInitializerFields(args) {
24315
24459
  )
24316
24460
  );
24317
24461
  const instanceSchema = new Map(
24318
- mergeStoredInstanceSchema(
24462
+ mergeInstanceSurfaceSchema(
24319
24463
  args.constructedClassId,
24320
24464
  ctx.vm.classes,
24321
24465
  ctx.vm.members
@@ -24339,12 +24483,6 @@ function evaluateBaseInitializerFields(args) {
24339
24483
  `Constructor '${record4.id}' settles base member '${field.name}', which the constructed instance does not store.`
24340
24484
  );
24341
24485
  }
24342
- assertConstructorFieldSlotWritable({
24343
- schemaKey: field.name,
24344
- settledClassId: args.constructedClassId,
24345
- schemaClassName: owningClass.name,
24346
- ctx
24347
- });
24348
24486
  const validated = validateConstructorFieldSlot({
24349
24487
  schemaKey: field.name,
24350
24488
  memberId: entry.memberId,
@@ -27212,7 +27350,7 @@ function createStoredValuePlacementTraversal(args, trackReferences = false) {
27212
27350
  const storedSchema = (classId) => {
27213
27351
  const cached = storedSchemaByClassId.get(classId);
27214
27352
  if (cached !== void 0) return cached;
27215
- const schema = mergeStoredInstanceSchema(
27353
+ const schema = mergeInstanceSurfaceSchema(
27216
27354
  classId,
27217
27355
  args.classes,
27218
27356
  args.members
@@ -27909,7 +28047,7 @@ function collectSoftOwnedConstructorArgumentValueIds(index, ownerValueId, preser
27909
28047
  const effectiveClassId = row.classId ?? (typeInfo.type === 7 /* Class */ ? typeInfo.classId : void 0);
27910
28048
  if (effectiveClassId === void 0) return;
27911
28049
  const env = rowGenericEnvironment(index.document, row);
27912
- const merged = mergeStoredInstanceSchema(
28050
+ const merged = mergeInstanceSurfaceSchema(
27913
28051
  effectiveClassId,
27914
28052
  index.document.classes,
27915
28053
  index.document.members
@@ -29803,6 +29941,12 @@ var Parser = class _Parser {
29803
29941
  value: this.parseExpr(),
29804
29942
  pos: at(name)
29805
29943
  });
29944
+ if (this.peek().text === ";") {
29945
+ throw new CompileError(
29946
+ "Object initializer assignments use commas, not semicolons. Replace ';' with ',' or omit it after the last assignment; the enclosing declaration still ends with ';'.",
29947
+ at(this.peek())
29948
+ );
29949
+ }
29806
29950
  if (!this.eat("punctuation", ",")) break;
29807
29951
  if (this.peek().kind === "punctuation" && this.peek().text === "}") break;
29808
29952
  }
@@ -30765,7 +30909,7 @@ function resolveVirtualInstanceGraph(args) {
30765
30909
  classId,
30766
30910
  args.document.classes,
30767
30911
  args.document.members
30768
- ).stored;
30912
+ ).surface;
30769
30913
  for (const entry of schema) {
30770
30914
  const childPath = appendVirtualValuePath(pathKey, {
30771
30915
  kind: "class",
@@ -31516,7 +31660,7 @@ function indexExpansion(args) {
31516
31660
  classId,
31517
31661
  args.document.classes,
31518
31662
  args.document.members
31519
- ).stored;
31663
+ ).surface;
31520
31664
  for (const entry of schema) {
31521
31665
  const childId = record4[entry.schemaKey];
31522
31666
  const childMember = membersById.get(entry.memberId);
@@ -34338,6 +34482,12 @@ var WRITE_TARGET_DESCRIPTIONS = {
34338
34482
  unknown: "something other than `this` or a local"
34339
34483
  };
34340
34484
  var ON_CHANGED_OPERATIONS_ERROR = "OnChanged supports only '+=', '-=', and Clear().";
34485
+ function immutableRuntimeConstructionError(name) {
34486
+ return `Runtime construction cannot set Immutable member '${name}'; it reads its declared initializer.`;
34487
+ }
34488
+ function readonlyWriteError(name) {
34489
+ return `Member '${name}' is readonly; set it in its initializer, a constructor, or an object initializer.`;
34490
+ }
34341
34491
  var FALLTHROUGH_LABELS = {
34342
34492
  function: "NSFunction",
34343
34493
  getter: "getter",
@@ -36081,7 +36231,12 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
36081
36231
  scope
36082
36232
  );
36083
36233
  const target = statement.op === "=" ? { ...resolvedTarget, type: storageType } : resolvedTarget;
36084
- const writability = local?.writability ?? target.writability;
36234
+ const initSlot = target.initWritability !== void 0 ? {
36235
+ pointer: target.pointer,
36236
+ initWritability: target.initWritability
36237
+ } : target.readonlyCollection;
36238
+ const initializing = initSlot !== void 0 && this.constructsSlot(initSlot.pointer, assignmentContext);
36239
+ const writability = initializing ? initSlot.initWritability : local?.writability ?? target.writability;
36085
36240
  if (target.symbol?.computed === true && target.symbol.writable !== true) {
36086
36241
  throw new CompileError(
36087
36242
  `Cannot assign to NeoScript property '${target.symbol.name}' because it does not declare a setter.`,
@@ -36094,9 +36249,15 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
36094
36249
  statement.pos
36095
36250
  );
36096
36251
  }
36097
- if (target.symbol?.readonlyDeclaration === true) {
36252
+ if (target.symbol?.readonlyDeclaration === true && !initializing) {
36253
+ throw new CompileError(
36254
+ readonlyWriteError(target.symbol.name),
36255
+ statement.pos
36256
+ );
36257
+ }
36258
+ if (target.readonlyCollection !== void 0 && !initializing) {
36098
36259
  throw new CompileError(
36099
- `Member '${target.symbol.name}' is readonly and can only be changed through its class default.`,
36260
+ readonlyWriteError(target.readonlyCollection.name),
36100
36261
  statement.pos
36101
36262
  );
36102
36263
  }
@@ -36115,7 +36276,15 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
36115
36276
  statement.pos
36116
36277
  );
36117
36278
  }
36118
- if (writability === "immutable" /* Immutable */ && assignmentContext !== "initializer") {
36279
+ if (writability === "immutable" /* Immutable */ && assignmentContext === "initializer") {
36280
+ throw new CompileError(
36281
+ immutableRuntimeConstructionError(
36282
+ target.symbol?.name ?? this.describe(target.type)
36283
+ ),
36284
+ statement.pos
36285
+ );
36286
+ }
36287
+ if (writability === "immutable" /* Immutable */) {
36119
36288
  throw new CompileError(
36120
36289
  "Cannot assign because the target's effective storage is immutable.",
36121
36290
  statement.pos
@@ -37010,8 +37179,7 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
37010
37179
  );
37011
37180
  }
37012
37181
  const declared = declaredTarget?.declaredConstructors ?? [];
37013
- const requiredConstructor = neoScriptRequiredConstructor(declaredTarget);
37014
- const generatedPositionalCall = requiredConstructor === null && declaredTarget?.constructorSignature !== void 0 && expression.argumentNames === void 0 && callHasPositionalArguments(expression);
37182
+ const generatedPositionalCall = declaredTarget !== void 0 && isGeneratedPositionalCall(declaredTarget, expression);
37015
37183
  if (!generatedPositionalCall && (declared.length > 0 || this.context.storedConstructionReplay === true && expression.args.length === 0)) {
37016
37184
  return this.resolveDeclaredConstructor(
37017
37185
  className,
@@ -38504,10 +38672,12 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
38504
38672
  } : {}
38505
38673
  };
38506
38674
  }
38507
- const writability = this.memberWritability(member, receiver);
38508
- const entryWritability = member.lookup ? this.lookupEntryWritability(member, receiver) : void 0;
38675
+ const readonlySlot = member.readonlyDeclaration === true;
38676
+ const storageWritability = this.memberWritability(member, receiver);
38677
+ const writability = readonlySlot ? "readOnly" /* ReadOnly */ : storageWritability;
38678
+ const entryWritability = member.lookup ? this.lookupEntryWritability(member, receiver) : readonlySlot ? storageWritability : void 0;
38509
38679
  const userData = this.memberUserData(member, receiver);
38510
- const entryUserData = member.lookup ? this.lookupEntryUserData(member) : false;
38680
+ const entryUserData = member.lookup ? this.lookupEntryUserData(member) : readonlySlot && userData;
38511
38681
  const lookupWire = member.lookup?.multiselect === true && memberType2.kind === "set" ? {
38512
38682
  type: 9 /* Lookup */,
38513
38683
  required: !isNullable(memberType2),
@@ -38530,6 +38700,7 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
38530
38700
  ...writability ? { writability } : {},
38531
38701
  ...lookupWire ? { wireType: lookupWire } : {},
38532
38702
  ...entryWritability ? { entryWritability } : {},
38703
+ ...readonlySlot && storageWritability ? { initWritability: storageWritability } : {},
38533
38704
  userData,
38534
38705
  entryUserData
38535
38706
  };
@@ -38621,7 +38792,8 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
38621
38792
  if (member.writability && !member.lookup) {
38622
38793
  return toWritability(member.writability, this.writesUserData);
38623
38794
  }
38624
- if (!member.writable) return void 0;
38795
+ if (!member.writable && member.readonlyDeclaration !== true)
38796
+ return void 0;
38625
38797
  if (!member.lookup) {
38626
38798
  return member.writability ? toWritability(member.writability, this.writesUserData) : receiver.entryWritability ?? receiver.writability ?? "save" /* Save */;
38627
38799
  }
@@ -38713,6 +38885,11 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
38713
38885
  writability: "readOnly" /* ReadOnly */
38714
38886
  };
38715
38887
  }
38888
+ const readonlyCollection = receiver.symbol?.readonlyDeclaration === true && receiver.initWritability !== void 0 ? {
38889
+ name: receiver.symbol.name,
38890
+ pointer: receiver.pointer,
38891
+ initWritability: receiver.initWritability
38892
+ } : void 0;
38716
38893
  let keyType;
38717
38894
  let valueType;
38718
38895
  let resolvedIndex;
@@ -38729,7 +38906,10 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
38729
38906
  type: nullPropagating ? { ...receiver.type.elementType, nullable: true } : receiver.type.elementType,
38730
38907
  ...nullPropagating ? { optionalChainType: receiver.type.elementType } : {},
38731
38908
  ...receiver.writability ? { writability: receiver.writability } : {},
38732
- ...receiver.userData ? { userData: true } : {}
38909
+ ...receiver.entryWritability ? { entryWritability: receiver.entryWritability } : {},
38910
+ ...receiver.userData ? { userData: true } : {},
38911
+ ...receiver.entryUserData ? { entryUserData: true } : {},
38912
+ ...readonlyCollection ? { readonlyCollection } : {}
38733
38913
  };
38734
38914
  }
38735
38915
  keyType = { kind: "primitive", name: "int" };
@@ -38764,7 +38944,10 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
38764
38944
  type: nullPropagating ? { ...valueType, nullable: true } : valueType,
38765
38945
  ...nullPropagating ? { optionalChainType: valueType } : {},
38766
38946
  ...receiver.writability ? { writability: receiver.writability } : {},
38767
- ...receiver.userData ? { userData: true } : {}
38947
+ ...receiver.entryWritability ? { entryWritability: receiver.entryWritability } : {},
38948
+ ...receiver.userData ? { userData: true } : {},
38949
+ ...receiver.entryUserData ? { entryUserData: true } : {},
38950
+ ...readonlyCollection ? { readonlyCollection } : {}
38768
38951
  };
38769
38952
  }
38770
38953
  resolveDictionaryKey(expectedKey, keyAst, scope, pos, requireNonOptional, dictionaryLiteral = false) {
@@ -39652,7 +39835,17 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
39652
39835
  };
39653
39836
  }
39654
39837
  resolveExecutableObjectInitializer(schemaClass2, expression, scope, expected) {
39655
- const constructed = this.resolveExpression(
39838
+ const settling = this.generatedConstructorSettlingEntries(
39839
+ schemaClass2,
39840
+ expression
39841
+ );
39842
+ const constructed = settling.length > 0 ? this.resolveClassConstructor(
39843
+ schemaClass2.name,
39844
+ { ...expression, initializer: settling },
39845
+ scope,
39846
+ expression.pos,
39847
+ expected
39848
+ ) : this.resolveExpression(
39656
39849
  { ...expression, className: schemaClass2.name, initializer: [] },
39657
39850
  scope,
39658
39851
  expected
@@ -39678,6 +39871,7 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
39678
39871
  const assignments = [];
39679
39872
  const seen = /* @__PURE__ */ new Set();
39680
39873
  for (const entry of expression.initializer ?? []) {
39874
+ if (settling.includes(entry)) continue;
39681
39875
  const key = entry.name.toLowerCase();
39682
39876
  if (seen.has(key)) {
39683
39877
  throw new CompileError(
@@ -39721,6 +39915,23 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
39721
39915
  writeRoot: "local"
39722
39916
  };
39723
39917
  }
39918
+ /** Block entries naming a required parameter the positional arguments skip. */
39919
+ generatedConstructorSettlingEntries(schemaClass2, expression) {
39920
+ const signature = schemaClass2.constructorSignature;
39921
+ if (signature === void 0) return [];
39922
+ const generated = isGeneratedPositionalCall(schemaClass2, expression) || (schemaClass2.declaredConstructors?.length ?? 0) === 0 && expression.argumentNames === void 0;
39923
+ if (!generated) return [];
39924
+ const required = new Set(
39925
+ requiredMembersAfterArguments(
39926
+ schemaClass2,
39927
+ signature.parameters,
39928
+ expression.args.length
39929
+ ).map((name) => name.toLowerCase())
39930
+ );
39931
+ return (expression.initializer ?? []).filter(
39932
+ (entry) => required.has(entry.name.toLowerCase())
39933
+ );
39934
+ }
39724
39935
  resolveClassConstructor(className, expression, scope, pos, expected) {
39725
39936
  const schemaClass2 = this.project.typeByName.get(className);
39726
39937
  if (!schemaClass2 || schemaClass2.kind !== "class") {
@@ -39742,7 +39953,13 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
39742
39953
  pos
39743
39954
  );
39744
39955
  }
39745
- const signature = schemaClass2.constructorSignature ?? (replayingStoredConstruction ? schemaClass2.storedConstructionReplaySignature : void 0);
39956
+ if (schemaClass2.constructorUnavailableReason === "requiredImmutableMember" && !replayingStoredConstruction) {
39957
+ throw new CompileError(
39958
+ `Cannot construct Class '${className}' at runtime; it has a required Immutable member, which only authored values can supply.`,
39959
+ pos
39960
+ );
39961
+ }
39962
+ const signature = replayingStoredConstruction ? schemaClass2.storedConstructionReplaySignature ?? schemaClass2.constructorSignature : schemaClass2.constructorSignature;
39746
39963
  if (!signature) {
39747
39964
  const open = (schemaClass2.typeParameters?.length ?? 0) > 0;
39748
39965
  throw new CompileError(
@@ -39775,16 +39992,21 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
39775
39992
  pos
39776
39993
  );
39777
39994
  }
39778
- const requiredCount = signature.parameters.filter(
39779
- (parameter3) => parameter3.required
39780
- ).length;
39781
- if (expression.argumentNames === void 0 && argumentsList2.length < requiredCount) {
39995
+ const blockKeys = new Set(
39996
+ (expression.initializer ?? []).map((entry) => entry.name.toLowerCase())
39997
+ );
39998
+ const unsettled = requiredMembersAfterArguments(
39999
+ schemaClass2,
40000
+ parameters,
40001
+ argumentsList2.length
40002
+ ).filter((name) => !blockKeys.has(name.toLowerCase()));
40003
+ if (unsettled.length > 0) {
39782
40004
  throw new CompileError(
39783
- `${className} constructor requires ${requiredCount} argument${requiredCount === 1 ? "" : "s"} but got ${argumentsList2.length}.`,
40005
+ `${className} construction does not set required ${unsettled.length === 1 ? "member" : "members"} ${unsettled.map((name) => `'${name}'`).join(", ")}. Pass each as a constructor argument or set it in an initializer block.`,
39784
40006
  pos
39785
40007
  );
39786
40008
  }
39787
- if (expression.argumentNames === void 0 && argumentsList2.length > parameters.length) {
40009
+ if (argumentsList2.length > parameters.length) {
39788
40010
  throw new CompileError(
39789
40011
  `${className} constructor accepts at most ${parameters.length} argument${parameters.length === 1 ? "" : "s"} but got ${argumentsList2.length}.`,
39790
40012
  pos
@@ -40100,9 +40322,9 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
40100
40322
  entry.pos
40101
40323
  );
40102
40324
  }
40103
- if (member.readonlyDeclaration === true) {
40325
+ if (member.writability === "immutable" && this.context.storedConstructionReplay !== true) {
40104
40326
  throw new CompileError(
40105
- `'${schemaClass2.name}.${member.name}' is readonly and can only be changed through its class default.`,
40327
+ immutableRuntimeConstructionError(member.name),
40106
40328
  entry.pos
40107
40329
  );
40108
40330
  }
@@ -41796,7 +42018,11 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
41796
42018
  pos
41797
42019
  );
41798
42020
  }
41799
- const writability = receiver.writability;
42021
+ const initializing = receiver.initWritability !== void 0 && this.constructsSlot(receiver.pointer, "ordinary");
42022
+ if (receiver.symbol?.readonlyDeclaration === true && !initializing) {
42023
+ throw new CompileError(readonlyWriteError(receiver.symbol.name), pos);
42024
+ }
42025
+ const writability = initializing ? receiver.initWritability : receiver.writability;
41800
42026
  const readOnlyCollection = (receiver.type.kind === "list" || receiver.type.kind === "dictionary" || receiver.type.kind === "set") && receiver.type.readOnly === true;
41801
42027
  if (!writability || writability === "readOnly" /* ReadOnly */ || writability === "immutable" /* Immutable */ || readOnlyCollection) {
41802
42028
  if (receiver.indexDefinition) {
@@ -41889,7 +42115,11 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
41889
42115
  pos
41890
42116
  );
41891
42117
  }
41892
- const writability = receiver.writability;
42118
+ const initializing = receiver.initWritability !== void 0 && this.constructsSlot(receiver.pointer, "ordinary");
42119
+ if (receiver.symbol?.readonlyDeclaration === true && !initializing) {
42120
+ throw new CompileError(readonlyWriteError(receiver.symbol.name), pos);
42121
+ }
42122
+ const writability = initializing ? receiver.initWritability : receiver.writability;
41893
42123
  if (writability === "immutable" /* Immutable */) {
41894
42124
  throw new CompileError(
41895
42125
  "Cannot clear an action whose effective storage is immutable.",
@@ -42281,6 +42511,19 @@ var StrictNeoScriptResolver = class _StrictNeoScriptResolver {
42281
42511
  pos
42282
42512
  );
42283
42513
  }
42514
+ /**
42515
+ * Whether a write to this member slot happens while its instance is
42516
+ * constructed: an object initializer entry, or `this.X` directly in a
42517
+ * constructor body.
42518
+ */
42519
+ constructsSlot(pointer, assignmentContext) {
42520
+ if (assignmentContext === "initializer") return true;
42521
+ if (this.context.kind !== "constructor") return false;
42522
+ if (this.lambdaDepth > 0) return false;
42523
+ if (pointer.type !== "keyOf" /* KeyOf */) return false;
42524
+ const receiver = pointer.keyOf.pointer;
42525
+ return receiver.type === "variable" /* Variable */ && receiver.variableId === this.thisVariable.id;
42526
+ }
42284
42527
  writeTargetRoot(pointer, scope) {
42285
42528
  switch (pointer.type) {
42286
42529
  case "variable" /* Variable */:
@@ -42702,6 +42945,20 @@ function variable(id, type, pointer, project) {
42702
42945
  }
42703
42946
  };
42704
42947
  }
42948
+ function isGeneratedPositionalCall(target, expression) {
42949
+ return neoScriptRequiredConstructor(target) === null && target.constructorSignature !== void 0 && expression.argumentNames === void 0 && callHasPositionalArguments(expression);
42950
+ }
42951
+ function requiredMembersAfterArguments(schemaClass2, parameters, positionalCount) {
42952
+ const names = [];
42953
+ for (const parameter3 of parameters.slice(positionalCount)) {
42954
+ if (!parameter3.required) continue;
42955
+ const member = schemaClass2.members.find(
42956
+ (candidate) => candidate.id === parameter3.memberId
42957
+ );
42958
+ names.push(member?.name ?? parameter3.name);
42959
+ }
42960
+ return names;
42961
+ }
42705
42962
  function callHasPositionalArguments(expression) {
42706
42963
  return expression.args.some(
42707
42964
  (_, index) => (expression.argumentNames?.[index] ?? null) === null
@@ -44457,31 +44714,29 @@ function attachConstructorSignature(type, environment) {
44457
44714
  for (const binding of genericEnvironment.values()) {
44458
44715
  if (binding.kind === "unbound") return type;
44459
44716
  }
44460
- const constructorSignature2 = buildNeoScriptConstructorSignature(
44461
- type.id,
44462
- type.members,
44463
- (memberId) => {
44464
- const declarationMember = environment.members.get(memberId);
44465
- if (declarationMember?.isReadOnly === true) return null;
44466
- const member = effectiveConstructorMember(
44467
- memberId,
44468
- genericEnvironment,
44469
- environment
44470
- );
44471
- return member ? {
44472
- required: boolean(member.required, `member ${memberId}.required`),
44473
- defaultValue: member.defaultValue
44474
- } : null;
44475
- }
44476
- );
44477
- if (resolvedAllowedStorage(type.id, environment) === "immutable") {
44478
- return {
44479
- ...type,
44480
- storedConstructionReplaySignature: constructorSignature2,
44481
- constructorUnavailableReason: "immutableOnly"
44482
- };
44483
- }
44484
- return { ...type, constructorSignature: constructorSignature2 };
44717
+ return {
44718
+ ...type,
44719
+ ...buildNeoScriptConstructionSignatures(
44720
+ type.id,
44721
+ type.members,
44722
+ (memberId) => {
44723
+ const member = effectiveConstructorMember(
44724
+ memberId,
44725
+ genericEnvironment,
44726
+ environment
44727
+ );
44728
+ return member ? {
44729
+ required: boolean(member.required, `member ${memberId}.required`),
44730
+ defaultValue: member.defaultValue,
44731
+ immutable: declaredStorage(
44732
+ environment.members.get(memberId),
44733
+ environment.members
44734
+ ) === "immutable"
44735
+ } : null;
44736
+ },
44737
+ resolvedAllowedStorage(type.id, environment) === "immutable"
44738
+ )
44739
+ };
44485
44740
  }
44486
44741
  function resolvedAllowedStorage(classId, environment) {
44487
44742
  const visited = /* @__PURE__ */ new Set();
@@ -44564,6 +44819,20 @@ function inferRootMemberIds(members) {
44564
44819
  user: unique("user")
44565
44820
  };
44566
44821
  }
44822
+ function declaredStorage(member, members) {
44823
+ const seen = /* @__PURE__ */ new Set();
44824
+ let current = member;
44825
+ while (current !== void 0 && !seen.has(current)) {
44826
+ seen.add(current);
44827
+ const storage = current.storage;
44828
+ if (storage === "immutable" || storage === "save" || storage === "session" || storage === "writable" || storage === "user") {
44829
+ return storage;
44830
+ }
44831
+ if (typeof current.overrideOf !== "string") return null;
44832
+ current = members.get(current.overrideOf);
44833
+ }
44834
+ return null;
44835
+ }
44567
44836
  function effectiveMemberWritability(members, classes, roots) {
44568
44837
  const memberById = /* @__PURE__ */ new Map();
44569
44838
  for (const member of members) {
@@ -44577,16 +44846,6 @@ function effectiveMemberWritability(members, classes, roots) {
44577
44846
  classById.set(schemaClass2.id, schemaClass2);
44578
44847
  }
44579
44848
  }
44580
- const declaredStorage = (memberId, seen = /* @__PURE__ */ new Set()) => {
44581
- if (seen.has(memberId)) return null;
44582
- seen.add(memberId);
44583
- const member = memberById.get(memberId);
44584
- if (!member) return null;
44585
- if (member.storage === "immutable" || member.storage === "save" || member.storage === "session" || member.storage === "writable" || member.storage === "user") {
44586
- return member.storage;
44587
- }
44588
- return typeof member.overrideOf === "string" ? declaredStorage(member.overrideOf, seen) : null;
44589
- };
44590
44849
  const classExtends = (candidateId, baseId) => {
44591
44850
  const seen = /* @__PURE__ */ new Set();
44592
44851
  let currentId = candidateId;
@@ -44652,7 +44911,7 @@ function effectiveMemberWritability(members, classes, roots) {
44652
44911
  }
44653
44912
  if (typeof roots.user === "string") rootStorage.set(roots.user, "user");
44654
44913
  for (const [memberId, member] of memberById) {
44655
- const declared = rootStorage.get(memberId) ?? declaredStorage(memberId);
44914
+ const declared = rootStorage.get(memberId) ?? declaredStorage(member, memberById);
44656
44915
  if (declared === "writable") {
44657
44916
  writable.add(memberId);
44658
44917
  continue;
@@ -44810,10 +45069,9 @@ function memberSymbol(member, schemaKey, environment, field) {
44810
45069
  };
44811
45070
  }
44812
45071
  const writable = isReadOnly ? false : kind === "computed" ? computedHasSetter(member, field) : true;
44813
- const storage = typeof member.storage === "string" ? member.storage : void 0;
45072
+ const storage = declaredStorage(member, environment.members) ?? void 0;
44814
45073
  let writability;
44815
- if (!writable) writability = "readOnly";
44816
- else if (kind === "computed") writability = "setter";
45074
+ if (kind === "computed") writability = writable ? "setter" : "readOnly";
44817
45075
  else {
44818
45076
  writability = declaredStorageWritability(
44819
45077
  storage,
@@ -46747,35 +47005,7 @@ function constructorSignature(schemaClass2, members, context, genericEnvironment
46747
47005
  if (!isClosedClass(schemaClass2.id, context.vm.classes)) {
46748
47006
  return {};
46749
47007
  }
46750
- if (resolveAllowedStorage(schemaClass2.id, context.vm.classes) === 1 /* Immutable */) {
46751
- const signature2 = buildNeoScriptConstructorSignature(
46752
- schemaClass2.id,
46753
- members,
46754
- (memberId) => {
46755
- const record4 = analyzerMemberById(context, memberId);
46756
- if (!record4) return null;
46757
- try {
46758
- const resolved = substituteMember(
46759
- record4,
46760
- genericEnvironment,
46761
- context.vm.members,
46762
- resolveAnalyzerMember(context, record4)
46763
- );
46764
- return {
46765
- required: isRequiredMember(resolved),
46766
- defaultValue: "defaultValue" in resolved ? resolved.defaultValue : void 0
46767
- };
46768
- } catch {
46769
- return null;
46770
- }
46771
- }
46772
- );
46773
- return {
46774
- storedConstructionReplaySignature: signature2,
46775
- constructorUnavailableReason: "immutableOnly"
46776
- };
46777
- }
46778
- const signature = buildNeoScriptConstructorSignature(
47008
+ return buildNeoScriptConstructionSignatures(
46779
47009
  schemaClass2.id,
46780
47010
  members,
46781
47011
  (memberId) => {
@@ -46790,14 +47020,15 @@ function constructorSignature(schemaClass2, members, context, genericEnvironment
46790
47020
  );
46791
47021
  return {
46792
47022
  required: isRequiredMember(resolved),
46793
- defaultValue: "defaultValue" in resolved ? resolved.defaultValue : void 0
47023
+ defaultValue: "defaultValue" in resolved ? resolved.defaultValue : void 0,
47024
+ immutable: declaredMemberStorage(record4.id, context.vm.members) === 1 /* Immutable */
46794
47025
  };
46795
47026
  } catch {
46796
47027
  return null;
46797
47028
  }
46798
- }
47029
+ },
47030
+ resolveAllowedStorage(schemaClass2.id, context.vm.classes) === 1 /* Immutable */
46799
47031
  );
46800
- return { constructorSignature: signature };
46801
47032
  }
46802
47033
  function declaredConstructors(schemaClass2, context) {
46803
47034
  const requiredConstructorId2 = schemaClass2.requiredConstructorId;
@@ -46882,6 +47113,7 @@ function memberToSymbol(record4, schemaKey, containingClass, ownerClassId, index
46882
47113
  ...scriptDefinitionLocations2(record4.id, context),
46883
47114
  documentation: getOptionalString(resolved, "docsText") ?? `${record4.name} (${record4.id})`,
46884
47115
  writable: !isReadOnlyMember(record4),
47116
+ ...isReadOnlyMember(record4) ? { readonlyDeclaration: true } : {},
46885
47117
  ...isStaticMember(record4) === true ? { static: true } : {},
46886
47118
  ...symbolWritability(
46887
47119
  record4.id,
@@ -49483,7 +49715,7 @@ async function loadMemberDefaultValueClosure(args) {
49483
49715
  const classId = source.classId ?? member.classId;
49484
49716
  classFields = classSchemas.get(classId);
49485
49717
  if (classFields === void 0) {
49486
- classFields = mergeStoredInstanceSchema(classId, classes, members);
49718
+ classFields = mergeInstanceSurfaceSchema(classId, classes, members);
49487
49719
  classSchemas.set(classId, classFields);
49488
49720
  }
49489
49721
  env = withStamp(
@@ -50771,6 +51003,11 @@ var BODY_CHILD_PAYLOAD = canonicalJsonStringify({
50771
51003
  });
50772
51004
 
50773
51005
  // ../src/models/project/world-content-sidecar-validation.ts
51006
+ var TILE_CLASS_LEVEL_KEYS = worldSystemSchemaFieldsForKind(
51007
+ NeoWorldSystemClassKind.Tile
51008
+ ).flatMap(
51009
+ (field) => field.mutability === 1 /* ReadOnly */ ? [field.schemaKey] : []
51010
+ );
50774
51011
  var WORLD_PLACEMENT_ASSET_KIND = /* @__PURE__ */ new Map([[NeoWorldSystemClassKind.Object, NeoWorldSystemClassKind.Object]]);
50775
51012
 
50776
51013
  // ../src/database/general-function-call-ir-source-recompile.ts
@@ -50788,7 +51025,7 @@ var STRING_TYPE_INFO = {
50788
51025
  };
50789
51026
 
50790
51027
  // ../src/database/project-version-whole-graph-validation.ts
50791
- import { ConvexError as ConvexError4 } from "convex/values";
51028
+ import { ConvexError as ConvexError3 } from "convex/values";
50792
51029
 
50793
51030
  // ../src/models/exports/unity-static-members.ts
50794
51031
  var nativePatternMembers = new Set(
@@ -50796,7 +51033,6 @@ var nativePatternMembers = new Set(
50796
51033
  );
50797
51034
 
50798
51035
  // ../convex/projectInterfaceValidation.ts
50799
- import { ConvexError as ConvexError3 } from "convex/values";
50800
51036
  var MEMBER_REQUIREMENT_KINDS = [
50801
51037
  0 /* Optional */,
50802
51038
  1 /* Required */
@@ -55714,7 +55950,7 @@ var SPECIALIZED_RELATION_KINDS = /* @__PURE__ */ new Set([
55714
55950
 
55715
55951
  // ../packages/manifest/schema-contract/registry.mjs
55716
55952
  var PROJECT_SCHEMA_CONTRACT = Object.freeze({
55717
- cliVersion: "0.75.1",
55953
+ cliVersion: "0.76.0",
55718
55954
  projectFileUploadBatchSize: 32,
55719
55955
  documentRecords: {
55720
55956
  member: {
@@ -57392,7 +57628,7 @@ function buildRootValue(document2, lookups) {
57392
57628
  var MAX_SOURCE_BYTES = 32 * 1024 * 1024;
57393
57629
 
57394
57630
  // ../src/database/client-commit-submit.ts
57395
- import { ConvexError as ConvexError5 } from "convex/values";
57631
+ import { ConvexError as ConvexError4 } from "convex/values";
57396
57632
 
57397
57633
  // ../src/common/client-commit-transport.ts
57398
57634
  var INLINE_COMMIT_MAX_PAYLOAD_BYTES = 512 * 1024;
@@ -57476,7 +57712,7 @@ var WORLD_OBJECT_CONTRACT_WORLD_KINDS = /* @__PURE__ */ new Set([
57476
57712
  ]);
57477
57713
 
57478
57714
  // ../src/models/exports/unity-codegen-revision.ts
57479
- var UNITY_CODEGEN_REVISION = "e4a632a177c87244e19da71c9840b8007735773ae5f81578f58ce246ec6cb03d";
57715
+ var UNITY_CODEGEN_REVISION = "ac7f9812e3b16cc37d09ba5006316dda6bac23884c83b368a10880bc3f2c765b";
57480
57716
 
57481
57717
  // src/export-cache.ts
57482
57718
  var CACHE_BUILD = JSON.stringify([