typeson-registry 8.0.0 → 9.0.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.
Files changed (80) hide show
  1. package/README.md +5 -0
  2. package/dist/index.d.ts +5 -3
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +99 -36
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.min.js +1 -1
  7. package/dist/index.min.js.map +1 -1
  8. package/dist/index.umd.cjs +370 -281
  9. package/dist/index.umd.cjs.map +1 -1
  10. package/dist/index.umd.min.cjs +1 -1
  11. package/dist/index.umd.min.cjs.map +1 -1
  12. package/dist/presets/array-nonindex-keys.umd.cjs +1 -1
  13. package/dist/presets/array-nonindex-keys.umd.cjs.map +1 -1
  14. package/dist/presets/builtin.umd.cjs +1 -1
  15. package/dist/presets/builtin.umd.cjs.map +1 -1
  16. package/dist/presets/postmessage.umd.cjs.map +1 -1
  17. package/dist/presets/socketio.umd.cjs +1 -1
  18. package/dist/presets/socketio.umd.cjs.map +1 -1
  19. package/dist/presets/sparse-undefined.umd.cjs +1 -1
  20. package/dist/presets/sparse-undefined.umd.cjs.map +1 -1
  21. package/dist/presets/special-numbers.umd.cjs +1 -1
  22. package/dist/presets/special-numbers.umd.cjs.map +1 -1
  23. package/dist/presets/structured-cloning-throwing.d.ts.map +1 -1
  24. package/dist/presets/structured-cloning-throwing.umd.cjs +1 -1
  25. package/dist/presets/structured-cloning-throwing.umd.cjs.map +1 -1
  26. package/dist/presets/structured-cloning.d.ts.map +1 -1
  27. package/dist/presets/structured-cloning.umd.cjs +1 -1
  28. package/dist/presets/structured-cloning.umd.cjs.map +1 -1
  29. package/dist/presets/undef.umd.cjs +1 -1
  30. package/dist/presets/undef.umd.cjs.map +1 -1
  31. package/dist/presets/universal.umd.cjs +1 -1
  32. package/dist/presets/universal.umd.cjs.map +1 -1
  33. package/dist/types/bigint-object.d.ts.map +1 -1
  34. package/dist/types/bigint-object.umd.cjs.map +1 -1
  35. package/dist/types/bigint.d.ts.map +1 -1
  36. package/dist/types/bigint.umd.cjs.map +1 -1
  37. package/dist/types/blob.umd.cjs.map +1 -1
  38. package/dist/types/cloneable.umd.cjs.map +1 -1
  39. package/dist/types/cryptokey.umd.cjs +1 -1
  40. package/dist/types/cryptokey.umd.cjs.map +1 -1
  41. package/dist/types/domexception.d.ts +6 -0
  42. package/dist/types/domexception.d.ts.map +1 -0
  43. package/dist/types/domexception.umd.cjs +2 -0
  44. package/dist/types/domexception.umd.cjs.map +1 -0
  45. package/dist/types/dompoint.d.ts +6 -0
  46. package/dist/types/dompoint.d.ts.map +1 -0
  47. package/dist/types/dompoint.umd.cjs +2 -0
  48. package/dist/types/dompoint.umd.cjs.map +1 -0
  49. package/dist/types/domrect.d.ts +6 -0
  50. package/dist/types/domrect.d.ts.map +1 -0
  51. package/dist/types/domrect.umd.cjs +2 -0
  52. package/dist/types/domrect.umd.cjs.map +1 -0
  53. package/dist/types/errors.d.ts.map +1 -1
  54. package/dist/types/errors.umd.cjs.map +1 -1
  55. package/dist/types/file.umd.cjs.map +1 -1
  56. package/dist/types/filelist.umd.cjs.map +1 -1
  57. package/dist/types/imagebitmap.umd.cjs +1 -1
  58. package/dist/types/imagebitmap.umd.cjs.map +1 -1
  59. package/dist/types/infinity.umd.cjs +1 -1
  60. package/dist/types/infinity.umd.cjs.map +1 -1
  61. package/dist/types/nan.umd.cjs +1 -1
  62. package/dist/types/nan.umd.cjs.map +1 -1
  63. package/dist/types/negative-infinity.umd.cjs +1 -1
  64. package/dist/types/negative-infinity.umd.cjs.map +1 -1
  65. package/dist/types/negative-zero.umd.cjs +1 -1
  66. package/dist/types/negative-zero.umd.cjs.map +1 -1
  67. package/dist/types/nonbuiltin-ignore.umd.cjs +1 -1
  68. package/dist/types/nonbuiltin-ignore.umd.cjs.map +1 -1
  69. package/dist/types/resurrectable.umd.cjs.map +1 -1
  70. package/dist/types/undef.umd.cjs +1 -1
  71. package/dist/types/undef.umd.cjs.map +1 -1
  72. package/dist/types/user-object.umd.cjs +1 -1
  73. package/dist/types/user-object.umd.cjs.map +1 -1
  74. package/dist/utils/generateUUID.d.ts.map +1 -1
  75. package/package.json +46 -45
  76. package/polyfills/createObjectURL.js +2 -2
  77. package/polyfills/createObjectURL.umd.cjs +1 -1
  78. package/polyfills/createObjectURL.umd.cjs.map +1 -1
  79. package/utils/generateUUID.js +3 -5
  80. package/utils/stringArrayBuffer.js +1 -1
package/README.md CHANGED
@@ -227,8 +227,12 @@ Note that the type name corresponds to the file name in the following manner:
227
227
  you are polyfilling a standard object, we welcome you to submit back as a
228
228
  PR!). The clones cannot be revived past the current window session,
229
229
  however.
230
+ - `cryptokey`
230
231
  - `dataview`
231
232
  - `date`
233
+ - `domexception`
234
+ - `dompoint`
235
+ - `domrect`
232
236
  - `error.js` (`Error`) and `errors.js` (`TypeError`, `RangeError`, `SyntaxError`, `ReferenceError`, `EvalError`, `URIError`, `InternalError`) - These
233
237
  provide a means of resurrecting error object across cloning boundaries
234
238
  (since they are not otherwise treated as cloneable by the Structured
@@ -247,6 +251,7 @@ Note that the type name corresponds to the file name in the following manner:
247
251
  - `map`
248
252
  - `nan` - Preserves `NaN` (not a number)
249
253
  - `NegativeInfinity` - Preserves negative infinity
254
+ - `negative-zero` - Preserves `-0` (produces + or - Infinity when used as divisor)
250
255
  - `nonBuiltInIgnore` - For roughly detecting non-builtin objects and to avoid
251
256
  adding them as properties
252
257
  - `primitive-objects.js` (`StringObject`, `BooleanObject`, `NumberObject`)
package/dist/index.d.ts CHANGED
@@ -7,6 +7,9 @@ import cloneable from './types/cloneable.js';
7
7
  import cryptokey from './types/cryptokey.js';
8
8
  import dataview from './types/dataview.js';
9
9
  import date from './types/date.js';
10
+ import domexception from './types/domexception.js';
11
+ import dompoint from './types/dompoint.js';
12
+ import domrect from './types/domrect.js';
10
13
  import error from './types/error.js';
11
14
  import errors from './types/errors.js';
12
15
  import file from './types/file.js';
@@ -38,6 +41,5 @@ import structuredCloningThrowing from './presets/structured-cloning-throwing.js'
38
41
  import structuredCloning from './presets/structured-cloning.js';
39
42
  import undefPreset from './presets/undef.js';
40
43
  import universal from './presets/universal.js';
41
- export { arraybuffer, bigintObject, bigint, blob, cloneable, cryptokey, dataview, date, error, errors, file, filelist, imagebitmap, imagedata, infinity, intlTypes, map, nan, negativeInfinity, negativeZero, nonbuiltinIgnore, primitiveObjects, regexp, resurrectable, set, typedArraysSocketio, typedArrays, undef, userObject, arrayNonindexKeys, builtin, postmessage, socketio, sparseUndefined, specialNumbers, structuredCloningThrowing, structuredCloning, undefPreset, universal };
42
- //# sourceMappingURL=index.d.ts.map
43
- export type * from 'typeson';
44
+ export { arraybuffer, bigintObject, bigint, blob, cloneable, cryptokey, dataview, date, domexception, dompoint, domrect, error, errors, file, filelist, imagebitmap, imagedata, infinity, intlTypes, map, nan, negativeInfinity, negativeZero, nonbuiltinIgnore, primitiveObjects, regexp, resurrectable, set, typedArraysSocketio, typedArrays, undef, userObject, arrayNonindexKeys, builtin, postmessage, socketio, sparseUndefined, specialNumbers, structuredCloningThrowing, structuredCloning, undefPreset, universal };
45
+ //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.js"],"names":[],"mappings":";wBAGwB,wBAAwB;yBACvB,0BAA0B;mBAChC,mBAAmB;iBACrB,iBAAiB;sBACZ,sBAAsB;sBACtB,sBAAsB;qBACvB,qBAAqB;iBACzB,iBAAiB;kBAChB,kBAAkB;mBACjB,mBAAmB;iBACrB,iBAAiB;qBACb,qBAAqB;wBAClB,wBAAwB;sBAC1B,sBAAsB;qBACvB,qBAAqB;sBACpB,uBAAuB;gBAC7B,gBAAgB;gBAChB,gBAAgB;6BACH,8BAA8B;yBAClC,0BAA0B;6BACtB,8BAA8B;6BAC9B,8BAA8B;mBACxC,mBAAmB;0BACZ,0BAA0B;gBACpC,gBAAgB;gCACA,kCAAkC;wBAC1C,yBAAyB;kBAC/B,kBAAkB;uBACb,wBAAwB;8BAGjB,kCAAkC;oBAC5C,sBAAsB;wBAClB,0BAA0B;qBAC7B,uBAAuB;4BAChB,+BAA+B;2BAChC,8BAA8B;sCAErD,0CAA0C;8BAChB,iCAAiC;wBACvC,oBAAoB;sBACtB,wBAAwB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.js"],"names":[],"mappings":";wBAGwB,wBAAwB;yBACvB,0BAA0B;mBAChC,mBAAmB;iBACrB,iBAAiB;sBACZ,sBAAsB;sBACtB,sBAAsB;qBACvB,qBAAqB;iBACzB,iBAAiB;yBACT,yBAAyB;qBAC7B,qBAAqB;oBACtB,oBAAoB;kBACtB,kBAAkB;mBACjB,mBAAmB;iBACrB,iBAAiB;qBACb,qBAAqB;wBAClB,wBAAwB;sBAC1B,sBAAsB;qBACvB,qBAAqB;sBACpB,uBAAuB;gBAC7B,gBAAgB;gBAChB,gBAAgB;6BACH,8BAA8B;yBAClC,0BAA0B;6BACtB,8BAA8B;6BAC9B,8BAA8B;mBACxC,mBAAmB;0BACZ,0BAA0B;gBACpC,gBAAgB;gCACA,kCAAkC;wBAC1C,yBAAyB;kBAC/B,kBAAkB;uBACb,wBAAwB;8BAGjB,kCAAkC;oBAC5C,sBAAsB;wBAClB,0BAA0B;qBAC7B,uBAAuB;4BAChB,+BAA+B;2BAChC,8BAA8B;sCAErD,0CAA0C;8BAChB,iCAAiC;wBACvC,oBAAoB;sBACtB,wBAAwB"}
package/dist/index.js CHANGED
@@ -136,8 +136,6 @@ const arraybuffer = {
136
136
 
137
137
  // See also typed-arrays!
138
138
 
139
- /* globals BigInt */
140
-
141
139
  /**
142
140
  * @type {import('typeson').TypeSpecSet}
143
141
  */
@@ -155,8 +153,6 @@ const bigintObject = {
155
153
  }
156
154
  };
157
155
 
158
- /* globals BigInt */
159
-
160
156
  /**
161
157
  * @type {import('typeson').TypeSpecSet}
162
158
  */
@@ -233,7 +229,7 @@ function string2arraybuffer (str) {
233
229
 
234
230
  const array = new Uint8Array(str.length);
235
231
  for (let i = 0; i < str.length; i++) {
236
- // eslint-disable-next-line max-len -- Long
232
+ // eslint-disable-next-line @stylistic/max-len -- Long
237
233
  // eslint-disable-next-line unicorn/prefer-code-point -- Iterating char. codes
238
234
  array[i] = str.charCodeAt(i); // & 0xff;
239
235
  }
@@ -296,8 +292,6 @@ const blob = {
296
292
  }
297
293
  };
298
294
 
299
- /* globals performance */
300
-
301
295
  // The `performance` global is optional
302
296
 
303
297
  /**
@@ -317,13 +311,13 @@ function generateUUID () { // Adapted from original: public domain/MIT: http://
317
311
  ? performance.now()
318
312
  : 0);
319
313
 
320
- // eslint-disable-next-line max-len -- Long
314
+ // eslint-disable-next-line @stylistic/max-len -- Long
321
315
  // eslint-disable-next-line no-use-extend-native/no-use-extend-native -- Need to update plugin
322
316
  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replaceAll(/[xy]/gu, function (c) {
323
317
  /* eslint-disable no-bitwise */
324
- const r = Math.trunc((d + Math.random() * 16) % 16);
318
+ const r = Math.trunc((d + (Math.random() * 16)) % 16);
325
319
  d = Math.floor(d / 16);
326
- return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
320
+ return (c === 'x' ? r : ((r & 0x3) | 0x8)).toString(16);
327
321
  /* eslint-enable no-bitwise */
328
322
  });
329
323
  }
@@ -486,6 +480,70 @@ const date = {
486
480
  }
487
481
  };
488
482
 
483
+ /**
484
+ * @type {import('typeson').TypeSpecSet}
485
+ */
486
+ const domexception = {
487
+ domexception: {
488
+ test (x) { return toStringTag(x) === 'DOMException'; },
489
+ replace (de) {
490
+ // `code` is based on `name` and readonly, so no
491
+ // need to keep here
492
+ return {
493
+ name: de.name,
494
+ message: de.message
495
+ };
496
+ },
497
+ revive ({message, name}) {
498
+ return new DOMException(message, name);
499
+ }
500
+ }
501
+ };
502
+
503
+ /* globals DOMPoint */
504
+
505
+ /**
506
+ * @type {import('typeson').TypeSpecSet}
507
+ */
508
+ const dompoint = {
509
+ dompoint: {
510
+ test (x) { return toStringTag(x) === 'DOMPoint'; },
511
+ replace (dp) {
512
+ return {
513
+ x: dp.x,
514
+ y: dp.y,
515
+ z: dp.z,
516
+ w: dp.w
517
+ };
518
+ },
519
+ revive ({x, y, z, w}) {
520
+ return new DOMPoint(x, y, z, w);
521
+ }
522
+ }
523
+ };
524
+
525
+ /* globals DOMRect */
526
+
527
+ /**
528
+ * @type {import('typeson').TypeSpecSet}
529
+ */
530
+ const domrect = {
531
+ domrect: {
532
+ test (x) { return toStringTag(x) === 'DOMRect'; },
533
+ replace (dr) {
534
+ return {
535
+ x: dr.x,
536
+ y: dr.y,
537
+ width: dr.width,
538
+ height: dr.height
539
+ };
540
+ },
541
+ revive ({x, y, width, height}) {
542
+ return new DOMRect(x, y, width, height);
543
+ }
544
+ }
545
+ };
546
+
489
547
  /**
490
548
  * @type {import('typeson').TypeSpecSet}
491
549
  */
@@ -541,9 +599,12 @@ if (typeof AggregateError !== 'undefined') {
541
599
  create$2(AggregateError);
542
600
  }
543
601
 
544
- /* c8 ignore next 2 */
545
- // @ts-ignore Non-standard
546
- typeof InternalError === 'function' && create$2(InternalError);
602
+ /* c8 ignore next 5 */
603
+ // @ts-expect-error Non-standard
604
+ if (typeof InternalError === 'function') {
605
+ // @ts-expect-error Non-standard
606
+ create$2(InternalError);
607
+ }
547
608
 
548
609
  /* eslint-disable jsdoc/valid-types -- https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/issues/131 */
549
610
  /**
@@ -725,7 +786,7 @@ const filelist = {
725
786
  }
726
787
  };
727
788
 
728
- /* globals createImageBitmap */
789
+ /* globals document, createImageBitmap */
729
790
  // `ImageBitmap` is browser / DOM specific. It also can only work
730
791
  // same-domain (or CORS)
731
792
 
@@ -837,8 +898,8 @@ const imagedata = {
837
898
  const infinity = {
838
899
  infinity: {
839
900
  test (x) { return x === Number.POSITIVE_INFINITY; },
840
- replace (n) { return 'Infinity'; },
841
- revive (s) { return Number.POSITIVE_INFINITY; }
901
+ replace (/* n */) { return 'Infinity'; },
902
+ revive (/* s */) { return Number.POSITIVE_INFINITY; }
842
903
  }
843
904
  };
844
905
 
@@ -894,8 +955,8 @@ const map = {
894
955
  const nan = {
895
956
  nan: {
896
957
  test (x) { return Number.isNaN(x); },
897
- replace (n) { return 'NaN'; },
898
- revive (s) { return Number.NaN; }
958
+ replace (/* n */) { return 'NaN'; },
959
+ revive (/* s */) { return Number.NaN; }
899
960
  }
900
961
  };
901
962
 
@@ -905,8 +966,8 @@ const nan = {
905
966
  const negativeInfinity = {
906
967
  negativeInfinity: {
907
968
  test (x) { return x === Number.NEGATIVE_INFINITY; },
908
- replace (n) { return '-Infinity'; },
909
- revive (s) { return Number.NEGATIVE_INFINITY; }
969
+ replace (/* n */) { return '-Infinity'; },
970
+ revive (/* s */) { return Number.NEGATIVE_INFINITY; }
910
971
  }
911
972
  };
912
973
 
@@ -918,11 +979,11 @@ const negativeZero = {
918
979
  test (x) {
919
980
  return Object.is(x, -0);
920
981
  },
921
- replace (n) {
982
+ replace (/* n */) {
922
983
  // Just adding 0 here for minimized space; will still revive as -0
923
984
  return 0;
924
985
  },
925
- revive (s) {
986
+ revive (/* s */) {
926
987
  return -0;
927
988
  }
928
989
  }
@@ -954,7 +1015,7 @@ const nonbuiltinIgnore = {
954
1015
  'Atomics', 'Module'
955
1016
  ].includes(toStringTag(x));
956
1017
  },
957
- replace (rexp) {
1018
+ replace (/* rexp */) {
958
1019
  // Not in use
959
1020
  }
960
1021
  }
@@ -1243,8 +1304,8 @@ const undef$1 = {
1243
1304
  return typeof x === 'undefined' &&
1244
1305
  (stateObj.ownKeys || !('ownKeys' in stateObj));
1245
1306
  },
1246
- replace (n) { return 0; },
1247
- revive (s$1) {
1307
+ replace (/* n */) { return 0; },
1308
+ revive (/* s */) {
1248
1309
  // Will add `undefined` (returning `undefined` would instead
1249
1310
  // avoid explicitly setting)
1250
1311
  return new s();
@@ -1257,7 +1318,7 @@ const undef$1 = {
1257
1318
  */
1258
1319
  const userObject = {
1259
1320
  userObject: {
1260
- test (x, stateObj) { return isUserObject(x); },
1321
+ test (x /* , stateObj */) { return isUserObject(x); },
1261
1322
  replace (n) { return {...n}; },
1262
1323
  revive (s) { return s; }
1263
1324
  }
@@ -1323,8 +1384,8 @@ const arrayNonindexKeys = [
1323
1384
  test (x, stateObj) {
1324
1385
  return typeof x === 'undefined' && stateObj.ownKeys === false;
1325
1386
  },
1326
- replace (n) { return 0; },
1327
- revive (s) { return undefined; } // Will avoid adding anything
1387
+ replace (/* n */) { return 0; },
1388
+ revive (/* s */) { return undefined; } // Will avoid adding anything
1328
1389
  }
1329
1390
  }
1330
1391
  ];
@@ -1438,8 +1499,8 @@ const sparseUndefined = [
1438
1499
  test (x, stateObj) {
1439
1500
  return typeof x === 'undefined' && stateObj.ownKeys === false;
1440
1501
  },
1441
- replace (n) { return 0; },
1442
- revive (s) { return undefined; } // Will avoid adding anything
1502
+ replace (/* n */) { return 0; },
1503
+ revive (/* s */) { return undefined; } // Will avoid adding anything
1443
1504
  }
1444
1505
  }
1445
1506
  ];
@@ -1481,15 +1542,17 @@ const expObj = [
1481
1542
  /* c8 ignore next */
1482
1543
  typeof DataView === 'function' ? dataview : [],
1483
1544
  /* c8 ignore next */
1484
- typeof Intl !== 'undefined' ? intlTypes : [],
1485
- /* c8 ignore next */
1486
1545
  typeof crypto !== 'undefined' ? cryptokey : [],
1487
1546
  /* c8 ignore next */
1488
- typeof BigInt !== 'undefined' ? [bigint, bigintObject] : []
1547
+ typeof BigInt !== 'undefined' ? [bigint, bigintObject] : [],
1548
+ /* c8 ignore next */
1549
+ typeof DOMException !== 'undefined' ? domexception : [],
1550
+ /* c8 ignore next */
1551
+ typeof DOMRect !== 'undefined' ? domrect : [],
1552
+ /* c8 ignore next */
1553
+ typeof DOMPoint !== 'undefined' ? dompoint : []
1489
1554
  );
1490
1555
 
1491
- /* globals DOMException */
1492
-
1493
1556
  /**
1494
1557
  * @type {import('typeson').Preset}
1495
1558
  */
@@ -1585,5 +1648,5 @@ const universal = [
1585
1648
  // built-in into ecmasript standard.
1586
1649
  ];
1587
1650
 
1588
- export { u as JSON_TYPES, c as Typeson, e as TypesonPromise, s as Undefined, arrayNonindexKeys, arraybuffer, bigint, bigintObject, blob, expObj$1 as builtin, cloneable, cryptokey, dataview, date, error, errors, escapeKeyPathComponent, file, filelist, getByKeyPath, getJSONType, hasConstructorOf, imagebitmap, imagedata, infinity, intlTypes, isObject, isPlainObject, isThenable, isUserObject, map, nan, negativeInfinity, negativeZero, nonbuiltinIgnore, postmessage, primitiveObjects, regexp, resurrectable, set, setAtKeyPath, socketio, sparseUndefined, specialNumbers, expObj as structuredCloning, structuredCloningThrowing, toStringTag, typedArrays, typedArraysSocketIO as typedArraysSocketio, undef$1 as undef, undef as undefPreset, unescapeKeyPathComponent, universal, userObject };
1651
+ export { u as JSON_TYPES, c as Typeson, e as TypesonPromise, s as Undefined, arrayNonindexKeys, arraybuffer, bigint, bigintObject, blob, expObj$1 as builtin, cloneable, cryptokey, dataview, date, domexception, dompoint, domrect, error, errors, escapeKeyPathComponent, file, filelist, getByKeyPath, getJSONType, hasConstructorOf, imagebitmap, imagedata, infinity, intlTypes, isObject, isPlainObject, isThenable, isUserObject, map, nan, negativeInfinity, negativeZero, nonbuiltinIgnore, postmessage, primitiveObjects, regexp, resurrectable, set, setAtKeyPath, socketio, sparseUndefined, specialNumbers, expObj as structuredCloning, structuredCloningThrowing, toStringTag, typedArrays, typedArraysSocketIO as typedArraysSocketio, undef$1 as undef, undef as undefPreset, unescapeKeyPathComponent, universal, userObject };
1589
1652
  //# sourceMappingURL=index.js.map