@perplexdotgg/bounce 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/bounce.js CHANGED
@@ -42,11 +42,10 @@ function ReferenceListType(monomorphClass) {
42
42
  return {
43
43
  monomorph: {
44
44
  serializedSize: 1,
45
- // getDynamicSize: (obj: ReferenceListClass<M>) => obj.length,
46
45
  // @ts-ignore
47
46
  theClass: monomorphClass
48
47
  },
49
- propertyType: 7,
48
+ propertyType: 6,
50
49
  // this should really be false, but for some unknown reason that causes a recursive reference
51
50
  // on a class if it has both a ReferenceListType and a self-referencing LazyReferenceType
52
51
  optional: true,
@@ -76,7 +75,7 @@ function LazyReferenceListType(fn, readOnly) {
76
75
  fnInArray: [fn],
77
76
  theClass: null
78
77
  },
79
- propertyType: 8,
78
+ propertyType: 7,
80
79
  optional: true,
81
80
  defaultValue: null,
82
81
  readOnly
@@ -96,7 +95,7 @@ function ReferenceType(monomorphClass, defaultValue, readOnly) {
96
95
  function ChildType(monomorphClass, defaultValue, readOnly) {
97
96
  return {
98
97
  monomorph: monomorphClass,
99
- propertyType: 9,
98
+ propertyType: 8,
100
99
  defaultValue,
101
100
  optional: defaultValue !== void 0,
102
101
  readOnly
@@ -141,12 +140,16 @@ function populatePropsQueue(props, propsQueue, keySoFar = "", monomorphPathSoFar
141
140
  referencePath,
142
141
  depth
143
142
  });
144
- if (propertyDefinition.propertyType === 9) {
143
+ if (propertyDefinition.propertyType === 8) {
145
144
  populatePropsQueue(propertyDefinition.monomorph.propertyDefinitionMap, propsQueue, fullKey + ".", fullMonomorphPath + ".monomorph.propertyDefinitionMap.", depth + 1);
146
145
  }
147
146
  }
148
147
  }
149
148
  // @__NO_SIDE_EFFECTS__
149
+ function stringifyDefaultValue(defaultValue) {
150
+ return typeof defaultValue === "undefined" ? "null" : JSON.stringify(defaultValue);
151
+ }
152
+ // @__NO_SIDE_EFFECTS__
150
153
  function getClassCode(props, options = {}) {
151
154
  options = {
152
155
  debug: false,
@@ -157,13 +160,16 @@ function getClassCode(props, options = {}) {
157
160
  let hasReferences = false;
158
161
  let hasPoolReferences = false;
159
162
  let hasRequiredProps = false;
160
- let dataHasBeenInitializedInFullSetCode = false;
161
- let beforeClass = "";
163
+ let dataHasBeenInitializedInResetCode = false;
164
+ let beforeClassCode = "";
162
165
  let constructorCode = "";
163
- let fullSetDataCode = "";
164
- let constructorAndFullSetDataDefaultValueCode = "";
165
- let onlyFullSetDataDefaultValueCode = "";
166
- let setDataCode = "";
166
+ let customTypesConstructorCode = "";
167
+ let constructorAndResetDataCode = "";
168
+ let constructorAndResetDataDefaultValueCode = "";
169
+ let onlyResetDataDefaultValueCode = "";
170
+ let customTypesOnlyResetCode = "";
171
+ let setCode = "";
172
+ let customTypesBeforeDestroyCode = "";
167
173
  let copyCode = "";
168
174
  let toArrayCode = "";
169
175
  let toArrayCodeForPoolReferences = "";
@@ -187,17 +193,17 @@ function getClassCode(props, options = {}) {
187
193
  while (propIndex < propsQueue.length) {
188
194
  const { depth, fullKey, propertyDefinition } = propsQueue[propIndex];
189
195
  propIndex++;
190
- if (!hasRequiredProps && propertyDefinition.propertyType !== 9 && propertyDefinition.optional !== true) {
196
+ if (!hasRequiredProps && propertyDefinition.propertyType !== 8 && propertyDefinition.optional !== true) {
191
197
  hasRequiredProps = true;
192
198
  }
193
199
  if (depth === 0) {
194
- if (!hasPoolReferences && propertyDefinition.propertyType === 9 && "hasPoolReferences" in propertyDefinition.monomorph) {
200
+ if (!hasPoolReferences && propertyDefinition.propertyType === 8 && "hasPoolReferences" in propertyDefinition.monomorph) {
195
201
  hasPoolReferences = true;
196
202
  }
197
- if (propertyDefinition.propertyType === 3 || propertyDefinition.propertyType === 4 || propertyDefinition.propertyType === 7 || propertyDefinition.propertyType === 8) {
203
+ if (propertyDefinition.propertyType === 3 || propertyDefinition.propertyType === 4 || propertyDefinition.propertyType === 6 || propertyDefinition.propertyType === 7) {
198
204
  hasReferences = true;
199
205
  totalStaticSize += 2;
200
- } else if (propertyDefinition.propertyType === 6) {
206
+ } else if (propertyDefinition.propertyType === 5) {
201
207
  hasPoolReferences = true;
202
208
  } else if (typeof propertyDefinition.monomorph.getDynamicSize === "function") {
203
209
  hasDynamicSize = true;
@@ -254,9 +260,9 @@ function getClassCode(props, options = {}) {
254
260
  let poolArray;
255
261
  `;
256
262
  fromArrayOnlyReferencesCode += fromArrayCode;
257
- constructorAndFullSetDataDefaultValueCode = `
263
+ constructorAndResetDataDefaultValueCode = `
258
264
  if (data !== undefined) {
259
- ${constructorAndFullSetDataDefaultValueCode}
265
+ ${constructorAndResetDataDefaultValueCode}
260
266
  }
261
267
  `;
262
268
  }
@@ -274,146 +280,171 @@ function getClassCode(props, options = {}) {
274
280
  } = propsQueue[propIndex];
275
281
  propIndex++;
276
282
  if (depth === 0) {
277
- if ("hasDynamicSize" in propertyDefinition.monomorph && propertyDefinition.monomorph.hasDynamicSize) {
278
- hasDynamicSize = true;
279
- }
280
- if (propertyDefinition.propertyType === 9) {
281
- constructorCode += `
282
- this.${fullKey} = ${propertyDefinition.monomorph.name}.create(data${hasRequiredProps ? "" : "?"}.${fullKey});
283
- `;
284
- if (propertyDefinition.defaultValue === void 0) {
285
- onlyFullSetDataDefaultValueCode += `
286
- this.${fullKey}.fullSet(data?.${fullKey});
283
+ if ("monomorph" in propertyDefinition) {
284
+ if ("hasDynamicSize" in propertyDefinition.monomorph && propertyDefinition.monomorph.hasDynamicSize) {
285
+ hasDynamicSize = true;
286
+ }
287
+ if (propertyDefinition.propertyType === 8) {
288
+ constructorCode += `
289
+ this.${fullKey} = ${propertyDefinition.monomorph.name}.create(data${hasRequiredProps ? "" : "?"}.${fullKey});
287
290
  `;
288
- } else {
289
- onlyFullSetDataDefaultValueCode += `
290
- this.${fullKey}.fullSet(data?.${fullKey}) ?? ${JSON.stringify(propertyDefinition.defaultValue)};
291
+ if (propertyDefinition.defaultValue === void 0) {
292
+ onlyResetDataDefaultValueCode += `
293
+ this.${fullKey}.reset(data?.${fullKey});
294
+ `;
295
+ } else {
296
+ onlyResetDataDefaultValueCode += `
297
+ this.${fullKey}.reset(data?.${fullKey}) ?? ${JSON.stringify(propertyDefinition.defaultValue)};
298
+ `;
299
+ }
300
+ } else if (propertyDefinition.propertyType === 3 || propertyDefinition.propertyType === 4) {
301
+ if (propertyDefinition.propertyType === 4) {
302
+ const name = "lazyRefMonomorph" + propIndex;
303
+ constructorCode += `
304
+ if (!${name}.theClass) {
305
+ ${name}.theClass = ${name}.fnInArray[0]();
306
+ }
307
+ this.__reference__${fullKey} = new ${name}.theClass.Reference(data${hasRequiredProps ? "" : "?"}.${fullKey});
308
+ `;
309
+ } else {
310
+ constructorCode += `
311
+ this.__reference__${fullKey} = new ${propertyDefinition.monomorph.name}.Reference(data${hasRequiredProps ? "" : "?"}.${fullKey});
312
+ `;
313
+ }
314
+ referenceGettersAndSettersCode += `
315
+ get ${fullKey}() {
316
+ const refInstance = this.__reference__${fullKey};
317
+ if (!refInstance.reference || refInstance.reference.version !== refInstance.version) {
318
+ return null;
319
+ }
320
+ return refInstance.reference;
321
+ }
322
+
323
+ set ${fullKey}(value) {
324
+ const refInstance = this.__reference__${fullKey};
325
+ if (!value || (value.version & 1)) {
326
+ refInstance.version = -1;
327
+ refInstance.reference = null;
328
+ } else {
329
+ refInstance.version = value.version;
330
+ refInstance.reference = value;
331
+ }
332
+ }
291
333
  `;
292
- }
293
- } else if (propertyDefinition.propertyType === 3 || propertyDefinition.propertyType === 4 || propertyDefinition.propertyType === 5) {
294
- if (propertyDefinition.propertyType === 4) {
295
- const name = "lazyRefMonomorph" + propIndex;
334
+ } else if (propertyDefinition.propertyType === 7) {
335
+ const name = "lazyRefList" + propIndex;
296
336
  constructorCode += `
297
337
  if (!${name}.theClass) {
298
338
  ${name}.theClass = ${name}.fnInArray[0]();
299
339
  }
300
- this.__reference__${fullKey} = new ${name}.theClass.Reference(data${hasRequiredProps ? "" : "?"}.${fullKey});
301
- `;
302
- } else if (propertyDefinition.propertyType === 5) {
303
- constructorCode += `
304
- this.__reference__${fullKey} = new this.constructor.Reference(data${hasRequiredProps ? "" : "?"}.${fullKey});
340
+ if (this.${fullKey}) {
341
+ this.${fullKey}.length = 0;
342
+ } else {
343
+ this.${fullKey} = new ${name}.theClass.ReferenceList(data${hasRequiredProps ? "" : "?"}.${fullKey}?.pool || new ${name}.theClass.Pool(), data${hasRequiredProps ? "" : "?"}.${fullKey}?.maxLength, data${hasRequiredProps ? "" : "?"}.${fullKey}?.items, ${name}.theClass);
344
+ }
305
345
  `;
306
- } else {
346
+ } else if (propertyDefinition.propertyType === 6) {
347
+ const className = propertyDefinition.monomorph.theClass.name;
307
348
  constructorCode += `
308
- this.__reference__${fullKey} = new ${propertyDefinition.monomorph.name}.Reference(data${hasRequiredProps ? "" : "?"}.${fullKey});
309
- `;
310
- }
311
- referenceGettersAndSettersCode += `
312
- get ${fullKey}() {
313
- const refInstance = this.__reference__${fullKey};
314
- if (!refInstance.reference || refInstance.reference.version !== refInstance.version) {
315
- return null;
316
- }
317
- return refInstance.reference;
318
- }
319
-
320
- set ${fullKey}(value) {
321
- const refInstance = this.__reference__${fullKey};
322
- if (!value || (value.version & 1)) {
323
- refInstance.version = -1;
324
- refInstance.reference = null;
349
+ if (this.${fullKey}) {
350
+ this.${fullKey}.length = 0;
325
351
  } else {
326
- refInstance.version = value.version;
327
- refInstance.reference = value;
352
+ this.${fullKey} = new ${className}.ReferenceList(data${hasRequiredProps ? "" : "?"}.${fullKey}?.pool || new ${className}.Pool(), data${hasRequiredProps ? "" : "?"}.${fullKey}?.maxLength, data${hasRequiredProps ? "" : "?"}.${fullKey}?.items, ${className});
328
353
  }
354
+ `;
355
+ } else if (propertyDefinition.propertyType === 9) {
356
+ const customTypeConfig = propertyDefinition.monomorph;
357
+ const params = {
358
+ depth,
359
+ key: fullKey,
360
+ thisProperty: `this.${fullKey}`,
361
+ dataProperty: `data${hasRequiredProps ? "" : "?"}.${fullKey}`,
362
+ customTypeData: "customType" + propIndex
363
+ };
364
+ if (typeof customTypeConfig.constructorCode !== "undefined") {
365
+ customTypesConstructorCode += typeof customTypeConfig.constructorCode === "function" ? customTypeConfig.constructorCode(params) : customTypeConfig.constructorCode;
366
+ } else {
367
+ customTypesConstructorCode += `
368
+ this.${fullKey} = data${hasRequiredProps ? "" : "?"}.${fullKey} ?? ${/* @__PURE__ */ stringifyDefaultValue(propertyDefinition.defaultValue)}; // 111
369
+ `;
329
370
  }
330
- `;
331
- } else if (propertyDefinition.propertyType === 8) {
332
- const name = "lazyRefList" + propIndex;
333
- constructorCode += `
334
- if (!${name}.theClass) {
335
- ${name}.theClass = ${name}.fnInArray[0]();
336
- }
337
- if (this.${fullKey}) {
338
- this.${fullKey}.length = 0;
371
+ if (typeof customTypeConfig.resetCode !== "undefined") {
372
+ customTypesOnlyResetCode += typeof customTypeConfig.resetCode === "function" ? customTypeConfig.resetCode(params) : customTypeConfig.resetCode;
339
373
  } else {
340
- this.${fullKey} = new ${name}.theClass.ReferenceList(data${hasRequiredProps ? "" : "?"}.${fullKey}?.pool || new ${name}.theClass.Pool(), data${hasRequiredProps ? "" : "?"}.${fullKey}?.maxLength, data${hasRequiredProps ? "" : "?"}.${fullKey}?.items, ${name}.theClass);
374
+ customTypesOnlyResetCode += `
375
+ this.${fullKey} = data${hasRequiredProps ? "" : "?"}.${fullKey} ?? this.${fullKey} ?? ${/* @__PURE__ */ stringifyDefaultValue(propertyDefinition.defaultValue)};
376
+ `;
341
377
  }
342
- `;
343
- } else if (propertyDefinition.propertyType === 7) {
344
- const className = propertyDefinition.monomorph.theClass.name;
345
- constructorCode += `
346
- if (this.${fullKey}) {
347
- this.${fullKey}.length = 0;
378
+ if (typeof customTypeConfig.beforeDestroyCode !== "undefined") {
379
+ customTypesBeforeDestroyCode += typeof customTypeConfig.beforeDestroyCode === "function" ? customTypeConfig.beforeDestroyCode(params) : customTypeConfig.beforeDestroyCode;
348
380
  } else {
349
- this.${fullKey} = new ${className}.ReferenceList(data${hasRequiredProps ? "" : "?"}.${fullKey}?.pool || new ${className}.Pool(), data${hasRequiredProps ? "" : "?"}.${fullKey}?.maxLength, data${hasRequiredProps ? "" : "?"}.${fullKey}?.items, ${className});
381
+ customTypesBeforeDestroyCode += `
382
+ this.${fullKey} = null;
383
+ `;
350
384
  }
351
- `;
385
+ }
352
386
  }
353
- if (propertyDefinition.defaultValue !== void 0 && propertyDefinition.propertyType !== 7 && propertyDefinition.propertyType !== 8) {
354
- if (!dataHasBeenInitializedInFullSetCode) {
355
- dataHasBeenInitializedInFullSetCode = true;
356
- constructorAndFullSetDataDefaultValueCode += `
387
+ if (propertyDefinition.defaultValue !== void 0 && propertyDefinition.propertyType !== 6 && propertyDefinition.propertyType !== 7) {
388
+ if (!dataHasBeenInitializedInResetCode) {
389
+ dataHasBeenInitializedInResetCode = true;
390
+ constructorAndResetDataDefaultValueCode += `
357
391
  data = data ?? {};
358
392
  `;
359
393
  }
360
394
  if (parentKey) {
361
- constructorAndFullSetDataDefaultValueCode += `
395
+ constructorAndResetDataDefaultValueCode += `
362
396
  data.${parentKey} = data.${parentKey} ?? {};
363
397
  `;
364
398
  }
365
- constructorAndFullSetDataDefaultValueCode += `
399
+ constructorAndResetDataDefaultValueCode += `
366
400
  data.${fullKey} = data.${fullKey} ?? ${JSON.stringify(propertyDefinition.defaultValue)};
367
401
  `;
368
402
  }
369
- if (propertyDefinition.propertyType !== 9 && propertyDefinition.propertyType !== 7 && propertyDefinition.propertyType !== 8) {
403
+ if (propertyDefinition.propertyType !== 8 && propertyDefinition.propertyType !== 6 && propertyDefinition.propertyType !== 7 && propertyDefinition.propertyType !== 9) {
370
404
  if (hasRequiredProps) {
371
405
  if (propertyDefinition.optional) {
372
- fullSetDataCode += `
406
+ constructorAndResetDataCode += `
373
407
  this.${fullKey} = data.${fullKey} ?? ${propertyDefinition.defaultValue};
374
408
  `;
375
409
  } else {
376
- fullSetDataCode += `
410
+ constructorAndResetDataCode += `
377
411
  this.${fullKey} = data.${fullKey};
378
412
  `;
379
413
  }
380
414
  } else {
381
- fullSetDataCode += `
382
- this.${fullKey} = data.${keyWithOptionalChaining}; // test 456
415
+ constructorAndResetDataCode += `
416
+ this.${fullKey} = data.${keyWithOptionalChaining};
383
417
  `;
384
418
  }
385
419
  }
386
420
  }
387
421
  if (previousDepth < depth) {
388
- if (depth - previousDepth > 1) {
389
- debugger;
390
- }
391
- setDataCode += `
422
+ setCode += `
392
423
  if (data.${previousKey} !== undefined) {
393
424
  `;
394
425
  previousDepth = depth;
395
426
  } else if (previousDepth > depth) {
396
427
  while (previousDepth > depth) {
397
- setDataCode += `
428
+ setCode += `
398
429
  }
399
430
  `;
400
431
  previousDepth--;
401
432
  }
402
433
  }
403
434
  previousKey = fullKey;
404
- if (propertyDefinition.propertyType === 9 || propertyDefinition.propertyType === 3 || propertyDefinition.propertyType === 6) {
435
+ if (propertyDefinition.propertyType === 8 || propertyDefinition.propertyType === 3 || propertyDefinition.propertyType === 5) {
405
436
  const monomorph = propertyDefinition.monomorph;
406
437
  if (!monomorphsAlreadyAdded.has(monomorph.name)) {
407
- beforeClass += `
438
+ beforeClassCode += `
408
439
  const ${monomorph.name} = input.${monomorphPath}.monomorph;
409
440
  `;
410
441
  monomorphsAlreadyAdded.add(monomorph.name);
411
442
  }
412
- } else if (propertyDefinition.propertyType === 7) {
443
+ } else if (propertyDefinition.propertyType === 6) {
413
444
  const monomorph = propertyDefinition.monomorph;
414
445
  const className = monomorph.theClass.name;
415
446
  if (!monomorphsAlreadyAdded.has(className)) {
416
- beforeClass += `
447
+ beforeClassCode += `
417
448
  const ${className} = input.${monomorphPath}.monomorph.theClass;
418
449
  `;
419
450
  monomorphsAlreadyAdded.add(className);
@@ -421,23 +452,40 @@ function getClassCode(props, options = {}) {
421
452
  } else if (propertyDefinition.propertyType === 4) {
422
453
  const name = "lazyRefMonomorph" + propIndex;
423
454
  if (!monomorphsAlreadyAdded.has(name)) {
424
- beforeClass += `
455
+ beforeClassCode += `
425
456
  const ${name} = input.${monomorphPath}.monomorph;
426
457
  `;
427
458
  monomorphsAlreadyAdded.add(name);
428
459
  }
429
- } else if (propertyDefinition.propertyType === 8) {
460
+ } else if (propertyDefinition.propertyType === 7) {
430
461
  const name = "lazyRefList" + propIndex;
431
462
  if (!monomorphsAlreadyAdded.has(name)) {
432
- beforeClass += `
463
+ beforeClassCode += `
433
464
  const ${name} = input.${monomorphPath}.monomorph;
434
465
  `;
435
466
  monomorphsAlreadyAdded.add(name);
436
467
  }
468
+ } else if (propertyDefinition.propertyType === 9) {
469
+ const customTypeConfig = propertyDefinition.monomorph;
470
+ const name = "customType" + propIndex;
471
+ if (customTypeConfig.beforeClassCode || customTypeConfig.constructorCode || customTypeConfig.resetCode || customTypeConfig.beforeDestroyCode) {
472
+ beforeClassCode += `
473
+ const ${name} = input.${monomorphPath}.monomorph.data;
474
+ `;
475
+ }
476
+ if (customTypeConfig.beforeClassCode) {
477
+ beforeClassCode += typeof customTypeConfig.beforeClassCode === "function" ? customTypeConfig.beforeClassCode({
478
+ depth,
479
+ key: fullKey,
480
+ // thisProperty: `this.${fullKey}`,
481
+ // dataProperty: `data${hasRequiredProps ? '' : '?'}.${fullKey}`,
482
+ customTypeData: name
483
+ }) : customTypeConfig.beforeClassCode;
484
+ }
437
485
  }
438
- if (propertyDefinition.propertyType !== 9) {
439
- if (propertyDefinition.propertyType === 7 || propertyDefinition.propertyType === 8) {
440
- setDataCode += `
486
+ if (propertyDefinition.propertyType !== 8) {
487
+ if (propertyDefinition.propertyType === 6 || propertyDefinition.propertyType === 7) {
488
+ setCode += `
441
489
  if (data.${fullKey} !== undefined) {
442
490
  this.${fullKey}.length = 0;
443
491
  }
@@ -452,8 +500,39 @@ function getClassCode(props, options = {}) {
452
500
  this.${fullKey}.arrayOfVersions[i] = other.${fullKey}.arrayOfVersions[i];
453
501
  }
454
502
  `;
503
+ } else if (propertyDefinition.propertyType === 9) {
504
+ const customTypeConfig = propertyDefinition.monomorph;
505
+ const params = {
506
+ depth,
507
+ key: fullKey,
508
+ thisProperty: `this.${fullKey}`,
509
+ dataProperty: `data.${fullKey}`,
510
+ customTypeData: "customType" + propIndex
511
+ };
512
+ if (typeof customTypeConfig.setCode !== "undefined") {
513
+ setCode += typeof customTypeConfig.setCode === "function" ? customTypeConfig.setCode(params) : customTypeConfig.setCode;
514
+ } else {
515
+ setCode += `
516
+ if (data.${fullKey} !== undefined) {
517
+ this.${fullKey} = data.${fullKey};
518
+ }
519
+ `;
520
+ }
521
+ if (typeof customTypeConfig.copyCode !== "undefined") {
522
+ copyCode += typeof customTypeConfig.copyCode === "function" ? customTypeConfig.copyCode({
523
+ depth,
524
+ key: fullKey,
525
+ thisProperty: `this.${fullKey}`,
526
+ otherProperty: `other.${fullKey}`,
527
+ customTypeData: "customType" + propIndex
528
+ }) : customTypeConfig.copyCode;
529
+ } else {
530
+ copyCode += `
531
+ this.${fullKey} = other.${fullKey};
532
+ `;
533
+ }
455
534
  } else {
456
- setDataCode += `
535
+ setCode += `
457
536
  if (data.${fullKey} !== undefined) {
458
537
  this.${fullKey} = data.${fullKey};
459
538
  }
@@ -501,7 +580,6 @@ function getClassCode(props, options = {}) {
501
580
  `;
502
581
  break;
503
582
  case 3:
504
- case 5:
505
583
  case 4:
506
584
  toArrayCode += `
507
585
  if (this.${referencePath}.reference && this.${referencePath}.version === this.${referencePath}.reference.version) {
@@ -538,7 +616,7 @@ function getClassCode(props, options = {}) {
538
616
  offset += 2;
539
617
  `;
540
618
  break;
541
- case 7:
619
+ case 6:
542
620
  toArrayCode += `
543
621
  array[offset++] = this.${fullKey}.length;
544
622
  for (let i = 0; i < this.${fullKey}.length; i++) {
@@ -561,7 +639,7 @@ function getClassCode(props, options = {}) {
561
639
  offset += arrayOfData[offset++] * 2;
562
640
  `;
563
641
  break;
564
- case 6:
642
+ case 5:
565
643
  toArrayCodeForPoolReferences += `
566
644
  if (this.${fullKey} && this.${fullKey}.length > 0) {
567
645
  array[offset++] = 1; // indicates that the pool reference is not empty
@@ -610,13 +688,13 @@ function getClassCode(props, options = {}) {
610
688
  `;
611
689
  }
612
690
  while (previousDepth > 0) {
613
- setDataCode += `
691
+ setCode += `
614
692
  }
615
693
  `;
616
694
  previousDepth--;
617
695
  }
618
696
  const code = `
619
- ${beforeClass}
697
+ ${beforeClassCode}
620
698
 
621
699
  function iterateOverPool(pool) {
622
700
  let index = 0;
@@ -709,9 +787,10 @@ function getClassCode(props, options = {}) {
709
787
  static hasDynamicSize = ${hasDynamicSize};
710
788
 
711
789
  constructor(data, index, pool) {
712
- ${constructorAndFullSetDataDefaultValueCode}
790
+ ${constructorAndResetDataDefaultValueCode}
713
791
  ${constructorCode}
714
- ${fullSetDataCode}
792
+ ${constructorAndResetDataCode}
793
+ ${customTypesConstructorCode}
715
794
  this.index = index;
716
795
  this.version = 0; ${""}
717
796
  this.pool = (pool === undefined) ? null : pool;
@@ -720,15 +799,16 @@ function getClassCode(props, options = {}) {
720
799
 
721
800
  ${referenceGettersAndSettersCode}
722
801
 
723
- fullSet(data) {
724
- ${constructorAndFullSetDataDefaultValueCode}
725
- ${onlyFullSetDataDefaultValueCode}
726
- ${fullSetDataCode}
802
+ reset(data) {
803
+ ${constructorAndResetDataDefaultValueCode}
804
+ ${onlyResetDataDefaultValueCode}
805
+ ${constructorAndResetDataCode}
806
+ ${customTypesOnlyResetCode}
727
807
  return this;
728
808
  }
729
809
 
730
810
  set(data) {
731
- ${setDataCode}
811
+ ${setCode}
732
812
  return this;
733
813
  }
734
814
 
@@ -738,6 +818,7 @@ function getClassCode(props, options = {}) {
738
818
  }
739
819
 
740
820
  destroy() {
821
+ ${customTypesBeforeDestroyCode}
741
822
  if (this.version & 1 === 1) {
742
823
  ${""}
743
824
  return;
@@ -1139,7 +1220,7 @@ function getClassCode(props, options = {}) {
1139
1220
  pool.length++;
1140
1221
  const instance = pool.array[index];
1141
1222
  instance.version++; ${""}
1142
- instance.fullSet(data);
1223
+ instance.reset(data);
1143
1224
  return instance;
1144
1225
  } else {
1145
1226
  const instance = new this(data, pool.length, pool);
@@ -1627,7 +1708,7 @@ class Vec3 extends (/* @__PURE__ */ createClass(vec3Props)) {
1627
1708
  }
1628
1709
  super(data, index, pool);
1629
1710
  }
1630
- fullSet(data) {
1711
+ reset(data) {
1631
1712
  if (Array.isArray(data)) {
1632
1713
  this.x = data[0] ?? 0;
1633
1714
  this.y = data[1] ?? 0;
@@ -2143,7 +2224,7 @@ class Quat extends (/* @__PURE__ */ createClass(quatProps)) {
2143
2224
  }
2144
2225
  super(data, index, pool);
2145
2226
  }
2146
- fullSet(data) {
2227
+ reset(data) {
2147
2228
  if (Array.isArray(data)) {
2148
2229
  if (data.length && data.length < 4) {
2149
2230
  return this.setFromEulerRadians(data[0], data[1] ?? 0, data[2] ?? 0);
@@ -7789,12 +7870,6 @@ const springProps = {
7789
7870
  stiffness: 0
7790
7871
  };
7791
7872
  class Spring extends (/* @__PURE__ */ createClass(springProps)) {
7792
- reset() {
7793
- this.mode = 0;
7794
- this.frequency = 0;
7795
- this.damping = 0;
7796
- this.stiffness = 0;
7797
- }
7798
7873
  hasStiffness() {
7799
7874
  return this.frequency > 0;
7800
7875
  }
@@ -8194,18 +8269,6 @@ const motorProps = {
8194
8269
  )
8195
8270
  };
8196
8271
  class Motor extends (/* @__PURE__ */ createClass(motorProps)) {
8197
- reset() {
8198
- this.spring.reset();
8199
- this.spring.mode = SpringMode.UseFrequency;
8200
- this.spring.damping = 1;
8201
- this.spring.frequency = 2;
8202
- this.spring.stiffness = 2;
8203
- this.minForce = -Infinity;
8204
- this.maxForce = Infinity;
8205
- this.minTorque = -Infinity;
8206
- this.maxTorque = Infinity;
8207
- this.mode = 0;
8208
- }
8209
8272
  isValid() {
8210
8273
  return this.spring.isValid() && this.minForce <= this.maxForce && this.minTorque <= this.maxTorque;
8211
8274
  }
@@ -9542,7 +9605,10 @@ var CollisionStatus = /* @__PURE__ */ ((CollisionStatus2) => {
9542
9605
  return CollisionStatus2;
9543
9606
  })(CollisionStatus || {});
9544
9607
  const collisionResultProps = {
9545
- status: 0,
9608
+ status: /* @__PURE__ */ NumberType(
9609
+ 2
9610
+ /* Indeterminate */
9611
+ ),
9546
9612
  hasContact: /* @__PURE__ */ BooleanType(false),
9547
9613
  penetration: 0,
9548
9614
  contactPointA: Vec3,
@@ -9562,18 +9628,6 @@ const collisionResultProps = {
9562
9628
  faceB: Face
9563
9629
  };
9564
9630
  class CollisionResult extends (/* @__PURE__ */ createClass(collisionResultProps)) {
9565
- reset() {
9566
- this.status = 2;
9567
- this.hasContact = false;
9568
- this.penetration = 0;
9569
- this.bodyA = null;
9570
- this.bodyB = null;
9571
- this.subShapeIdA = 0;
9572
- this.subShapeIdB = 0;
9573
- this.isBackFace = false;
9574
- this.faceA.clear();
9575
- this.faceB.clear();
9576
- }
9577
9631
  /**
9578
9632
  * swaps the A and B data
9579
9633
  */
@@ -9647,7 +9701,10 @@ function createDefaultCollisionSettings() {
9647
9701
  };
9648
9702
  }
9649
9703
  const castResultProps = {
9650
- status: 0,
9704
+ status: /* @__PURE__ */ NumberType(
9705
+ 2
9706
+ /* Indeterminate */
9707
+ ),
9651
9708
  hasContact: /* @__PURE__ */ BooleanType(false),
9652
9709
  penetration: 0,
9653
9710
  contactPointA: Vec3,
@@ -9669,18 +9726,6 @@ const castResultProps = {
9669
9726
  isBackFaceHit: /* @__PURE__ */ BooleanType(false)
9670
9727
  };
9671
9728
  class CastResult extends (/* @__PURE__ */ createClass(castResultProps)) {
9672
- reset() {
9673
- this.status = 2;
9674
- this.hasContact = false;
9675
- this.penetration = 0;
9676
- this.bodyA = null;
9677
- this.bodyB = null;
9678
- this.subShapeIdA = 0;
9679
- this.subShapeIdB = 0;
9680
- this.isBackFace = false;
9681
- this.faceA.clear();
9682
- this.faceB.clear();
9683
- }
9684
9729
  /**
9685
9730
  * swaps the A and B data
9686
9731
  */
@@ -10114,33 +10159,16 @@ const gjkClosestPointsProps = {
10114
10159
  pointA: Vec3,
10115
10160
  pointB: Vec3
10116
10161
  };
10117
- class GjkClosestPoints extends (/* @__PURE__ */ createClass(
10118
- gjkClosestPointsProps
10119
- )) {
10120
- reset() {
10121
- this.pointA.zero();
10122
- this.pointB.zero();
10123
- this.penetrationAxis.zero();
10124
- this.squaredDistance = 0;
10125
- }
10162
+ class GjkClosestPoints extends (/* @__PURE__ */ createClass(gjkClosestPointsProps)) {
10126
10163
  }
10127
10164
  const gjkCastShapeResultProps = {
10128
- isHitFound: /* @__PURE__ */ BooleanType(false),
10129
- lambda: 0,
10165
+ isHitFound: false,
10166
+ lambda: 1,
10130
10167
  separatingAxis: Vec3,
10131
10168
  pointA: Vec3,
10132
10169
  pointB: Vec3
10133
10170
  };
10134
- class GjkCastShapeResult extends (/* @__PURE__ */ createClass(
10135
- gjkCastShapeResultProps
10136
- )) {
10137
- reset() {
10138
- this.isHitFound = false;
10139
- this.pointA.zero();
10140
- this.pointB.zero();
10141
- this.separatingAxis.zero();
10142
- this.lambda = 1;
10143
- }
10171
+ class GjkCastShapeResult extends (/* @__PURE__ */ createClass(gjkCastShapeResultProps)) {
10144
10172
  }
10145
10173
  const transformedConvexObject = /* @__PURE__ */ new TransformedConvexObject();
10146
10174
  const y0 = /* @__PURE__ */ Vec3.create();