typeson-registry 14.2.1 → 14.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.
@@ -3225,7 +3225,21 @@
3225
3225
  // HTML-SPECIFIC
3226
3226
  'Event',
3227
3227
  // Also in Node `worker_threads` (currently experimental)
3228
- 'MessageChannel'].includes(stringTag) ||
3228
+ 'MessageChannel', 'MessagePort'].includes(stringTag) ||
3229
+ // Node's native `worker_threads` `MessageChannel`/
3230
+ // `MessagePort` don't set `Symbol.toStringTag` per
3231
+ // https://github.com/nodejs/node/issues/65527
3232
+ // (verified directly:
3233
+ // `{}.toString.call(new MessageChannel())` is
3234
+ // `"[object Object]"`, and `.port1`'s is
3235
+ // `"[object EventTarget]"`, its own base class), so the
3236
+ // `stringTag` check above can't catch them there; a real
3237
+ // browser's `MessagePort`/`MessageChannel` already match
3238
+ // via `stringTag` (or, for `MessagePort`, would need its
3239
+ // own `stringTag` entry if ever seen failing to match) --
3240
+ // this is purely a fallback for environments (like Node)
3241
+ // that don't set the tag.
3242
+ val && val.constructor && ['MessageChannel', 'MessagePort'].includes(val.constructor.name) ||
3229
3243
  // 1. `IsDetachedBuffer` (a process not called within the
3230
3244
  // ECMAScript spec)
3231
3245
  ['ArrayBuffer', 'DataView', 'Int8Array', 'Uint8Array', 'Uint8ClampedArray', 'Int16Array', 'Uint16Array', 'Int32Array', 'Uint32Array', 'Float32Array', 'Float64Array', 'BigInt64Array', 'BigUint64Array'].includes(stringTag) && isBufferDetached(val) || (
@@ -3245,6 +3259,27 @@
3245
3259
  }
3246
3260
  });
3247
3261
 
3262
+ /**
3263
+ * @type {import('typeson').Preset}
3264
+ */
3265
+ var structuredCloningForStorage = structuredCloningThrowing.concat({
3266
+ checkSharedArrayBufferException: {
3267
+ test: function test(val) {
3268
+ // Per https://webidl.spec.whatwg.org/#idl-SharedArrayBuffer ,
3269
+ // `SharedArrayBuffer` is a structured-cloneable *transferable*
3270
+ // type only for `postMessage`-style contexts (with
3271
+ // `crossOriginIsolated`); storage-oriented consumers of the
3272
+ // structured clone algorithm (e.g. IndexedDB) reject it
3273
+ // outright instead, so this isn't part of the more general
3274
+ // `structuredCloningThrowing` preset this one builds on.
3275
+ if ({}.toString.call(val).slice(8, -1) === 'SharedArrayBuffer') {
3276
+ throw new DOMException('The object cannot be cloned.', 'DataCloneError');
3277
+ }
3278
+ return false;
3279
+ }
3280
+ }
3281
+ });
3282
+
3248
3283
  /**
3249
3284
  * @type {import('typeson').Preset}
3250
3285
  */
@@ -3313,6 +3348,7 @@
3313
3348
  exports.sparseUndefined = sparseUndefined;
3314
3349
  exports.specialNumbers = specialNumbers;
3315
3350
  exports.structuredCloning = expObj;
3351
+ exports.structuredCloningForStorage = structuredCloningForStorage;
3316
3352
  exports.structuredCloningThrowing = structuredCloningThrowing;
3317
3353
  exports.symbol = symbol;
3318
3354
  exports.toStringTag = toStringTag;