@velarscript/compiler 0.10.3 → 0.10.4

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.
@@ -1,6 +1,6 @@
1
1
  export declare const VELAR_COLLECTION_LOWERING_MODULE = "velar/compiler-runtime-collection-lowering-v1";
2
2
  /** Stateless collection algorithms shared by project compilation. */
3
- export declare const VELAR_COLLECTION_LOWERING_EXPORTS: readonly ["__velarMaxCollectionItems", "__velarCollectionValue", "__velarSameValueZero", "__velarEquals", "__velarValidateDenseList", "__velarReactiveListIterator", "__velarReactiveSetIterator", "__velarReactiveMapKeyIterator", "__velarReactiveRecordIterator", "__velarCollectionIterator", "__velarCollectionPairIterator", "__velarCopyList", "__velarOrderedListValue", "__velarCreateList", "__velarCreateListAsync", "__velarCreateSet", "__velarCreateMap", "__velarCollectionSize", "__velarCollectionGet", "__velarCollectionSlice", "__VelarIndexError", "__velarIndex", "__velarOptionalIndex", "__velarSetIndex", "__velarListAppend", "__velarListExtend", "__velarListInsert", "__velarListRemove", "__velarListPop", "__velarListCopy", "__velarListCount", "__velarListIndex", "__velarListFind", "__velarListMap", "__velarListFilter", "__velarListReduce", "__velarListEvery", "__velarListSome", "__velarListSum", "__velarListExtremum", "__velarListMin", "__velarListMax", "__velarListJoin", "__velarListSorted", "__velarListReversed", "__velarListFlatMap", "__velarSetAdd", "__velarSetUpdate", "__velarSetCopy", "__velarSetUnion", "__velarSetIntersection", "__velarSetDifference", "__velarMapSet", "__velarMapUpdate", "__velarMapCopy", "__velarRecordFields", "__velarRecordSet", "__velarRecordCopy", "__velarCollectionHas", "__velarContains", "__velarCollectionRemove", "__velarCollectionClear", "__velarCollectionKeys", "__velarCollectionValues", "__velarCollectionEntries", "__velarOptionalCollection"];
3
+ export declare const VELAR_COLLECTION_LOWERING_EXPORTS: readonly ["__velarMaxCollectionItems", "__velarCollectionValue", "__velarSameValueZero", "__velarEquals", "__velarValidateDenseList", "__velarReactiveListIterator", "__velarReactiveSetIterator", "__velarReactiveMapKeyIterator", "__velarReactiveRecordIterator", "__velarReactiveMapPairIterator", "__velarReactiveRecordPairIterator", "__velarCollectionIterator", "__velarCollectionPairIterator", "__velarCopyList", "__velarOrderedListValue", "__velarCreateList", "__velarCreateListAsync", "__velarCreateSet", "__velarCreateMap", "__velarCollectionSize", "__velarListSize", "__velarMapSize", "__velarSetSize", "__velarRecordSize", "__velarCollectionGet", "__velarListGet", "__velarMapGet", "__velarRecordGet", "__velarCollectionSlice", "__VelarIndexError", "__velarIndex", "__velarListIndexGet", "__velarRecordIndexGet", "__velarOptionalIndex", "__velarSetIndex", "__velarListIndexSet", "__velarRecordIndexSet", "__velarListAppend", "__velarListExtend", "__velarListInsert", "__velarListRemove", "__velarListPop", "__velarListCopy", "__velarListCount", "__velarListIndex", "__velarListFind", "__velarListMap", "__velarListFilter", "__velarListReduce", "__velarListEvery", "__velarListSome", "__velarListSum", "__velarListExtremum", "__velarListMin", "__velarListMax", "__velarListJoin", "__velarListSorted", "__velarListReversed", "__velarListFlatMap", "__velarSetAdd", "__velarSetUpdate", "__velarSetCopy", "__velarSetUnion", "__velarSetIntersection", "__velarSetDifference", "__velarMapSet", "__velarMapUpdate", "__velarMapCopy", "__velarRecordFields", "__velarRecordSet", "__velarRecordCopy", "__velarCollectionHas", "__velarListHas", "__velarMapHas", "__velarSetHas", "__velarRecordHas", "__velarListContains", "__velarMapContains", "__velarSetContains", "__velarRecordContains", "__velarContains", "__velarCollectionRemove", "__velarMapRemove", "__velarSetRemove", "__velarRecordRemove", "__velarCollectionClear", "__velarListClear", "__velarMapClear", "__velarSetClear", "__velarRecordClear", "__velarCollectionKeys", "__velarMapKeys", "__velarRecordKeys", "__velarCollectionValues", "__velarMapValues", "__velarSetValues", "__velarRecordValues", "__velarCollectionEntries", "__velarMapEntries", "__velarRecordEntries", "__velarOptionalCollection"];
4
4
  export declare const VELAR_COLLECTION_LOWERING_DEPENDENCIES: readonly ["velar/compiler-runtime-collections-v1", "velar/compiler-runtime-reactive-v1"];
5
5
  export declare const VELAR_COLLECTION_LOWERING_RUNTIME: string;
6
6
  export declare const VELAR_COLLECTION_LOWERING_MODULE_SOURCE: string;
@@ -1 +1 @@
1
- {"version":3,"file":"collection-lowering-runtime.d.ts","sourceRoot":"","sources":["../src/collection-lowering-runtime.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,gCAAgC,kDAAkD,CAAC;AAEhG,qEAAqE;AACrE,eAAO,MAAM,iCAAiC,YAC5C,2BAA2B,EAC3B,wBAAwB,EACxB,sBAAsB,EACtB,eAAe,EACf,0BAA0B,EAC1B,6BAA6B,EAC7B,4BAA4B,EAC5B,+BAA+B,EAC/B,+BAA+B,EAC/B,2BAA2B,EAC3B,+BAA+B,EAC/B,iBAAiB,EACjB,yBAAyB,EACzB,mBAAmB,EACnB,wBAAwB,EACxB,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACvB,sBAAsB,EACtB,wBAAwB,EAMxB,mBAAmB,EACnB,cAAc,EACd,sBAAsB,EACtB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,wBAAwB,EACxB,sBAAsB,EACtB,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,iBAAiB,EACjB,yBAAyB,EACzB,wBAAwB,EACxB,uBAAuB,EACvB,yBAAyB,EACzB,0BAA0B,EAC1B,2BAA2B,CACnB,CAAC;AAEX,eAAO,MAAM,sCAAsC,0FAGzC,CAAC;AAEX,eAAO,MAAM,iCAAiC,QAk1B2D,CAAC;AAE1G,eAAO,MAAM,uCAAuC,QAkBvC,CAAC"}
1
+ {"version":3,"file":"collection-lowering-runtime.d.ts","sourceRoot":"","sources":["../src/collection-lowering-runtime.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,gCAAgC,kDAAkD,CAAC;AAEhG,qEAAqE;AACrE,eAAO,MAAM,iCAAiC,YAC5C,2BAA2B,EAC3B,wBAAwB,EACxB,sBAAsB,EACtB,eAAe,EACf,0BAA0B,EAC1B,6BAA6B,EAC7B,4BAA4B,EAC5B,+BAA+B,EAC/B,+BAA+B,EAC/B,gCAAgC,EAChC,mCAAmC,EACnC,2BAA2B,EAC3B,+BAA+B,EAC/B,iBAAiB,EACjB,yBAAyB,EACzB,mBAAmB,EACnB,wBAAwB,EACxB,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACvB,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,sBAAsB,EACtB,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,wBAAwB,EAMxB,mBAAmB,EACnB,cAAc,EACd,qBAAqB,EACrB,uBAAuB,EACvB,sBAAsB,EACtB,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,wBAAwB,EACxB,sBAAsB,EACtB,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,uBAAuB,EACvB,iBAAiB,EACjB,yBAAyB,EACzB,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,wBAAwB,EACxB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,uBAAuB,EACvB,gBAAgB,EAChB,mBAAmB,EACnB,yBAAyB,EACzB,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,0BAA0B,EAC1B,mBAAmB,EACnB,sBAAsB,EACtB,2BAA2B,CACnB,CAAC;AAEX,eAAO,MAAM,sCAAsC,0FAGzC,CAAC;AAEX,eAAO,MAAM,iCAAiC,QA+7B2D,CAAC;AAE1G,eAAO,MAAM,uCAAuC,QAkBvC,CAAC"}
@@ -12,6 +12,8 @@ export const VELAR_COLLECTION_LOWERING_EXPORTS = [
12
12
  "__velarReactiveSetIterator",
13
13
  "__velarReactiveMapKeyIterator",
14
14
  "__velarReactiveRecordIterator",
15
+ "__velarReactiveMapPairIterator",
16
+ "__velarReactiveRecordPairIterator",
15
17
  "__velarCollectionIterator",
16
18
  "__velarCollectionPairIterator",
17
19
  "__velarCopyList",
@@ -21,7 +23,14 @@ export const VELAR_COLLECTION_LOWERING_EXPORTS = [
21
23
  "__velarCreateSet",
22
24
  "__velarCreateMap",
23
25
  "__velarCollectionSize",
26
+ "__velarListSize",
27
+ "__velarMapSize",
28
+ "__velarSetSize",
29
+ "__velarRecordSize",
24
30
  "__velarCollectionGet",
31
+ "__velarListGet",
32
+ "__velarMapGet",
33
+ "__velarRecordGet",
25
34
  "__velarCollectionSlice",
26
35
  // COL-U5: `IndexError` is a nameable source type, so a project build must be
27
36
  // able to import the one runtime class every List position raises. The
@@ -30,8 +39,12 @@ export const VELAR_COLLECTION_LOWERING_EXPORTS = [
30
39
  // unbound reference.
31
40
  "__VelarIndexError",
32
41
  "__velarIndex",
42
+ "__velarListIndexGet",
43
+ "__velarRecordIndexGet",
33
44
  "__velarOptionalIndex",
34
45
  "__velarSetIndex",
46
+ "__velarListIndexSet",
47
+ "__velarRecordIndexSet",
35
48
  "__velarListAppend",
36
49
  "__velarListExtend",
37
50
  "__velarListInsert",
@@ -67,12 +80,34 @@ export const VELAR_COLLECTION_LOWERING_EXPORTS = [
67
80
  "__velarRecordSet",
68
81
  "__velarRecordCopy",
69
82
  "__velarCollectionHas",
83
+ "__velarListHas",
84
+ "__velarMapHas",
85
+ "__velarSetHas",
86
+ "__velarRecordHas",
87
+ "__velarListContains",
88
+ "__velarMapContains",
89
+ "__velarSetContains",
90
+ "__velarRecordContains",
70
91
  "__velarContains",
71
92
  "__velarCollectionRemove",
93
+ "__velarMapRemove",
94
+ "__velarSetRemove",
95
+ "__velarRecordRemove",
72
96
  "__velarCollectionClear",
97
+ "__velarListClear",
98
+ "__velarMapClear",
99
+ "__velarSetClear",
100
+ "__velarRecordClear",
73
101
  "__velarCollectionKeys",
102
+ "__velarMapKeys",
103
+ "__velarRecordKeys",
74
104
  "__velarCollectionValues",
105
+ "__velarMapValues",
106
+ "__velarSetValues",
107
+ "__velarRecordValues",
75
108
  "__velarCollectionEntries",
109
+ "__velarMapEntries",
110
+ "__velarRecordEntries",
76
111
  "__velarOptionalCollection",
77
112
  ];
78
113
  export const VELAR_COLLECTION_LOWERING_DEPENDENCIES = [
@@ -208,41 +243,54 @@ function __velarCollectionIterator(value) {
208
243
  if (__velarIsRecord(value)) return __velarReactiveRecordIterator(value);
209
244
  throw new __velarCollectionNativeTypeError("VelarScript iteration requires a List, Set, Map, or Record");
210
245
  }
211
- function* __velarCollectionPairIterator(value) {
246
+ function* __velarReactiveMapPairIterator(value) {
212
247
  const raw = __velarReactiveRaw(value);
213
- if (__velarIsMap(raw)) {
214
- if (__velarCollectionSetMapMapSize(raw) > __velarMaxCollectionItems) throw new __velarCollectionSetMapNativeRangeError("A Map cannot exceed 1000000 entries");
215
- __velarReactiveCollectionTrack(raw);
216
- const iterator = __velarCollectionSetMapMapEntries(raw);
217
- while (true) { const step = __velarCollectionSetMapMapNext(iterator); if (step.done) return; const entry = step.value; yield [__velarReactiveCollectionRead(raw, __velarReactiveIterateKey, entry[0]), __velarReactiveCollectionRead(raw, entry[0], entry[1])]; }
218
- }
219
- if (__velarIsRecord(raw)) {
220
- const fields = __velarRecordFields(raw, "Record iteration");
221
- __velarReactiveCollectionTrack(raw);
222
- for (let index = 0; index < fields.length; index += 1) {
223
- const field = fields[index];
224
- const descriptor = __velarCollectionRecordGetOwnPropertyDescriptor(raw, field);
225
- // COL-D1: the key snapshot can outlive the field — a body that removes
226
- // a later key must see that key skipped (Map iteration parity), not a
227
- // raw TypeError from reading a missing descriptor.
228
- if (descriptor === undefined) continue;
229
- yield [__velarReactiveCollectionRead(raw, __velarReactiveIterateKey, field), __velarReactiveCollectionRead(raw, field, descriptor.value)];
230
- }
231
- return;
248
+ if (__velarCheckedMapSize(raw, "Map iteration") > __velarMaxCollectionItems) throw new __velarCollectionSetMapNativeRangeError("A Map cannot exceed 1000000 entries");
249
+ __velarReactiveCollectionTrack(raw);
250
+ const iterator = __velarCollectionSetMapMapEntries(raw);
251
+ while (true) { const step = __velarCollectionSetMapMapNext(iterator); if (step.done) return; const entry = step.value; yield [__velarReactiveCollectionRead(raw, __velarReactiveIterateKey, entry[0]), __velarReactiveCollectionRead(raw, entry[0], entry[1])]; }
252
+ }
253
+ function* __velarReactiveRecordPairIterator(value) {
254
+ const raw = __velarReactiveRaw(value);
255
+ const fields = __velarRecordFields(raw, "Record iteration");
256
+ __velarReactiveCollectionTrack(raw);
257
+ for (let index = 0; index < fields.length; index += 1) {
258
+ const field = fields[index];
259
+ const descriptor = __velarCollectionRecordGetOwnPropertyDescriptor(raw, field);
260
+ // COL-D1: the key snapshot can outlive the field — a body that removes
261
+ // a later key must see that key skipped (Map iteration parity), not a
262
+ // raw TypeError from reading a missing descriptor.
263
+ if (descriptor === undefined) continue;
264
+ yield [__velarReactiveCollectionRead(raw, __velarReactiveIterateKey, field), __velarReactiveCollectionRead(raw, field, descriptor.value)];
232
265
  }
266
+ }
267
+ function* __velarCollectionPairIterator(value) {
268
+ const raw = __velarReactiveRaw(value);
269
+ if (__velarIsMap(raw)) { yield* __velarReactiveMapPairIterator(raw); return; }
270
+ if (__velarIsRecord(raw)) { yield* __velarReactiveRecordPairIterator(raw); return; }
233
271
  let index = 0;
234
272
  for (const item of __velarCollectionIterator(value)) yield [item, index++];
235
273
  }
236
274
 
275
+ function __velarCheckedMapSize(value, name) {
276
+ try { return __velarCollectionSetMapMapSize(value); }
277
+ catch { throw new __velarCollectionNativeTypeError(name + " requires a Map"); }
278
+ }
279
+ function __velarCheckedSetSize(value, name) {
280
+ try { return __velarCollectionSetMapSetSize(value); }
281
+ catch { throw new __velarCollectionNativeTypeError(name + " requires a Set"); }
282
+ }
283
+ function __velarListSize(value) { value = __velarValidateOwnedList(value, "List size"); __velarReactiveCollectionTrack(value, __velarReactiveStructureKey); return value.length; }
284
+ function __velarMapSize(value) { value = __velarReactiveRaw(value); __velarReactiveCollectionTrack(value, __velarReactiveStructureKey); const size = __velarCheckedMapSize(value, "Map.size"); if (size > __velarMaxCollectionItems) throw new __velarCollectionSetMapNativeRangeError("A Map cannot exceed 1000000 entries"); return size; }
285
+ function __velarSetSize(value) { value = __velarReactiveRaw(value); __velarReactiveCollectionTrack(value, __velarReactiveStructureKey); const size = __velarCheckedSetSize(value, "Set.size"); if (size > __velarMaxCollectionItems) throw new __velarCollectionSetMapNativeRangeError("A Set cannot exceed 1000000 items"); return size; }
286
+ function __velarRecordSize(value) { value = __velarReactiveRaw(value); __velarReactiveCollectionTrack(value, __velarReactiveStructureKey); return __velarRecordFields(value, "Record size").length; }
237
287
  function __velarCollectionSize(value) {
238
- value = __velarReactiveRaw(value);
239
- __velarReactiveCollectionTrack(value, __velarReactiveStructureKey);
240
- if (__velarCollectionListIsArray(value)) return __velarValidateOwnedList(value, "List size").length;
241
- if (__velarIsRecord(value)) return __velarRecordFields(value, "Record size").length;
242
- const size = __velarIsMap(value) ? __velarCollectionSetMapMapSize(value) : __velarIsSet(value) ? __velarCollectionSetMapSetSize(value) : null;
243
- if (size === null) throw new __velarCollectionNativeTypeError("VelarScript size requires a List, Set, Map, or Record");
244
- if (size > __velarMaxCollectionItems) throw new __velarCollectionSetMapNativeRangeError("A collection cannot exceed 1000000 items");
245
- return size;
288
+ const raw = __velarReactiveRaw(value);
289
+ if (__velarCollectionListIsArray(raw)) return __velarListSize(raw);
290
+ if (__velarIsRecord(raw)) return __velarRecordSize(raw);
291
+ if (__velarIsMap(raw)) return __velarMapSize(raw);
292
+ if (__velarIsSet(raw)) return __velarSetSize(raw);
293
+ throw new __velarCollectionNativeTypeError("VelarScript size requires a List, Set, Map, or Record");
246
294
  }
247
295
 
248
296
  function __velarCreateList(parts) {
@@ -329,32 +377,38 @@ function __velarCreateMap(value) {
329
377
  throw new __velarCollectionNativeTypeError("Map construction requires a Map, a List of [key, value] Lists, or a record");
330
378
  }
331
379
 
332
- function __velarCollectionGet(value, key) {
380
+ function __velarListGet(value, key) {
381
+ value = __velarValidateOwnedList(value, "List.get");
382
+ if (!__velarCollectionListIsInteger(key)) throw new __VelarIndexError("List.get index must be an integer");
383
+ const index = key < 0 ? value.length + key : key;
384
+ if (index >= 0 && index < value.length) return __velarReactiveCollectionRead(value, index, __velarOwnedListElement(value, index, "List.get"));
385
+ __velarReactiveCollectionTrack(value, key < 0 ? __velarReactiveIterateKey : index);
386
+ __velarReactiveCollectionTrack(value);
387
+ return null;
388
+ }
389
+ function __velarRecordGet(value, key) {
333
390
  value = __velarReactiveRaw(value);
334
- if (__velarCollectionListIsArray(value)) {
335
- __velarValidateOwnedList(value, "List.get");
336
- if (!__velarCollectionListIsInteger(key)) throw new __VelarIndexError("List.get index must be an integer");
337
- const index = key < 0 ? value.length + key : key;
338
- if (index >= 0 && index < value.length) return __velarReactiveCollectionRead(value, index, __velarOwnedListElement(value, index, "List.get"));
339
- __velarReactiveCollectionTrack(value, key < 0 ? __velarReactiveIterateKey : index);
340
- __velarReactiveCollectionTrack(value);
341
- return null;
342
- }
343
- if (__velarIsRecord(value)) {
344
- if (typeof key !== "string") throw new __velarCollectionNativeTypeError("Record.get requires a string key");
345
- __velarRecordFields(value, "Record.get");
346
- __velarReactiveCollectionTrack(value, key);
347
- const descriptor = __velarCollectionRecordGetOwnPropertyDescriptor(value, key);
348
- return descriptor === undefined ? null : __velarReactiveCollectionRead(value, key, descriptor.value);
349
- }
350
- if (!__velarIsMap(value)) throw new __velarCollectionNativeTypeError("Map.get requires a Map");
351
- const size = __velarCollectionSetMapMapSize(value);
391
+ if (typeof key !== "string") throw new __velarCollectionNativeTypeError("Record.get requires a string key");
392
+ __velarRecordFields(value, "Record.get");
393
+ __velarReactiveCollectionTrack(value, key);
394
+ const descriptor = __velarCollectionRecordGetOwnPropertyDescriptor(value, key);
395
+ return descriptor === undefined ? null : __velarReactiveCollectionRead(value, key, descriptor.value);
396
+ }
397
+ function __velarMapGet(value, key) {
398
+ value = __velarReactiveRaw(value);
399
+ const size = __velarCheckedMapSize(value, "Map.get");
352
400
  if (size > __velarMaxCollectionItems) throw new __velarCollectionSetMapNativeRangeError("A Map cannot exceed 1000000 entries");
353
401
  key = __velarReactiveRaw(key);
354
402
  __velarReactiveCollectionTrack(value, key);
355
403
  const item = __velarCollectionSetMapMapGet(value, key);
356
404
  return item === undefined ? null : __velarReactiveCollectionRead(value, key, item);
357
405
  }
406
+ function __velarCollectionGet(value, key) {
407
+ const raw = __velarReactiveRaw(value);
408
+ if (__velarCollectionListIsArray(raw)) return __velarListGet(raw, key);
409
+ if (__velarIsRecord(raw)) return __velarRecordGet(raw, key);
410
+ return __velarMapGet(raw, key);
411
+ }
358
412
 
359
413
  function __velarCollectionSlice(value, start = 0, end = null) {
360
414
  value = __velarValidateOwnedList(value, "List.slice");
@@ -387,37 +441,41 @@ function __velarStrictListIndex(value, requested) {
387
441
  if (index < 0 || index >= value.length) throw new __VelarIndexError("List index must be an in-range integer");
388
442
  return index;
389
443
  }
390
- function __velarIndex(value, index) {
444
+ function __velarListIndexGet(value, index) {
445
+ value = __velarValidateOwnedList(value, "List index");
446
+ index = __velarStrictListIndex(value, index);
447
+ return __velarReactiveCollectionRead(value, index, __velarOwnedListElement(value, index, "List index"));
448
+ }
449
+ function __velarRecordIndexGet(value, index) {
391
450
  value = __velarReactiveRaw(value);
392
- if (__velarCollectionListIsArray(value)) {
393
- __velarValidateOwnedList(value, "List index");
394
- index = __velarStrictListIndex(value, index);
395
- return __velarReactiveCollectionRead(value, index, __velarOwnedListElement(value, index, "List index"));
396
- }
397
- if (!__velarIsRecord(value) || typeof index !== "string") throw new __velarCollectionNativeTypeError("Record index requires a plain record and a string key");
451
+ if (typeof index !== "string") throw new __velarCollectionNativeTypeError("Record index requires a plain record and a string key");
398
452
  __velarRecordFields(value, "Record index");
399
453
  const descriptor = __velarCollectionRecordGetOwnPropertyDescriptor(value, index);
400
454
  return __velarReactiveCollectionRead(value, index, descriptor?.value);
401
455
  }
456
+ function __velarIndex(value, index) {
457
+ const raw = __velarReactiveRaw(value);
458
+ return __velarCollectionListIsArray(raw) ? __velarListIndexGet(raw, index) : __velarRecordIndexGet(raw, index);
459
+ }
402
460
  function __velarOptionalIndex(value, index) {
403
461
  return value == null ? null : __velarIndex(value, index());
404
462
  }
405
- function __velarSetIndex(value, index, next) {
463
+ function __velarListIndexSet(value, index, next) {
464
+ value = __velarValidateOwnedList(value, "List index assignment");
465
+ index = __velarStrictListIndex(value, index);
466
+ const previous = __velarOwnedListElement(value, index, "List index assignment");
467
+ next = __velarReactiveRaw(next);
468
+ if (__velarCollectionListObjectIs(__velarReactiveRaw(previous), next)) return next;
469
+ value[index] = next;
470
+ __velarReactiveCollectionUnlink(value, previous);
471
+ __velarReactiveCollectionLink(value, next);
472
+ __velarReactiveCollectionTrigger(value, index, true, false);
473
+ __velarMarkOwnedList(value);
474
+ return next;
475
+ }
476
+ function __velarRecordIndexSet(value, index, next) {
406
477
  value = __velarReactiveRaw(value);
407
- if (__velarCollectionListIsArray(value)) {
408
- __velarValidateOwnedList(value, "List index assignment");
409
- index = __velarStrictListIndex(value, index);
410
- const previous = __velarOwnedListElement(value, index, "List index assignment");
411
- next = __velarReactiveRaw(next);
412
- if (__velarCollectionListObjectIs(__velarReactiveRaw(previous), next)) return next;
413
- value[index] = next;
414
- __velarReactiveCollectionUnlink(value, previous);
415
- __velarReactiveCollectionLink(value, next);
416
- __velarReactiveCollectionTrigger(value, index, true, false);
417
- __velarMarkOwnedList(value);
418
- return next;
419
- }
420
- if (!__velarIsRecord(value) || typeof index !== "string") throw new __velarCollectionNativeTypeError("Record index assignment requires a plain record and a string key");
478
+ if (typeof index !== "string") throw new __velarCollectionNativeTypeError("Record index assignment requires a plain record and a string key");
421
479
  const fields = __velarRecordFields(value, "Record index assignment");
422
480
  const descriptor = __velarCollectionRecordGetOwnPropertyDescriptor(value, index);
423
481
  if (descriptor === undefined && fields.length >= 1000000) throw new __velarCollectionRecordNativeRangeError("A Record cannot exceed 1000000 fields");
@@ -430,6 +488,10 @@ function __velarSetIndex(value, index, next) {
430
488
  __velarReactiveCollectionTrigger(value, index, true, descriptor === undefined);
431
489
  return next;
432
490
  }
491
+ function __velarSetIndex(value, index, next) {
492
+ const raw = __velarReactiveRaw(value);
493
+ return __velarCollectionListIsArray(raw) ? __velarListIndexSet(raw, index, next) : __velarRecordIndexSet(raw, index, next);
494
+ }
433
495
 
434
496
  function __velarListAppend(value, item) {
435
497
  value = __velarValidateOwnedList(value, "List.append");
@@ -675,17 +737,24 @@ function __velarRecordCopy(value) {
675
737
  return output;
676
738
  }
677
739
 
740
+ function __velarListHas(value, item) { value = __velarValidateOwnedList(value, "List.has"); item = __velarReactiveRaw(item); __velarReactiveCollectionTrack(value); for (let index = 0; index < value.length; index += 1) if (__velarSameValueZero(__velarReactiveRaw(__velarOwnedListElement(value, index, "List.has")), item)) return true; return false; }
741
+ function __velarRecordHas(value, item) { value = __velarReactiveRaw(value); item = __velarReactiveRaw(item); if (typeof item !== "string") throw new __velarCollectionNativeTypeError("Record.has requires a string key"); __velarRecordFields(value, "Record.has"); __velarReactiveCollectionTrack(value, item); return __velarCollectionRecordGetOwnPropertyDescriptor(value, item) !== undefined; }
742
+ function __velarMapHas(value, item) { value = __velarReactiveRaw(value); item = __velarReactiveRaw(item); const size = __velarCheckedMapSize(value, "Map.has"); if (size > __velarMaxCollectionItems) throw new __velarCollectionSetMapNativeRangeError("A Map cannot exceed 1000000 entries"); __velarReactiveCollectionTrack(value, item); return __velarCollectionSetMapMapHas(value, item); }
743
+ function __velarSetHas(value, item) { value = __velarReactiveRaw(value); item = __velarReactiveRaw(item); const size = __velarCheckedSetSize(value, "Set.has"); if (size > __velarMaxCollectionItems) throw new __velarCollectionSetMapNativeRangeError("A Set cannot exceed 1000000 items"); __velarReactiveCollectionTrack(value, item); return __velarCollectionSetMapSetHas(value, item); }
678
744
  function __velarCollectionHas(value, item) {
679
- value = __velarReactiveRaw(value); item = __velarReactiveRaw(item);
680
- if (__velarCollectionListIsArray(value)) { value = __velarValidateOwnedList(value, "List.has"); __velarReactiveCollectionTrack(value); for (let index = 0; index < value.length; index += 1) if (__velarSameValueZero(__velarReactiveRaw(__velarOwnedListElement(value, index, "List.has")), item)) return true; return false; }
681
- if (__velarIsRecord(value)) { if (typeof item !== "string") throw new __velarCollectionNativeTypeError("Record.has requires a string key"); __velarRecordFields(value, "Record.has"); __velarReactiveCollectionTrack(value, item); return __velarCollectionRecordGetOwnPropertyDescriptor(value, item) !== undefined; }
682
- const map = __velarIsMap(value); const set = !map && __velarIsSet(value);
683
- if (!map && !set) throw new __velarCollectionNativeTypeError("VelarScript membership requires a List, Set, Map, or Record");
684
- const size = map ? __velarCollectionSetMapMapSize(value) : __velarCollectionSetMapSetSize(value);
685
- if (size > __velarMaxCollectionItems) throw new __velarCollectionSetMapNativeRangeError("A collection cannot exceed 1000000 items");
686
- __velarReactiveCollectionTrack(value, item);
687
- return map ? __velarCollectionSetMapMapHas(value, item) : __velarCollectionSetMapSetHas(value, item);
745
+ const raw = __velarReactiveRaw(value);
746
+ if (__velarCollectionListIsArray(raw)) return __velarListHas(raw, item);
747
+ if (__velarIsRecord(raw)) return __velarRecordHas(raw, item);
748
+ if (__velarIsMap(raw)) return __velarMapHas(raw, item);
749
+ if (__velarIsSet(raw)) return __velarSetHas(raw, item);
750
+ throw new __velarCollectionNativeTypeError("VelarScript membership requires a List, Set, Map, or Record");
688
751
  }
752
+ // Membership keeps source evaluation order (item before container) while the
753
+ // method-shaped helpers keep receiver-first order for values.has(item).
754
+ function __velarListContains(item, value) { return __velarListHas(value, item); }
755
+ function __velarMapContains(item, value) { return __velarMapHas(value, item); }
756
+ function __velarSetContains(item, value) { return __velarSetHas(value, item); }
757
+ function __velarRecordContains(item, value) { return __velarRecordHas(value, item); }
689
758
  function __velarContains(item, value) {
690
759
  if (typeof value === "string") { if (typeof item !== "string") throw new __velarCollectionNativeTypeError("String membership requires a string"); return value.includes(item); }
691
760
  value = __velarReactiveRaw(value);
@@ -857,78 +926,153 @@ function __velarEqualsVisit(left, right, active, depth) {
857
926
  }
858
927
  }
859
928
 
860
- function __velarCollectionRemove(value, item) {
929
+ function __velarRecordRemove(value, item) {
861
930
  value = __velarReactiveRaw(value); item = __velarReactiveRaw(item);
862
- if (__velarIsRecord(value)) {
863
- if (typeof item !== "string") throw new __velarCollectionNativeTypeError("Record.remove requires a string key");
864
- __velarRecordFields(value, "Record.remove");
865
- const descriptor = __velarCollectionRecordGetOwnPropertyDescriptor(value, item);
866
- if (descriptor === undefined) return false;
867
- if (!descriptor.configurable) throw new __velarCollectionNativeTypeError("Record.remove requires a configurable data field");
868
- if (!__velarCollectionRecordDeleteProperty(value, item)) throw new __velarCollectionNativeTypeError("Record.remove could not delete the field");
869
- __velarReactiveCollectionUnlink(value, descriptor.value);
870
- __velarReactiveCollectionTrigger(value, item, true, true);
871
- return true;
872
- }
873
- const map = __velarIsMap(value);
874
- const previous = map ? __velarCollectionSetMapMapGet(value, item) : undefined;
875
- const removed = map ? __velarCollectionSetMapMapDelete(value, item) : __velarCollectionSetMapSetDelete(value, item);
876
- // A Set member is its own entry: unlinking it twice repeats an O(children)
877
- // scan for nothing. Only a Map has a separate value to unlink.
878
- if (removed) { __velarReactiveCollectionUnlink(value, item); if (map) __velarReactiveCollectionUnlink(value, previous); __velarReactiveCollectionTrigger(value, item, true, true); }
931
+ if (typeof item !== "string") throw new __velarCollectionNativeTypeError("Record.remove requires a string key");
932
+ __velarRecordFields(value, "Record.remove");
933
+ const descriptor = __velarCollectionRecordGetOwnPropertyDescriptor(value, item);
934
+ if (descriptor === undefined) return false;
935
+ if (!descriptor.configurable) throw new __velarCollectionNativeTypeError("Record.remove requires a configurable data field");
936
+ if (!__velarCollectionRecordDeleteProperty(value, item)) throw new __velarCollectionNativeTypeError("Record.remove could not delete the field");
937
+ __velarReactiveCollectionUnlink(value, descriptor.value);
938
+ __velarReactiveCollectionTrigger(value, item, true, true);
939
+ return true;
940
+ }
941
+ function __velarMapRemove(value, item) {
942
+ value = __velarReactiveRaw(value); item = __velarReactiveRaw(item);
943
+ const size = __velarCheckedMapSize(value, "Map.remove");
944
+ if (size > __velarMaxCollectionItems) throw new __velarCollectionSetMapNativeRangeError("A Map cannot exceed 1000000 entries");
945
+ const previous = __velarCollectionSetMapMapGet(value, item);
946
+ const removed = __velarCollectionSetMapMapDelete(value, item);
947
+ if (removed) { __velarReactiveCollectionUnlink(value, item); __velarReactiveCollectionUnlink(value, previous); __velarReactiveCollectionTrigger(value, item, true, true); }
879
948
  return removed;
880
949
  }
950
+ function __velarSetRemove(value, item) {
951
+ value = __velarReactiveRaw(value); item = __velarReactiveRaw(item);
952
+ const size = __velarCheckedSetSize(value, "Set.remove");
953
+ if (size > __velarMaxCollectionItems) throw new __velarCollectionSetMapNativeRangeError("A Set cannot exceed 1000000 items");
954
+ const removed = __velarCollectionSetMapSetDelete(value, item);
955
+ if (removed) { __velarReactiveCollectionUnlink(value, item); __velarReactiveCollectionTrigger(value, item, true, true); }
956
+ return removed;
957
+ }
958
+ function __velarCollectionRemove(value, item) {
959
+ const raw = __velarReactiveRaw(value);
960
+ if (__velarIsRecord(raw)) return __velarRecordRemove(raw, item);
961
+ if (__velarIsMap(raw)) return __velarMapRemove(raw, item);
962
+ return __velarSetRemove(raw, item);
963
+ }
881
964
 
882
- function __velarCollectionClear(value) {
965
+ function __velarListClear(value) {
883
966
  value = __velarReactiveRaw(value);
884
- if (__velarCollectionListIsArray(value)) {
885
- const previous = __velarCopyList(value, "List.clear");
886
- if (previous.length === 0) return null;
887
- value.length = 0;
888
- __velarMarkOwnedList(value);
889
- for (let index = 0; index < previous.length; index += 1) __velarReactiveCollectionUnlink(value, previous[index]);
890
- __velarReactiveCollectionTrigger(value, __velarReactiveIterateKey, true, true, 0);
891
- return null;
892
- }
893
- if (__velarIsRecord(value)) {
894
- const fields = __velarRecordFields(value, "Record.clear");
895
- if (fields.length === 0) return null;
896
- const previous = new __velarCollectionNativeArray(fields.length);
897
- for (let index = 0; index < fields.length; index += 1) { const descriptor = __velarCollectionRecordGetOwnPropertyDescriptor(value, fields[index]); if (!descriptor.configurable) throw new __velarCollectionNativeTypeError("Record.clear requires configurable data fields"); previous[index] = descriptor.value; }
898
- for (let index = 0; index < fields.length; index += 1) if (!__velarCollectionRecordDeleteProperty(value, fields[index])) throw new __velarCollectionNativeTypeError("Record.clear could not delete a field");
899
- for (let index = 0; index < previous.length; index += 1) __velarReactiveCollectionUnlink(value, previous[index]);
900
- __velarReactiveCollectionTrigger(value, __velarReactiveIterateKey, true, true, null, true);
901
- return null;
902
- }
903
- const map = __velarIsMap(value);
904
- const previous = [];
905
- if (map) { const iterator = __velarCollectionSetMapMapEntries(value); while (true) { const step = __velarCollectionSetMapMapNext(iterator); if (step.done) break; const entry = step.value; previous[previous.length] = entry[0]; previous[previous.length] = entry[1]; } }
906
- else { const iterator = __velarCollectionSetMapSetValues(value); while (true) { const step = __velarCollectionSetMapSetNext(iterator); if (step.done) break; previous[previous.length] = step.value; } }
967
+ const previous = __velarCopyList(value, "List.clear");
907
968
  if (previous.length === 0) return null;
908
- if (map) __velarCollectionSetMapMapClear(value); else __velarCollectionSetMapSetClear(value);
969
+ value.length = 0;
970
+ __velarMarkOwnedList(value);
909
971
  for (let index = 0; index < previous.length; index += 1) __velarReactiveCollectionUnlink(value, previous[index]);
972
+ __velarReactiveCollectionTrigger(value, __velarReactiveIterateKey, true, true, 0);
973
+ return null;
974
+ }
975
+ function __velarRecordClear(value) {
976
+ value = __velarReactiveRaw(value);
977
+ const fields = __velarRecordFields(value, "Record.clear");
978
+ if (fields.length === 0) return null;
979
+ const previous = new __velarCollectionNativeArray(fields.length);
980
+ for (let index = 0; index < fields.length; index += 1) { const descriptor = __velarCollectionRecordGetOwnPropertyDescriptor(value, fields[index]); if (!descriptor.configurable) throw new __velarCollectionNativeTypeError("Record.clear requires configurable data fields"); previous[index] = descriptor.value; }
981
+ for (let index = 0; index < fields.length; index += 1) if (!__velarCollectionRecordDeleteProperty(value, fields[index])) throw new __velarCollectionNativeTypeError("Record.clear could not delete a field");
982
+ for (let index = 0; index < previous.length; index += 1) __velarReactiveCollectionUnlink(value, previous[index]);
983
+ __velarReactiveCollectionTrigger(value, __velarReactiveIterateKey, true, true, null, true);
984
+ return null;
985
+ }
986
+ function __velarMapClear(value) {
987
+ value = __velarReactiveRaw(value);
988
+ const size = __velarCheckedMapSize(value, "Map.clear");
989
+ if (size > __velarMaxCollectionItems) throw new __velarCollectionSetMapNativeRangeError("A Map cannot exceed 1000000 entries");
990
+ if (size === 0) return null;
991
+ const previous = new __velarCollectionNativeArray(size * 2);
992
+ const iterator = __velarCollectionSetMapMapEntries(value);
993
+ let index = 0;
994
+ while (true) { const step = __velarCollectionSetMapMapNext(iterator); if (step.done) break; previous[index++] = step.value[0]; previous[index++] = step.value[1]; }
995
+ __velarCollectionSetMapMapClear(value);
996
+ for (let previousIndex = 0; previousIndex < previous.length; previousIndex += 1) __velarReactiveCollectionUnlink(value, previous[previousIndex]);
997
+ __velarReactiveCollectionTrigger(value, __velarReactiveIterateKey, true, true, null, true);
998
+ return null;
999
+ }
1000
+ function __velarSetClear(value) {
1001
+ value = __velarReactiveRaw(value);
1002
+ const size = __velarCheckedSetSize(value, "Set.clear");
1003
+ if (size > __velarMaxCollectionItems) throw new __velarCollectionSetMapNativeRangeError("A Set cannot exceed 1000000 items");
1004
+ if (size === 0) return null;
1005
+ const previous = new __velarCollectionNativeArray(size);
1006
+ const iterator = __velarCollectionSetMapSetValues(value);
1007
+ let index = 0;
1008
+ while (true) { const step = __velarCollectionSetMapSetNext(iterator); if (step.done) break; previous[index++] = step.value; }
1009
+ __velarCollectionSetMapSetClear(value);
1010
+ for (let previousIndex = 0; previousIndex < previous.length; previousIndex += 1) __velarReactiveCollectionUnlink(value, previous[previousIndex]);
910
1011
  __velarReactiveCollectionTrigger(value, __velarReactiveIterateKey, true, true, null, true);
911
1012
  return null;
912
1013
  }
1014
+ function __velarCollectionClear(value) {
1015
+ const raw = __velarReactiveRaw(value);
1016
+ if (__velarCollectionListIsArray(raw)) return __velarListClear(raw);
1017
+ if (__velarIsRecord(raw)) return __velarRecordClear(raw);
1018
+ if (__velarIsMap(raw)) return __velarMapClear(raw);
1019
+ return __velarSetClear(raw);
1020
+ }
913
1021
 
914
- function __velarCollectionKeys(value) {
1022
+ function __velarRecordKeys(value) {
1023
+ value = __velarReactiveRaw(value); __velarReactiveCollectionTrack(value, __velarReactiveStructureKey);
1024
+ const fields = __velarRecordFields(value, "Record.keys");
1025
+ const output = new __velarCollectionNativeArray(fields.length);
1026
+ for (let index = 0; index < fields.length; index += 1) output[index] = __velarReactiveCollectionRead(value, __velarReactiveStructureKey, fields[index]);
1027
+ return __velarMarkOwnedList(output);
1028
+ }
1029
+ function __velarMapKeys(value) {
915
1030
  value = __velarReactiveRaw(value); __velarReactiveCollectionTrack(value, __velarReactiveStructureKey);
916
- if (__velarIsRecord(value)) { const fields = __velarRecordFields(value, "Record.keys"); const output = new __velarCollectionNativeArray(fields.length); for (let index = 0; index < fields.length; index += 1) output[index] = __velarReactiveCollectionRead(value, __velarReactiveStructureKey, fields[index]); return __velarMarkOwnedList(output); }
917
- const size = __velarCollectionSetMapMapSize(value); if (size > __velarMaxCollectionItems) throw new __velarCollectionSetMapNativeRangeError("A Map cannot exceed 1000000 entries");
918
- const output = new __velarCollectionNativeArray(size); const iterator = __velarCollectionSetMapMapKeys(value); let index = 0; while (true) { const step = __velarCollectionSetMapMapNext(iterator); if (step.done) return __velarMarkOwnedList(output); output[index++] = __velarReactiveCollectionRead(value, __velarReactiveStructureKey, step.value); }
1031
+ const size = __velarCheckedMapSize(value, "Map.keys");
1032
+ if (size > __velarMaxCollectionItems) throw new __velarCollectionSetMapNativeRangeError("A Map cannot exceed 1000000 entries");
1033
+ const output = new __velarCollectionNativeArray(size); const iterator = __velarCollectionSetMapMapKeys(value); let index = 0;
1034
+ while (true) { const step = __velarCollectionSetMapMapNext(iterator); if (step.done) return __velarMarkOwnedList(output); output[index++] = __velarReactiveCollectionRead(value, __velarReactiveStructureKey, step.value); }
1035
+ }
1036
+ function __velarCollectionKeys(value) { value = __velarReactiveRaw(value); return __velarIsRecord(value) ? __velarRecordKeys(value) : __velarMapKeys(value); }
1037
+
1038
+ function __velarRecordValues(value) {
1039
+ value = __velarReactiveRaw(value); __velarReactiveCollectionTrack(value);
1040
+ const fields = __velarRecordFields(value, "Record.values"); const output = new __velarCollectionNativeArray(fields.length);
1041
+ for (let index = 0; index < fields.length; index += 1) { const field = fields[index]; output[index] = __velarReactiveCollectionRead(value, field, __velarCollectionRecordGetOwnPropertyDescriptor(value, field).value); }
1042
+ return __velarMarkOwnedList(output);
1043
+ }
1044
+ function __velarMapValues(value) {
1045
+ value = __velarReactiveRaw(value); __velarReactiveCollectionTrack(value);
1046
+ const size = __velarCheckedMapSize(value, "Map.values"); if (size > __velarMaxCollectionItems) throw new __velarCollectionSetMapNativeRangeError("A Map cannot exceed 1000000 entries");
1047
+ const output = new __velarCollectionNativeArray(size); const iterator = __velarCollectionSetMapMapValues(value); let index = 0;
1048
+ while (true) { const step = __velarCollectionSetMapMapNext(iterator); if (step.done) return __velarMarkOwnedList(output); output[index++] = __velarReactiveCollectionRead(value, __velarReactiveIterateKey, step.value); }
1049
+ }
1050
+ function __velarSetValues(value) {
1051
+ value = __velarReactiveRaw(value); __velarReactiveCollectionTrack(value);
1052
+ const size = __velarCheckedSetSize(value, "Set.values"); if (size > __velarMaxCollectionItems) throw new __velarCollectionSetMapNativeRangeError("A Set cannot exceed 1000000 items");
1053
+ const output = new __velarCollectionNativeArray(size); const iterator = __velarCollectionSetMapSetValues(value); let index = 0;
1054
+ while (true) { const step = __velarCollectionSetMapSetNext(iterator); if (step.done) return __velarMarkOwnedList(output); output[index++] = __velarReactiveCollectionRead(value, __velarReactiveIterateKey, step.value); }
919
1055
  }
920
1056
  function __velarCollectionValues(value) {
1057
+ value = __velarReactiveRaw(value);
1058
+ if (__velarIsRecord(value)) return __velarRecordValues(value);
1059
+ if (__velarIsMap(value)) return __velarMapValues(value);
1060
+ return __velarSetValues(value);
1061
+ }
1062
+
1063
+ function __velarRecordEntries(value) {
921
1064
  value = __velarReactiveRaw(value); __velarReactiveCollectionTrack(value);
922
- if (__velarIsRecord(value)) { const fields = __velarRecordFields(value, "Record.values"); const output = new __velarCollectionNativeArray(fields.length); for (let index = 0; index < fields.length; index += 1) { const field = fields[index]; output[index] = __velarReactiveCollectionRead(value, field, __velarCollectionRecordGetOwnPropertyDescriptor(value, field).value); } return __velarMarkOwnedList(output); }
923
- const map = __velarIsMap(value); const size = map ? __velarCollectionSetMapMapSize(value) : __velarCollectionSetMapSetSize(value); if (size > __velarMaxCollectionItems) throw new __velarCollectionSetMapNativeRangeError("A collection cannot exceed 1000000 items");
924
- const output = new __velarCollectionNativeArray(size); const iterator = map ? __velarCollectionSetMapMapValues(value) : __velarCollectionSetMapSetValues(value); let index = 0; while (true) { const step = map ? __velarCollectionSetMapMapNext(iterator) : __velarCollectionSetMapSetNext(iterator); if (step.done) return __velarMarkOwnedList(output); output[index++] = __velarReactiveCollectionRead(value, __velarReactiveIterateKey, step.value); }
1065
+ const fields = __velarRecordFields(value, "Record.entries"); const output = new __velarCollectionNativeArray(fields.length);
1066
+ for (let index = 0; index < fields.length; index += 1) { const field = fields[index]; output[index] = __velarCollectionRecordFreeze({ key: __velarReactiveCollectionRead(value, __velarReactiveIterateKey, field), value: __velarReactiveCollectionRead(value, field, __velarCollectionRecordGetOwnPropertyDescriptor(value, field).value) }); }
1067
+ return __velarMarkOwnedList(output);
925
1068
  }
926
- function __velarCollectionEntries(value) {
1069
+ function __velarMapEntries(value) {
927
1070
  value = __velarReactiveRaw(value); __velarReactiveCollectionTrack(value);
928
- if (__velarIsRecord(value)) { const fields = __velarRecordFields(value, "Record.entries"); const output = new __velarCollectionNativeArray(fields.length); for (let index = 0; index < fields.length; index += 1) { const field = fields[index]; output[index] = __velarCollectionRecordFreeze({ key: __velarReactiveCollectionRead(value, __velarReactiveIterateKey, field), value: __velarReactiveCollectionRead(value, field, __velarCollectionRecordGetOwnPropertyDescriptor(value, field).value) }); } return __velarMarkOwnedList(output); }
929
- const size = __velarCollectionSetMapMapSize(value); if (size > __velarMaxCollectionItems) throw new __velarCollectionSetMapNativeRangeError("A Map cannot exceed 1000000 entries");
930
- const output = new __velarCollectionNativeArray(size); const iterator = __velarCollectionSetMapMapEntries(value); let index = 0; while (true) { const step = __velarCollectionSetMapMapNext(iterator); if (step.done) return __velarMarkOwnedList(output); const entry = step.value; output[index++] = __velarCollectionSetMapFreeze({ key: __velarReactiveCollectionRead(value, __velarReactiveIterateKey, entry[0]), value: __velarReactiveCollectionRead(value, entry[0], entry[1]) }); }
1071
+ const size = __velarCheckedMapSize(value, "Map.entries"); if (size > __velarMaxCollectionItems) throw new __velarCollectionSetMapNativeRangeError("A Map cannot exceed 1000000 entries");
1072
+ const output = new __velarCollectionNativeArray(size); const iterator = __velarCollectionSetMapMapEntries(value); let index = 0;
1073
+ while (true) { const step = __velarCollectionSetMapMapNext(iterator); if (step.done) return __velarMarkOwnedList(output); const entry = step.value; output[index++] = __velarCollectionSetMapFreeze({ key: __velarReactiveCollectionRead(value, __velarReactiveIterateKey, entry[0]), value: __velarReactiveCollectionRead(value, entry[0], entry[1]) }); }
931
1074
  }
1075
+ function __velarCollectionEntries(value) { value = __velarReactiveRaw(value); return __velarIsRecord(value) ? __velarRecordEntries(value) : __velarMapEntries(value); }
932
1076
  function __velarOptionalCollection(value, operation) { return value == null ? null : operation(value); }`;
933
1077
  export const VELAR_COLLECTION_LOWERING_MODULE_SOURCE = String.raw `
934
1078
  import {
@@ -1 +1 @@
1
- {"version":3,"file":"collection-lowering-runtime.js","sourceRoot":"","sources":["../src/collection-lowering-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AACtG,OAAO,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAE5E,MAAM,CAAC,MAAM,gCAAgC,GAAG,+CAA+C,CAAC;AAEhG,qEAAqE;AACrE,MAAM,CAAC,MAAM,iCAAiC,GAAG;IAC/C,2BAA2B;IAC3B,wBAAwB;IACxB,sBAAsB;IACtB,eAAe;IACf,0BAA0B;IAC1B,6BAA6B;IAC7B,4BAA4B;IAC5B,+BAA+B;IAC/B,+BAA+B;IAC/B,2BAA2B;IAC3B,+BAA+B;IAC/B,iBAAiB;IACjB,yBAAyB;IACzB,mBAAmB;IACnB,wBAAwB;IACxB,kBAAkB;IAClB,kBAAkB;IAClB,uBAAuB;IACvB,sBAAsB;IACtB,wBAAwB;IACxB,6EAA6E;IAC7E,uEAAuE;IACvE,4EA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yGA+7B8C,CAAC;AAE1G,MAAM,CAAC,MAAM,uCAAuC,GAAG,MAAM,CAAC,GAAG,CAAA;;EAE/D,6BAA6B,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;SAC7D,IAAI,CAAC,SAAS,CAAC,4BAA4B,CAAC;;;;;;;;;;SAU5C,IAAI,CAAC,SAAS,CAAC,4BAA4B,CAAC;EACnD,iCAAiC;;EAEjC,iCAAiC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;;CAEzE,CAAC,SAAS,EAAE,CAAC"}
package/dist/emitter.d.ts CHANGED
@@ -7,6 +7,8 @@ export declare class JavaScriptEmitter {
7
7
  private readonly typeDeclarations;
8
8
  private readonly runtimeTypes;
9
9
  private readonly expandedRuntimeTypes;
10
+ /** Whether a runtime Type can revisit the same value through its declared type graph. */
11
+ private readonly runtimeTypeTraversalGuards;
10
12
  /**
11
13
  * D55 rule 121: the type parameters of the generic record currently being
12
14
  * emitted. Inside that body a `T`-typed position is checked by the argument
@@ -137,6 +139,17 @@ export declare class JavaScriptEmitter {
137
139
  * than unknown.
138
140
  */
139
141
  private resolveDeclarationType;
142
+ /** The Type object expression for a source-visible record name or application. */
143
+ private runtimeTypeObjectExpression;
144
+ /**
145
+ * Acyclic declared type graphs have a statically bounded walk, even when the
146
+ * JavaScript data itself contains a cycle: every recursive check consumes one
147
+ * layer of the finite type. Only a declaration cycle, an erased generic, or
148
+ * an imported runtime Type needs the shared WeakMap/Set traversal guard.
149
+ */
150
+ private runtimeTypeNeedsTraversalGuard;
151
+ private declarationNeedsTraversalGuard;
152
+ private typeNeedsTraversalGuard;
140
153
  /**
141
154
  * D60 rule 148: a `named` ValueType carries the type's *display* name, which
142
155
  * is a runtime binding only when this module really has a Type object under
@@ -175,6 +188,8 @@ export declare class JavaScriptEmitter {
175
188
  protected expressionContainsDirectAwait(expression: Expression): boolean;
176
189
  private typeRuntimeName;
177
190
  private collectionHelper;
191
+ private collectionSizeHelper;
192
+ private collectionIteratorHelper;
178
193
  private binaryHelper;
179
194
  private binaryIndexHelper;
180
195
  private binarySetIndexHelper;