@volter/tabnode 0.5.16 → 0.5.17

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.
@@ -88,6 +88,23 @@ export function markAsUntransferable(object: unknown): void {
88
88
  // No-op
89
89
  }
90
90
 
91
+ /**
92
+ * Node 22's `markAsUncloneable` and its query: an object so marked is refused
93
+ * by `structuredClone` and `postMessage`. undici's WebIDL layer marks every
94
+ * `CacheStorage`, `Request` and `Response` it makes, at construction, so a
95
+ * program that loads undici 7.x+ or 8.x died on `markAsUncloneable is not a
96
+ * function` before its first line. The mark is kept; this engine's message
97
+ * channels do not yet read it, so a marked object that is posted is copied
98
+ * rather than refused.
99
+ */
100
+ const uncloneable = new WeakSet<object>();
101
+ export function markAsUncloneable(object: unknown): void {
102
+ if (object !== null && (typeof object === 'object' || typeof object === 'function')) uncloneable.add(object as object);
103
+ }
104
+ export function isMarkedAsUncloneable(object: unknown): boolean {
105
+ return object !== null && (typeof object === 'object' || typeof object === 'function') && uncloneable.has(object as object);
106
+ }
107
+
91
108
  export function getEnvironmentData(key: unknown): unknown {
92
109
  return undefined;
93
110
  }
@@ -109,6 +126,8 @@ export default {
109
126
  receiveMessageOnPort,
110
127
  SHARE_ENV,
111
128
  markAsUntransferable,
129
+ markAsUncloneable,
130
+ isMarkedAsUncloneable,
112
131
  getEnvironmentData,
113
132
  setEnvironmentData,
114
133
  };