typeson-registry 13.2.0 → 13.3.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/README.md CHANGED
@@ -257,6 +257,7 @@ Note that the type name corresponds to the file name in the following manner:
257
257
  adding them as properties
258
258
  - `primitive-objects.js` (`StringObject`, `BooleanObject`, `NumberObject`)
259
259
  - `promise`
260
+ - `quotaexceedederror`
260
261
  - `regexp`
261
262
  - `resurrectable` - Resurrects any non-array object, function, or symbol; can
262
263
  only be revived for the current window session.
@@ -275,6 +276,7 @@ Note that the type name corresponds to the file name in the following manner:
275
276
  - `userObjects` - Allows for inherited objects but ensures the prototype chain
276
277
  inherits from `Object` (or `null`). Should be low priority if one is
277
278
  matching other objects as it will readily match many objects.
279
+ - `webtransporterror`
278
280
 
279
281
  ### Presets
280
282
 
package/dist/index.d.ts CHANGED
@@ -28,6 +28,7 @@ import negativeZero from './types/negative-zero.js';
28
28
  import nonbuiltinIgnore from './types/nonbuiltin-ignore.js';
29
29
  import primitiveObjects from './types/primitive-objects.js';
30
30
  import promise from './types/promise.js';
31
+ import quotaexceedederror from './types/quotaexceedederror.js';
31
32
  import regexp from './types/regexp.js';
32
33
  import resurrectable from './types/resurrectable.js';
33
34
  import set from './types/set.js';
@@ -36,6 +37,7 @@ import typedArraysSocketio from './types/typed-arrays-socketio.js';
36
37
  import typedArrays from './types/typed-arrays.js';
37
38
  import undef from './types/undef.js';
38
39
  import userObject from './types/user-object.js';
40
+ import webtransporterror from './types/webtransporterror.js';
39
41
  import arrayNonindexKeys from './presets/array-nonindex-keys.js';
40
42
  import builtin from './presets/builtin.js';
41
43
  import postmessage from './presets/postmessage.js';
@@ -46,6 +48,5 @@ import structuredCloningThrowing from './presets/structured-cloning-throwing.js'
46
48
  import structuredCloning from './presets/structured-cloning.js';
47
49
  import undefPreset from './presets/undef.js';
48
50
  import universal from './presets/universal.js';
49
- export { arraybuffer, audiodata, bigintObject, bigint, blob, cloneable, cryptokey, dataview, date, domexception, dommatrix, dompoint, domquad, domrect, error, errors, file, filelist, imagebitmap, imagedata, infinity, intlTypes, map, nan, negativeInfinity, negativeZero, nonbuiltinIgnore, primitiveObjects, promise, regexp, resurrectable, set, symbol, typedArraysSocketio, typedArrays, undef, userObject, arrayNonindexKeys, builtin, postmessage, socketio, sparseUndefined, specialNumbers, structuredCloningThrowing, structuredCloning, undefPreset, universal };
50
- //# sourceMappingURL=index.d.ts.map
51
- export type * from 'typeson';
51
+ export { arraybuffer, audiodata, bigintObject, bigint, blob, cloneable, cryptokey, dataview, date, domexception, dommatrix, dompoint, domquad, domrect, error, errors, file, filelist, imagebitmap, imagedata, infinity, intlTypes, map, nan, negativeInfinity, negativeZero, nonbuiltinIgnore, primitiveObjects, promise, quotaexceedederror, regexp, resurrectable, set, symbol, typedArraysSocketio, typedArrays, undef, userObject, webtransporterror, arrayNonindexKeys, builtin, postmessage, socketio, sparseUndefined, specialNumbers, structuredCloningThrowing, structuredCloning, undefPreset, universal };
52
+ //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.js"],"names":[],"mappings":";wBAGwB,wBAAwB;sBAC1B,sBAAsB;yBACnB,0BAA0B;mBAChC,mBAAmB;iBACrB,iBAAiB;sBACZ,sBAAsB;sBACtB,sBAAsB;qBACvB,qBAAqB;iBACzB,iBAAiB;yBACT,yBAAyB;sBAC5B,sBAAsB;qBACvB,qBAAqB;oBACtB,oBAAoB;oBACpB,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;oBACvC,oBAAoB;mBACrB,mBAAmB;0BACZ,0BAA0B;gBACpC,gBAAgB;mBACb,mBAAmB;gCACN,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;sBAC1B,sBAAsB;yBACnB,0BAA0B;mBAChC,mBAAmB;iBACrB,iBAAiB;sBACZ,sBAAsB;sBACtB,sBAAsB;qBACvB,qBAAqB;iBACzB,iBAAiB;yBACT,yBAAyB;sBAC5B,sBAAsB;qBACvB,qBAAqB;oBACtB,oBAAoB;oBACpB,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;oBACvC,oBAAoB;+BACT,+BAA+B;mBAC3C,mBAAmB;0BACZ,0BAA0B;gBACpC,gBAAgB;mBACb,mBAAmB;gCACN,kCAAkC;wBAC1C,yBAAyB;kBAC/B,kBAAkB;uBACb,wBAAwB;8BACjB,8BAA8B;8BAG9B,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
@@ -982,6 +982,8 @@ const filelist = {
982
982
  return 'FileList';
983
983
  }
984
984
  }
985
+
986
+ // @ts-ignore Override API
985
987
  return new FileList(o);
986
988
  }
987
989
  }
@@ -1296,6 +1298,29 @@ const promise = {
1296
1298
  }
1297
1299
  };
1298
1300
 
1301
+ /**
1302
+ * @type {import('typeson').TypeSpecSet}
1303
+ */
1304
+ const quotaexceedederror = {
1305
+ quotaexceedederror: {
1306
+ test (x) { return toStringTag(x) === 'QuotaExceededError'; },
1307
+ replace ({message, quota, requested}) {
1308
+ return {message, quota, requested};
1309
+ },
1310
+ revive ({message, quota, requested}) {
1311
+ /** @type {{quota?: number, requested?: number}} */
1312
+ const options = {};
1313
+ if (quota !== null && quota !== undefined) {
1314
+ options.quota = quota;
1315
+ }
1316
+ if (requested !== null && requested !== undefined) {
1317
+ options.requested = requested;
1318
+ }
1319
+ return new QuotaExceededError(message, options);
1320
+ }
1321
+ }
1322
+ };
1323
+
1299
1324
  /**
1300
1325
  * @type {import('typeson').TypeSpecSet}
1301
1326
  */
@@ -1587,6 +1612,29 @@ const userObject = {
1587
1612
  }
1588
1613
  };
1589
1614
 
1615
+ /* globals WebTransportError -- Newer API */
1616
+
1617
+ /**
1618
+ * @type {import('typeson').TypeSpecSet}
1619
+ */
1620
+ const webtransporterror = {
1621
+ webtransporterror: {
1622
+ test (x) { return toStringTag(x) === 'WebTransportError'; },
1623
+ // Note that we can't support the `source` property (defaults
1624
+ // to `stream` instead of `session`)
1625
+ replace ({message, streamErrorCode}) {
1626
+ return {message, streamErrorCode};
1627
+ },
1628
+ revive ({message, streamErrorCode}) {
1629
+ // TS lib still models the older two-argument
1630
+ // `(message, options)` form; browsers implement a single
1631
+ // `init` object (which also carries `message`).
1632
+ // @ts-expect-error - More recent API
1633
+ return new WebTransportError({message, streamErrorCode});
1634
+ }
1635
+ }
1636
+ };
1637
+
1590
1638
  /**
1591
1639
  * @type {import('typeson').Preset}
1592
1640
  */
@@ -1809,6 +1857,10 @@ const expObj = [
1809
1857
  /* c8 ignore next */
1810
1858
  typeof DOMException !== 'undefined' ? domexception : [],
1811
1859
  /* c8 ignore next */
1860
+ typeof QuotaExceededError !== 'undefined' ? quotaexceedederror : [],
1861
+ /* c8 ignore next */
1862
+ typeof WebTransportError !== 'undefined' ? webtransporterror : [],
1863
+ /* c8 ignore next */
1812
1864
  typeof DOMRect !== 'undefined' ? domrect : [],
1813
1865
  /* c8 ignore next */
1814
1866
  typeof DOMPoint !== 'undefined' ? dompoint : [],
@@ -1820,6 +1872,34 @@ const expObj = [
1820
1872
  typeof AudioData !== 'undefined' ? audiodata : []
1821
1873
  );
1822
1874
 
1875
+ /**
1876
+ * @param {BufferSource} buffer
1877
+ * @returns {boolean}
1878
+ */
1879
+ function isBufferDetached (buffer) {
1880
+ // Use the standard property if available
1881
+ // @ts-expect-error - More recent API
1882
+ if (typeof buffer.detached === 'boolean') {
1883
+ // @ts-expect-error - More recent API
1884
+ return buffer.detached;
1885
+ }
1886
+ /* c8 ignore next 14 -- Older browsers */
1887
+
1888
+ // Fallback check via byteLength and constructor test
1889
+ if (buffer.byteLength !== 0) {
1890
+ return false;
1891
+ }
1892
+
1893
+ try {
1894
+ // @ts-expect-error Ok
1895
+ // eslint-disable-next-line no-new -- Throwaway
1896
+ new Uint8Array(buffer);
1897
+ return false;
1898
+ } catch {
1899
+ return true;
1900
+ }
1901
+ }
1902
+
1823
1903
  /**
1824
1904
  * @type {import('typeson').Preset}
1825
1905
  */
@@ -1827,13 +1907,11 @@ const structuredCloningThrowing = expObj.concat({
1827
1907
  checkDataCloneException: {
1828
1908
  test (val) {
1829
1909
  // Should also throw with:
1830
- // 1. `IsDetachedBuffer` (a process not called within the
1831
- // ECMAScript spec)
1832
- // 2. `IsCallable` (covered by `typeof === 'function'` or a
1910
+ // 1. `IsCallable` (covered by `typeof === 'function'` or a
1833
1911
  // function's `toStringTag`)
1834
- // 3. internal slots besides [[Prototype]] or [[Extensible]] (e.g.,
1912
+ // 2. internal slots besides [[Prototype]] or [[Extensible]] (e.g.,
1835
1913
  // [[PromiseState]] or [[WeakMapData]])
1836
- // 4. exotic object (e.g., `Proxy`) (unless an `%ObjectPrototype%`
1914
+ // 3. exotic object (e.g., `Proxy`) (unless an `%ObjectPrototype%`
1837
1915
  // intrinsic object) (which does not have default
1838
1916
  // behavior for one or more of the essential internal methods
1839
1917
  // that are limited to the following for non-function objects
@@ -1875,6 +1953,23 @@ const structuredCloningThrowing = expObj.concat({
1875
1953
  // Also in Node `worker_threads` (currently experimental)
1876
1954
  'MessageChannel'
1877
1955
  ].includes(stringTag) ||
1956
+ // 1. `IsDetachedBuffer` (a process not called within the
1957
+ // ECMAScript spec)
1958
+ ([
1959
+ 'ArrayBuffer',
1960
+ 'DataView',
1961
+ 'Int8Array',
1962
+ 'Uint8Array',
1963
+ 'Uint8ClampedArray',
1964
+ 'Int16Array',
1965
+ 'Uint16Array',
1966
+ 'Int32Array',
1967
+ 'Uint32Array',
1968
+ 'Float32Array',
1969
+ 'Float64Array',
1970
+ 'BigInt64Array',
1971
+ 'BigUint64Array'
1972
+ ].includes(stringTag) && isBufferDetached(val)) ||
1878
1973
  /*
1879
1974
  // isClosed is no longer documented
1880
1975
  ((stringTag === 'Blob' || stringTag === 'File') &&
@@ -1912,5 +2007,5 @@ const universal = [
1912
2007
  // built-in into ecmasript standard.
1913
2008
  ];
1914
2009
 
1915
- export { i$1 as JSON_TYPES, Typeson, TypesonPromise, Undefined, arrayNonindexKeys, arraybuffer, audiodata, bigint, bigintObject, blob, expObj$1 as builtin, cloneable, cryptokey, dataview, date, domexception, dommatrix, dompoint, domquad, domrect, error, errors, escapeKeyPathComponent, file, filelist, getByKeyPath, getJSONType, hasConstructorOf, imagebitmap, imagedata, infinity, intlTypes, isObject, isPlainObject, isThenable, isUserObject, map, nan, negativeInfinity, negativeZero, nonbuiltinIgnore, postmessage, primitiveObjects, promise, regexp, resurrectable, set, setAtKeyPath, socketio, sparseUndefined, specialNumbers, expObj as structuredCloning, structuredCloningThrowing, symbol, toStringTag, typedArrays, typedArraysSocketIO as typedArraysSocketio, undef$1 as undef, undef as undefPreset, unescapeKeyPathComponent, universal, userObject };
2010
+ export { i$1 as JSON_TYPES, Typeson, TypesonPromise, Undefined, arrayNonindexKeys, arraybuffer, audiodata, bigint, bigintObject, blob, expObj$1 as builtin, cloneable, cryptokey, dataview, date, domexception, dommatrix, dompoint, domquad, domrect, error, errors, escapeKeyPathComponent, file, filelist, getByKeyPath, getJSONType, hasConstructorOf, imagebitmap, imagedata, infinity, intlTypes, isObject, isPlainObject, isThenable, isUserObject, map, nan, negativeInfinity, negativeZero, nonbuiltinIgnore, postmessage, primitiveObjects, promise, quotaexceedederror, regexp, resurrectable, set, setAtKeyPath, socketio, sparseUndefined, specialNumbers, expObj as structuredCloning, structuredCloningThrowing, symbol, toStringTag, typedArrays, typedArraysSocketIO as typedArraysSocketio, undef$1 as undef, undef as undefPreset, unescapeKeyPathComponent, universal, userObject, webtransporterror };
1916
2011
  //# sourceMappingURL=index.js.map