@mittwald/flow-remote-core 1.0.1 → 1.0.2

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 (38) hide show
  1. package/dist/js/node_modules/.pnpm/{@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb → @quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15}/node_modules/@quilted/threads/build/esm/Thread.mjs +24 -6
  2. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/Thread.mjs.map +1 -0
  3. package/dist/js/node_modules/.pnpm/{@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb → @quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15}/node_modules/@quilted/threads/build/esm/constants.mjs +1 -1
  4. package/dist/js/node_modules/.pnpm/{@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb → @quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15}/node_modules/@quilted/threads/build/esm/constants.mjs.map +1 -1
  5. package/dist/js/node_modules/.pnpm/{@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb → @quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15}/node_modules/@quilted/threads/build/esm/errors.mjs +1 -1
  6. package/dist/js/node_modules/.pnpm/{@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb → @quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15}/node_modules/@quilted/threads/build/esm/errors.mjs.map +1 -1
  7. package/dist/js/node_modules/.pnpm/{@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb → @quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15}/node_modules/@quilted/threads/build/esm/functions/ThreadFunctionsAutomatic.mjs +1 -1
  8. package/dist/js/node_modules/.pnpm/{@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb → @quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15}/node_modules/@quilted/threads/build/esm/functions/ThreadFunctionsAutomatic.mjs.map +1 -1
  9. package/dist/js/node_modules/.pnpm/{@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb → @quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15}/node_modules/@quilted/threads/build/esm/nanoid.mjs +1 -1
  10. package/dist/js/node_modules/.pnpm/{@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb → @quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15}/node_modules/@quilted/threads/build/esm/nanoid.mjs.map +1 -1
  11. package/dist/js/node_modules/.pnpm/{@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb → @quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15}/node_modules/@quilted/threads/build/esm/serialization/ThreadSerializationStructuredClone.mjs +7 -6
  12. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/serialization/ThreadSerializationStructuredClone.mjs.map +1 -0
  13. package/dist/js/node_modules/.pnpm/{@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb → @quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15}/node_modules/@quilted/threads/build/esm/serialization/shared.mjs +1 -1
  14. package/dist/js/node_modules/.pnpm/{@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb → @quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15}/node_modules/@quilted/threads/build/esm/serialization/shared.mjs.map +1 -1
  15. package/dist/js/node_modules/.pnpm/{@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb → @quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15}/node_modules/@quilted/threads/build/esm/threads/ThreadIframe.mjs +1 -1
  16. package/dist/js/node_modules/.pnpm/{@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb → @quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15}/node_modules/@quilted/threads/build/esm/threads/ThreadIframe.mjs.map +1 -1
  17. package/dist/js/node_modules/.pnpm/{@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb → @quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15}/node_modules/@quilted/threads/build/esm/threads/ThreadNestedIframe.mjs +1 -1
  18. package/dist/js/node_modules/.pnpm/{@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb → @quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15}/node_modules/@quilted/threads/build/esm/threads/ThreadNestedIframe.mjs.map +1 -1
  19. package/dist/js/node_modules/.pnpm/{@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb → @quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15}/node_modules/@quilted/threads/build/esm/threads/window/ThreadNestedWindow.mjs +1 -1
  20. package/dist/js/node_modules/.pnpm/{@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb → @quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15}/node_modules/@quilted/threads/build/esm/threads/window/ThreadNestedWindow.mjs.map +1 -1
  21. package/dist/js/node_modules/.pnpm/{@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb → @quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15}/node_modules/@quilted/threads/build/esm/threads/window/ThreadWindow.mjs +1 -1
  22. package/dist/js/node_modules/.pnpm/{@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb → @quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15}/node_modules/@quilted/threads/build/esm/threads/window/ThreadWindow.mjs.map +1 -1
  23. package/dist/js/node_modules/.pnpm/{@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb → @quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15}/node_modules/@quilted/threads/build/esm/threads/window/shared.mjs +1 -1
  24. package/dist/js/node_modules/.pnpm/{@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb → @quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15}/node_modules/@quilted/threads/build/esm/threads/window/shared.mjs.map +1 -1
  25. package/dist/js/node_modules/.pnpm/{@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb → @quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15}/node_modules/@quilted/threads/build/esm/transfer.mjs +1 -1
  26. package/dist/js/node_modules/.pnpm/{@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb → @quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15}/node_modules/@quilted/threads/build/esm/transfer.mjs.map +1 -1
  27. package/dist/js/packages/remote-core/src/connection/connectHostRenderRoot.mjs +1 -1
  28. package/dist/js/packages/remote-core/src/connection/connectRemoteIframe.mjs +1 -1
  29. package/dist/js/packages/remote-core/src/serialization/FlowThreadSerialization.mjs +33 -2
  30. package/dist/js/packages/remote-core/src/serialization/FlowThreadSerialization.mjs.map +1 -1
  31. package/dist/js/packages/remote-core/src/serialization/serializers/file.mjs +1 -1
  32. package/dist/types/connection/threadMessageOrder.test.d.ts +2 -0
  33. package/dist/types/connection/threadMessageOrder.test.d.ts.map +1 -0
  34. package/dist/types/serialization/FlowThreadSerialization.d.ts +6 -0
  35. package/dist/types/serialization/FlowThreadSerialization.d.ts.map +1 -1
  36. package/package.json +7 -7
  37. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/Thread.mjs.map +0 -1
  38. 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 +0 -1
@@ -3,7 +3,7 @@ import { ThreadClosedError } from "./errors.mjs";
3
3
  import { nanoid } from "./nanoid.mjs";
4
4
  import { ThreadFunctionsAutomatic } from "./functions/ThreadFunctionsAutomatic.mjs";
5
5
  import { ThreadSerializationStructuredClone } from "./serialization/ThreadSerializationStructuredClone.mjs";
6
- //#region ../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/Thread.mjs
6
+ //#region ../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/Thread.mjs
7
7
  /**
8
8
  * A thread represents a target JavaScript environment that exposes a set
9
9
  * of callable, asynchronous methods. The thread takes care of automatically
@@ -20,6 +20,8 @@ var Thread = class {
20
20
  }
21
21
  #abort;
22
22
  #idsToResolver = (() => /* @__PURE__ */ new Map())();
23
+ #sendQueue = (() => Promise.resolve())();
24
+ #receiveQueue = (() => Promise.resolve())();
23
25
  constructor(messages, { imports, exports, functions = new ThreadFunctionsAutomatic(), serialization = new ThreadSerializationStructuredClone(), signal } = {}) {
24
26
  this.messages = messages;
25
27
  this.#abort = signal ? new NestedAbortController(signal) : new AbortController();
@@ -80,21 +82,37 @@ var Thread = class {
80
82
  close() {
81
83
  this.#abort.abort();
82
84
  }
83
- async call(func, args) {
85
+ call(func, args) {
84
86
  if (this.closed) return Promise.reject(new ThreadClosedError());
85
- const transferable = [];
86
- const serialized = await this.serialization.serialize(args, this, transferable);
87
87
  const id = nanoid();
88
88
  const done = this.#waitForResult(id);
89
- func(id, serialized, transferable);
89
+ this.#sendQueue = this.#sendQueue.then(async () => {
90
+ try {
91
+ const transferable = [];
92
+ const serialized = await this.serialization.serialize(args, this, transferable);
93
+ func(id, serialized, transferable);
94
+ } catch (error) {
95
+ this.#resolveCall(id, void 0, error);
96
+ }
97
+ });
90
98
  return done;
91
99
  }
92
100
  async #callLocal(func, args, withResult) {
101
+ let releaseQueue;
102
+ const invoked = new Promise((resolve) => {
103
+ releaseQueue = resolve;
104
+ });
105
+ const predecessor = this.#receiveQueue;
106
+ this.#receiveQueue = invoked;
93
107
  try {
94
- const result = this.functions.call ? await this.functions.call(func, args, this) : await func(...await this.serialization.deserialize(args, this));
108
+ await predecessor;
109
+ const pendingResult = this.functions.call ? this.functions.call(func, args, this) : func(...await this.serialization.deserialize(args, this));
110
+ releaseQueue();
111
+ const result = await pendingResult;
95
112
  const transferable = [];
96
113
  withResult(await this.serialization.serialize(result, this, transferable), void 0, transferable);
97
114
  } catch (error) {
115
+ releaseQueue();
98
116
  withResult(void 0, await this.serialization.serialize(error, this));
99
117
  }
100
118
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Thread.mjs","names":["#abort","#handlerForCall","#idsToResolver","#resolveCall","#callLocal","#waitForResult","#sendQueue","#receiveQueue"],"sources":["../../../../../../../../../../../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/Thread.mjs"],"sourcesContent":["import { NestedAbortController } from '@quilted/events';\nimport { ThreadClosedError } from './errors.mjs';\nimport { nanoid } from './nanoid.mjs';\nimport { MESSAGE_FUNCTION_RELEASE, MESSAGE_FUNCTION_RESULT, MESSAGE_CALL_RESULT, MESSAGE_FUNCTION_CALL, MESSAGE_CALL } from './constants.mjs';\nimport { ThreadFunctionsAutomatic } from './functions/ThreadFunctionsAutomatic.mjs';\nimport { ThreadSerializationStructuredClone } from './serialization/ThreadSerializationStructuredClone.mjs';\n\n/**\n * A thread represents a target JavaScript environment that exposes a set\n * of callable, asynchronous methods. The thread takes care of automatically\n * encoding and decoding its arguments and return values, so you can interact\n * with it as if its methods were implemented in the same environment as your\n * own code.\n */\nclass Thread {\n get signal() {\n return this.#abort.signal;\n }\n\n get closed() {\n return this.#abort.signal.aborted;\n }\n\n #abort;\n #idsToResolver = (() => new Map())();\n\n /*\n * Serialization is async in this build, and the number of microtask turns a\n * payload takes is proportional to its size. Upstream is synchronous, so a\n * message was posted in the same stack frame as the call that produced it and\n * order came for free. Here two calls made in one task race, and the one whose\n * payload serializes in fewer turns wins — a larger batch followed by a smaller\n * one arrives second. For a stream of remote-DOM mutations that silently\n * applies the tree in the wrong order.\n *\n * So both directions get a queue. #sendQueue keeps `serialize` then post\n * atomic per call, #receiveQueue keeps `deserialize` then invoke atomic per\n * message. Each is a promise chain that never rejects, so one failed call\n * cannot wedge the thread.\n */\n #sendQueue = (() => Promise.resolve())();\n #receiveQueue = (() => Promise.resolve())();\n\n constructor(messages, {\n imports,\n exports,\n functions = new ThreadFunctionsAutomatic(),\n serialization = new ThreadSerializationStructuredClone(),\n signal\n } = {}) {\n this.messages = messages;\n this.#abort = signal ? new NestedAbortController(signal) : new AbortController();\n this.exports = exports ?? {};\n this.imports = createThreadImports(this.#handlerForCall.bind(this), imports);\n this.functions = functions;\n this.serialization = serialization;\n\n this.functions.start?.(this);\n this.serialization.start?.(this);\n\n this.signal.addEventListener('abort', () => {\n for (const id of this.#idsToResolver.keys()) {\n this.#resolveCall(id, undefined, new ThreadClosedError());\n }\n this.#idsToResolver.clear();\n }, { once: true });\n\n messages.listen(async (rawData) => {\n const isThreadMessageData = Array.isArray(rawData) && typeof rawData[0] === 'number';\n if (!isThreadMessageData) return;\n\n const data = rawData;\n\n switch (data[0]) {\n case MESSAGE_CALL: {\n const [, id, property, args] = data;\n const func = this.exports[property] ?? (() => {\n throw new Error(`No '${property}' method is exported from this thread`);\n });\n\n await this.#callLocal(func, args, (value, error, transferable) => {\n this.messages.send([MESSAGE_CALL_RESULT, id, value, error], transferable);\n });\n\n break;\n }\n\n case MESSAGE_FUNCTION_CALL: {\n const [, callID, funcID, args] = data;\n const func = this.functions.get(funcID, this) ?? missingThreadFunction;\n\n await this.#callLocal(func, args, (value, error, transferable) => {\n this.messages.send([MESSAGE_FUNCTION_RESULT, callID, value, error], transferable);\n });\n\n break;\n }\n\n case MESSAGE_CALL_RESULT:\n case MESSAGE_FUNCTION_RESULT: {\n this.#resolveCall(...data.slice(1));\n break;\n }\n\n case MESSAGE_FUNCTION_RELEASE: {\n const id = data[1];\n this.functions.release(id, this);\n break;\n }\n }\n }, { signal: this.signal });\n }\n\n close() {\n this.#abort.abort();\n }\n\n call(func, args) {\n if (this.closed) {\n return Promise.reject(new ThreadClosedError());\n }\n\n // Claim the id and its resolver before yielding, so the ids reflect call\n // order and a result cannot arrive before there is something to receive it.\n const id = nanoid();\n const done = this.#waitForResult(id);\n\n this.#sendQueue = this.#sendQueue.then(async () => {\n try {\n const transferable = [];\n const serialized = await this.serialization.serialize(args, this, transferable);\n\n func(id, serialized, transferable);\n } catch (error) {\n // Serializing the arguments failed, so nothing was sent and no result\n // will ever come back. Reject this call and leave the queue usable.\n this.#resolveCall(id, undefined, error);\n }\n });\n\n return done;\n }\n\n async #callLocal(func, args, withResult) {\n /*\n * The queue is handed on as soon as the function has been *invoked*, not\n * when it settles. Ordering only needs the calls to start in message order;\n * waiting for completion would let one slow export stall every later\n * message, and deadlock outright if that export awaits a call back to the\n * paired thread.\n */\n let releaseQueue;\n const invoked = new Promise((resolve) => {\n releaseQueue = resolve;\n });\n\n const predecessor = this.#receiveQueue;\n this.#receiveQueue = invoked;\n\n try {\n await predecessor;\n\n const pendingResult = this.functions.call\n ? this.functions.call(func, args, this) // keep original contract\n : func(...(await this.serialization.deserialize(args, this)));\n\n releaseQueue();\n\n const result = await pendingResult;\n\n const transferable = [];\n const serialized = await this.serialization.serialize(result, this, transferable);\n\n withResult(serialized, undefined, transferable);\n } catch (error) {\n releaseQueue();\n withResult(undefined, await this.serialization.serialize(error, this));\n }\n }\n\n #handlerForCall(property) {\n return (...args) => {\n try {\n if (typeof property !== 'string' && typeof property !== 'number') {\n throw new Error(`Can’t call a symbol method on a thread: ${property.toString()}`);\n }\n\n return this.call((id, serializedArgs, transferable) => {\n this.messages.send([MESSAGE_CALL, id, property, serializedArgs], transferable);\n }, args);\n } catch (error) {\n return Promise.reject(error);\n }\n };\n }\n\n #resolveCall(...args) {\n const callID = args[0];\n const resolver = this.#idsToResolver.get(callID);\n\n if (resolver) {\n resolver(...args);\n this.#idsToResolver.delete(callID);\n }\n }\n\n #waitForResult(id) {\n const promise = new Promise((resolve, reject) => {\n this.#idsToResolver.set(id, async (_, value, error) => {\n try {\n if (error == null) {\n resolve(await this.serialization.deserialize(value, this));\n } else {\n reject(await this.serialization.deserialize(error, this));\n }\n } catch (deserializeError) {\n reject(deserializeError);\n }\n });\n });\n\n Object.defineProperty(promise, Symbol.asyncIterator, {\n async *value() {\n const result = await promise;\n\n Object.defineProperty(result, Symbol.asyncIterator, {\n value: () => result\n });\n\n yield* result;\n }\n });\n\n return promise;\n }\n}\n\nfunction createThreadImports(handlerForImport, imported) {\n let call;\n\n if (imported == null) {\n if (typeof Proxy !== 'function') {\n throw new Error(`You must pass an array of callable methods in environments without Proxies.`);\n }\n\n const cache = new Map();\n\n call = new Proxy({}, {\n get(_target, property) {\n if (cache.has(property)) {\n return cache.get(property);\n }\n\n const handler = handlerForImport(property);\n cache.set(property, handler);\n return handler;\n }\n });\n } else {\n call = {};\n\n for (const method of imported) {\n Object.defineProperty(call, method, {\n value: handlerForImport(method),\n writable: false,\n configurable: true,\n enumerable: true\n });\n }\n }\n\n return call;\n}\n\nfunction missingThreadFunction() {\n throw new Error(`You attempted to call a function that is not stored. It may have already been released.`);\n}\n\nexport { Thread };\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;AAcA,IAAM,SAAN,MAAa;CACX,IAAI,SAAS;EACX,OAAO,KAAKA,OAAO;CACrB;C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AED,OAAO;EACT,EACF,CAAC;EAED,OAAO;CACT;AACF;AAEA,SAAS,oBAAoB,kBAAkB,UAAU;CACvD,IAAI;CAEJ,IAAI,YAAY,MAAM;EACpB,IAAI,OAAO,UAAU,YACnB,MAAM,IAAI,MAAM,6EAA6E;EAG/F,MAAM,wBAAQ,IAAI,IAAI;EAEtB,OAAO,IAAI,MAAM,CAAC,GAAG,EACnB,IAAI,SAAS,UAAU;GACrB,IAAI,MAAM,IAAI,QAAQ,GACpB,OAAO,MAAM,IAAI,QAAQ;GAG3B,MAAM,UAAU,iBAAiB,QAAQ;GACzC,MAAM,IAAI,UAAU,OAAO;GAC3B,OAAO;EACT,EACF,CAAC;CACH,OAAO;EACL,OAAO,CAAC;EAER,KAAK,MAAM,UAAU,UACnB,OAAO,eAAe,MAAM,QAAQ;GAClC,OAAO,iBAAiB,MAAM;GAC9B,UAAU;GACV,cAAc;GACd,YAAY;EACd,CAAC;CAEL;CAEA,OAAO;AACT;AAEA,SAAS,wBAAwB;CAC/B,MAAM,IAAI,MAAM,yFAAyF;AAC3G"}
@@ -1,4 +1,4 @@
1
- //#region ../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/constants.mjs
1
+ //#region ../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/constants.mjs
2
2
  var SERIALIZE_METHOD = Symbol.for("quilt.threads.serialize");
3
3
  var TRANSFERABLE = Symbol.for("quilt.threads.transferable");
4
4
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"constants.mjs","names":[],"sources":["../../../../../../../../../../../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/constants.mjs"],"sourcesContent":["const MESSAGE_CALL = 1;\nconst MESSAGE_CALL_RESULT = 2;\nconst MESSAGE_FUNCTION_CALL = 3;\nconst MESSAGE_FUNCTION_RESULT = 4;\nconst MESSAGE_FUNCTION_RELEASE = 5;\nconst SERIALIZE_METHOD = Symbol.for('quilt.threads.serialize');\nconst TRANSFERABLE = Symbol.for('quilt.threads.transferable');\n\nexport { MESSAGE_CALL, MESSAGE_CALL_RESULT, MESSAGE_FUNCTION_CALL, MESSAGE_FUNCTION_RELEASE, MESSAGE_FUNCTION_RESULT, SERIALIZE_METHOD, TRANSFERABLE };\n"],"x_google_ignoreList":[0],"mappings":";AAKA,IAAM,mBAAmB,OAAO,IAAI,yBAAyB;AAC7D,IAAM,eAAe,OAAO,IAAI,4BAA4B"}
1
+ {"version":3,"file":"constants.mjs","names":[],"sources":["../../../../../../../../../../../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/constants.mjs"],"sourcesContent":["const MESSAGE_CALL = 1;\nconst MESSAGE_CALL_RESULT = 2;\nconst MESSAGE_FUNCTION_CALL = 3;\nconst MESSAGE_FUNCTION_RESULT = 4;\nconst MESSAGE_FUNCTION_RELEASE = 5;\nconst SERIALIZE_METHOD = Symbol.for('quilt.threads.serialize');\nconst TRANSFERABLE = Symbol.for('quilt.threads.transferable');\n\nexport { MESSAGE_CALL, MESSAGE_CALL_RESULT, MESSAGE_FUNCTION_CALL, MESSAGE_FUNCTION_RELEASE, MESSAGE_FUNCTION_RESULT, SERIALIZE_METHOD, TRANSFERABLE };\n"],"x_google_ignoreList":[0],"mappings":";AAKA,IAAM,mBAAmB,OAAO,IAAI,yBAAyB;AAC7D,IAAM,eAAe,OAAO,IAAI,4BAA4B"}
@@ -1,4 +1,4 @@
1
- //#region ../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/errors.mjs
1
+ //#region ../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/errors.mjs
2
2
  var ThreadClosedError = class extends Error {
3
3
  constructor() {
4
4
  super("You attempted to call a function on a closed thread.");
@@ -1 +1 @@
1
- {"version":3,"file":"errors.mjs","names":[],"sources":["../../../../../../../../../../../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/errors.mjs"],"sourcesContent":["class ThreadClosedError extends Error {\n constructor() {\n super('You attempted to call a function on a closed thread.');\n }\n}\n\nexport { ThreadClosedError };\n"],"x_google_ignoreList":[0],"mappings":";AAAA,IAAM,oBAAN,cAAgC,MAAM;CACpC,cAAc;EACZ,MAAM,sDAAsD;CAC9D;AACF"}
1
+ {"version":3,"file":"errors.mjs","names":[],"sources":["../../../../../../../../../../../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/errors.mjs"],"sourcesContent":["class ThreadClosedError extends Error {\n constructor() {\n super('You attempted to call a function on a closed thread.');\n }\n}\n\nexport { ThreadClosedError };\n"],"x_google_ignoreList":[0],"mappings":";AAAA,IAAM,oBAAN,cAAgC,MAAM;CACpC,cAAc;EACZ,MAAM,sDAAsD;CAC9D;AACF"}
@@ -1,5 +1,5 @@
1
1
  import { nanoid } from "../nanoid.mjs";
2
- //#region ../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/functions/ThreadFunctionsAutomatic.mjs
2
+ //#region ../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/functions/ThreadFunctionsAutomatic.mjs
3
3
  /**
4
4
  * A strategy for managing functions across threads that automatically releases
5
5
  * functions when they are no longer needed. This is done by deserializing functions
@@ -1 +1 @@
1
- {"version":3,"file":"ThreadFunctionsAutomatic.mjs","names":["#idsToFunction","#functionsToId","#idsToProxy","#finalizationRegistry","#finalization"],"sources":["../../../../../../../../../../../../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/functions/ThreadFunctionsAutomatic.mjs"],"sourcesContent":["import { MESSAGE_FUNCTION_CALL, MESSAGE_FUNCTION_RELEASE } from '../constants.mjs';\nimport { nanoid } from '../nanoid.mjs';\n\n/**\n * A strategy for managing functions across threads that automatically releases\n * functions when they are no longer needed. This is done by deserializing functions\n * into a proxy that can be called, and wrapping that proxy in a `FinalizationRegistry`,\n * which allows us to send a message to the parent thread when the function is no\n * longer used.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry\n */\nclass ThreadFunctionsAutomatic {\n #functionsToId = (() => new Map())();\n #idsToFunction = (() => new Map())();\n #idsToProxy = (() => new Map())();\n #finalization = (() => new WeakMap())();\n get(id) {\n return this.#idsToFunction.get(id);\n }\n release(id) {\n const func = this.#idsToFunction.get(id);\n if (func) {\n this.#idsToFunction.delete(id);\n this.#functionsToId.delete(func);\n }\n return Boolean(func);\n }\n serialize(func) {\n let id = this.#functionsToId.get(func);\n if (id == null) {\n id = nanoid();\n this.#functionsToId.set(func, id);\n this.#idsToFunction.set(id, func);\n }\n return id;\n }\n deserialize(id, thread) {\n let proxy = this.#idsToProxy.get(id)?.deref();\n if (proxy) return proxy;\n proxy = (...args) => {\n if (!this.#idsToProxy.has(id)) {\n throw new Error('You attempted to call a function that was already revoked.');\n }\n return thread.call((callID, args, transferable) => {\n thread.messages.send([MESSAGE_FUNCTION_CALL, callID, id, args], transferable);\n }, args);\n };\n this.#finalizationRegistry(thread)?.register(proxy, id);\n this.#idsToProxy.set(id, new WeakRef(proxy));\n return proxy;\n }\n #finalizationRegistry(thread) {\n let finalization = this.#finalization.get(thread);\n if (typeof FinalizationRegistry === 'undefined') {\n return undefined;\n }\n if (!finalization) {\n finalization = new FinalizationRegistry(id => {\n thread.messages.send([MESSAGE_FUNCTION_RELEASE, id]);\n });\n this.#finalization.set(thread, finalization);\n }\n return finalization;\n }\n}\n\nexport { ThreadFunctionsAutomatic };\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;AAYA,IAAM,2BAAN,MAA+B;CAC7B,wCAAwB,IAAI,IAAI,EAAA,CAAG;CACnC,wCAAwB,IAAI,IAAI,EAAA,CAAG;CACnC,qCAAqB,IAAI,IAAI,EAAA,CAAG;CAChC,uCAAuB,IAAI,QAAQ,EAAA,CAAG;CACtC,IAAI,IAAI;EACN,OAAO,KAAKA,eAAe,IAAI,EAAE;CACnC;CACA,QAAQ,IAAI;EACV,MAAM,OAAO,KAAKA,eAAe,IAAI,EAAE;EACvC,IAAI,MAAM;GACR,KAAKA,eAAe,OAAO,EAAE;GAC7B,KAAKC,eAAe,OAAO,IAAI;EACjC;EACA,OAAO,QAAQ,IAAI;CACrB;CACA,UAAU,MAAM;EACd,IAAI,KAAK,KAAKA,eAAe,IAAI,IAAI;EACrC,IAAI,MAAM,MAAM;GACd,KAAK,OAAO;GACZ,KAAKA,eAAe,IAAI,MAAM,EAAE;GAChC,KAAKD,eAAe,IAAI,IAAI,IAAI;EAClC;EACA,OAAO;CACT;CACA,YAAY,IAAI,QAAQ;EACtB,IAAI,QAAQ,KAAKE,YAAY,IAAI,EAAE,CAAC,EAAE,MAAM;EAC5C,IAAI,OAAO,OAAO;EAClB,SAAS,GAAG,SAAS;GACnB,IAAI,CAAC,KAAKA,YAAY,IAAI,EAAE,GAC1B,MAAM,IAAI,MAAM,4DAA4D;GAE9E,OAAO,OAAO,MAAM,QAAQ,MAAM,iBAAiB;IACjD,OAAO,SAAS,KAAK;;KAAwB;KAAQ;KAAI;IAAI,GAAG,YAAY;GAC9E,GAAG,IAAI;EACT;EACA,KAAKC,sBAAsB,MAAM,CAAC,EAAE,SAAS,OAAO,EAAE;EACtD,KAAKD,YAAY,IAAI,IAAI,IAAI,QAAQ,KAAK,CAAC;EAC3C,OAAO;CACT;CACA,sBAAsB,QAAQ;EAC5B,IAAI,eAAe,KAAKE,cAAc,IAAI,MAAM;EAChD,IAAI,OAAO,yBAAyB,aAClC;EAEF,IAAI,CAAC,cAAc;GACjB,eAAe,IAAI,sBAAqB,OAAM;IAC5C,OAAO,SAAS,KAAK,CAAA,GAA2B,EAAE,CAAC;GACrD,CAAC;GACD,KAAKA,cAAc,IAAI,QAAQ,YAAY;EAC7C;EACA,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"ThreadFunctionsAutomatic.mjs","names":["#idsToFunction","#functionsToId","#idsToProxy","#finalizationRegistry","#finalization"],"sources":["../../../../../../../../../../../../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/functions/ThreadFunctionsAutomatic.mjs"],"sourcesContent":["import { MESSAGE_FUNCTION_CALL, MESSAGE_FUNCTION_RELEASE } from '../constants.mjs';\nimport { nanoid } from '../nanoid.mjs';\n\n/**\n * A strategy for managing functions across threads that automatically releases\n * functions when they are no longer needed. This is done by deserializing functions\n * into a proxy that can be called, and wrapping that proxy in a `FinalizationRegistry`,\n * which allows us to send a message to the parent thread when the function is no\n * longer used.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry\n */\nclass ThreadFunctionsAutomatic {\n #functionsToId = (() => new Map())();\n #idsToFunction = (() => new Map())();\n #idsToProxy = (() => new Map())();\n #finalization = (() => new WeakMap())();\n get(id) {\n return this.#idsToFunction.get(id);\n }\n release(id) {\n const func = this.#idsToFunction.get(id);\n if (func) {\n this.#idsToFunction.delete(id);\n this.#functionsToId.delete(func);\n }\n return Boolean(func);\n }\n serialize(func) {\n let id = this.#functionsToId.get(func);\n if (id == null) {\n id = nanoid();\n this.#functionsToId.set(func, id);\n this.#idsToFunction.set(id, func);\n }\n return id;\n }\n deserialize(id, thread) {\n let proxy = this.#idsToProxy.get(id)?.deref();\n if (proxy) return proxy;\n proxy = (...args) => {\n if (!this.#idsToProxy.has(id)) {\n throw new Error('You attempted to call a function that was already revoked.');\n }\n return thread.call((callID, args, transferable) => {\n thread.messages.send([MESSAGE_FUNCTION_CALL, callID, id, args], transferable);\n }, args);\n };\n this.#finalizationRegistry(thread)?.register(proxy, id);\n this.#idsToProxy.set(id, new WeakRef(proxy));\n return proxy;\n }\n #finalizationRegistry(thread) {\n let finalization = this.#finalization.get(thread);\n if (typeof FinalizationRegistry === 'undefined') {\n return undefined;\n }\n if (!finalization) {\n finalization = new FinalizationRegistry(id => {\n thread.messages.send([MESSAGE_FUNCTION_RELEASE, id]);\n });\n this.#finalization.set(thread, finalization);\n }\n return finalization;\n }\n}\n\nexport { ThreadFunctionsAutomatic };\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;AAYA,IAAM,2BAAN,MAA+B;CAC7B,wCAAwB,IAAI,IAAI,EAAA,CAAG;CACnC,wCAAwB,IAAI,IAAI,EAAA,CAAG;CACnC,qCAAqB,IAAI,IAAI,EAAA,CAAG;CAChC,uCAAuB,IAAI,QAAQ,EAAA,CAAG;CACtC,IAAI,IAA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@3.3.1_patch_hash=df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/nanoid.mjs
1
+ //#region ../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/nanoid.mjs
2
2
  var a = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
3
3
  function nanoid(e = 21) {
4
4
  let t = "", r = crypto.getRandomValues(new Uint8Array(e));
@@ -1 +1 @@
1
- {"version":3,"file":"nanoid.mjs","names":[],"sources":["../../../../../../../../../../../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/nanoid.mjs"],"sourcesContent":["// Copied from https://github.com/ai/nanoid/blob/main/nanoid.js\nlet a = 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';\nfunction nanoid(e = 21) {\n let t = '',\n r = crypto.getRandomValues(new Uint8Array(e));\n for (let n = 0; n < e; n++) t += a[63 & r[n]];\n return t;\n}\n\nexport { nanoid };\n"],"x_google_ignoreList":[0],"mappings":";AACA,IAAI,IAAI;AACR,SAAS,OAAO,IAAI,IAAI;CACtB,IAAI,IAAI,IACN,IAAI,OAAO,gBAAgB,IAAI,WAAW,CAAC,CAAC;CAC9C,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG,KAAK,KAAK,EAAE,KAAK,EAAE;CAC1C,OAAO;AACT"}
1
+ {"version":3,"file":"nanoid.mjs","names":[],"sources":["../../../../../../../../../../../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/nanoid.mjs"],"sourcesContent":["// Copied from https://github.com/ai/nanoid/blob/main/nanoid.js\nlet a = 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';\nfunction nanoid(e = 21) {\n let t = '',\n r = crypto.getRandomValues(new Uint8Array(e));\n for (let n = 0; n < e; n++) t += a[63 & r[n]];\n return t;\n}\n\nexport { nanoid };\n"],"x_google_ignoreList":[0],"mappings":";AACA,IAAI,IAAI;AACR,SAAS,OAAO,IAAI,IAAI;CACtB,IAAI,IAAI,IACN,IAAI,OAAO,gBAAgB,IAAI,WAAW,CAAC,CAAC;CAC9C,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG,KAAK,KAAK,EAAE,KAAK,EAAE;CAC1C,OAAO;AACT"}
@@ -1,6 +1,6 @@
1
1
  import { SERIALIZE_METHOD, TRANSFERABLE } from "../constants.mjs";
2
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
3
+ //#region ../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/serialization/ThreadSerializationStructuredClone.mjs
4
4
  var FUNCTION = "_@f";
5
5
  var ASYNC_ITERATOR = "_@i";
6
6
  /**
@@ -52,20 +52,21 @@ var ThreadSerializationStructuredClone = class {
52
52
  return result;
53
53
  }
54
54
  if (Array.isArray(value)) {
55
- const result = await Promise.all(value.map((item) => serializeValue(item)));
55
+ const result = [];
56
+ for (const item of value) result.push(await serializeValue(item));
56
57
  seen.set(value, result);
57
58
  return result;
58
59
  }
59
60
  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
- }));
61
+ const entries = [];
62
+ for (const [entryKey, entryValue] of value.entries()) entries.push([await serializeValue(entryKey), await serializeValue(entryValue)]);
63
63
  const result = new Map(entries);
64
64
  seen.set(value, result);
65
65
  return result;
66
66
  }
67
67
  if (value instanceof Set) {
68
- const entries = await Promise.all([...value].map((entry) => serializeValue(entry)));
68
+ const entries = [];
69
+ for (const entry of value) entries.push(await serializeValue(entry));
69
70
  const result = new Set(entries);
70
71
  seen.set(value, result);
71
72
  return result;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThreadSerializationStructuredClone.mjs","names":["#customSerializer","#customDeserializer","#serializeInternal","#deserializeInternal"],"sources":["../../../../../../../../../../../../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/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 /*\n * Prevent circular references. `undefined` parks a placeholder so a value\n * that reaches itself terminates instead of recursing forever; the real\n * result overwrites it once this frame is done.\n *\n * This only holds while serialization visits one value at a time. Upstream\n * is synchronous, so that is free. This build is async (Flow's serializers\n * await File reads), which makes it a rule the traversal has to keep: every\n * container below walks its members sequentially. Serialize them\n * concurrently and a second reference reaching the same value from a\n * parallel branch reads the placeholder while the first branch is still in\n * flight, and silently serializes to `undefined`.\n */\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 = [];\n\n for (const item of value) {\n result.push(await serializeValue(item));\n }\n\n seen.set(value, result);\n return result;\n }\n\n if (value instanceof Map) {\n const entries = [];\n\n for (const [entryKey, entryValue] of value.entries()) {\n entries.push([\n await serializeValue(entryKey),\n await serializeValue(entryValue),\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 = [];\n\n for (const entry of value) {\n entries.push(await 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,W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+1,4 @@
1
- //#region ../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/serialization/shared.mjs
1
+ //#region ../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/serialization/shared.mjs
2
2
  function isIterator(value) {
3
3
  return value != null && (Symbol.asyncIterator in value || Symbol.iterator in value) && typeof value.next === "function";
4
4
  }
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"shared.mjs","names":[],"sources":["../../../../../../../../../../../../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/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"}
@@ -1,7 +1,7 @@
1
1
  import { Thread } from "../Thread.mjs";
2
2
  import { windowToThreadTarget } from "./window/ThreadWindow.mjs";
3
3
  import { ThreadNestedIframe } from "./ThreadNestedIframe.mjs";
4
- //#region ../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/ThreadIframe.mjs
4
+ //#region ../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/threads/ThreadIframe.mjs
5
5
  /**
6
6
  * Creates a thread from an iframe element.
7
7
  *
@@ -1 +1 @@
1
- {"version":3,"file":"ThreadIframe.mjs","names":[],"sources":["../../../../../../../../../../../../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/ThreadIframe.mjs"],"sourcesContent":["import { Thread } from '../Thread.mjs';\nimport { windowToThreadTarget } from './window/ThreadWindow.mjs';\nimport { ThreadNestedIframe } from './ThreadNestedIframe.mjs';\n\n/**\n * Creates a thread from an iframe element.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe\n *\n * @example\n * import {ThreadIframe} from '@quilted/threads';\n *\n * const iframe = document.querySelector('iframe#thread-iframe');\n * const thread = new ThreadIframe(iframe);\n * await thread.imports.sendMessage('Hello world!');\n */\nclass ThreadIframe extends Thread {\n /**\n * Creates a thread from an iframe element.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe\n *\n * @example\n * import {ThreadIframe} from '@quilted/threads';\n *\n * const iframe = document.querySelector('iframe#thread-iframe');\n * const thread = ThreadIframe.from(iframe);\n * await thread.imports.sendMessage('Hello world!');\n */\n static from(iframe, options) {\n return new ThreadIframe(iframe, options);\n }\n\n /**\n * Starts a thread wrapped around an iframe element, and returns the imports\n * of the thread.\n *\n * @example\n * ```ts\n * import {ThreadIframe} from '@quilted/threads';\n *\n * const {getMessage} = ThreadIframe.import(iframe);\n * const message = await getMessage(); // 'Hello, world!'\n *\n * // In the nested window:\n *\n * import {ThreadIframe} from '@quilted/threads';\n *\n * ThreadIframe.parent.export({\n * async getMessage() {\n * return 'Hello, world!';\n * },\n * });\n * ```\n */\n static import(iframe, options) {\n return new ThreadIframe(iframe, options).imports;\n }\n\n /**\n * Starts a thread wrapped around an iframe element, providing the second\n * argument as the exports of the thread.\n *\n * @example\n * ```ts\n * import {ThreadIframe} from '@quilted/threads';\n *\n * ThreadIframe.export(iframe, {\n * async getMessage() {\n * return 'Hello, world!';\n * },\n * });\n *\n * // In the nested iframe:\n *\n * import {ThreadIframe} from '@quilted/threads';\n *\n * const {getMessage} = ThreadIframe.parent.import();\n * const message = await getMessage(); // 'Hello, world!'\n * ```\n */\n static export(iframe, exports, options) {\n new ThreadIframe(iframe, {\n ...options,\n exports\n });\n }\n\n /**\n * Creates a thread from a `window.parent`, a reference to the parent window when rendering\n * in a nested iframe.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/parent\n *\n * @example\n * import {ThreadIframe} from '@quilted/threads';\n *\n * const thread = ThreadIframe.parent();\n * await thread.imports.sendMessage('Hello world!');\n */\n static parent = (() => Object.assign(options => new ThreadNestedIframe(options), {\n /**\n * Starts a thread wrapped around a parent window, and returns the imports\n * of the thread.\n *\n * @example\n * ```ts\n * import {ThreadIframe} from '@quilted/threads';\n *\n * const {getMessage} = ThreadIframe.parent.import();\n * const message = await getMessage(); // 'Hello, world!'\n *\n * // In the parent window:\n *\n * import {ThreadIframe} from '@quilted/threads';\n *\n * ThreadIframe.export(iframe, {\n * async getMessage() {\n * return 'Hello, world!';\n * },\n * });\n * ```\n */\n import: options => ThreadNestedIframe.import(options),\n /**\n * Starts a thread wrapped around a parent window, providing the second\n * argument as the exports of the thread.\n *\n * @example\n * ```ts\n * import {ThreadIframe} from '@quilted/threads';\n *\n * ThreadIframe.parent.export({\n * async getMessage() {\n * return 'Hello, world!';\n * },\n * });\n *\n * // In the parent window:\n *\n * import {ThreadIframe} from '@quilted/threads';\n *\n * const {getMessage} = ThreadIframe.import(iframe);\n * const message = await getMessage(); // 'Hello, world!'\n * ```\n */\n export: (exports, options) => ThreadNestedIframe.export(exports, options)\n }))();\n constructor(iframe, {\n targetOrigin = '*',\n ...options\n } = {}) {\n super(windowToThreadTarget(iframe.contentWindow, {\n targetOrigin\n }), options);\n this.iframe = iframe;\n }\n}\n\nexport { ThreadIframe };\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;AAgBA,IAAM,eAAN,MAAM,qBAAqB,OAAO;;;;;;;;;;;;;CAahC,OAAO,KAAK,QAAQ,SAAS;EAC3B,OAAO,IAAI,aAAa,QAAQ,OAAO;CACzC;;;;;;;;;;;;;;;;;;;;;;;CAwBA,OAAO,OAAO,QAAQ,SAAS;EAC7B,OAAO,IAAI,aAAa,QAAQ,OAAO,CAAC,CAAC;CAC3C;;;;;;;;;;;;;;;;;;;;;;;CAwBA,OAAO,OAAO,QAAQ,SAAS,SAAS;EACtC,IAAI,aAAa,QAAQ;GACvB,GAAG;GACH;EACF,CAAC;CACH;;;;;;;;;;;;;CAcA,OAAO,gBAAgB,OAAO,QAAO,YAAW,IAAI,mBAAmB,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;EAuB/E,SAAQ,YAAW,mBAAmB,OAAO,OAAO;;;;;;;;;;;;;;;;;;;;;;;EAuBpD,SAAS,SAAS,YAAY,mBAAmB,OAAO,SAAS,OAAO;CAC1E,CAAC,EAAA,CAAG;CACJ,YAAY,QAAQ,EAClB,eAAe,KACf,GAAG,YACD,CAAC,GAAG;EACN,MAAM,qBAAqB,OAAO,eAAe,EAC/C,aACF,CAAC,GAAG,OAAO;EACX,KAAK,SAAS;CAChB;AACF"}
1
+ {"version":3,"file":"ThreadIframe.mjs","names":[],"sources":["../../../../../../../../../../../../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/threads/ThreadIframe.mjs"],"sourcesContent":["import { Thread } from '../Thread.mjs';\nimport { windowToThreadTarget } from './window/ThreadWindow.mjs';\nimport { ThreadNestedIframe } from './ThreadNestedIframe.mjs';\n\n/**\n * Creates a thread from an iframe element.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe\n *\n * @example\n * import {ThreadIframe} from '@quilted/threads';\n *\n * const iframe = document.querySelector('iframe#thread-iframe');\n * const thread = new ThreadIframe(iframe);\n * await thread.imports.sendMessage('Hello world!');\n */\nclass ThreadIframe extends Thread {\n /**\n * Creates a thread from an iframe element.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe\n *\n * @example\n * import {ThreadIframe} from '@quilted/threads';\n *\n * const iframe = document.querySelector('iframe#thread-iframe');\n * const thread = ThreadIframe.from(iframe);\n * await thread.imports.sendMessage('Hello world!');\n */\n static from(iframe, options) {\n return new ThreadIframe(iframe, options);\n }\n\n /**\n * Starts a thread wrapped around an iframe element, and returns the imports\n * of the thread.\n *\n * @example\n * ```ts\n * import {ThreadIframe} from '@quilted/threads';\n *\n * const {getMessage} = ThreadIframe.import(iframe);\n * const message = await getMessage(); // 'Hello, world!'\n *\n * // In the nested window:\n *\n * import {ThreadIframe} from '@quilted/threads';\n *\n * ThreadIframe.parent.export({\n * async getMessage() {\n * return 'Hello, world!';\n * },\n * });\n * ```\n */\n static import(iframe, options) {\n return new ThreadIframe(iframe, options).imports;\n }\n\n /**\n * Starts a thread wrapped around an iframe element, providing the second\n * argument as the exports of the thread.\n *\n * @example\n * ```ts\n * import {ThreadIframe} from '@quilted/threads';\n *\n * ThreadIframe.export(iframe, {\n * async getMessage() {\n * return 'Hello, world!';\n * },\n * });\n *\n * // In the nested iframe:\n *\n * import {ThreadIframe} from '@quilted/threads';\n *\n * const {getMessage} = ThreadIframe.parent.import();\n * const message = await getMessage(); // 'Hello, world!'\n * ```\n */\n static export(iframe, exports, options) {\n new ThreadIframe(iframe, {\n ...options,\n exports\n });\n }\n\n /**\n * Creates a thread from a `window.parent`, a reference to the parent window when rendering\n * in a nested iframe.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/parent\n *\n * @example\n * import {ThreadIframe} from '@quilted/threads';\n *\n * const thread = ThreadIframe.parent();\n * await thread.imports.sendMessage('Hello world!');\n */\n static parent = (() => Object.assign(options => new ThreadNestedIframe(options), {\n /**\n * Starts a thread wrapped around a parent window, and returns the imports\n * of the thread.\n *\n * @example\n * ```ts\n * import {ThreadIframe} from '@quilted/threads';\n *\n * const {getMessage} = ThreadIframe.parent.import();\n * const message = await getMessage(); // 'Hello, world!'\n *\n * // In the parent window:\n *\n * import {ThreadIframe} from '@quilted/threads';\n *\n * ThreadIframe.export(iframe, {\n * async getMessage() {\n * return 'Hello, world!';\n * },\n * });\n * ```\n */\n import: options => ThreadNestedIframe.import(options),\n /**\n * Starts a thread wrapped around a parent window, providing the second\n * argument as the exports of the thread.\n *\n * @example\n * ```ts\n * import {ThreadIframe} from '@quilted/threads';\n *\n * ThreadIframe.parent.export({\n * async getMessage() {\n * return 'Hello, world!';\n * },\n * });\n *\n * // In the parent window:\n *\n * import {ThreadIframe} from '@quilted/threads';\n *\n * const {getMessage} = ThreadIframe.import(iframe);\n * const message = await getMessage(); // 'Hello, world!'\n * ```\n */\n export: (exports, options) => ThreadNestedIframe.export(exports, options)\n }))();\n constructor(iframe, {\n targetOrigin = '*',\n ...options\n } = {}) {\n super(windowToThreadTarget(iframe.contentWindow, {\n targetOrigin\n }), options);\n this.iframe = iframe;\n }\n}\n\nexport { ThreadIframe };\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;AAgBA,IAAM,eAAN,MAAM,qBAAqB,OAAO;;;;;;;;;;;;;CAahC,OAAO,KAAK,QAAQ,SAAS;EAC3B,OAAO,IAAI,aAAa,QAAQ,OAAO;CACzC;;;;;;;;;;;;;;;;;;;;;;;CAwBA,OAAO,OAAO,QAAQ,SAAS;EAC7B,OAAO,IAAI,aAAa,QAAQ,OAAO,CAAC,CAAC;CAC3C;;;;;;;;;;;;;;;;;;;;;;;CAwBA,OAAO,OAAO,QAAQ,SAAS,SAAS;EACtC,IAAI,aAAa,QAAQ;GACvB,GAAG;GACH;EACF,CAAC;CACH;;;;;;;;;;;;;CAcA,OAAO,gBAAgB,OAAO,QAAO,YAAW,IAAI,mBAAmB,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;EAuB/E,SAAQ,YAAW,mBAAmB,OAAO,OAAO;;;;;;;;;;;;;;;;;;;;;;;EAuBpD,SAAS,SAAS,YAAY,mBAAmB,OAAO,SAAS,OAAO;CAC1E,CAAC,EAAA,CAAG;CACJ,YAAY,QAAQ,EAClB,eAAe,KACf,GAAG,YACD,CAAC,GAAG;EACN,MAAM,qBAAqB,OAAO,eAAe,EAC/C,aACF,CAAC,GAAG,OAAO;EACX,KAAK,SAAS;CAChB;AACF"}
@@ -1,6 +1,6 @@
1
1
  import { Thread } from "../Thread.mjs";
2
2
  import { nestedWindowToThreadTarget } from "./window/ThreadNestedWindow.mjs";
3
- //#region ../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/ThreadNestedIframe.mjs
3
+ //#region ../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/threads/ThreadNestedIframe.mjs
4
4
  /**
5
5
  * Creates a thread from within an iframe nested in a top-level document.
6
6
  *
@@ -1 +1 @@
1
- {"version":3,"file":"ThreadNestedIframe.mjs","names":[],"sources":["../../../../../../../../../../../../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/ThreadNestedIframe.mjs"],"sourcesContent":["import { Thread } from '../Thread.mjs';\nimport { nestedWindowToThreadTarget } from './window/ThreadNestedWindow.mjs';\n\n/**\n * Creates a thread from within an iframe nested in a top-level document.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe\n *\n * @example\n * import {ThreadNestedIframe} from '@quilted/threads';\n *\n * const thread = new ThreadNestedIframe();\n * await thread.imports.sendMessage('Hello world!');\n */\nclass ThreadNestedIframe extends Thread {\n /**\n * Starts a thread wrapped around a parent window, and returns the imports\n * of the thread.\n *\n * @example\n * ```ts\n * import {ThreadNestedIframe} from '@quilted/threads';\n *\n * const {getMessage} = ThreadNestedIframe.import();\n * const message = await getMessage(); // 'Hello, world!'\n *\n * // In the parent window:\n *\n * import {ThreadIframe} from '@quilted/threads';\n *\n * ThreadIframe.export(iframe, {\n * async getMessage() {\n * return 'Hello, world!';\n * },\n * });\n * ```\n */\n static import(options) {\n return new ThreadNestedIframe(options).imports;\n }\n\n /**\n * Starts a thread wrapped around a parent window, providing the second\n * argument as the exports of the thread.\n *\n * @example\n * ```ts\n * import {ThreadNestedIframe} from '@quilted/threads';\n *\n * ThreadNestedIframe.export({\n * async getMessage() {\n * return 'Hello, world!';\n * },\n * });\n *\n * // In the parent window:\n *\n * import {ThreadIframe} from '@quilted/threads';\n *\n * const {getMessage} = ThreadIframe.import(iframe);\n * const message = await getMessage(); // 'Hello, world!'\n * ```\n */\n static export(exports, options) {\n new ThreadNestedIframe({\n ...options,\n exports\n });\n }\n constructor({\n parent = globalThis.parent,\n targetOrigin = '*',\n ...options\n } = {}) {\n if (typeof self === 'undefined' || parent == null) {\n throw new Error('You are not inside an iframe, because there is no parent window.');\n }\n super(nestedWindowToThreadTarget(parent, {\n targetOrigin\n }), options);\n this.parent = parent;\n }\n}\n\nexport { ThreadNestedIframe };\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;;AAcA,IAAM,qBAAN,MAAM,2BAA2B,OAAO;;;;;;;;;;;;;;;;;;;;;;;CAuBtC,OAAO,OAAO,SAAS;EACrB,OAAO,IAAI,mBAAmB,OAAO,CAAC,CAAC;CACzC;;;;;;;;;;;;;;;;;;;;;;;CAwBA,OAAO,OAAO,SAAS,SAAS;EAC9B,IAAI,mBAAmB;GACrB,GAAG;GACH;EACF,CAAC;CACH;CACA,YAAY,EACV,SAAS,WAAW,QACpB,eAAe,KACf,GAAG,YACD,CAAC,GAAG;EACN,IAAI,OAAO,SAAS,eAAe,UAAU,MAC3C,MAAM,IAAI,MAAM,kEAAkE;EAEpF,MAAM,2BAA2B,QAAQ,EACvC,aACF,CAAC,GAAG,OAAO;EACX,KAAK,SAAS;CAChB;AACF"}
1
+ {"version":3,"file":"ThreadNestedIframe.mjs","names":[],"sources":["../../../../../../../../../../../../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/threads/ThreadNestedIframe.mjs"],"sourcesContent":["import { Thread } from '../Thread.mjs';\nimport { nestedWindowToThreadTarget } from './window/ThreadNestedWindow.mjs';\n\n/**\n * Creates a thread from within an iframe nested in a top-level document.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe\n *\n * @example\n * import {ThreadNestedIframe} from '@quilted/threads';\n *\n * const thread = new ThreadNestedIframe();\n * await thread.imports.sendMessage('Hello world!');\n */\nclass ThreadNestedIframe extends Thread {\n /**\n * Starts a thread wrapped around a parent window, and returns the imports\n * of the thread.\n *\n * @example\n * ```ts\n * import {ThreadNestedIframe} from '@quilted/threads';\n *\n * const {getMessage} = ThreadNestedIframe.import();\n * const message = await getMessage(); // 'Hello, world!'\n *\n * // In the parent window:\n *\n * import {ThreadIframe} from '@quilted/threads';\n *\n * ThreadIframe.export(iframe, {\n * async getMessage() {\n * return 'Hello, world!';\n * },\n * });\n * ```\n */\n static import(options) {\n return new ThreadNestedIframe(options).imports;\n }\n\n /**\n * Starts a thread wrapped around a parent window, providing the second\n * argument as the exports of the thread.\n *\n * @example\n * ```ts\n * import {ThreadNestedIframe} from '@quilted/threads';\n *\n * ThreadNestedIframe.export({\n * async getMessage() {\n * return 'Hello, world!';\n * },\n * });\n *\n * // In the parent window:\n *\n * import {ThreadIframe} from '@quilted/threads';\n *\n * const {getMessage} = ThreadIframe.import(iframe);\n * const message = await getMessage(); // 'Hello, world!'\n * ```\n */\n static export(exports, options) {\n new ThreadNestedIframe({\n ...options,\n exports\n });\n }\n constructor({\n parent = globalThis.parent,\n targetOrigin = '*',\n ...options\n } = {}) {\n if (typeof self === 'undefined' || parent == null) {\n throw new Error('You are not inside an iframe, because there is no parent window.');\n }\n super(nestedWindowToThreadTarget(parent, {\n targetOrigin\n }), options);\n this.parent = parent;\n }\n}\n\nexport { ThreadNestedIframe };\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;;AAcA,IAAM,qBAAN,MAAM,2BAA2B,OAAO;;;;;;;;;;;;;;;;;;;;;;;CAuBtC,OAAO,OAAO,SAAS;EACrB,OAAO,IAAI,mBAAmB,OAAO,CAAC,CAAC;CACzC;;;;;;;;;;;;;;;;;;;;;;;CAwBA,OAAO,OAAO,SAAS,SAAS;EAC9B,IAAI,mBAAmB;GACrB,GAAG;GACH;EACF,CAAC;CACH;CACA,YAAY,EACV,SAAS,WAAW,QACpB,eAAe,KACf,GAAG,YACD,CAAC,GAAG;EACN,IAAI,OAAO,SAAS,eAAe,UAAU,MAC3C,MAAM,IAAI,MAAM,kEAAkE;EAEpF,MAAM,2BAA2B,QAAQ,EACvC,aACF,CAAC,GAAG,OAAO;EACX,KAAK,SAAS;CAChB;AACF"}
@@ -1,6 +1,6 @@
1
1
  import { Thread } from "../../Thread.mjs";
2
2
  import { RESPONSE_MESSAGE } from "./shared.mjs";
3
- //#region ../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/window/ThreadNestedWindow.mjs
3
+ //#region ../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/threads/window/ThreadNestedWindow.mjs
4
4
  /**
5
5
  * Creates a thread from within a window created by a parent document (for example,
6
6
  * an `iframe` or popup window).
@@ -1 +1 @@
1
- {"version":3,"file":"ThreadNestedWindow.mjs","names":[],"sources":["../../../../../../../../../../../../../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/window/ThreadNestedWindow.mjs"],"sourcesContent":["import { Thread } from '../../Thread.mjs';\nimport { CHECK_MESSAGE, RESPONSE_MESSAGE } from './shared.mjs';\n\n/**\n * Creates a thread from within a window created by a parent document (for example,\n * an `iframe` or popup window).\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/opener\n *\n * @example\n * import {ThreadNestedWindow} from '@quilted/threads';\n *\n * // Inside a document opened as a popup window\n * const thread = new ThreadNestedWindow(window.opener);\n * await thread.imports.sendMessage('Hello world!');\n */\nclass ThreadNestedWindow extends Thread {\n /**\n * Creates a thread from within a window created by a parent document (for example,\n * an `iframe` or popup window).\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/opener\n *\n * @example\n * import {ThreadNestedWindow} from '@quilted/threads';\n *\n * // Inside a document opened as a popup window\n * const thread = ThreadNestedWindow.from(window.opener);\n * await thread.imports.sendMessage('Hello world!');\n */\n static from(window, options) {\n return new ThreadNestedWindow(window, options);\n }\n\n /**\n * Starts a thread wrapped around a nested `window` object, and returns the imports\n * of the thread.\n *\n * @example\n * ```ts\n * import {ThreadNestedWindow} from '@quilted/threads';\n *\n * const {getMessage} = ThreadNestedWindow.import(window.opener);\n * const message = await getMessage(); // 'Hello, world!'\n *\n * // In the parent window:\n *\n * import {ThreadWindow} from '@quilted/threads';\n *\n * ThreadWindow.export(window, {\n * async getMessage() {\n * return 'Hello, world!';\n * },\n * });\n * ```\n */\n static import(window, options) {\n return new ThreadNestedWindow(window, options).imports;\n }\n\n /**\n * Starts a thread wrapped around a nested `window` object, providing the second\n * argument as the exports of the thread.\n *\n * @example\n * ```ts\n * import {ThreadNestedWindow} from '@quilted/threads';\n *\n * ThreadNestedWindow.export(window.opener, {\n * async getMessage() {\n * return 'Hello, world!';\n * },\n * });\n *\n * // In the parent window:\n *\n * import {ThreadWindow} from '@quilted/threads';\n *\n * const {getMessage} = ThreadWindow.import(window);\n * const message = await getMessage(); // 'Hello, world!'\n * ```\n */\n static export(window, exports, options) {\n new ThreadNestedWindow(window, {\n ...options,\n exports\n });\n }\n constructor(parent, {\n targetOrigin = '*',\n ...options\n } = {}) {\n super(nestedWindowToThreadTarget(parent, {\n targetOrigin\n }), options);\n this.parent = parent;\n }\n}\nfunction nestedWindowToThreadTarget(parent, {\n targetOrigin = '*'\n} = {}) {\n const ready = () => {\n const respond = () => parent.postMessage(RESPONSE_MESSAGE, targetOrigin);\n self.addEventListener('message', ({\n data,\n source\n }) => {\n if (source !== parent) return;\n if (data === CHECK_MESSAGE) respond();\n });\n respond();\n };\n if (document.readyState === 'complete') {\n ready();\n } else {\n document.addEventListener('readystatechange', () => {\n if (document.readyState === 'complete') {\n ready();\n }\n });\n }\n return {\n send(message, transfer) {\n return parent.postMessage(message, targetOrigin, transfer);\n },\n listen(listen, {\n signal\n }) {\n self.addEventListener('message', event => {\n if (event.data === CHECK_MESSAGE) return;\n listen(event.data);\n }, {\n signal\n });\n }\n };\n}\n\nexport { ThreadNestedWindow, nestedWindowToThreadTarget };\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;AAgBA,IAAM,qBAAN,MAAM,2BAA2B,OAAO;;;;;;;;;;;;;;CActC,OAAO,KAAK,QAAQ,SAAS;EAC3B,OAAO,IAAI,mBAAmB,QAAQ,OAAO;CAC/C;;;;;;;;;;;;;;;;;;;;;;;CAwBA,OAAO,OAAO,QAAQ,SAAS;EAC7B,OAAO,IAAI,mBAAmB,QAAQ,OAAO,CAAC,CAAC;CACjD;;;;;;;;;;;;;;;;;;;;;;;CAwBA,OAAO,OAAO,QAAQ,SAAS,SAAS;EACtC,IAAI,mBAAmB,QAAQ;GAC7B,GAAG;GACH;EACF,CAAC;CACH;CACA,YAAY,QAAQ,EAClB,eAAe,KACf,GAAG,YACD,CAAC,GAAG;EACN,MAAM,2BAA2B,QAAQ,EACvC,aACF,CAAC,GAAG,OAAO;EACX,KAAK,SAAS;CAChB;AACF;AACA,SAAS,2BAA2B,QAAQ,EAC1C,eAAe,QACb,CAAC,GAAG;CACN,MAAM,cAAc;EAClB,MAAM,gBAAgB,OAAO,YAAY,kBAAkB,YAAY;EACvE,KAAK,iBAAiB,YAAY,EAChC,MACA,aACI;GACJ,IAAI,WAAW,QAAQ;GACvB,IAAI,SAAA,sBAAwB,QAAQ;EACtC,CAAC;EACD,QAAQ;CACV;CACA,IAAI,SAAS,eAAe,YAC1B,MAAM;MAEN,SAAS,iBAAiB,0BAA0B;EAClD,IAAI,SAAS,eAAe,YAC1B,MAAM;CAEV,CAAC;CAEH,OAAO;EACL,KAAK,SAAS,UAAU;GACtB,OAAO,OAAO,YAAY,SAAS,cAAc,QAAQ;EAC3D;EACA,OAAO,QAAQ,EACb,UACC;GACD,KAAK,iBAAiB,YAAW,UAAS;IACxC,IAAI,MAAM,SAAA,sBAAwB;IAClC,OAAO,MAAM,IAAI;GACnB,GAAG,EACD,OACF,CAAC;EACH;CACF;AACF"}
1
+ {"version":3,"file":"ThreadNestedWindow.mjs","names":[],"sources":["../../../../../../../../../../../../../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/threads/window/ThreadNestedWindow.mjs"],"sourcesContent":["import { Thread } from '../../Thread.mjs';\nimport { CHECK_MESSAGE, RESPONSE_MESSAGE } from './shared.mjs';\n\n/**\n * Creates a thread from within a window created by a parent document (for example,\n * an `iframe` or popup window).\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/opener\n *\n * @example\n * import {ThreadNestedWindow} from '@quilted/threads';\n *\n * // Inside a document opened as a popup window\n * const thread = new ThreadNestedWindow(window.opener);\n * await thread.imports.sendMessage('Hello world!');\n */\nclass ThreadNestedWindow extends Thread {\n /**\n * Creates a thread from within a window created by a parent document (for example,\n * an `iframe` or popup window).\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/opener\n *\n * @example\n * import {ThreadNestedWindow} from '@quilted/threads';\n *\n * // Inside a document opened as a popup window\n * const thread = ThreadNestedWindow.from(window.opener);\n * await thread.imports.sendMessage('Hello world!');\n */\n static from(window, options) {\n return new ThreadNestedWindow(window, options);\n }\n\n /**\n * Starts a thread wrapped around a nested `window` object, and returns the imports\n * of the thread.\n *\n * @example\n * ```ts\n * import {ThreadNestedWindow} from '@quilted/threads';\n *\n * const {getMessage} = ThreadNestedWindow.import(window.opener);\n * const message = await getMessage(); // 'Hello, world!'\n *\n * // In the parent window:\n *\n * import {ThreadWindow} from '@quilted/threads';\n *\n * ThreadWindow.export(window, {\n * async getMessage() {\n * return 'Hello, world!';\n * },\n * });\n * ```\n */\n static import(window, options) {\n return new ThreadNestedWindow(window, options).imports;\n }\n\n /**\n * Starts a thread wrapped around a nested `window` object, providing the second\n * argument as the exports of the thread.\n *\n * @example\n * ```ts\n * import {ThreadNestedWindow} from '@quilted/threads';\n *\n * ThreadNestedWindow.export(window.opener, {\n * async getMessage() {\n * return 'Hello, world!';\n * },\n * });\n *\n * // In the parent window:\n *\n * import {ThreadWindow} from '@quilted/threads';\n *\n * const {getMessage} = ThreadWindow.import(window);\n * const message = await getMessage(); // 'Hello, world!'\n * ```\n */\n static export(window, exports, options) {\n new ThreadNestedWindow(window, {\n ...options,\n exports\n });\n }\n constructor(parent, {\n targetOrigin = '*',\n ...options\n } = {}) {\n super(nestedWindowToThreadTarget(parent, {\n targetOrigin\n }), options);\n this.parent = parent;\n }\n}\nfunction nestedWindowToThreadTarget(parent, {\n targetOrigin = '*'\n} = {}) {\n const ready = () => {\n const respond = () => parent.postMessage(RESPONSE_MESSAGE, targetOrigin);\n self.addEventListener('message', ({\n data,\n source\n }) => {\n if (source !== parent) return;\n if (data === CHECK_MESSAGE) respond();\n });\n respond();\n };\n if (document.readyState === 'complete') {\n ready();\n } else {\n document.addEventListener('readystatechange', () => {\n if (document.readyState === 'complete') {\n ready();\n }\n });\n }\n return {\n send(message, transfer) {\n return parent.postMessage(message, targetOrigin, transfer);\n },\n listen(listen, {\n signal\n }) {\n self.addEventListener('message', event => {\n if (event.data === CHECK_MESSAGE) return;\n listen(event.data);\n }, {\n signal\n });\n }\n };\n}\n\nexport { ThreadNestedWindow, nestedWindowToThreadTarget };\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;AAgBA,IAAM,qBAAN,MAAM,2BAA2B,OAAO;;;;;;;;;;;;;;CActC,OAAO,KAAK,QAAQ,SAAS;EAC3B,OAAO,IAAI,mBAAmB,QAAQ,OAAO;CAC/C;;;;;;;;;;;;;;;;;;;;;;;CAwBA,OAAO,OAAO,QAAQ,SAAS;EAC7B,OAAO,IAAI,mBAAmB,QAAQ,OAAO,CAAC,CAAC;CACjD;;;;;;;;;;;;;;;;;;;;;;;CAwBA,OAAO,OAAO,QAAQ,SAAS,SAAS;EACtC,IAAI,mBAAmB,QAAQ;GAC7B,GAAG;GACH;EACF,CAAC;CACH;CACA,YAAY,QAAQ,EAClB,eAAe,KACf,GAAG,YACD,CAAC,GAAG;EACN,MAAM,2BAA2B,QAAQ,EACvC,aACF,CAAC,GAAG,OAAO;EACX,KAAK,SAAS;CAChB;AACF;AACA,SAAS,2BAA2B,QAAQ,EAC1C,eAAe,QACb,CAAC,GAAG;CACN,MAAM,cAAc;EAClB,MAAM,gBAAgB,OAAO,YAAY,kBAAkB,YAAY;EACvE,KAAK,iBAAiB,YAAY,EAChC,MACA,aACI;GACJ,IAAI,WAAW,QAAQ;GACvB,IAAI,SAAA,sBAAwB,QAAQ;EACtC,CAAC;EACD,QAAQ;CACV;CACA,IAAI,SAAS,eAAe,YAC1B,MAAM;MAEN,SAAS,iBAAiB,0BAA0B;EAClD,IAAI,SAAS,eAAe,YAC1B,MAAM;CAEV,CAAC;CAEH,OAAO;EACL,KAAK,SAAS,UAAU;GACtB,OAAO,OAAO,YAAY,SAAS,cAAc,QAAQ;EAC3D;EACA,OAAO,QAAQ,EACb,UACC;GACD,KAAK,iBAAiB,YAAW,UAAS;IACxC,IAAI,MAAM,SAAA,sBAAwB;IAClC,OAAO,MAAM,IAAI;GACnB,GAAG,EACD,OACF,CAAC;EACH;CACF;AACF"}
@@ -1,7 +1,7 @@
1
1
  import { Thread } from "../../Thread.mjs";
2
2
  import { CHECK_MESSAGE } from "./shared.mjs";
3
3
  import { ThreadNestedWindow } from "./ThreadNestedWindow.mjs";
4
- //#region ../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/window/ThreadWindow.mjs
4
+ //#region ../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/threads/window/ThreadWindow.mjs
5
5
  /**
6
6
  * Creates a thread from a `Window` created by this environment.
7
7
  *
@@ -1 +1 @@
1
- {"version":3,"file":"ThreadWindow.mjs","names":[],"sources":["../../../../../../../../../../../../../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/window/ThreadWindow.mjs"],"sourcesContent":["import { Thread } from '../../Thread.mjs';\nimport { RESPONSE_MESSAGE, CHECK_MESSAGE } from './shared.mjs';\nimport { ThreadNestedWindow } from './ThreadNestedWindow.mjs';\n\n/**\n * Creates a thread from a `Window` created by this environment.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe\n *\n * @example\n * import {ThreadWindow} from '@quilted/threads';\n *\n * const popup = window.open('https://my-app.com/popup', 'MyAppPopup', 'popup');\n * const thread = new ThreadWindow(popup);\n * await thread.imports.sendMessage('Hello world!');\n */\nclass ThreadWindow extends Thread {\n /**\n * Creates a thread from a `Window` created by this environment.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe\n *\n * @example\n * import {ThreadWindow} from '@quilted/threads';\n *\n * const popup = window.open('https://my-app.com/popup', 'MyAppPopup', 'popup');\n * const thread = ThreadWindow.from(popup);\n * await thread.imports.sendMessage('Hello world!');\n */\n static from(window, options) {\n return new ThreadWindow(window, options);\n }\n\n /**\n * Starts a thread wrapped around a `window` object, and returns the imports\n * of the thread.\n *\n * @example\n * ```ts\n * import {ThreadWindow} from '@quilted/threads';\n *\n * const {getMessage} = ThreadWindow.import(window);\n * const message = await getMessage(); // 'Hello, world!'\n *\n * // In the nested window:\n *\n * import {ThreadNestedWindow} from '@quilted/threads';\n *\n * ThreadNestedWindow.export(window.opener, {\n * async getMessage() {\n * return 'Hello, world!';\n * },\n * });\n * ```\n */\n static import(window, options) {\n return new ThreadWindow(window, options).imports;\n }\n\n /**\n * Starts a thread wrapped around a `window` object, providing the second\n * argument as the exports of the thread.\n *\n * @example\n * ```ts\n * import {ThreadWindow} from '@quilted/threads';\n *\n * ThreadWindow.export(window, {\n * async getMessage() {\n * return 'Hello, world!';\n * },\n * });\n *\n * // In the nested window:\n *\n * import {ThreadNestedWindow} from '@quilted/threads';\n *\n * const {getMessage} = ThreadNestedWindow.import(window.opener);\n * const message = await getMessage(); // 'Hello, world!'\n * ```\n */\n static export(window, exports, options) {\n new ThreadWindow(window, {\n ...options,\n exports\n });\n }\n\n /**\n * Creates a thread from within a window created by a parent document (for example,\n * an `iframe` or popup window).\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/opener\n *\n * @example\n * import {ThreadWindow} from '@quilted/threads';\n *\n * // Inside a document opened as a popup window\n * const thread = ThreadWindow.opener();\n * await thread.imports.sendMessage('Hello world!');\n */\n static opener = (() => Object.assign(options => ThreadNestedWindow.from(window.opener, options), {\n /**\n * Starts a thread wrapped around a nested `window` object, and returns the imports\n * of the thread.\n *\n * @example\n * ```ts\n * import {ThreadWindow} from '@quilted/threads';\n *\n * const {getMessage} = ThreadWindow.opener.import();\n * const message = await getMessage(); // 'Hello, world!'\n *\n * // In the parent window:\n *\n * import {ThreadWindow} from '@quilted/threads';\n *\n * ThreadWindow.export(window, {\n * async getMessage() {\n * return 'Hello, world!';\n * },\n * });\n * ```\n */\n import: options => ThreadNestedWindow.import(window.opener, options),\n /**\n * Starts a thread wrapped around a nested `window` object, providing the second\n * argument as the exports of the thread.\n *\n * @example\n * ```ts\n * import {ThreadWindow} from '@quilted/threads';\n *\n * ThreadWindow.opener.export({\n * async getMessage() {\n * return 'Hello, world!';\n * },\n * });\n *\n * // In the parent window:\n *\n * import {ThreadWindow} from '@quilted/threads';\n *\n * const {getMessage} = ThreadWindow.import(window);\n * const message = await getMessage(); // 'Hello, world!'\n * ```\n */\n export: (exports, options) => ThreadNestedWindow.export(window.opener, {\n ...options,\n exports\n })\n }))();\n constructor(window, {\n targetOrigin = '*',\n ...options\n } = {}) {\n super(windowToThreadTarget(window, {\n targetOrigin\n }), options);\n this.window = window;\n }\n}\nfunction windowToThreadTarget(window, {\n targetOrigin = '*'\n} = {}) {\n let connected = false;\n const sendMessage = function send(message, transfer) {\n window.postMessage(message, targetOrigin, transfer);\n };\n const connectedPromise = new Promise(resolve => {\n const abort = new AbortController();\n globalThis.window.addEventListener('message', event => {\n if (event.source !== window) return;\n if (event.data === RESPONSE_MESSAGE) {\n connected = true;\n abort.abort();\n resolve();\n }\n }, {\n signal: abort.signal\n });\n abort.signal.addEventListener('abort', () => resolve(), {\n once: true\n });\n sendMessage(CHECK_MESSAGE);\n });\n return {\n send(message, transfer) {\n if (!connected) {\n return connectedPromise.then(() => {\n if (connected) return sendMessage(message, transfer);\n });\n }\n return sendMessage(message, transfer);\n },\n listen(listen, {\n signal\n }) {\n self.addEventListener('message', event => {\n if (event.source !== window) return;\n if (event.data === RESPONSE_MESSAGE) return;\n listen(event.data);\n }, {\n signal\n });\n }\n };\n}\n\nexport { ThreadWindow,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AM,MAAM;IACZ,QAAQ;GACV;EACF,GAAG,EACD,QAAQ,MAAM,OAChB,CAAC;EACD,MAAM,OAAO,iBAAiB,eAAe,QAAQ,GAAG,EACtD,MAAM,KACR,CAAC;EACD,YAAY,aAAa;CAC3B,CAAC;CACD,OAAO;EACL,KAAK,SAAS,UAAU;GACtB,IAAI,CAAC,WACH,OAAO,iBAAiB,WAAW;IACjC,IAAI,WAAW,OAAO,YAAY,SAAS,QAAQ;GACrD,CAAC;GAEH,OAAO,YAAY,SAAS,QAAQ;EACtC;EACA,OAAO,QAAQ,EACb,UACC;GACD,KAAK,iBAAiB,YAAW,UAAS;IACxC,IAAI,MAAM,WAAW,QAAQ;IAC7B,IAAI,MAAM,SAAA,sBAA2B;IACrC,OAAO,MAAM,IAAI;GACnB,GAAG,EACD,OACF,CAAC;EACH;CACF;AACF"}
1
+ {"version":3,"file":"ThreadWindow.mjs","names":[],"sources":["../../../../../../../../../../../../../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/threads/window/ThreadWindow.mjs"],"sourcesContent":["import { Thread } from '../../Thread.mjs';\nimport { RESPONSE_MESSAGE, CHECK_MESSAGE } from './shared.mjs';\nimport { ThreadNestedWindow } from './ThreadNestedWindow.mjs';\n\n/**\n * Creates a thread from a `Window` created by this environment.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe\n *\n * @example\n * import {ThreadWindow} from '@quilted/threads';\n *\n * const popup = window.open('https://my-app.com/popup', 'MyAppPopup', 'popup');\n * const thread = new ThreadWindow(popup);\n * await thread.imports.sendMessage('Hello world!');\n */\nclass ThreadWindow extends Thread {\n /**\n * Creates a thread from a `Window` created by this environment.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe\n *\n * @example\n * import {ThreadWindow} from '@quilted/threads';\n *\n * const popup = window.open('https://my-app.com/popup', 'MyAppPopup', 'popup');\n * const thread = ThreadWindow.from(popup);\n * await thread.imports.sendMessage('Hello world!');\n */\n static from(window, options) {\n return new ThreadWindow(window, options);\n }\n\n /**\n * Starts a thread wrapped around a `window` object, and returns the imports\n * of the thread.\n *\n * @example\n * ```ts\n * import {ThreadWindow} from '@quilted/threads';\n *\n * const {getMessage} = ThreadWindow.import(window);\n * const message = await getMessage(); // 'Hello, world!'\n *\n * // In the nested window:\n *\n * import {ThreadNestedWindow} from '@quilted/threads';\n *\n * ThreadNestedWindow.export(window.opener, {\n * async getMessage() {\n * return 'Hello, world!';\n * },\n * });\n * ```\n */\n static import(window, options) {\n return new ThreadWindow(window, options).imports;\n }\n\n /**\n * Starts a thread wrapped around a `window` object, providing the second\n * argument as the exports of the thread.\n *\n * @example\n * ```ts\n * import {ThreadWindow} from '@quilted/threads';\n *\n * ThreadWindow.export(window, {\n * async getMessage() {\n * return 'Hello, world!';\n * },\n * });\n *\n * // In the nested window:\n *\n * import {ThreadNestedWindow} from '@quilted/threads';\n *\n * const {getMessage} = ThreadNestedWindow.import(window.opener);\n * const message = await getMessage(); // 'Hello, world!'\n * ```\n */\n static export(window, exports, options) {\n new ThreadWindow(window, {\n ...options,\n exports\n });\n }\n\n /**\n * Creates a thread from within a window created by a parent document (for example,\n * an `iframe` or popup window).\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/opener\n *\n * @example\n * import {ThreadWindow} from '@quilted/threads';\n *\n * // Inside a document opened as a popup window\n * const thread = ThreadWindow.opener();\n * await thread.imports.sendMessage('Hello world!');\n */\n static opener = (() => Object.assign(options => ThreadNestedWindow.from(window.opener, options), {\n /**\n * Starts a thread wrapped around a nested `window` object, and returns the imports\n * of the thread.\n *\n * @example\n * ```ts\n * import {ThreadWindow} from '@quilted/threads';\n *\n * const {getMessage} = ThreadWindow.opener.import();\n * const message = await getMessage(); // 'Hello, world!'\n *\n * // In the parent window:\n *\n * import {ThreadWindow} from '@quilted/threads';\n *\n * ThreadWindow.export(window, {\n * async getMessage() {\n * return 'Hello, world!';\n * },\n * });\n * ```\n */\n import: options => ThreadNestedWindow.import(window.opener, options),\n /**\n * Starts a thread wrapped around a nested `window` object, providing the second\n * argument as the exports of the thread.\n *\n * @example\n * ```ts\n * import {ThreadWindow} from '@quilted/threads';\n *\n * ThreadWindow.opener.export({\n * async getMessage() {\n * return 'Hello, world!';\n * },\n * });\n *\n * // In the parent window:\n *\n * import {ThreadWindow} from '@quilted/threads';\n *\n * const {getMessage} = ThreadWindow.import(window);\n * const message = await getMessage(); // 'Hello, world!'\n * ```\n */\n export: (exports, options) => ThreadNestedWindow.export(window.opener, {\n ...options,\n exports\n })\n }))();\n constructor(window, {\n targetOrigin = '*',\n ...options\n } = {}) {\n super(windowToThreadTarget(window, {\n targetOrigin\n }), options);\n this.window = window;\n }\n}\nfunction windowToThreadTarget(window, {\n targetOrigin = '*'\n} = {}) {\n let connected = false;\n const sendMessage = function send(message, transfer) {\n window.postMessage(message, targetOrigin, transfer);\n };\n const connectedPromise = new Promise(resolve => {\n const abort = new AbortController();\n globalThis.window.addEventListener('message', event => {\n if (event.source !== window) return;\n if (event.data === RESPONSE_MESSAGE) {\n connected = true;\n abort.abort();\n resolve();\n }\n }, {\n signal: abort.signal\n });\n abort.signal.addEventListener('abort', () => resolve(), {\n once: true\n });\n sendMessage(CHECK_MESSAGE);\n });\n return {\n send(message, transfer) {\n if (!connected) {\n return connectedPromise.then(() => {\n if (connected) return sendMessage(message, transfer);\n });\n }\n return sendMessage(message, transfer);\n },\n listen(listen, {\n signal\n }) {\n self.addEventListener('message', event => {\n if (event.source !== window) return;\n if (event.data === RESPONSE_MESSAGE) return;\n listen(event.data);\n }, {\n signal\n });\n }\n };\n}\n\nexport { ThreadWindow, windowToThreadTarget };\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;AAgBA,IAAM,eAAN,MAAM,qBAAqB,OAAO;;;;;;;;;;;;;CAahC,OAAO,KAAK,QAAQ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EACD,YAAY,aAAa;CAC3B,CAAC;CACD,OAAO;EACL,KAAK,SAAS,UAAU;GACtB,IAAI,CAAC,WACH,OAAO,iBAAiB,WAAW;IACjC,IAAI,WAAW,OAAO,YAAY,SAAS,QAAQ;GACrD,CAAC;GAEH,OAAO,YAAY,SAAS,QAAQ;EACtC;EACA,OAAO,QAAQ,EACb,UACC;GACD,KAAK,iBAAiB,YAAW,UAAS;IACxC,IAAI,MAAM,WAAW,QAAQ;IAC7B,IAAI,MAAM,SAAA,sBAA2B;IACrC,OAAO,MAAM,IAAI;GACnB,GAAG,EACD,OACF,CAAC;EACH;CACF;AACF"}
@@ -1,4 +1,4 @@
1
- //#region ../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/window/shared.mjs
1
+ //#region ../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/threads/window/shared.mjs
2
2
  var CHECK_MESSAGE = "quilt.threads.ping";
3
3
  var RESPONSE_MESSAGE = "quilt.threads.pong";
4
4
  //#endregion
@@ -1 +1 @@
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/threads/window/shared.mjs"],"sourcesContent":["const CHECK_MESSAGE = 'quilt.threads.ping';\nconst RESPONSE_MESSAGE = 'quilt.threads.pong';\n\nexport { CHECK_MESSAGE, RESPONSE_MESSAGE };\n"],"x_google_ignoreList":[0],"mappings":";AAAA,IAAM,gBAAgB;AACtB,IAAM,mBAAmB"}
1
+ {"version":3,"file":"shared.mjs","names":[],"sources":["../../../../../../../../../../../../../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/threads/window/shared.mjs"],"sourcesContent":["const CHECK_MESSAGE = 'quilt.threads.ping';\nconst RESPONSE_MESSAGE = 'quilt.threads.pong';\n\nexport { CHECK_MESSAGE, RESPONSE_MESSAGE };\n"],"x_google_ignoreList":[0],"mappings":";AAAA,IAAM,gBAAgB;AACtB,IAAM,mBAAmB"}
@@ -1,5 +1,5 @@
1
1
  import { TRANSFERABLE } from "./constants.mjs";
2
- //#region ../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/transfer.mjs
2
+ //#region ../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/transfer.mjs
3
3
  /**
4
4
  * Marks the value as being transferable between threads. The memory for this object
5
5
  * will be moved to the target thread once the object is sent.
@@ -1 +1 @@
1
- {"version":3,"file":"transfer.mjs","names":[],"sources":["../../../../../../../../../../../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/transfer.mjs"],"sourcesContent":["import { TRANSFERABLE } from './constants.mjs';\n\n/**\n * Marks the value as being transferable between threads. The memory for this object\n * will be moved to the target thread once the object is sent.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Transferable_objects\n */\nfunction markAsTransferable(value) {\n Object.assign(value, {\n [TRANSFERABLE]: true\n });\n return value;\n}\n\nexport { markAsTransferable };\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;AAQA,SAAS,mBAAmB,OAAO;CACjC,OAAO,OAAO,OAAO,GAClB,eAAe,KAClB,CAAC;CACD,OAAO;AACT"}
1
+ {"version":3,"file":"transfer.mjs","names":[],"sources":["../../../../../../../../../../../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/transfer.mjs"],"sourcesContent":["import { TRANSFERABLE } from './constants.mjs';\n\n/**\n * Marks the value as being transferable between threads. The memory for this object\n * will be moved to the target thread once the object is sent.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Transferable_objects\n */\nfunction markAsTransferable(value) {\n Object.assign(value, {\n [TRANSFERABLE]: true\n });\n return value;\n}\n\nexport { markAsTransferable };\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;AAQA,SAAS,mBAAmB,OAAO;CACjC,OAAO,OAAO,OAAO,GAClB,eAAe,KAClB,CAAC;CACD,OAAO;AACT"}
@@ -1,4 +1,4 @@
1
- import { ThreadNestedIframe } from "../../../../node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/ThreadNestedIframe.mjs";
1
+ import { ThreadNestedIframe } from "../../../../node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/threads/ThreadNestedIframe.mjs";
2
2
  import { FlowThreadSerialization } from "../serialization/FlowThreadSerialization.mjs";
3
3
  import { Version } from "./types.mjs";
4
4
  import { RemoteError } from "../error.mjs";
@@ -1,4 +1,4 @@
1
- import { ThreadIframe } from "../../../../node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/ThreadIframe.mjs";
1
+ import { ThreadIframe } from "../../../../node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/threads/ThreadIframe.mjs";
2
2
  import { FlowThreadSerialization } from "../serialization/FlowThreadSerialization.mjs";
3
3
  import { Version } from "./types.mjs";
4
4
  import { parseReportedEvent } from "../events/remoteEvents.mjs";
@@ -1,17 +1,38 @@
1
1
  import { Serializer } from "./Serializer.mjs";
2
- import { TRANSFERABLE } from "../../../../node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/constants.mjs";
3
- import { ThreadSerializationStructuredClone } from "../../../../node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/serialization/ThreadSerializationStructuredClone.mjs";
2
+ import { TRANSFERABLE } from "../../../../node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/constants.mjs";
3
+ import { ThreadSerializationStructuredClone } from "../../../../node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/serialization/ThreadSerializationStructuredClone.mjs";
4
4
  import { serializers_exports } from "./serializers/index.mjs";
5
5
  import { isObjectType } from "remeda";
6
6
  //#region src/serialization/FlowThreadSerialization.ts
7
7
  var serializers = Object.values(serializers_exports).filter((val) => val instanceof Serializer);
8
+ var isReactValue = (val) => isObjectType(val) && "$$typeof" in val && typeof val.$$typeof === "symbol";
9
+ /**
10
+ * Names the component behind an element, for the warning below. `type` is a
11
+ * string for a DOM element, a function for a component, and an object for a
12
+ * context provider or a `memo`/`forwardRef` wrapper — the last of which is what
13
+ * a rendered react-aria tree is mostly made of.
14
+ */
15
+ var reactValueLabel = (val) => {
16
+ const type = val.type;
17
+ if (typeof type === "string") return type;
18
+ if (typeof type === "function" || isObjectType(type)) {
19
+ const named = type;
20
+ return named.displayName ?? named.name ?? named.$$typeof?.toString() ?? "anonymous";
21
+ }
22
+ return "unknown";
23
+ };
8
24
  var FlowThreadSerialization = class extends ThreadSerializationStructuredClone {
25
+ warnedAboutReactValues = /* @__PURE__ */ new Set();
9
26
  constructor() {
10
27
  super({
11
28
  serialize: async (val, serialize) => {
12
29
  try {
13
30
  if (this.isSerializableByBase(val)) return;
14
31
  if (this.omitSerialization(val)) return null;
32
+ if (isReactValue(val)) {
33
+ this.warnAboutReactValue(val);
34
+ return null;
35
+ }
15
36
  for (const serializer of serializers) {
16
37
  const serialization = await serializer.serialize(val);
17
38
  if (serialization.applied) return await serialize(serialization.result);
@@ -43,6 +64,16 @@ var FlowThreadSerialization = class extends ThreadSerializationStructuredClone {
43
64
  omitSerialization(val) {
44
65
  return val instanceof HTMLElement || val === window;
45
66
  }
67
+ /**
68
+ * Once per component, so a table of many rows reports its cause once instead
69
+ * of once per cell.
70
+ */
71
+ warnAboutReactValue(val) {
72
+ const label = reactValueLabel(val);
73
+ if (this.warnedAboutReactValues.has(label)) return;
74
+ this.warnedAboutReactValues.add(label);
75
+ console.error(`Cannot send the React element <${label} /> to the host: rendered output is not serializable, and it was replaced with null. Pass it as a slot instead of a property — a property would have dropped the whole update.`);
76
+ }
46
77
  };
47
78
  //#endregion
48
79
  export { FlowThreadSerialization };
@@ -1 +1 @@
1
- {"version":3,"file":"FlowThreadSerialization.mjs","names":[],"sources":["../../../../../../src/serialization/FlowThreadSerialization.ts"],"sourcesContent":["import {\n ThreadSerializationStructuredClone,\n type ThreadSerializationOptions,\n TRANSFERABLE,\n} from \"@quilted/threads\";\nimport * as serializerModules from \"./serializers\";\nimport { isObjectType } from \"remeda\";\nimport { Serializer } from \"@/serialization/Serializer\";\n\nconst serializers = Object.values(serializerModules).filter(\n (val) => val instanceof Serializer,\n);\n\nexport class FlowThreadSerialization extends ThreadSerializationStructuredClone {\n public constructor() {\n const options: ThreadSerializationOptions = {\n serialize: async (val, serialize) => {\n try {\n if (this.isSerializableByBase(val)) {\n return;\n }\n if (this.omitSerialization(val)) {\n return null;\n }\n for (const serializer of serializers) {\n const serialization = await serializer.serialize(val);\n\n if (serialization.applied) {\n return await serialize(serialization.result);\n }\n }\n\n if (isObjectType(val)) {\n return await serialize({ ...val });\n }\n\n return undefined;\n } catch (error) {\n console.error(\"Error while serializing\", error);\n throw error;\n }\n },\n\n deserialize: async (val, deserialize) => {\n try {\n for (const serializer of serializers) {\n const deserialization = await serializer.deserialize(val);\n\n if (deserialization.applied) {\n return deserialization.result.value;\n }\n }\n\n return await deserialize(val);\n } catch (error) {\n console.error(\"Error while deserializing\", error);\n throw error;\n }\n },\n };\n\n super(options);\n }\n\n private isSerializableByBase(val: unknown) {\n return (\n val instanceof Map ||\n val instanceof Set ||\n Array.isArray(val) ||\n typeof val === \"function\" ||\n (isObjectType(val) && TRANSFERABLE in val)\n );\n }\n\n private omitSerialization(val: unknown) {\n return val instanceof HTMLElement || val === window;\n }\n}\n"],"mappings":";;;;;;AASA,IAAM,cAAc,OAAO,OAAO,mBAAiB,CAAC,CAAC,QAClD,QAAQ,eAAe,UAC1B;AAEA,IAAa,0BAAb,cAA6C,mCAAmC;CAC9E,cAAqB;EA+CnB,MAAM;GA7CJ,WAAW,OAAO,KAAK,cAAc;IACnC,IAAI;KACF,IAAI,KAAK,qBAAqB,GAAG,GAC/B;KAEF,IAAI,KAAK,kBAAkB,GAAG,GAC5B,OAAO;KAET,KAAK,MAAM,cAAc,aAAa;MACpC,MAAM,gBAAgB,MAAM,WAAW,UAAU,GAAG;MAEpD,IAAI,cAAc,SAChB,OAAO,MAAM,UAAU,cAAc,MAAM;KAE/C;KAEA,IAAI,aAAa,GAAG,GAClB,OAAO,MAAM,UAAU,EAAE,GAAG,IAAI,CAAC;KAGnC;IACF,SAAS,OAAO;KACd,QAAQ,MAAM,2BAA2B,KAAK;KAC9C,MAAM;IACR;GACF;GAEA,aAAa,OAAO,KAAK,gBAAgB;IACvC,IAAI;KACF,KAAK,MAAM,cAAc,aAAa;MACpC,MAAM,kBAAkB,MAAM,WAAW,YAAY,GAAG;MAExD,IAAI,gBAAgB,SAClB,OAAO,gBAAgB,OAAO;KAElC;KAEA,OAAO,MAAM,YAAY,GAAG;IAC9B,SAAS,OAAO;KACd,QAAQ,MAAM,6BAA6B,KAAK;KAChD,MAAM;IACR;GACF;EAGI,CAAO;CACf;CAEA,qBAA6B,KAAc;EACzC,OACE,eAAe,OACf,eAAe,OACf,MAAM,QAAQ,GAAG,KACjB,OAAO,QAAQ,cACd,aAAa,GAAG,KAAK,gBAAgB;CAE1C;CAEA,kBAA0B,KAAc;EACtC,OAAO,eAAe,eAAe,QAAQ;CAC/C;AACF"}
1
+ {"version":3,"file":"FlowThreadSerialization.mjs","names":[],"sources":["../../../../../../src/serialization/FlowThreadSerialization.ts"],"sourcesContent":["import {\n ThreadSerializationStructuredClone,\n type ThreadSerializationOptions,\n TRANSFERABLE,\n} from \"@quilted/threads\";\nimport * as serializerModules from \"./serializers\";\nimport { isObjectType } from \"remeda\";\nimport { Serializer } from \"@/serialization/Serializer\";\n\nconst serializers = Object.values(serializerModules).filter(\n (val) => val instanceof Serializer,\n);\n\n/*\n * React tags its elements, portals and lazy values with a symbol under\n * `$$typeof`. Symbols pass through serialization untouched and `postMessage`\n * refuses them — and it refuses the *whole* message, so a single element in one\n * prop takes down the entire mutation batch and the extension renders nothing at\n * all. The failure is silent apart from an unhandled `DataCloneError`.\n *\n * Rendered output belongs in a slot, not in a property (see `isSlot` in the\n * remote-components generator). Where it ends up in a property anyway, dropping\n * it keeps the batch intact: the one prop is missing instead of the whole tree.\n */\nconst isReactValue = (val: unknown): boolean =>\n isObjectType(val) &&\n \"$$typeof\" in val &&\n typeof (val as { $$typeof: unknown }).$$typeof === \"symbol\";\n\n/**\n * Names the component behind an element, for the warning below. `type` is a\n * string for a DOM element, a function for a component, and an object for a\n * context provider or a `memo`/`forwardRef` wrapper — the last of which is what\n * a rendered react-aria tree is mostly made of.\n */\nconst reactValueLabel = (val: unknown): string => {\n const type = (val as { type?: unknown }).type;\n\n if (typeof type === \"string\") {\n return type;\n }\n if (typeof type === \"function\" || isObjectType(type)) {\n const named = type as {\n displayName?: string;\n name?: string;\n $$typeof?: symbol;\n };\n return (\n named.displayName ??\n named.name ??\n named.$$typeof?.toString() ??\n \"anonymous\"\n );\n }\n\n return \"unknown\";\n};\n\nexport class FlowThreadSerialization extends ThreadSerializationStructuredClone {\n private readonly warnedAboutReactValues = new Set<string>();\n\n public constructor() {\n const options: ThreadSerializationOptions = {\n serialize: async (val, serialize) => {\n try {\n if (this.isSerializableByBase(val)) {\n return;\n }\n if (this.omitSerialization(val)) {\n return null;\n }\n if (isReactValue(val)) {\n this.warnAboutReactValue(val);\n return null;\n }\n for (const serializer of serializers) {\n const serialization = await serializer.serialize(val);\n\n if (serialization.applied) {\n return await serialize(serialization.result);\n }\n }\n\n if (isObjectType(val)) {\n return await serialize({ ...val });\n }\n\n return undefined;\n } catch (error) {\n console.error(\"Error while serializing\", error);\n throw error;\n }\n },\n\n deserialize: async (val, deserialize) => {\n try {\n for (const serializer of serializers) {\n const deserialization = await serializer.deserialize(val);\n\n if (deserialization.applied) {\n return deserialization.result.value;\n }\n }\n\n return await deserialize(val);\n } catch (error) {\n console.error(\"Error while deserializing\", error);\n throw error;\n }\n },\n };\n\n super(options);\n }\n\n private isSerializableByBase(val: unknown) {\n return (\n val instanceof Map ||\n val instanceof Set ||\n Array.isArray(val) ||\n typeof val === \"function\" ||\n (isObjectType(val) && TRANSFERABLE in val)\n );\n }\n\n private omitSerialization(val: unknown) {\n return val instanceof HTMLElement || val === window;\n }\n\n /**\n * Once per component, so a table of many rows reports its cause once instead\n * of once per cell.\n */\n private warnAboutReactValue(val: unknown) {\n const label = reactValueLabel(val);\n\n if (this.warnedAboutReactValues.has(label)) {\n return;\n }\n this.warnedAboutReactValues.add(label);\n\n console.error(\n `Cannot send the React element <${label} /> to the host: rendered output is not serializable, and it was replaced with null. Pass it as a slot instead of a property — a property would have dropped the whole update.`,\n );\n }\n}\n"],"mappings":";;;;;;AASA,IAAM,cAAc,OAAO,OAAO,mBAAiB,CAAC,CAAC,QAClD,QAAQ,eAAe,UAC1B;AAaA,IAAM,gBAAgB,QACpB,aAAa,GAAG,KAChB,cAAc,OACd,OAAQ,IAA8B,aAAa;;;;;;;AAQrD,IAAM,mBAAmB,QAAyB;CAChD,MAAM,OAAQ,IAA2B;CAEzC,IAAI,OAAO,SAAS,UAClB,OAAO;CAET,IAAI,OAAO,SAAS,cAAc,aAAa,IAAI,GAAG;EACpD,MAAM,QAAQ;EAKd,OACE,MAAM,eACN,MAAM,QACN,MAAM,UAAU,SAAS,KACzB;CAEJ;CAEA,OAAO;AACT;AAEA,IAAa,0BAAb,cAA6C,mCAAmC;CAC9E,yCAA0C,IAAI,IAAY;CAE1D,cAAqB;EAmDnB,MAAM;GAjDJ,WAAW,OAAO,KAAK,cAAc;IACnC,IAAI;KACF,IAAI,KAAK,qBAAqB,GAAG,GAC/B;KAEF,IAAI,KAAK,kBAAkB,GAAG,GAC5B,OAAO;KAET,IAAI,aAAa,GAAG,GAAG;MACrB,KAAK,oBAAoB,GAAG;MAC5B,OAAO;KACT;KACA,KAAK,MAAM,cAAc,aAAa;MACpC,MAAM,gBAAgB,MAAM,WAAW,UAAU,GAAG;MAEpD,IAAI,cAAc,SAChB,OAAO,MAAM,UAAU,cAAc,MAAM;KAE/C;KAEA,IAAI,aAAa,GAAG,GAClB,OAAO,MAAM,UAAU,EAAE,GAAG,IAAI,CAAC;KAGnC;IACF,SAAS,OAAO;KACd,QAAQ,MAAM,2BAA2B,KAAK;KAC9C,MAAM;IACR;GACF;GAEA,aAAa,OAAO,KAAK,gBAAgB;IACvC,IAAI;KACF,KAAK,MAAM,cAAc,aAAa;MACpC,MAAM,kBAAkB,MAAM,WAAW,YAAY,GAAG;MAExD,IAAI,gBAAgB,SAClB,OAAO,gBAAgB,OAAO;KAElC;KAEA,OAAO,MAAM,YAAY,GAAG;IAC9B,SAAS,OAAO;KACd,QAAQ,MAAM,6BAA6B,KAAK;KAChD,MAAM;IACR;GACF;EAGI,CAAO;CACf;CAEA,qBAA6B,KAAc;EACzC,OACE,eAAe,OACf,eAAe,OACf,MAAM,QAAQ,GAAG,KACjB,OAAO,QAAQ,cACd,aAAa,GAAG,KAAK,gBAAgB;CAE1C;CAEA,kBAA0B,KAAc;EACtC,OAAO,eAAe,eAAe,QAAQ;CAC/C;;;;;CAMA,oBAA4B,KAAc;EACxC,MAAM,QAAQ,gBAAgB,GAAG;EAEjC,IAAI,KAAK,uBAAuB,IAAI,KAAK,GACvC;EAEF,KAAK,uBAAuB,IAAI,KAAK;EAErC,QAAQ,MACN,kCAAkC,MAAM,+KAC1C;CACF;AACF"}
@@ -1,5 +1,5 @@
1
1
  import { Serializer } from "../Serializer.mjs";
2
- import { markAsTransferable } from "../../../../../node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/transfer.mjs";
2
+ import { markAsTransferable } from "../../../../../node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/transfer.mjs";
3
3
  //#region src/serialization/serializers/file.ts
4
4
  var isSerializedFile = (value) => {
5
5
  return !!(value && typeof value === "object" && "name" in value && "type" in value && "lastModified" in value && "content" in value);
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=threadMessageOrder.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"threadMessageOrder.test.d.ts","sourceRoot":"","sources":["../../../src/connection/threadMessageOrder.test.ts"],"names":[],"mappings":""}
@@ -1,7 +1,13 @@
1
1
  import { ThreadSerializationStructuredClone } from '@quilted/threads';
2
2
  export declare class FlowThreadSerialization extends ThreadSerializationStructuredClone {
3
+ private readonly warnedAboutReactValues;
3
4
  constructor();
4
5
  private isSerializableByBase;
5
6
  private omitSerialization;
7
+ /**
8
+ * Once per component, so a table of many rows reports its cause once instead
9
+ * of once per cell.
10
+ */
11
+ private warnAboutReactValue;
6
12
  }
7
13
  //# sourceMappingURL=FlowThreadSerialization.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FlowThreadSerialization.d.ts","sourceRoot":"","sources":["../../../src/serialization/FlowThreadSerialization.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kCAAkC,EAGnC,MAAM,kBAAkB,CAAC;AAS1B,qBAAa,uBAAwB,SAAQ,kCAAkC;;IAmD7E,OAAO,CAAC,oBAAoB;IAU5B,OAAO,CAAC,iBAAiB;CAG1B"}
1
+ {"version":3,"file":"FlowThreadSerialization.d.ts","sourceRoot":"","sources":["../../../src/serialization/FlowThreadSerialization.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kCAAkC,EAGnC,MAAM,kBAAkB,CAAC;AAsD1B,qBAAa,uBAAwB,SAAQ,kCAAkC;IAC7E,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAqB;;IAwD5D,OAAO,CAAC,oBAAoB;IAU5B,OAAO,CAAC,iBAAiB;IAIzB;;;OAGG;IACH,OAAO,CAAC,mBAAmB;CAY5B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mittwald/flow-remote-core",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "type": "module",
5
5
  "description": "Core functionality to setup a remote/host environment",
6
6
  "homepage": "https://flow.mittwald.de",
@@ -35,9 +35,9 @@
35
35
  "zod": "^4.4.3"
36
36
  },
37
37
  "devDependencies": {
38
- "@mittwald/ext-bridge": "1.0.1",
39
- "@mittwald/flow-react-components": "1.0.1",
40
- "@mittwald/typescript-config": "1.0.1",
38
+ "@mittwald/ext-bridge": "1.0.2",
39
+ "@mittwald/flow-react-components": "1.0.2",
40
+ "@mittwald/typescript-config": "1.0.2",
41
41
  "@types/node": "^25.9.3",
42
42
  "nx": "^22.7.5",
43
43
  "rimraf": "^6.1.3",
@@ -49,13 +49,13 @@
49
49
  "vitest": "^4.1.11"
50
50
  },
51
51
  "peerDependencies": {
52
- "@mittwald/ext-bridge": "1.0.1",
53
- "@mittwald/flow-react-components": "1.0.1"
52
+ "@mittwald/ext-bridge": "1.0.2",
53
+ "@mittwald/flow-react-components": "1.0.2"
54
54
  },
55
55
  "peerDependenciesMeta": {
56
56
  "@mittwald/ext-bridge": {
57
57
  "optional": true
58
58
  }
59
59
  },
60
- "gitHead": "293f7e960fe087fa5110a7d1bc63e530492d9316"
60
+ "gitHead": "2f6210d8cc65c69f77c779c7c08dabd2848fa5eb"
61
61
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"Thread.mjs","names":["#abort","#handlerForCall","#idsToResolver","#resolveCall","#callLocal","#waitForResult"],"sources":["../../../../../../../../../../../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/Thread.mjs"],"sourcesContent":["import { NestedAbortController } from '@quilted/events';\nimport { ThreadClosedError } from './errors.mjs';\nimport { nanoid } from './nanoid.mjs';\nimport { MESSAGE_FUNCTION_RELEASE, MESSAGE_FUNCTION_RESULT, MESSAGE_CALL_RESULT, MESSAGE_FUNCTION_CALL, MESSAGE_CALL } from './constants.mjs';\nimport { ThreadFunctionsAutomatic } from './functions/ThreadFunctionsAutomatic.mjs';\nimport { ThreadSerializationStructuredClone } from './serialization/ThreadSerializationStructuredClone.mjs';\n\n/**\n * A thread represents a target JavaScript environment that exposes a set\n * of callable, asynchronous methods. The thread takes care of automatically\n * encoding and decoding its arguments and return values, so you can interact\n * with it as if its methods were implemented in the same environment as your\n * own code.\n */\nclass Thread {\n get signal() {\n return this.#abort.signal;\n }\n\n get closed() {\n return this.#abort.signal.aborted;\n }\n\n #abort;\n #idsToResolver = (() => new Map())();\n\n constructor(messages, {\n imports,\n exports,\n functions = new ThreadFunctionsAutomatic(),\n serialization = new ThreadSerializationStructuredClone(),\n signal\n } = {}) {\n this.messages = messages;\n this.#abort = signal ? new NestedAbortController(signal) : new AbortController();\n this.exports = exports ?? {};\n this.imports = createThreadImports(this.#handlerForCall.bind(this), imports);\n this.functions = functions;\n this.serialization = serialization;\n\n this.functions.start?.(this);\n this.serialization.start?.(this);\n\n this.signal.addEventListener('abort', () => {\n for (const id of this.#idsToResolver.keys()) {\n this.#resolveCall(id, undefined, new ThreadClosedError());\n }\n this.#idsToResolver.clear();\n }, { once: true });\n\n messages.listen(async (rawData) => {\n const isThreadMessageData = Array.isArray(rawData) && typeof rawData[0] === 'number';\n if (!isThreadMessageData) return;\n\n const data = rawData;\n\n switch (data[0]) {\n case MESSAGE_CALL: {\n const [, id, property, args] = data;\n const func = this.exports[property] ?? (() => {\n throw new Error(`No '${property}' method is exported from this thread`);\n });\n\n await this.#callLocal(func, args, (value, error, transferable) => {\n this.messages.send([MESSAGE_CALL_RESULT, id, value, error], transferable);\n });\n\n break;\n }\n\n case MESSAGE_FUNCTION_CALL: {\n const [, callID, funcID, args] = data;\n const func = this.functions.get(funcID, this) ?? missingThreadFunction;\n\n await this.#callLocal(func, args, (value, error, transferable) => {\n this.messages.send([MESSAGE_FUNCTION_RESULT, callID, value, error], transferable);\n });\n\n break;\n }\n\n case MESSAGE_CALL_RESULT:\n case MESSAGE_FUNCTION_RESULT: {\n this.#resolveCall(...data.slice(1));\n break;\n }\n\n case MESSAGE_FUNCTION_RELEASE: {\n const id = data[1];\n this.functions.release(id, this);\n break;\n }\n }\n }, { signal: this.signal });\n }\n\n close() {\n this.#abort.abort();\n }\n\n async call(func, args) {\n if (this.closed) {\n return Promise.reject(new ThreadClosedError());\n }\n\n const transferable = [];\n const serialized = await this.serialization.serialize(args, this, transferable);\n\n const id = nanoid();\n const done = this.#waitForResult(id);\n\n func(id, serialized, transferable);\n\n return done;\n }\n\n async #callLocal(func, args, withResult) {\n try {\n const result = this.functions.call\n ? await this.functions.call(func, args, this) // keep original contract\n : await func(...(await this.serialization.deserialize(args, this)));\n\n const transferable = [];\n const serialized = await this.serialization.serialize(result, this, transferable);\n\n withResult(serialized, undefined, transferable);\n } catch (error) {\n withResult(undefined, await this.serialization.serialize(error, this));\n }\n }\n\n #handlerForCall(property) {\n return (...args) => {\n try {\n if (typeof property !== 'string' && typeof property !== 'number') {\n throw new Error(`Can’t call a symbol method on a thread: ${property.toString()}`);\n }\n\n return this.call((id, serializedArgs, transferable) => {\n this.messages.send([MESSAGE_CALL, id, property, serializedArgs], transferable);\n }, args);\n } catch (error) {\n return Promise.reject(error);\n }\n };\n }\n\n #resolveCall(...args) {\n const callID = args[0];\n const resolver = this.#idsToResolver.get(callID);\n\n if (resolver) {\n resolver(...args);\n this.#idsToResolver.delete(callID);\n }\n }\n\n #waitForResult(id) {\n const promise = new Promise((resolve, reject) => {\n this.#idsToResolver.set(id, async (_, value, error) => {\n try {\n if (error == null) {\n resolve(await this.serialization.deserialize(value, this));\n } else {\n reject(await this.serialization.deserialize(error, this));\n }\n } catch (deserializeError) {\n reject(deserializeError);\n }\n });\n });\n\n Object.defineProperty(promise, Symbol.asyncIterator, {\n async *value() {\n const result = await promise;\n\n Object.defineProperty(result, Symbol.asyncIterator, {\n value: () => result\n });\n\n yield* result;\n }\n });\n\n return promise;\n }\n}\n\nfunction createThreadImports(handlerForImport, imported) {\n let call;\n\n if (imported == null) {\n if (typeof Proxy !== 'function') {\n throw new Error(`You must pass an array of callable methods in environments without Proxies.`);\n }\n\n const cache = new Map();\n\n call = new Proxy({}, {\n get(_target, property) {\n if (cache.has(property)) {\n return cache.get(property);\n }\n\n const handler = handlerForImport(property);\n cache.set(property, handler);\n return handler;\n }\n });\n } else {\n call = {};\n\n for (const method of imported) {\n Object.defineProperty(call, method, {\n value: handlerForImport(method),\n writable: false,\n configurable: true,\n enumerable: true\n });\n }\n }\n\n return call;\n}\n\nfunction missingThreadFunction() {\n throw new Error(`You attempted to call a function that is not stored. It may have already been released.`);\n}\n\nexport { Thread };\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;AAcA,IAAM,SAAN,MAAa;CACX,IAAI,SAAS;EACX,OAAO,KAAKA,OAAO;CACrB;CAEA,IAAI,SAAS;EACX,OAAO,KAAKA,OAAO,OAAO;CAC5B;CAEA;CACA,wCAAwB,IAAI,IAAI,EAAA,CAAG;CAEnC,YAAY,UAAU,EACpB,SACA,SACA,YAAY,IAAI,yBAAyB,GACzC,gBAAgB,IAAI,mCAAmC,GACvD,WACE,CAAC,GAAG;EACN,KAAK,WAAW;EAChB,KAAKA,SAAS,SAAS,IAAI,sBAAsB,MAAM,IAAI,IAAI,gBAAgB;EAC/E,KAAK,UAAU,WAAW,CAAC;EAC3B,KAAK,UAAU,oBAAoB,KAAKC,gBAAgB,KAAK,IAAI,GAAG,OAAO;EAC3E,KAAK,YAAY;EACjB,KAAK,gBAAgB;EAErB,KAAK,UAAU,QAAQ,IAAI;EAC3B,KAAK,cAAc,QAAQ,IAAI;EAE/B,KAAK,OAAO,iBAAiB,eAAe;GAC1C,KAAK,MAAM,MAAM,KAAKC,eAAe,KAAK,GACxC,KAAKC,aAAa,IAAI,KAAA,GAAW,IAAI,kBAAkB,CAAC;GAE1D,KAAKD,eAAe,MAAM;EAC5B,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AS,kBAAkB;KACzB,OAAO,gBAAgB;IACzB;GACF,CAAC;EACH,CAAC;EAED,OAAO,eAAe,SAAS,OAAO,eAAe,EACnD,OAAO,QAAQ;GACb,MAAM,SAAS,MAAM;GAErB,OAAO,eAAe,QAAQ,OAAO,eAAe,EAClD,aAAa,OACf,CAAC;GAED,OAAO;EACT,EACF,CAAC;EAED,OAAO;CACT;AACF;AAEA,SAAS,oBAAoB,kBAAkB,UAAU;CACvD,IAAI;CAEJ,IAAI,YAAY,MAAM;EACpB,IAAI,OAAO,UAAU,YACnB,MAAM,IAAI,MAAM,6EAA6E;EAG/F,MAAM,wBAAQ,IAAI,IAAI;EAEtB,OAAO,IAAI,MAAM,CAAC,GAAG,EACnB,IAAI,SAAS,UAAU;GACrB,IAAI,MAAM,IAAI,QAAQ,GACpB,OAAO,MAAM,IAAI,QAAQ;GAG3B,MAAM,UAAU,iBAAiB,QAAQ;GACzC,MAAM,IAAI,UAAU,OAAO;GAC3B,OAAO;EACT,EACF,CAAC;CACH,OAAO;EACL,OAAO,CAAC;EAER,KAAK,MAAM,UAAU,UACnB,OAAO,eAAe,MAAM,QAAQ;GAClC,OAAO,iBAAiB,MAAM;GAC9B,UAAU;GACV,cAAc;GACd,YAAY;EACd,CAAC;CAEL;CAEA,OAAO;AACT;AAEA,SAAS,wBAAwB;CAC/B,MAAM,IAAI,MAAM,yFAAyF;AAC3G"}
@@ -1 +0,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,KA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