typeson-registry 14.4.0 → 14.5.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 (37) hide show
  1. package/dist/index.js +57 -11
  2. package/dist/index.js.map +1 -1
  3. package/dist/index.min.js +1 -1
  4. package/dist/index.min.js.map +1 -1
  5. package/dist/index.umd.cjs +56 -11
  6. package/dist/index.umd.cjs.map +1 -1
  7. package/dist/index.umd.min.cjs +1 -1
  8. package/dist/index.umd.min.cjs.map +1 -1
  9. package/dist/polyfills/AudioData.d.ts.map +1 -1
  10. package/dist/polyfills/EncodedAudioChunk.d.ts.map +1 -1
  11. package/dist/polyfills/EncodedVideoChunk.d.ts.map +1 -1
  12. package/dist/polyfills/VideoFrame.d.ts.map +1 -1
  13. package/dist/presets/structured-cloning-for-storage.umd.cjs +1 -1
  14. package/dist/presets/structured-cloning-for-storage.umd.cjs.map +1 -1
  15. package/dist/presets/structured-cloning-throwing.umd.cjs +1 -1
  16. package/dist/presets/structured-cloning-throwing.umd.cjs.map +1 -1
  17. package/dist/presets/structured-cloning.umd.cjs +1 -1
  18. package/dist/presets/structured-cloning.umd.cjs.map +1 -1
  19. package/dist/types/encodedaudiochunk.d.ts.map +1 -1
  20. package/dist/types/encodedaudiochunk.umd.cjs +1 -1
  21. package/dist/types/encodedaudiochunk.umd.cjs.map +1 -1
  22. package/dist/types/encodedvideochunk.d.ts.map +1 -1
  23. package/dist/types/encodedvideochunk.umd.cjs +1 -1
  24. package/dist/types/encodedvideochunk.umd.cjs.map +1 -1
  25. package/dist/types/imagedata.d.ts.map +1 -1
  26. package/dist/types/imagedata.umd.cjs +1 -1
  27. package/dist/types/imagedata.umd.cjs.map +1 -1
  28. package/dist/types/videoframe.d.ts.map +1 -1
  29. package/dist/types/videoframe.umd.cjs +1 -1
  30. package/dist/types/videoframe.umd.cjs.map +1 -1
  31. package/package.json +2 -2
  32. package/polyfills/AudioData.js +6 -1
  33. package/polyfills/EncodedAudioChunk.js +2 -1
  34. package/polyfills/EncodedVideoChunk.js +2 -1
  35. package/polyfills/VideoFrame.js +30 -7
  36. package/polyfills/index.cjs +45 -16
  37. package/polyfills/index.cjs.map +1 -1
package/dist/index.js CHANGED
@@ -764,9 +764,16 @@ const encodedaudiochunk = {
764
764
  return {type, timestamp, duration, data};
765
765
  },
766
766
  revive ({type, timestamp, duration, data}) {
767
- return new EncodedAudioChunk({
768
- type, timestamp, duration, data: new Uint8Array(data)
769
- });
767
+ // A browser's `EncodedAudioChunkInit` has no `duration`
768
+ // default and coerces an explicit `null`/`undefined` to `0`,
769
+ // so only pass it through when the source chunk actually
770
+ // had one (otherwise `duration` must round-trip as `null`).
771
+ /** @type {EncodedAudioChunkInit} */
772
+ const init = {type, timestamp, data: new Uint8Array(data)};
773
+ if (duration !== null && duration !== undefined) {
774
+ init.duration = duration;
775
+ }
776
+ return new EncodedAudioChunk(init);
770
777
  }
771
778
  }
772
779
  };
@@ -788,9 +795,16 @@ const encodedvideochunk = {
788
795
  return {type, timestamp, duration, data};
789
796
  },
790
797
  revive ({type, timestamp, duration, data}) {
791
- return new EncodedVideoChunk({
792
- type, timestamp, duration, data: new Uint8Array(data)
793
- });
798
+ // A browser's `EncodedVideoChunkInit` has no `duration`
799
+ // default and coerces an explicit `null`/`undefined` to `0`,
800
+ // so only pass it through when the source chunk actually
801
+ // had one (otherwise `duration` must round-trip as `null`).
802
+ /** @type {EncodedVideoChunkInit} */
803
+ const init = {type, timestamp, data: new Uint8Array(data)};
804
+ if (duration !== null && duration !== undefined) {
805
+ init.duration = duration;
806
+ }
807
+ return new EncodedVideoChunk(init);
794
808
  }
795
809
  }
796
810
  };
@@ -1132,16 +1146,39 @@ const imagedata = {
1132
1146
  imagedata: {
1133
1147
  test (x) { return toStringTag(x) === 'ImageData'; },
1134
1148
  replace (d) {
1149
+ const pixelFormat = toStringTag(d.data) === 'Float16Array'
1150
+ /* c8 ignore next -- Not yet supported in `canvas` */
1151
+ ? 'rgba-float16'
1152
+ : 'rgba-unorm8';
1135
1153
  return {
1136
1154
  // Ensure `length` gets preserved for revival
1137
1155
  array: [...d.data],
1138
1156
  width: d.width,
1139
- height: d.height
1157
+ height: d.height,
1158
+ pixelFormat,
1159
+ colorSpace: d.colorSpace
1140
1160
  };
1141
1161
  },
1142
1162
  revive (o) {
1163
+ const {array, width, height, colorSpace, pixelFormat} = o;
1164
+ /* c8 ignore next 12 -- Not yet supported in `canvas` */
1165
+ if (pixelFormat === 'rgba-float16') {
1166
+ return new ImageData(
1167
+ // @ts-expect-error -- Ok
1168
+ new Float16Array(array),
1169
+ width,
1170
+ height,
1171
+ {
1172
+ colorSpace,
1173
+ pixelFormat
1174
+ }
1175
+ );
1176
+ }
1143
1177
  return new ImageData(
1144
- new Uint8ClampedArray(o.array), o.width, o.height
1178
+ new Uint8ClampedArray(array), width, height, {
1179
+ colorSpace,
1180
+ pixelFormat
1181
+ }
1145
1182
  );
1146
1183
  }
1147
1184
  }
@@ -1760,10 +1797,19 @@ const videoframe = {
1760
1797
  format, codedWidth, codedHeight, timestamp, duration,
1761
1798
  visibleRect, displayWidth, displayHeight, colorSpace, data
1762
1799
  }) {
1763
- return new VideoFrame(new Uint8Array(data), {
1764
- format, codedWidth, codedHeight, timestamp, duration,
1800
+ // A browser's `VideoFrameBufferInit` has no `duration` default
1801
+ // and coerces an explicit `null`/`undefined` to `0`, so only
1802
+ // pass it through when the source frame actually had one
1803
+ // (otherwise `duration` must round-trip as `null`).
1804
+ /** @type {VideoFrameBufferInit} */
1805
+ const init = {
1806
+ format, codedWidth, codedHeight, timestamp,
1765
1807
  visibleRect, displayWidth, displayHeight, colorSpace
1766
- });
1808
+ };
1809
+ if (duration !== null && duration !== undefined) {
1810
+ init.duration = duration;
1811
+ }
1812
+ return new VideoFrame(new Uint8Array(data), init);
1767
1813
  }
1768
1814
  }
1769
1815
  };