typeson-registry 13.3.0 → 14.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 (89) hide show
  1. package/README.md +12 -2
  2. package/dist/index.d.cts +3 -0
  3. package/dist/index.d.cts.map +1 -0
  4. package/dist/index.d.ts +4 -1
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +115 -4
  7. package/dist/index.js.map +1 -1
  8. package/dist/index.min.js +2 -2
  9. package/dist/index.min.js.map +1 -1
  10. package/dist/index.umd.cjs +174 -3
  11. package/dist/index.umd.cjs.map +1 -1
  12. package/dist/index.umd.min.cjs +2 -2
  13. package/dist/index.umd.min.cjs.map +1 -1
  14. package/dist/polyfills/AudioData.d.ts +70 -0
  15. package/dist/polyfills/AudioData.d.ts.map +1 -0
  16. package/dist/polyfills/DOMMatrix.d.ts +43 -0
  17. package/dist/polyfills/DOMMatrix.d.ts.map +1 -0
  18. package/dist/polyfills/DOMMatrixReadOnly.d.ts +43 -0
  19. package/dist/polyfills/DOMMatrixReadOnly.d.ts.map +1 -0
  20. package/dist/polyfills/DOMPoint.d.ts +21 -0
  21. package/dist/polyfills/DOMPoint.d.ts.map +1 -0
  22. package/dist/polyfills/DOMPointReadOnly.d.ts +21 -0
  23. package/dist/polyfills/DOMPointReadOnly.d.ts.map +1 -0
  24. package/dist/polyfills/DOMQuad.d.ts +22 -0
  25. package/dist/polyfills/DOMQuad.d.ts.map +1 -0
  26. package/dist/polyfills/DOMRect.d.ts +25 -0
  27. package/dist/polyfills/DOMRect.d.ts.map +1 -0
  28. package/dist/polyfills/DOMRectReadOnly.d.ts +25 -0
  29. package/dist/polyfills/DOMRectReadOnly.d.ts.map +1 -0
  30. package/dist/polyfills/EncodedAudioChunk.d.ts +40 -0
  31. package/dist/polyfills/EncodedAudioChunk.d.ts.map +1 -0
  32. package/dist/polyfills/EncodedVideoChunk.d.ts +40 -0
  33. package/dist/polyfills/EncodedVideoChunk.d.ts.map +1 -0
  34. package/dist/polyfills/FileList.d.ts +21 -0
  35. package/dist/polyfills/FileList.d.ts.map +1 -0
  36. package/dist/polyfills/QuotaExceededError.d.ts +28 -0
  37. package/dist/polyfills/QuotaExceededError.d.ts.map +1 -0
  38. package/dist/polyfills/URL.d.ts +25 -0
  39. package/dist/polyfills/URL.d.ts.map +1 -0
  40. package/dist/polyfills/VideoFrame.d.ts +142 -0
  41. package/dist/polyfills/VideoFrame.d.ts.map +1 -0
  42. package/dist/polyfills/WebTransportError.d.ts +32 -0
  43. package/dist/polyfills/WebTransportError.d.ts.map +1 -0
  44. package/dist/polyfills/createImageBitmap.d.ts +14 -0
  45. package/dist/polyfills/createImageBitmap.d.ts.map +1 -0
  46. package/dist/polyfills/index.d.cts +3 -0
  47. package/dist/polyfills/index.d.cts.map +1 -0
  48. package/dist/polyfills/index.d.ts +16 -0
  49. package/dist/polyfills/index.d.ts.map +1 -0
  50. package/dist/presets/postmessage.d.ts.map +1 -1
  51. package/dist/presets/postmessage.umd.cjs.map +1 -1
  52. package/dist/presets/structured-cloning-throwing.umd.cjs +1 -1
  53. package/dist/presets/structured-cloning-throwing.umd.cjs.map +1 -1
  54. package/dist/presets/structured-cloning.d.ts.map +1 -1
  55. package/dist/presets/structured-cloning.umd.cjs +1 -1
  56. package/dist/presets/structured-cloning.umd.cjs.map +1 -1
  57. package/dist/types/encodedaudiochunk.d.ts +6 -0
  58. package/dist/types/encodedaudiochunk.d.ts.map +1 -0
  59. package/dist/types/encodedaudiochunk.umd.cjs +2 -0
  60. package/dist/types/encodedaudiochunk.umd.cjs.map +1 -0
  61. package/dist/types/encodedvideochunk.d.ts +6 -0
  62. package/dist/types/encodedvideochunk.d.ts.map +1 -0
  63. package/dist/types/encodedvideochunk.umd.cjs +2 -0
  64. package/dist/types/encodedvideochunk.umd.cjs.map +1 -0
  65. package/dist/types/videoframe.d.ts +6 -0
  66. package/dist/types/videoframe.d.ts.map +1 -0
  67. package/dist/types/videoframe.umd.cjs +4 -0
  68. package/dist/types/videoframe.umd.cjs.map +1 -0
  69. package/package.json +16 -8
  70. package/polyfills/AudioData.js +173 -0
  71. package/polyfills/DOMMatrix.js +55 -0
  72. package/polyfills/DOMMatrixReadOnly.js +55 -0
  73. package/polyfills/DOMPoint.js +29 -0
  74. package/polyfills/DOMPointReadOnly.js +30 -0
  75. package/polyfills/DOMQuad.js +31 -0
  76. package/polyfills/DOMRect.js +31 -0
  77. package/polyfills/DOMRectReadOnly.js +31 -0
  78. package/polyfills/EncodedAudioChunk.js +74 -0
  79. package/polyfills/EncodedVideoChunk.js +74 -0
  80. package/polyfills/FileList.js +51 -0
  81. package/polyfills/QuotaExceededError.js +53 -0
  82. package/polyfills/VideoFrame.js +350 -0
  83. package/polyfills/WebTransportError.js +44 -0
  84. package/polyfills/createImageBitmap.js +22 -0
  85. package/polyfills/{createObjectURL.cjs → index.cjs} +1474 -4
  86. package/polyfills/index.cjs.map +1 -0
  87. package/polyfills/index.js +15 -0
  88. package/polyfills/createObjectURL.cjs.map +0 -1
  89. /package/polyfills/{createObjectURL.js → URL.js} +0 -0
package/README.md CHANGED
@@ -25,7 +25,7 @@ Note that our `URL.createObjectURL` polyfill expects a global
25
25
  which can handle `data:` URLs). For Node, you can add it like this:
26
26
 
27
27
  ```js
28
- const {createObjectURL} = require('typeson-registry/polyfills/createObjectURL.cjs');
28
+ import {createObjectURL} from 'typeson-registry/polyfills';
29
29
 
30
30
  URL.createObjectURL = createObjectURL;
31
31
  ```
@@ -33,11 +33,16 @@ URL.createObjectURL = createObjectURL;
33
33
  We have not added `jsdom` as a dependency, but it is required if this
34
34
  polyfill is used.
35
35
 
36
+ Also exported: `QuotaExceededError`, `WebTransportError`, `AudioData`, `EncodedAudioChunk`,
37
+ `EncodedVideoChunk`, `VideoFrame`, `DOMRect`,
38
+ `DOMRectReadOnly`, `DOMPoint`, `DOMPointReadOnly`, `DOMQuad`, `DOMMatrix`, `DOMMatrixReadOnly`,
39
+ `createImageBitmap`, `createObjectURL`, `revokeObjectURL`, `xmlHttpRequestOverrideMimeType`
40
+
36
41
  Besides the polyfills for `file` or `blob`, the `structuredCloningThrowing`
37
42
  preset also needs a global `DOMException` polyfill.
38
43
 
39
44
  The `filelist` type, in addition to the polyfills for `file`, will need
40
- a `FileList` polyfill (including a `FileList` string tag).
45
+ a `FileList` polyfill (including a `FileList` string tag) like the one provided.
41
46
 
42
47
  The `imagebitmap` type requires a global `createImageBitmap` polyfill (and
43
48
  an `ImageBitmap` polyfill (including an `ImageBitmap` string tag).
@@ -233,6 +238,8 @@ Note that the type name corresponds to the file name in the following manner:
233
238
  - `domquad`
234
239
  - `domrect`
235
240
  - `domrectreadonly`
241
+ - `encodedaudiochunk`
242
+ - `encodedvideochunk`
236
243
  - `error.js` (`Error`) and `errors.js` (`TypeError`, `RangeError`, `SyntaxError`, `ReferenceError`, `EvalError`, `URIError`, `InternalError`) - These
237
244
  provide a means of resurrecting error object across cloning boundaries
238
245
  (since they are not otherwise treated as cloneable by the Structured
@@ -276,6 +283,9 @@ Note that the type name corresponds to the file name in the following manner:
276
283
  - `userObjects` - Allows for inherited objects but ensures the prototype chain
277
284
  inherits from `Object` (or `null`). Should be low priority if one is
278
285
  matching other objects as it will readily match many objects.
286
+ - `videoframe` - Reconstructs a `VideoFrame` from its raw pixel data (via
287
+ `allocationSize`/`copyTo`); has an async encapsulation only, as
288
+ `VideoFrame#copyTo` is itself asynchronous.
279
289
  - `webtransporterror`
280
290
 
281
291
  ### Presets
@@ -0,0 +1,3 @@
1
+ import * as index from './index.js';
2
+ export = index;
3
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../index.cts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AAEpC,SAAS,KAAK,CAAC"}
package/dist/index.d.ts CHANGED
@@ -13,6 +13,8 @@ import dommatrix from './types/dommatrix.js';
13
13
  import dompoint from './types/dompoint.js';
14
14
  import domquad from './types/domquad.js';
15
15
  import domrect from './types/domrect.js';
16
+ import encodedaudiochunk from './types/encodedaudiochunk.js';
17
+ import encodedvideochunk from './types/encodedvideochunk.js';
16
18
  import error from './types/error.js';
17
19
  import errors from './types/errors.js';
18
20
  import file from './types/file.js';
@@ -37,6 +39,7 @@ import typedArraysSocketio from './types/typed-arrays-socketio.js';
37
39
  import typedArrays from './types/typed-arrays.js';
38
40
  import undef from './types/undef.js';
39
41
  import userObject from './types/user-object.js';
42
+ import videoframe from './types/videoframe.js';
40
43
  import webtransporterror from './types/webtransporterror.js';
41
44
  import arrayNonindexKeys from './presets/array-nonindex-keys.js';
42
45
  import builtin from './presets/builtin.js';
@@ -48,5 +51,5 @@ import structuredCloningThrowing from './presets/structured-cloning-throwing.js'
48
51
  import structuredCloning from './presets/structured-cloning.js';
49
52
  import undefPreset from './presets/undef.js';
50
53
  import universal from './presets/universal.js';
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 };
54
+ export { arraybuffer, audiodata, bigintObject, bigint, blob, cloneable, cryptokey, dataview, date, domexception, dommatrix, dompoint, domquad, domrect, encodedaudiochunk, encodedvideochunk, error, errors, file, filelist, imagebitmap, imagedata, infinity, intlTypes, map, nan, negativeInfinity, negativeZero, nonbuiltinIgnore, primitiveObjects, promise, quotaexceedederror, regexp, resurrectable, set, symbol, typedArraysSocketio, typedArrays, undef, userObject, videoframe, webtransporterror, arrayNonindexKeys, builtin, postmessage, socketio, sparseUndefined, specialNumbers, structuredCloningThrowing, structuredCloning, undefPreset, universal };
52
55
  //# 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;+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"}
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;8BACV,8BAA8B;8BAC9B,8BAA8B;kBAC1C,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;uBACxB,uBAAuB;8BAChB,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
@@ -747,6 +747,54 @@ function create$3 (Ctor) {
747
747
  };
748
748
  }
749
749
 
750
+ /* globals EncodedAudioChunk -- Polyfills */
751
+
752
+ /**
753
+ * @type {import('typeson').TypeSpecSet}
754
+ */
755
+ const encodedaudiochunk = {
756
+ encodedaudiochunk: {
757
+ test (x) {
758
+ return toStringTag(x) === 'EncodedAudioChunk';
759
+ },
760
+ replace (chunk) {
761
+ const {type, timestamp, duration, byteLength} = chunk;
762
+ const data = new ArrayBuffer(byteLength);
763
+ chunk.copyTo(data);
764
+ return {type, timestamp, duration, data};
765
+ },
766
+ revive ({type, timestamp, duration, data}) {
767
+ return new EncodedAudioChunk({
768
+ type, timestamp, duration, data: new Uint8Array(data)
769
+ });
770
+ }
771
+ }
772
+ };
773
+
774
+ /* globals EncodedVideoChunk -- Polyfills */
775
+
776
+ /**
777
+ * @type {import('typeson').TypeSpecSet}
778
+ */
779
+ const encodedvideochunk = {
780
+ encodedvideochunk: {
781
+ test (x) {
782
+ return toStringTag(x) === 'EncodedVideoChunk';
783
+ },
784
+ replace (chunk) {
785
+ const {type, timestamp, duration, byteLength} = chunk;
786
+ const data = new ArrayBuffer(byteLength);
787
+ chunk.copyTo(data);
788
+ return {type, timestamp, duration, data};
789
+ },
790
+ revive ({type, timestamp, duration, data}) {
791
+ return new EncodedVideoChunk({
792
+ type, timestamp, duration, data: new Uint8Array(data)
793
+ });
794
+ }
795
+ }
796
+ };
797
+
750
798
  /**
751
799
  * @type {import('typeson').TypeSpecSet}
752
800
  */
@@ -1612,6 +1660,62 @@ const userObject = {
1612
1660
  }
1613
1661
  };
1614
1662
 
1663
+ /* globals VideoFrame -- Polyfills */
1664
+
1665
+ /**
1666
+ * @type {import('typeson').TypeSpecSet}
1667
+ */
1668
+ const videoframe = {
1669
+ videoframe: {
1670
+ test (x) {
1671
+ return toStringTag(x) === 'VideoFrame';
1672
+ },
1673
+ replaceAsync (frame) {
1674
+ return new TypesonPromise(async (resolve, reject) => {
1675
+ try {
1676
+ const {
1677
+ format, codedWidth, codedHeight, timestamp, duration,
1678
+ visibleRect, displayWidth, displayHeight, colorSpace
1679
+ } = frame;
1680
+
1681
+ const data = new ArrayBuffer(frame.allocationSize());
1682
+ await frame.copyTo(data);
1683
+
1684
+ resolve({
1685
+ format, codedWidth, codedHeight, timestamp, duration,
1686
+ visibleRect: {
1687
+ x: visibleRect.x,
1688
+ y: visibleRect.y,
1689
+ width: visibleRect.width,
1690
+ height: visibleRect.height
1691
+ },
1692
+ displayWidth, displayHeight,
1693
+ colorSpace: {
1694
+ primaries: colorSpace.primaries,
1695
+ transfer: colorSpace.transfer,
1696
+ matrix: colorSpace.matrix,
1697
+ fullRange: colorSpace.fullRange
1698
+ },
1699
+ data
1700
+ });
1701
+ /* c8 ignore next 3 -- How to simulate? */
1702
+ } catch (err) {
1703
+ reject(err);
1704
+ }
1705
+ });
1706
+ },
1707
+ revive ({
1708
+ format, codedWidth, codedHeight, timestamp, duration,
1709
+ visibleRect, displayWidth, displayHeight, colorSpace, data
1710
+ }) {
1711
+ return new VideoFrame(new Uint8Array(data), {
1712
+ format, codedWidth, codedHeight, timestamp, duration,
1713
+ visibleRect, displayWidth, displayHeight, colorSpace
1714
+ });
1715
+ }
1716
+ }
1717
+ };
1718
+
1615
1719
  /* globals WebTransportError -- Newer API */
1616
1720
 
1617
1721
  /**
@@ -1763,8 +1867,9 @@ clone algorithm). This algorithm supports all built-in types as well as many
1763
1867
  DOM types. Therefore, only types that are not included in the structured clone
1764
1868
  algorithm need to be registered, which is:
1765
1869
 
1766
- * Error
1767
- * Specific Errors like SyntaxError, TypeError, etc.
1870
+ * Error (now included in structured cloning)
1871
+ * Specific Errors like SyntaxError, TypeError, etc. (now included in structured
1872
+ * cloning)
1768
1873
  * Any custom type you want to send across window- or worker boundraries
1769
1874
 
1770
1875
  This preset will only include the Error types and you can register your
@@ -1869,7 +1974,13 @@ const expObj = [
1869
1974
  /* c8 ignore next */
1870
1975
  typeof DOMMatrix !== 'undefined' ? dommatrix : [],
1871
1976
  /* c8 ignore next */
1872
- typeof AudioData !== 'undefined' ? audiodata : []
1977
+ typeof AudioData !== 'undefined' ? audiodata : [],
1978
+ /* c8 ignore next */
1979
+ typeof EncodedAudioChunk !== 'undefined' ? encodedaudiochunk : [],
1980
+ /* c8 ignore next */
1981
+ typeof EncodedVideoChunk !== 'undefined' ? encodedvideochunk : [],
1982
+ /* c8 ignore next */
1983
+ typeof VideoFrame !== 'undefined' ? videoframe : []
1873
1984
  );
1874
1985
 
1875
1986
  /**
@@ -2007,5 +2118,5 @@ const universal = [
2007
2118
  // built-in into ecmasript standard.
2008
2119
  ];
2009
2120
 
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 };
2121
+ 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, encodedaudiochunk, encodedvideochunk, 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, videoframe, webtransporterror };
2011
2122
  //# sourceMappingURL=index.js.map