@mittwald/flow-remote-core 0.2.0-alpha.1032 → 0.2.0-alpha.1034

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 (74) hide show
  1. package/dist/js/_virtual/_rolldown/runtime.mjs +13 -0
  2. package/dist/js/index-node.mjs +21 -17
  3. package/dist/js/index-node.mjs.map +1 -1
  4. package/dist/js/index.mjs +24 -16
  5. package/dist/js/index.mjs.map +1 -1
  6. package/dist/js/node_modules/.pnpm/@quilted_events@2.1.5/node_modules/@quilted/events/build/esm/abort/NestedAbortController.mjs +33 -36
  7. package/dist/js/node_modules/.pnpm/@quilted_events@2.1.5/node_modules/@quilted/events/build/esm/abort/NestedAbortController.mjs.map +1 -1
  8. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/Thread.mjs +167 -225
  9. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/Thread.mjs.map +1 -1
  10. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/constants.mjs +6 -9
  11. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/constants.mjs.map +1 -1
  12. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/errors.mjs +9 -7
  13. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/errors.mjs.map +1 -1
  14. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/functions/ThreadFunctionsAutomatic.mjs +68 -67
  15. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/functions/ThreadFunctionsAutomatic.mjs.map +1 -1
  16. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/nanoid.mjs +8 -8
  17. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/nanoid.mjs.map +1 -1
  18. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/serialization/ThreadSerializationStructuredClone.mjs +130 -210
  19. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/serialization/ThreadSerializationStructuredClone.mjs.map +1 -1
  20. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/serialization/shared.mjs +8 -6
  21. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/serialization/shared.mjs.map +1 -1
  22. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/ThreadIframe.mjs +152 -159
  23. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/ThreadIframe.mjs.map +1 -1
  24. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/ThreadNestedIframe.mjs +76 -84
  25. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/ThreadNestedIframe.mjs.map +1 -1
  26. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/window/ThreadNestedWindow.mjs +117 -137
  27. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/window/ThreadNestedWindow.mjs.map +1 -1
  28. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/window/ThreadWindow.mjs +189 -208
  29. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/window/ThreadWindow.mjs.map +1 -1
  30. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/window/shared.mjs +6 -4
  31. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/window/shared.mjs.map +1 -1
  32. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/transfer.mjs +12 -13
  33. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/transfer.mjs.map +1 -1
  34. package/dist/js/packages/remote-core/src/connection/connectHostRenderRoot.mjs +51 -61
  35. package/dist/js/packages/remote-core/src/connection/connectHostRenderRoot.mjs.map +1 -1
  36. package/dist/js/packages/remote-core/src/connection/connectRemoteIframe.mjs +73 -101
  37. package/dist/js/packages/remote-core/src/connection/connectRemoteIframe.mjs.map +1 -1
  38. package/dist/js/packages/remote-core/src/connection/index.mjs +4 -0
  39. package/dist/js/packages/remote-core/src/connection/types.mjs +13 -11
  40. package/dist/js/packages/remote-core/src/connection/types.mjs.map +1 -1
  41. package/dist/js/packages/remote-core/src/error.mjs +10 -8
  42. package/dist/js/packages/remote-core/src/error.mjs.map +1 -1
  43. package/dist/js/packages/remote-core/src/events/remoteEvents.mjs +14 -16
  44. package/dist/js/packages/remote-core/src/events/remoteEvents.mjs.map +1 -1
  45. package/dist/js/packages/remote-core/src/ext-bridge/getWithMergedHostConfig.mjs +10 -8
  46. package/dist/js/packages/remote-core/src/ext-bridge/getWithMergedHostConfig.mjs.map +1 -1
  47. package/dist/js/packages/remote-core/src/ext-bridge/implementation.mjs +8 -12
  48. package/dist/js/packages/remote-core/src/ext-bridge/implementation.mjs.map +1 -1
  49. package/dist/js/packages/remote-core/src/serialization/FlowThreadSerialization.mjs +49 -61
  50. package/dist/js/packages/remote-core/src/serialization/FlowThreadSerialization.mjs.map +1 -1
  51. package/dist/js/packages/remote-core/src/serialization/Serializer.mjs +31 -31
  52. package/dist/js/packages/remote-core/src/serialization/Serializer.mjs.map +1 -1
  53. package/dist/js/packages/remote-core/src/serialization/index.mjs +10 -0
  54. package/dist/js/packages/remote-core/src/serialization/serializers/dataTransferText.mjs +20 -21
  55. package/dist/js/packages/remote-core/src/serialization/serializers/dataTransferText.mjs.map +1 -1
  56. package/dist/js/packages/remote-core/src/serialization/serializers/date.mjs +13 -14
  57. package/dist/js/packages/remote-core/src/serialization/serializers/date.mjs.map +1 -1
  58. package/dist/js/packages/remote-core/src/serialization/serializers/file.mjs +27 -28
  59. package/dist/js/packages/remote-core/src/serialization/serializers/file.mjs.map +1 -1
  60. package/dist/js/packages/remote-core/src/serialization/serializers/fileList.mjs +18 -22
  61. package/dist/js/packages/remote-core/src/serialization/serializers/fileList.mjs.map +1 -1
  62. package/dist/js/packages/remote-core/src/serialization/serializers/formData.mjs +27 -34
  63. package/dist/js/packages/remote-core/src/serialization/serializers/formData.mjs.map +1 -1
  64. package/dist/js/packages/remote-core/src/serialization/serializers/index.mjs +23 -7
  65. package/dist/js/packages/remote-core/src/serialization/serializers/index.mjs.map +1 -1
  66. package/dist/js/packages/remote-core/src/serialization/serializers/passwordPolicy.mjs +13 -14
  67. package/dist/js/packages/remote-core/src/serialization/serializers/passwordPolicy.mjs.map +1 -1
  68. package/dist/js/packages/remote-core/src/shim.mjs +32 -15
  69. package/dist/js/packages/remote-core/src/shim.mjs.map +1 -1
  70. package/dist/types/index-node.d.ts.map +1 -1
  71. package/dist/types/index.d.ts.map +1 -1
  72. package/dist/types/shim.d.ts +13 -1
  73. package/dist/types/shim.d.ts.map +1 -1
  74. package/package.json +9 -11
@@ -1,212 +1,132 @@
1
- import { TRANSFERABLE, SERIALIZE_METHOD } from '../constants.mjs';
2
- import { isIterator, isBasicObject } from './shared.mjs';
3
-
4
- const FUNCTION = '_@f';
5
- const ASYNC_ITERATOR = '_@i';
6
-
1
+ import { SERIALIZE_METHOD, TRANSFERABLE } from "../constants.mjs";
2
+ import { isBasicObject, isIterator } from "./shared.mjs";
3
+ //#region ../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/serialization/ThreadSerializationStructuredClone.mjs
4
+ var FUNCTION = "_@f";
5
+ var ASYNC_ITERATOR = "_@i";
7
6
  /**
8
- * A thread encoder that can transfer supports a wide variety of JavaScript types by
9
- * converting them to a format that the [`structuredClone`](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm)
10
- * algorithm can process. This
11
- *
12
- * Additionally, this encoder will convert functions into a JSON-friendly representation.
13
- * These functions will use a manual memory management technique to ensure they can be
14
- * garbage collected by default, but can be configured to use a `WeakRef`-based automatic
15
- * memory management system by setting the `garbageCollection: 'weak-ref'` option.
16
- */
17
- class ThreadSerializationStructuredClone {
18
- #customSerializer;
19
- #customDeserializer;
20
-
21
- constructor(options) {
22
- this.#customSerializer = options?.serialize;
23
- this.#customDeserializer = options?.deserialize;
24
- }
25
-
26
- /**
27
- * Serializes a value into a structured cloning-compatible format that can be transferred between threads.
28
- */
29
- async serialize(value, thread, transferable) {
30
- return this.#serializeInternal(value, thread, transferable);
31
- }
32
-
33
- async #serializeInternal(value, thread, transferable, seen = new Map(), isApplyingDefault = false) {
34
- if (value == null) return value;
35
- if (seen.has(value)) return seen.get(value);
36
-
37
- // Prevent circular references
38
- seen.set(value, undefined);
39
-
40
- if (typeof value === 'object') {
41
- if (this.#customSerializer && !isApplyingDefault) {
42
- const customValue = await this.#customSerializer(
43
- value,
44
- (value) => this.#serializeInternal(value, thread, transferable, seen, true),
45
- thread,
46
- transferable,
47
- );
48
-
49
- if (customValue !== undefined) {
50
- seen.set(value, customValue);
51
- return customValue;
52
- }
53
- }
54
-
55
- if (value[TRANSFERABLE]) {
56
- transferable?.push(value);
57
- seen.set(value, value);
58
- return value;
59
- }
60
-
61
- const serializeValue = (value) => {
62
- return this.#serializeInternal(value, thread, transferable, seen);
63
- };
64
-
65
- if (typeof value[SERIALIZE_METHOD] === 'function') {
66
- const result = await value[SERIALIZE_METHOD]({
67
- serialize: serializeValue,
68
- });
69
-
70
- seen.set(value, result);
71
- return result;
72
- }
73
-
74
- if (Array.isArray(value)) {
75
- const result = await Promise.all(value.map((item) => serializeValue(item)));
76
- seen.set(value, result);
77
- return result;
78
- }
79
-
80
- if (value instanceof Map) {
81
- const entries = await Promise.all(
82
- [...value.entries()].map(async ([key, value]) => {
83
- return [await serializeValue(key), await serializeValue(value)];
84
- }),
85
- );
86
-
87
- const result = new Map(entries);
88
- seen.set(value, result);
89
- return result;
90
- }
91
-
92
- if (value instanceof Set) {
93
- const entries = await Promise.all(
94
- [...value].map((entry) => serializeValue(entry)),
95
- );
96
-
97
- const result = new Set(entries);
98
- seen.set(value, result);
99
- return result;
100
- }
101
-
102
- const valueIsIterator = isIterator(value);
103
-
104
- if (isBasicObject(value) || valueIsIterator) {
105
- const result = {};
106
-
107
- for (const key of Object.keys(value)) {
108
- result[key] = await serializeValue(value[key]);
109
- }
110
-
111
- if (valueIsIterator) {
112
- result.next ??= await serializeValue(value.next.bind(value));
113
- result.return ??= await serializeValue(value.return.bind(value));
114
- result.throw ??= await serializeValue(value.throw.bind(value));
115
- result[ASYNC_ITERATOR] = true;
116
- }
117
-
118
- seen.set(value, result);
119
- return result;
120
- }
121
- }
122
-
123
- if (typeof value === 'function') {
124
- const serialized = thread.functions.serialize(value, thread, transferable);
125
- const result = { [FUNCTION]: serialized };
126
-
127
- seen.set(value, result);
128
- return result;
129
- }
130
-
131
- seen.set(value, value);
132
- return value;
133
- }
134
-
135
- /**
136
- * Deserializes a structured cloning-compatible value from another thread.
137
- */
138
- async deserialize(value, thread) {
139
- return this.#deserializeInternal(value, thread);
140
- }
141
-
142
- async #deserializeInternal(value, thread, isApplyingDefault = false) {
143
- if (value == null) return value;
144
-
145
- if (typeof value === 'object') {
146
- if (this.#customDeserializer && !isApplyingDefault) {
147
- const customValue = await this.#customDeserializer(
148
- value,
149
- (value) => this.#deserializeInternal(value, thread, true),
150
- thread,
151
- );
152
-
153
- if (customValue !== undefined) {
154
- return customValue;
155
- }
156
- }
157
-
158
- if (value == null) {
159
- return value;
160
- }
161
-
162
- if (Array.isArray(value)) {
163
- return Promise.all(value.map((value) => this.#deserializeInternal(value, thread)));
164
- }
165
-
166
- if (value instanceof Map) {
167
- const entries = await Promise.all(
168
- [...value].map(async ([key, value]) => [
169
- await this.#deserializeInternal(key, thread),
170
- await this.#deserializeInternal(value, thread),
171
- ]),
172
- );
173
-
174
- return new Map(entries);
175
- }
176
-
177
- if (value instanceof Set) {
178
- const entries = await Promise.all(
179
- [...value].map((entry) => this.#deserializeInternal(entry, thread)),
180
- );
181
-
182
- return new Set(entries);
183
- }
184
-
185
- if (FUNCTION in value) {
186
- const func = thread.functions.deserialize(value[FUNCTION], thread);
187
- return func;
188
- }
189
-
190
- if (!isBasicObject(value)) {
191
- return value;
192
- }
193
-
194
- const result = {};
195
-
196
- for (const key of Object.keys(value)) {
197
- if (key === ASYNC_ITERATOR) {
198
- result[Symbol.asyncIterator] = () => result;
199
- } else {
200
- result[key] = await this.#deserializeInternal(value[key], thread);
201
- }
202
- }
203
-
204
- return result;
205
- }
206
-
207
- return value;
208
- }
209
- }
210
-
7
+ * A thread encoder that can transfer supports a wide variety of JavaScript types by
8
+ * converting them to a format that the [`structuredClone`](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm)
9
+ * algorithm can process. This
10
+ *
11
+ * Additionally, this encoder will convert functions into a JSON-friendly representation.
12
+ * These functions will use a manual memory management technique to ensure they can be
13
+ * garbage collected by default, but can be configured to use a `WeakRef`-based automatic
14
+ * memory management system by setting the `garbageCollection: 'weak-ref'` option.
15
+ */
16
+ var ThreadSerializationStructuredClone = class {
17
+ #customSerializer;
18
+ #customDeserializer;
19
+ constructor(options) {
20
+ this.#customSerializer = options?.serialize;
21
+ this.#customDeserializer = options?.deserialize;
22
+ }
23
+ /**
24
+ * Serializes a value into a structured cloning-compatible format that can be transferred between threads.
25
+ */
26
+ async serialize(value, thread, transferable) {
27
+ return this.#serializeInternal(value, thread, transferable);
28
+ }
29
+ async #serializeInternal(value, thread, transferable, seen = /* @__PURE__ */ new Map(), isApplyingDefault = false) {
30
+ if (value == null) return value;
31
+ if (seen.has(value)) return seen.get(value);
32
+ seen.set(value, void 0);
33
+ if (typeof value === "object") {
34
+ if (this.#customSerializer && !isApplyingDefault) {
35
+ const customValue = await this.#customSerializer(value, (value) => this.#serializeInternal(value, thread, transferable, seen, true), thread, transferable);
36
+ if (customValue !== void 0) {
37
+ seen.set(value, customValue);
38
+ return customValue;
39
+ }
40
+ }
41
+ if (value[TRANSFERABLE]) {
42
+ transferable?.push(value);
43
+ seen.set(value, value);
44
+ return value;
45
+ }
46
+ const serializeValue = (value) => {
47
+ return this.#serializeInternal(value, thread, transferable, seen);
48
+ };
49
+ if (typeof value[SERIALIZE_METHOD] === "function") {
50
+ const result = await value[SERIALIZE_METHOD]({ serialize: serializeValue });
51
+ seen.set(value, result);
52
+ return result;
53
+ }
54
+ if (Array.isArray(value)) {
55
+ const result = await Promise.all(value.map((item) => serializeValue(item)));
56
+ seen.set(value, result);
57
+ return result;
58
+ }
59
+ if (value instanceof Map) {
60
+ const entries = await Promise.all([...value.entries()].map(async ([key, value]) => {
61
+ return [await serializeValue(key), await serializeValue(value)];
62
+ }));
63
+ const result = new Map(entries);
64
+ seen.set(value, result);
65
+ return result;
66
+ }
67
+ if (value instanceof Set) {
68
+ const entries = await Promise.all([...value].map((entry) => serializeValue(entry)));
69
+ const result = new Set(entries);
70
+ seen.set(value, result);
71
+ return result;
72
+ }
73
+ const valueIsIterator = isIterator(value);
74
+ if (isBasicObject(value) || valueIsIterator) {
75
+ const result = {};
76
+ for (const key of Object.keys(value)) result[key] = await serializeValue(value[key]);
77
+ if (valueIsIterator) {
78
+ result.next ??= await serializeValue(value.next.bind(value));
79
+ result.return ??= await serializeValue(value.return.bind(value));
80
+ result.throw ??= await serializeValue(value.throw.bind(value));
81
+ result[ASYNC_ITERATOR] = true;
82
+ }
83
+ seen.set(value, result);
84
+ return result;
85
+ }
86
+ }
87
+ if (typeof value === "function") {
88
+ const serialized = thread.functions.serialize(value, thread, transferable);
89
+ const result = { [FUNCTION]: serialized };
90
+ seen.set(value, result);
91
+ return result;
92
+ }
93
+ seen.set(value, value);
94
+ return value;
95
+ }
96
+ /**
97
+ * Deserializes a structured cloning-compatible value from another thread.
98
+ */
99
+ async deserialize(value, thread) {
100
+ return this.#deserializeInternal(value, thread);
101
+ }
102
+ async #deserializeInternal(value, thread, isApplyingDefault = false) {
103
+ if (value == null) return value;
104
+ if (typeof value === "object") {
105
+ if (this.#customDeserializer && !isApplyingDefault) {
106
+ const customValue = await this.#customDeserializer(value, (value) => this.#deserializeInternal(value, thread, true), thread);
107
+ if (customValue !== void 0) return customValue;
108
+ }
109
+ if (value == null) return value;
110
+ if (Array.isArray(value)) return Promise.all(value.map((value) => this.#deserializeInternal(value, thread)));
111
+ if (value instanceof Map) {
112
+ const entries = await Promise.all([...value].map(async ([key, value]) => [await this.#deserializeInternal(key, thread), await this.#deserializeInternal(value, thread)]));
113
+ return new Map(entries);
114
+ }
115
+ if (value instanceof Set) {
116
+ const entries = await Promise.all([...value].map((entry) => this.#deserializeInternal(entry, thread)));
117
+ return new Set(entries);
118
+ }
119
+ if (FUNCTION in value) return thread.functions.deserialize(value[FUNCTION], thread);
120
+ if (!isBasicObject(value)) return value;
121
+ const result = {};
122
+ for (const key of Object.keys(value)) if (key === ASYNC_ITERATOR) result[Symbol.asyncIterator] = () => result;
123
+ else result[key] = await this.#deserializeInternal(value[key], thread);
124
+ return result;
125
+ }
126
+ return value;
127
+ }
128
+ };
129
+ //#endregion
211
130
  export { ThreadSerializationStructuredClone };
212
- //# sourceMappingURL=ThreadSerializationStructuredClone.mjs.map
131
+
132
+ //# sourceMappingURL=ThreadSerializationStructuredClone.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ThreadSerializationStructuredClone.mjs","sources":["../../../../../../../../../../../../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/serialization/ThreadSerializationStructuredClone.mjs"],"sourcesContent":["import { TRANSFERABLE, SERIALIZE_METHOD } from '../constants.mjs';\nimport { isIterator, isBasicObject } from './shared.mjs';\n\nconst FUNCTION = '_@f';\nconst ASYNC_ITERATOR = '_@i';\n\n/**\n * A thread encoder that can transfer supports a wide variety of JavaScript types by\n * converting them to a format that the [`structuredClone`](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm)\n * algorithm can process. This\n *\n * Additionally, this encoder will convert functions into a JSON-friendly representation.\n * These functions will use a manual memory management technique to ensure they can be\n * garbage collected by default, but can be configured to use a `WeakRef`-based automatic\n * memory management system by setting the `garbageCollection: 'weak-ref'` option.\n */\nclass ThreadSerializationStructuredClone {\n #customSerializer;\n #customDeserializer;\n\n constructor(options) {\n this.#customSerializer = options?.serialize;\n this.#customDeserializer = options?.deserialize;\n }\n\n /**\n * Serializes a value into a structured cloning-compatible format that can be transferred between threads.\n */\n async serialize(value, thread, transferable) {\n return this.#serializeInternal(value, thread, transferable);\n }\n\n async #serializeInternal(value, thread, transferable, seen = new Map(), isApplyingDefault = false) {\n if (value == null) return value;\n if (seen.has(value)) return seen.get(value);\n\n // Prevent circular references\n seen.set(value, undefined);\n\n if (typeof value === 'object') {\n if (this.#customSerializer && !isApplyingDefault) {\n const customValue = await this.#customSerializer(\n value,\n (value) => this.#serializeInternal(value, thread, transferable, seen, true),\n thread,\n transferable,\n );\n\n if (customValue !== undefined) {\n seen.set(value, customValue);\n return customValue;\n }\n }\n\n if (value[TRANSFERABLE]) {\n transferable?.push(value);\n seen.set(value, value);\n return value;\n }\n\n const serializeValue = (value) => {\n return this.#serializeInternal(value, thread, transferable, seen);\n };\n\n if (typeof value[SERIALIZE_METHOD] === 'function') {\n const result = await value[SERIALIZE_METHOD]({\n serialize: serializeValue,\n });\n\n seen.set(value, result);\n return result;\n }\n\n if (Array.isArray(value)) {\n const result = await Promise.all(value.map((item) => serializeValue(item)));\n seen.set(value, result);\n return result;\n }\n\n if (value instanceof Map) {\n const entries = await Promise.all(\n [...value.entries()].map(async ([key, value]) => {\n return [await serializeValue(key), await serializeValue(value)];\n }),\n );\n\n const result = new Map(entries);\n seen.set(value, result);\n return result;\n }\n\n if (value instanceof Set) {\n const entries = await Promise.all(\n [...value].map((entry) => serializeValue(entry)),\n );\n\n const result = new Set(entries);\n seen.set(value, result);\n return result;\n }\n\n const valueIsIterator = isIterator(value);\n\n if (isBasicObject(value) || valueIsIterator) {\n const result = {};\n\n for (const key of Object.keys(value)) {\n result[key] = await serializeValue(value[key]);\n }\n\n if (valueIsIterator) {\n result.next ??= await serializeValue(value.next.bind(value));\n result.return ??= await serializeValue(value.return.bind(value));\n result.throw ??= await serializeValue(value.throw.bind(value));\n result[ASYNC_ITERATOR] = true;\n }\n\n seen.set(value, result);\n return result;\n }\n }\n\n if (typeof value === 'function') {\n const serialized = thread.functions.serialize(value, thread, transferable);\n const result = { [FUNCTION]: serialized };\n\n seen.set(value, result);\n return result;\n }\n\n seen.set(value, value);\n return value;\n }\n\n /**\n * Deserializes a structured cloning-compatible value from another thread.\n */\n async deserialize(value, thread) {\n return this.#deserializeInternal(value, thread);\n }\n\n async #deserializeInternal(value, thread, isApplyingDefault = false) {\n if (value == null) return value;\n\n if (typeof value === 'object') {\n if (this.#customDeserializer && !isApplyingDefault) {\n const customValue = await this.#customDeserializer(\n value,\n (value) => this.#deserializeInternal(value, thread, true),\n thread,\n );\n\n if (customValue !== undefined) {\n return customValue;\n }\n }\n\n if (value == null) {\n return value;\n }\n\n if (Array.isArray(value)) {\n return Promise.all(value.map((value) => this.#deserializeInternal(value, thread)));\n }\n\n if (value instanceof Map) {\n const entries = await Promise.all(\n [...value].map(async ([key, value]) => [\n await this.#deserializeInternal(key, thread),\n await this.#deserializeInternal(value, thread),\n ]),\n );\n\n return new Map(entries);\n }\n\n if (value instanceof Set) {\n const entries = await Promise.all(\n [...value].map((entry) => this.#deserializeInternal(entry, thread)),\n );\n\n return new Set(entries);\n }\n\n if (FUNCTION in value) {\n const func = thread.functions.deserialize(value[FUNCTION], thread);\n return func;\n }\n\n if (!isBasicObject(value)) {\n return value;\n }\n\n const result = {};\n\n for (const key of Object.keys(value)) {\n if (key === ASYNC_ITERATOR) {\n result[Symbol.asyncIterator] = () => result;\n } else {\n result[key] = await this.#deserializeInternal(value[key], thread);\n }\n }\n\n return result;\n }\n\n return value;\n }\n}\n\nexport { ThreadSerializationStructuredClone };\n"],"names":[],"mappings":";;;AAGA,MAAM,QAAQ,GAAG,KAAK;AACtB,MAAM,cAAc,GAAG,KAAK;;AAE5B;A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C/B,MAAM;;AAEN,MAAM,IAAI,QAAQ,IAAI,KAAK,EAAE;AAC7B,QAAQ,MAAM,IAAI,GAAG,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;AAC1E,QAAQ,OAAO,IAAI;AACnB,MAAM;;AAEN,MAAM,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE;AACjC,QAAQ,OAAO,KAAK;AACpB,MAAM;;AAEN,MAAM,MAAM,MAAM,GAAG,EAAE;;AAEvB,MAAM,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;AAC5C,QAAQ,IAAI,GAAG,KAAK,cAAc,EAAE;AACpC,UAAU,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,MAAM,MAAM;AACrD,QAAQ,CAAC,MAAM;AACf,UAAU,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;AAC3E,QAAQ;AACR,MAAM;;AAEN,MAAM,OAAO,MAAM;AACnB,IAAI;;AAEJ,IAAI,OAAO,KAAK;AAChB,EAAE;AACF;;;;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"ThreadSerializationStructuredClone.mjs","names":["#customSerializer","#customDeserializer","#serializeInternal","#deserializeInternal"],"sources":["../../../../../../../../../../../../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/serialization/ThreadSerializationStructuredClone.mjs"],"sourcesContent":["import { TRANSFERABLE, SERIALIZE_METHOD } from '../constants.mjs';\nimport { isIterator, isBasicObject } from './shared.mjs';\n\nconst FUNCTION = '_@f';\nconst ASYNC_ITERATOR = '_@i';\n\n/**\n * A thread encoder that can transfer supports a wide variety of JavaScript types by\n * converting them to a format that the [`structuredClone`](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm)\n * algorithm can process. This\n *\n * Additionally, this encoder will convert functions into a JSON-friendly representation.\n * These functions will use a manual memory management technique to ensure they can be\n * garbage collected by default, but can be configured to use a `WeakRef`-based automatic\n * memory management system by setting the `garbageCollection: 'weak-ref'` option.\n */\nclass ThreadSerializationStructuredClone {\n #customSerializer;\n #customDeserializer;\n\n constructor(options) {\n this.#customSerializer = options?.serialize;\n this.#customDeserializer = options?.deserialize;\n }\n\n /**\n * Serializes a value into a structured cloning-compatible format that can be transferred between threads.\n */\n async serialize(value, thread, transferable) {\n return this.#serializeInternal(value, thread, transferable);\n }\n\n async #serializeInternal(value, thread, transferable, seen = new Map(), isApplyingDefault = false) {\n if (value == null) return value;\n if (seen.has(value)) return seen.get(value);\n\n // Prevent circular references\n seen.set(value, undefined);\n\n if (typeof value === 'object') {\n if (this.#customSerializer && !isApplyingDefault) {\n const customValue = await this.#customSerializer(\n value,\n (value) => this.#serializeInternal(value, thread, transferable, seen, true),\n thread,\n transferable,\n );\n\n if (customValue !== undefined) {\n seen.set(value, customValue);\n return customValue;\n }\n }\n\n if (value[TRANSFERABLE]) {\n transferable?.push(value);\n seen.set(value, value);\n return value;\n }\n\n const serializeValue = (value) => {\n return this.#serializeInternal(value, thread, transferable, seen);\n };\n\n if (typeof value[SERIALIZE_METHOD] === 'function') {\n const result = await value[SERIALIZE_METHOD]({\n serialize: serializeValue,\n });\n\n seen.set(value, result);\n return result;\n }\n\n if (Array.isArray(value)) {\n const result = await Promise.all(value.map((item) => serializeValue(item)));\n seen.set(value, result);\n return result;\n }\n\n if (value instanceof Map) {\n const entries = await Promise.all(\n [...value.entries()].map(async ([key, value]) => {\n return [await serializeValue(key), await serializeValue(value)];\n }),\n );\n\n const result = new Map(entries);\n seen.set(value, result);\n return result;\n }\n\n if (value instanceof Set) {\n const entries = await Promise.all(\n [...value].map((entry) => serializeValue(entry)),\n );\n\n const result = new Set(entries);\n seen.set(value, result);\n return result;\n }\n\n const valueIsIterator = isIterator(value);\n\n if (isBasicObject(value) || valueIsIterator) {\n const result = {};\n\n for (const key of Object.keys(value)) {\n result[key] = await serializeValue(value[key]);\n }\n\n if (valueIsIterator) {\n result.next ??= await serializeValue(value.next.bind(value));\n result.return ??= await serializeValue(value.return.bind(value));\n result.throw ??= await serializeValue(value.throw.bind(value));\n result[ASYNC_ITERATOR] = true;\n }\n\n seen.set(value, result);\n return result;\n }\n }\n\n if (typeof value === 'function') {\n const serialized = thread.functions.serialize(value, thread, transferable);\n const result = { [FUNCTION]: serialized };\n\n seen.set(value, result);\n return result;\n }\n\n seen.set(value, value);\n return value;\n }\n\n /**\n * Deserializes a structured cloning-compatible value from another thread.\n */\n async deserialize(value, thread) {\n return this.#deserializeInternal(value, thread);\n }\n\n async #deserializeInternal(value, thread, isApplyingDefault = false) {\n if (value == null) return value;\n\n if (typeof value === 'object') {\n if (this.#customDeserializer && !isApplyingDefault) {\n const customValue = await this.#customDeserializer(\n value,\n (value) => this.#deserializeInternal(value, thread, true),\n thread,\n );\n\n if (customValue !== undefined) {\n return customValue;\n }\n }\n\n if (value == null) {\n return value;\n }\n\n if (Array.isArray(value)) {\n return Promise.all(value.map((value) => this.#deserializeInternal(value, thread)));\n }\n\n if (value instanceof Map) {\n const entries = await Promise.all(\n [...value].map(async ([key, value]) => [\n await this.#deserializeInternal(key, thread),\n await this.#deserializeInternal(value, thread),\n ]),\n );\n\n return new Map(entries);\n }\n\n if (value instanceof Set) {\n const entries = await Promise.all(\n [...value].map((entry) => this.#deserializeInternal(entry, thread)),\n );\n\n return new Set(entries);\n }\n\n if (FUNCTION in value) {\n const func = thread.functions.deserialize(value[FUNCTION], thread);\n return func;\n }\n\n if (!isBasicObject(value)) {\n return value;\n }\n\n const result = {};\n\n for (const key of Object.keys(value)) {\n if (key === ASYNC_ITERATOR) {\n result[Symbol.asyncIterator] = () => result;\n } else {\n result[key] = await this.#deserializeInternal(value[key], thread);\n }\n }\n\n return result;\n }\n\n return value;\n }\n}\n\nexport { ThreadSerializationStructuredClone };\n"],"x_google_ignoreList":[0],"mappings":";;;AAGA,IAAM,WAAW;AACjB,IAAM,iBAAiB;;;;;;;;;;;AAYvB,IAAM,qCAAN,MAAyC;CACvC;CACA;CAEA,YAAY,SAAS;EACnB,KAAKA,oBAAoB,SAAS;EAClC,KAAKC,sBAAsB,SAAS;CACtC;;;;CAKA,MAAM,UAAU,OAAO,QAAQ,cAAc;EAC3C,OAAO,KAAKC,mBAAmB,OAAO,QAAQ,YAAY;CAC5D;CAEA,MAAMA,mBAAmB,OAAO,QAAQ,cAAc,uBAAO,IAAI,IAAI,GAAG,oBAAoB,OAAO;EACjG,IAAI,SAAS,MAAM,OAAO;EAC1B,IAAI,KAAK,IAAI,KAAK,GAAG,OAAO,KAAK,IAAI,KAAK;EAG1C,KAAK,IAAI,OAAO,KAAA,CAAS;EAEzB,IAAI,OAAO,UAAU,UAAU;GAC7B,IAAI,KAAKF,qBAAqB,CAAC,mBAAmB;IAChD,MAAM,cAAc,MAAM,KAAKA,kBAC7B,QACC,UAAU,KAAKE,mBAAmB,OAAO,QAAQ,cAAc,MAAM,IAAI,GAC1E,QACA,YACF;IAEA,IAAI,gBAAgB,KAAA,GAAW;KAC7B,KAAK,IAAI,OAAO,WAAW;KAC3B,OAAO;IACT;GACF;GAEA,IAAI,MAAM,eAAe;IACvB,cAAc,KAAK,KAAK;IACxB,KAAK,IAAI,OAAO,KAAK;IACrB,OAAO;GACT;GAEA,MAAM,kBAAkB,UAAU;IAChC,OAAO,KAAKA,mBAAmB,OAAO,QAAQ,cAAc,IAAI;GAClE;GAEA,IAAI,OAAO,MAAM,sBAAsB,YAAY;IACjD,MAAM,SAAS,MAAM,MAAM,iBAAiB,CAAC,EAC3C,WAAW,eACb,CAAC;IAED,KAAK,IAAI,OAAO,MAAM;IACtB,OAAO;GACT;GAEA,IAAI,MAAM,QAAQ,KAAK,GAAG;IACxB,MA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GACjC,IAAI,QAAQ,gBACV,OAAO,OAAO,uBAAuB;QAErC,OAAO,OAAO,MAAM,KAAKA,qBAAqB,MAAM,MAAM,MAAM;GAIpE,OAAO;EACT;EAEA,OAAO;CACT;AACF"}
@@ -1,11 +1,13 @@
1
+ //#region ../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/serialization/shared.mjs
1
2
  function isIterator(value) {
2
- return value != null && (Symbol.asyncIterator in value || Symbol.iterator in value) && typeof value.next === 'function';
3
+ return value != null && (Symbol.asyncIterator in value || Symbol.iterator in value) && typeof value.next === "function";
3
4
  }
4
5
  function isBasicObject(value) {
5
- if (value == null || typeof value !== 'object') return false;
6
- const prototype = Object.getPrototypeOf(value);
7
- return prototype == null || prototype === Object.prototype;
6
+ if (value == null || typeof value !== "object") return false;
7
+ const prototype = Object.getPrototypeOf(value);
8
+ return prototype == null || prototype === Object.prototype;
8
9
  }
9
-
10
+ //#endregion
10
11
  export { isBasicObject, isIterator };
11
- //# sourceMappingURL=shared.mjs.map
12
+
13
+ //# sourceMappingURL=shared.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"shared.mjs","sources":["../../../../../../../../../../../../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/serialization/shared.mjs"],"sourcesContent":["function isIterator(value) {\n return value != null && (Symbol.asyncIterator in value || Symbol.iterator in value) && typeof value.next === 'function';\n}\nfunction isBasicObject(value) {\n if (value == null || typeof value !== 'object') return false;\n const prototype = Object.getPrototypeOf(value);\n return prototype == null || prototype === Object.prototype;\n}\n\nexport { isBasicObject, isIterator };\n"],"names":[],"mappings":"AAAA,SAAS,UAAU,CAAC,KAAK,EAAE;AAC3B,EAAE,OAAO,KAAK,IAAI,IAAI,KAAK,MAAM,CAAC,aAAa,IAAI,KAAK,IAAI,MAAM,CAAC,QAAQ,IAAI,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,UAAU;AACzH;AACA,SAAS,aAAa,CAAC,KAAK,EAAE;AAC9B,EAAE,IAAI,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,OAAO,KAAK;AAC9D,EAAE,MAAM,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC;AAChD,EAAE,OAAO,SAAS,IAAI,IAAI,IAAI,SAAS,KAAK,MAAM,CAAC,SAAS;AAC5D;;;;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"shared.mjs","names":[],"sources":["../../../../../../../../../../../../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/serialization/shared.mjs"],"sourcesContent":["function isIterator(value) {\n return value != null && (Symbol.asyncIterator in value || Symbol.iterator in value) && typeof value.next === 'function';\n}\nfunction isBasicObject(value) {\n if (value == null || typeof value !== 'object') return false;\n const prototype = Object.getPrototypeOf(value);\n return prototype == null || prototype === Object.prototype;\n}\n\nexport { isBasicObject, isIterator };\n"],"x_google_ignoreList":[0],"mappings":";AAAA,SAAS,WAAW,OAAO;CACzB,OAAO,SAAS,SAAS,OAAO,iBAAiB,SAAS,OAAO,YAAY,UAAU,OAAO,MAAM,SAAS;AAC/G;AACA,SAAS,cAAc,OAAO;CAC5B,IAAI,SAAS,QAAQ,OAAO,UAAU,UAAU,OAAO;CACvD,MAAM,YAAY,OAAO,eAAe,KAAK;CAC7C,OAAO,aAAa,QAAQ,cAAc,OAAO;AACnD"}