typeson-registry 14.6.1 → 14.7.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/dist/index.js CHANGED
@@ -1072,8 +1072,7 @@ const idbkeyrange = {
1072
1072
  };
1073
1073
 
1074
1074
  /* globals document, OffscreenCanvas, createImageBitmap -- Polyfills */
1075
- // `ImageBitmap` is browser / DOM specific. It also can only work
1076
- // same-domain (or CORS)
1075
+ // `ImageBitmap` can only work same-domain (or CORS) in the browser
1077
1076
 
1078
1077
 
1079
1078
  /**
@@ -1082,10 +1081,7 @@ const idbkeyrange = {
1082
1081
  const imagebitmap = {
1083
1082
  imagebitmap: {
1084
1083
  test (x) {
1085
- return toStringTag(x) === 'ImageBitmap' ||
1086
- // In Node, our polyfill sets the dataset on a canvas
1087
- // element as JSDom no longer allows overriding toStringTag
1088
- (x && x.dataset && x.dataset.toStringTag === 'ImageBitmap');
1084
+ return toStringTag(x) === 'ImageBitmap';
1089
1085
  },
1090
1086
  replace (bm) {
1091
1087
  const canvas = document.createElement('canvas');
@@ -1099,8 +1095,8 @@ const imagebitmap = {
1099
1095
  },
1100
1096
  revive (o) {
1101
1097
  const canvas = typeof OffscreenCanvas === 'undefined'
1098
+ /* c8 ignore next -- Older environments */
1102
1099
  ? document.createElement('canvas')
1103
- /* c8 ignore next -- Browser only */
1104
1100
  : new OffscreenCanvas(o.width, o.height);
1105
1101
  /*
1106
1102
  var req = new XMLHttpRequest();
@@ -1117,14 +1113,19 @@ const imagebitmap = {
1117
1113
  const img = document.createElement('img');
1118
1114
  // The onload is needed by some browsers per https://stackoverflow.com/a/4776378/271577
1119
1115
  img.addEventListener('load', function () {
1120
- ctx.drawImage(img, 0, 0);
1116
+ try {
1117
+ ctx.drawImage(img, 0, 0);
1118
+ } catch {
1119
+ // Issues on Node
1120
+ }
1121
1121
  });
1122
1122
  img.src = o.dataURL;
1123
+
1123
1124
  // Works in contexts allowing an `ImageBitmap` (We might use
1124
1125
  // `OffscreenCanvas.transferToBitmap` when supported)
1125
1126
  return typeof OffscreenCanvas === 'undefined'
1127
+ /* c8 ignore next 3 -- Older environments */
1126
1128
  ? canvas
1127
- /* c8 ignore next 3 -- Browser only */
1128
1129
  : /** @type {OffscreenCanvas} */ (
1129
1130
  canvas
1130
1131
  ).transferToImageBitmap();
@@ -2229,12 +2230,40 @@ const structuredCloningThrowing = expObj.concat({
2229
2230
  // WeakSet instances have an extra slot ([[WeakSetData]])
2230
2231
  // but not throwing in Chrome `postMessage`
2231
2232
  'WeakSet',
2233
+ // WeakRef instances have an extra slot
2234
+ // ([[WeakRefTarget]])
2235
+ 'WeakRef',
2236
+ // FinalizationRegistry instances have extra internal
2237
+ // slots (e.g., [[Cells]])
2238
+ 'FinalizationRegistry',
2239
+ // Generator objects have an extra slot
2240
+ // ([[GeneratorState]])
2241
+ 'Generator',
2242
+ // Async generator objects have an extra slot
2243
+ // ([[AsyncGeneratorState]])
2244
+ 'AsyncGenerator',
2245
+ // Built-in iterator result objects have internal slots
2246
+ // tied to the collection/string being iterated
2247
+ 'String Iterator', 'Array Iterator',
2248
+ 'Map Iterator', 'Set Iterator', 'RegExp String Iterator',
2249
+ // `Intl` objects (e.g., `Intl.Collator`) all have
2250
+ // internal slots and are not structured-cloneable
2251
+ 'Intl.Collator', 'Intl.DateTimeFormat',
2252
+ 'Intl.DisplayNames', 'Intl.DurationFormat',
2253
+ 'Intl.ListFormat', 'Intl.Locale', 'Intl.NumberFormat',
2254
+ 'Intl.PluralRules', 'Intl.RelativeTimeFormat',
2255
+ 'Intl.Segmenter',
2232
2256
 
2233
2257
  // HTML-SPECIFIC
2234
2258
  'Event',
2235
2259
  // Also in Node `worker_threads` (currently experimental)
2236
2260
  'MessageChannel',
2237
- 'MessagePort'
2261
+ 'MessagePort',
2262
+ // Streams are Transferable but not Serializable, so
2263
+ // cloning them (as opposed to transferring) throws
2264
+ 'ReadableStream', 'WritableStream', 'TransformStream',
2265
+ // Also Transferable but not Serializable
2266
+ 'OffscreenCanvas'
2238
2267
  ].includes(stringTag) ||
2239
2268
  // Node's native `worker_threads` `MessageChannel`/
2240
2269
  // `MessagePort` don't set `Symbol.toStringTag` per