@mittwald/flow-remote-core 0.2.0-alpha.99 → 0.2.0-alpha.990
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/js/index-node.mjs +16 -0
- package/dist/js/index-node.mjs.map +1 -0
- package/dist/js/index.mjs +15 -0
- package/dist/js/index.mjs.map +1 -0
- package/dist/js/node_modules/.pnpm/@quilted_events@2.1.5/node_modules/@quilted/events/build/esm/abort/NestedAbortController.mjs +38 -0
- package/dist/js/node_modules/.pnpm/@quilted_events@2.1.5/node_modules/@quilted/events/build/esm/abort/NestedAbortController.mjs.map +1 -0
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/Thread.mjs +231 -0
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/Thread.mjs.map +1 -0
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/constants.mjs +10 -0
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/constants.mjs.map +1 -0
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/errors.mjs +8 -0
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/errors.mjs.map +1 -0
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/functions/ThreadFunctionsAutomatic.mjs +69 -0
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/functions/ThreadFunctionsAutomatic.mjs.map +1 -0
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/nanoid.mjs +11 -0
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/nanoid.mjs.map +1 -0
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/serialization/ThreadSerializationStructuredClone.mjs +212 -0
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/serialization/ThreadSerializationStructuredClone.mjs.map +1 -0
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/serialization/shared.mjs +11 -0
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/serialization/shared.mjs.map +1 -0
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/ThreadIframe.mjs +161 -0
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/ThreadIframe.mjs.map +1 -0
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/ThreadNestedIframe.mjs +86 -0
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/ThreadNestedIframe.mjs.map +1 -0
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/window/ThreadNestedWindow.mjs +140 -0
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/window/ThreadNestedWindow.mjs.map +1 -0
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/window/ThreadWindow.mjs +211 -0
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/window/ThreadWindow.mjs.map +1 -0
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/window/shared.mjs +5 -0
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/window/shared.mjs.map +1 -0
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/transfer.mjs +17 -0
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/transfer.mjs.map +1 -0
- package/dist/js/packages/remote-core/src/connection/connectHostRenderRoot.mjs +64 -0
- package/dist/js/packages/remote-core/src/connection/connectHostRenderRoot.mjs.map +1 -0
- package/dist/js/packages/remote-core/src/connection/connectRemoteIframe.mjs +97 -0
- package/dist/js/packages/remote-core/src/connection/connectRemoteIframe.mjs.map +1 -0
- package/dist/js/packages/remote-core/src/connection/types.mjs +12 -0
- package/dist/js/packages/remote-core/src/connection/types.mjs.map +1 -0
- package/dist/js/packages/remote-core/src/error.mjs +10 -0
- package/dist/js/packages/remote-core/src/error.mjs.map +1 -0
- package/dist/js/packages/remote-core/src/ext-bridge/getWithMergedHostConfig.mjs +10 -0
- package/dist/js/packages/remote-core/src/ext-bridge/getWithMergedHostConfig.mjs.map +1 -0
- package/dist/js/packages/remote-core/src/ext-bridge/implementation.mjs +13 -0
- package/dist/js/packages/remote-core/src/ext-bridge/implementation.mjs.map +1 -0
- package/dist/js/packages/remote-core/src/serialization/FlowThreadSerialization.mjs +62 -0
- package/dist/js/packages/remote-core/src/serialization/FlowThreadSerialization.mjs.map +1 -0
- package/dist/js/packages/remote-core/src/serialization/Serializer.mjs +32 -0
- package/dist/js/packages/remote-core/src/serialization/Serializer.mjs.map +1 -0
- package/dist/js/packages/remote-core/src/serialization/serializers/dataTransferText.mjs +23 -0
- package/dist/js/packages/remote-core/src/serialization/serializers/dataTransferText.mjs.map +1 -0
- package/dist/js/packages/remote-core/src/serialization/serializers/date.mjs +16 -0
- package/dist/js/packages/remote-core/src/serialization/serializers/date.mjs.map +1 -0
- package/dist/js/packages/remote-core/src/serialization/serializers/file.mjs +33 -0
- package/dist/js/packages/remote-core/src/serialization/serializers/file.mjs.map +1 -0
- package/dist/js/packages/remote-core/src/serialization/serializers/fileList.mjs +24 -0
- package/dist/js/packages/remote-core/src/serialization/serializers/fileList.mjs.map +1 -0
- package/dist/js/packages/remote-core/src/serialization/serializers/formData.mjs +36 -0
- package/dist/js/packages/remote-core/src/serialization/serializers/formData.mjs.map +1 -0
- package/dist/js/packages/remote-core/src/serialization/serializers/index.mjs +7 -0
- package/dist/js/packages/remote-core/src/serialization/serializers/index.mjs.map +1 -0
- package/dist/js/packages/remote-core/src/serialization/serializers/passwordPolicy.mjs +16 -0
- package/dist/js/packages/remote-core/src/serialization/serializers/passwordPolicy.mjs.map +1 -0
- package/dist/js/packages/remote-core/src/shim.mjs +16 -0
- package/dist/js/packages/remote-core/src/shim.mjs.map +1 -0
- package/dist/types/connection/connectHostRenderRoot.d.ts +12 -6
- package/dist/types/connection/connectHostRenderRoot.d.ts.map +1 -1
- package/dist/types/connection/connectRemoteIframe.d.ts +13 -9
- package/dist/types/connection/connectRemoteIframe.d.ts.map +1 -1
- package/dist/types/connection/index.d.ts +4 -0
- package/dist/types/connection/index.d.ts.map +1 -0
- package/dist/types/connection/types.d.ts +57 -0
- package/dist/types/connection/types.d.ts.map +1 -0
- package/dist/types/error.d.ts +4 -0
- package/dist/types/error.d.ts.map +1 -0
- package/dist/types/ext-bridge/getWithMergedHostConfig.d.ts +5 -0
- package/dist/types/ext-bridge/getWithMergedHostConfig.d.ts.map +1 -0
- package/dist/types/ext-bridge/implementation.d.ts +3 -0
- package/dist/types/ext-bridge/implementation.d.ts.map +1 -0
- package/dist/types/index-node.d.ts +2 -0
- package/dist/types/index-node.d.ts.map +1 -0
- package/dist/types/index.d.ts +5 -6
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/serialization/FlowThreadSerialization.d.ts +7 -0
- package/dist/types/serialization/FlowThreadSerialization.d.ts.map +1 -0
- package/dist/types/serialization/FlowThreadSerialization.test.d.ts +2 -0
- package/dist/types/serialization/FlowThreadSerialization.test.d.ts.map +1 -0
- package/dist/types/serialization/Serialization.test.d.ts +2 -0
- package/dist/types/serialization/Serialization.test.d.ts.map +1 -0
- package/dist/types/serialization/Serializer.d.ts +28 -0
- package/dist/types/serialization/Serializer.d.ts.map +1 -0
- package/dist/types/serialization/index.d.ts +4 -0
- package/dist/types/serialization/index.d.ts.map +1 -0
- package/dist/types/serialization/serializers/dataTransferText.d.ts +3 -0
- package/dist/types/serialization/serializers/dataTransferText.d.ts.map +1 -0
- package/dist/types/serialization/serializers/date.d.ts +4 -0
- package/dist/types/serialization/serializers/date.d.ts.map +1 -0
- package/dist/types/serialization/serializers/file.d.ts +12 -0
- package/dist/types/serialization/serializers/file.d.ts.map +1 -0
- package/dist/types/serialization/serializers/fileList.d.ts +4 -0
- package/dist/types/serialization/serializers/fileList.d.ts.map +1 -0
- package/dist/types/serialization/serializers/formData.d.ts +7 -0
- package/dist/types/serialization/serializers/formData.d.ts.map +1 -0
- package/dist/types/serialization/serializers/index.d.ts +7 -0
- package/dist/types/serialization/serializers/index.d.ts.map +1 -0
- package/dist/types/serialization/serializers/passwordPolicy.d.ts +4 -0
- package/dist/types/serialization/serializers/passwordPolicy.d.ts.map +1 -0
- package/dist/types/shim.d.ts +2 -0
- package/dist/types/shim.d.ts.map +1 -0
- package/dist/types/tests/utils.d.ts +2 -0
- package/dist/types/tests/utils.d.ts.map +1 -0
- package/package.json +38 -20
- package/dist/index.js +0 -48
- package/dist/types/events/FlowRemoteEvent.d.ts +0 -4
- package/dist/types/events/FlowRemoteEvent.d.ts.map +0 -1
- package/dist/types/events/index.d.ts +0 -5
- package/dist/types/events/index.d.ts.map +0 -1
- package/dist/types/events/serializers.d.ts +0 -5
- package/dist/types/events/serializers.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ThreadNestedWindow.mjs","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"],"names":[],"mappings":";;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,kBAAkB,SAAS,MAAM,CAAC;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,OAAO,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE;AAC/B,IAAI,OAAO,IAAI,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC;AAClD,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,OAAO,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE;AACjC,IAAI,OAAO,IAAI,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,OAAO;AAC1D,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,OAAO,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE;AAC1C,IAAI,IAAI,kBAAkB,CAAC,MAAM,EAAE;AACnC,MAAM,GAAG,OAAO;AAChB,MAAM;AACN,KAAK,CAAC;AACN,EAAE;AACF,EAAE,WAAW,CAAC,MAAM,EAAE;AACtB,IAAI,YAAY,GAAG,GAAG;AACtB,IAAI,GAAG;AACP,GAAG,GAAG,EAAE,EAAE;AACV,IAAI,KAAK,CAAC,0BAA0B,CAAC,MAAM,EAAE;AAC7C,MAAM;AACN,KAAK,CAAC,EAAE,OAAO,CAAC;AAChB,IAAI,IAAI,CAAC,MAAM,GAAG,MAAM;AACxB,EAAE;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ACJ,GAAG;AACH;;;;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { Thread } from '../../Thread.mjs';
|
|
2
|
+
import { RESPONSE_MESSAGE, CHECK_MESSAGE } from './shared.mjs';
|
|
3
|
+
import { ThreadNestedWindow } from './ThreadNestedWindow.mjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Creates a thread from a `Window` created by this environment.
|
|
7
|
+
*
|
|
8
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* import {ThreadWindow} from '@quilted/threads';
|
|
12
|
+
*
|
|
13
|
+
* const popup = window.open('https://my-app.com/popup', 'MyAppPopup', 'popup');
|
|
14
|
+
* const thread = new ThreadWindow(popup);
|
|
15
|
+
* await thread.imports.sendMessage('Hello world!');
|
|
16
|
+
*/
|
|
17
|
+
class ThreadWindow extends Thread {
|
|
18
|
+
/**
|
|
19
|
+
* Creates a thread from a `Window` created by this environment.
|
|
20
|
+
*
|
|
21
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* import {ThreadWindow} from '@quilted/threads';
|
|
25
|
+
*
|
|
26
|
+
* const popup = window.open('https://my-app.com/popup', 'MyAppPopup', 'popup');
|
|
27
|
+
* const thread = ThreadWindow.from(popup);
|
|
28
|
+
* await thread.imports.sendMessage('Hello world!');
|
|
29
|
+
*/
|
|
30
|
+
static from(window, options) {
|
|
31
|
+
return new ThreadWindow(window, options);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Starts a thread wrapped around a `window` object, and returns the imports
|
|
36
|
+
* of the thread.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* import {ThreadWindow} from '@quilted/threads';
|
|
41
|
+
*
|
|
42
|
+
* const {getMessage} = ThreadWindow.import(window);
|
|
43
|
+
* const message = await getMessage(); // 'Hello, world!'
|
|
44
|
+
*
|
|
45
|
+
* // In the nested window:
|
|
46
|
+
*
|
|
47
|
+
* import {ThreadNestedWindow} from '@quilted/threads';
|
|
48
|
+
*
|
|
49
|
+
* ThreadNestedWindow.export(window.opener, {
|
|
50
|
+
* async getMessage() {
|
|
51
|
+
* return 'Hello, world!';
|
|
52
|
+
* },
|
|
53
|
+
* });
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
static import(window, options) {
|
|
57
|
+
return new ThreadWindow(window, options).imports;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Starts a thread wrapped around a `window` object, providing the second
|
|
62
|
+
* argument as the exports of the thread.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* import {ThreadWindow} from '@quilted/threads';
|
|
67
|
+
*
|
|
68
|
+
* ThreadWindow.export(window, {
|
|
69
|
+
* async getMessage() {
|
|
70
|
+
* return 'Hello, world!';
|
|
71
|
+
* },
|
|
72
|
+
* });
|
|
73
|
+
*
|
|
74
|
+
* // In the nested window:
|
|
75
|
+
*
|
|
76
|
+
* import {ThreadNestedWindow} from '@quilted/threads';
|
|
77
|
+
*
|
|
78
|
+
* const {getMessage} = ThreadNestedWindow.import(window.opener);
|
|
79
|
+
* const message = await getMessage(); // 'Hello, world!'
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
static export(window, exports, options) {
|
|
83
|
+
new ThreadWindow(window, {
|
|
84
|
+
...options,
|
|
85
|
+
exports
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Creates a thread from within a window created by a parent document (for example,
|
|
91
|
+
* an `iframe` or popup window).
|
|
92
|
+
*
|
|
93
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Window/opener
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* import {ThreadWindow} from '@quilted/threads';
|
|
97
|
+
*
|
|
98
|
+
* // Inside a document opened as a popup window
|
|
99
|
+
* const thread = ThreadWindow.opener();
|
|
100
|
+
* await thread.imports.sendMessage('Hello world!');
|
|
101
|
+
*/
|
|
102
|
+
static opener = (() => Object.assign(options => ThreadNestedWindow.from(window.opener, options), {
|
|
103
|
+
/**
|
|
104
|
+
* Starts a thread wrapped around a nested `window` object, and returns the imports
|
|
105
|
+
* of the thread.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```ts
|
|
109
|
+
* import {ThreadWindow} from '@quilted/threads';
|
|
110
|
+
*
|
|
111
|
+
* const {getMessage} = ThreadWindow.opener.import();
|
|
112
|
+
* const message = await getMessage(); // 'Hello, world!'
|
|
113
|
+
*
|
|
114
|
+
* // In the parent window:
|
|
115
|
+
*
|
|
116
|
+
* import {ThreadWindow} from '@quilted/threads';
|
|
117
|
+
*
|
|
118
|
+
* ThreadWindow.export(window, {
|
|
119
|
+
* async getMessage() {
|
|
120
|
+
* return 'Hello, world!';
|
|
121
|
+
* },
|
|
122
|
+
* });
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
import: options => ThreadNestedWindow.import(window.opener, options),
|
|
126
|
+
/**
|
|
127
|
+
* Starts a thread wrapped around a nested `window` object, providing the second
|
|
128
|
+
* argument as the exports of the thread.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```ts
|
|
132
|
+
* import {ThreadWindow} from '@quilted/threads';
|
|
133
|
+
*
|
|
134
|
+
* ThreadWindow.opener.export({
|
|
135
|
+
* async getMessage() {
|
|
136
|
+
* return 'Hello, world!';
|
|
137
|
+
* },
|
|
138
|
+
* });
|
|
139
|
+
*
|
|
140
|
+
* // In the parent window:
|
|
141
|
+
*
|
|
142
|
+
* import {ThreadWindow} from '@quilted/threads';
|
|
143
|
+
*
|
|
144
|
+
* const {getMessage} = ThreadWindow.import(window);
|
|
145
|
+
* const message = await getMessage(); // 'Hello, world!'
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
export: (exports, options) => ThreadNestedWindow.export(window.opener, {
|
|
149
|
+
...options,
|
|
150
|
+
exports
|
|
151
|
+
})
|
|
152
|
+
}))();
|
|
153
|
+
constructor(window, {
|
|
154
|
+
targetOrigin = '*',
|
|
155
|
+
...options
|
|
156
|
+
} = {}) {
|
|
157
|
+
super(windowToThreadTarget(window, {
|
|
158
|
+
targetOrigin
|
|
159
|
+
}), options);
|
|
160
|
+
this.window = window;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
function windowToThreadTarget(window, {
|
|
164
|
+
targetOrigin = '*'
|
|
165
|
+
} = {}) {
|
|
166
|
+
let connected = false;
|
|
167
|
+
const sendMessage = function send(message, transfer) {
|
|
168
|
+
window.postMessage(message, targetOrigin, transfer);
|
|
169
|
+
};
|
|
170
|
+
const connectedPromise = new Promise(resolve => {
|
|
171
|
+
const abort = new AbortController();
|
|
172
|
+
globalThis.window.addEventListener('message', event => {
|
|
173
|
+
if (event.source !== window) return;
|
|
174
|
+
if (event.data === RESPONSE_MESSAGE) {
|
|
175
|
+
connected = true;
|
|
176
|
+
abort.abort();
|
|
177
|
+
resolve();
|
|
178
|
+
}
|
|
179
|
+
}, {
|
|
180
|
+
signal: abort.signal
|
|
181
|
+
});
|
|
182
|
+
abort.signal.addEventListener('abort', () => resolve(), {
|
|
183
|
+
once: true
|
|
184
|
+
});
|
|
185
|
+
sendMessage(CHECK_MESSAGE);
|
|
186
|
+
});
|
|
187
|
+
return {
|
|
188
|
+
send(message, transfer) {
|
|
189
|
+
if (!connected) {
|
|
190
|
+
return connectedPromise.then(() => {
|
|
191
|
+
if (connected) return sendMessage(message, transfer);
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
return sendMessage(message, transfer);
|
|
195
|
+
},
|
|
196
|
+
listen(listen, {
|
|
197
|
+
signal
|
|
198
|
+
}) {
|
|
199
|
+
self.addEventListener('message', event => {
|
|
200
|
+
if (event.source !== window) return;
|
|
201
|
+
if (event.data === RESPONSE_MESSAGE) return;
|
|
202
|
+
listen(event.data);
|
|
203
|
+
}, {
|
|
204
|
+
signal
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export { ThreadWindow, windowToThreadTarget };
|
|
211
|
+
//# sourceMappingURL=ThreadWindow.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ThreadWindow.mjs","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, windowToThreadTarget };\n"],"names":[],"mappings":";;;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,YAAY,SAAS,MAAM,CAAC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,OAAO,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE;AAC/B,IAAI,OAAO,IAAI,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC;AAC5C,EAAE;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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,MAAM,IAAI,CAAC,SAAS,EAAE;AACtB,QAAQ,OAAO,gBAAgB,CAAC,IAAI,CAAC,MAAM;AAC3C,UAAU,IAAI,SAAS,EAAE,OAAO,WAAW,CAAC,OAAO,EAAE,QAAQ,CAAC;AAC9D,QAAQ,CAAC,CAAC;AACV,MAAM;AACN,MAAM,OAAO,WAAW,CAAC,OAAO,EAAE,QAAQ,CAAC;AAC3C,IAAI,CAAC;AACL,IAAI,MAAM,CAAC,MAAM,EAAE;AACnB,MAAM;AACN,KAAK,EAAE;AACP,MAAM,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,KAAK,IAAI;AAChD,QAAQ,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM,EAAE;AACrC,QAAQ,IAAI,KAAK,CAAC,IAAI,KAAK,gBAAgB,EAAE;AAC7C,QAAQ,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;AAC1B,MAAM,CAAC,EAAE;AACT,QAAQ;AACR,OAAO,CAAC;AACR,IAAI;AACJ,GAAG;AACH;;;;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.mjs","sources":["../../../../../../../../../../../../../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/window/shared.mjs"],"sourcesContent":["const CHECK_MESSAGE = 'quilt.threads.ping';\nconst RESPONSE_MESSAGE = 'quilt.threads.pong';\n\nexport { CHECK_MESSAGE, RESPONSE_MESSAGE };\n"],"names":[],"mappings":"AAAK,MAAC,aAAa,GAAG;AACjB,MAAC,gBAAgB,GAAG;;;;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TRANSFERABLE } from './constants.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Marks the value as being transferable between threads. The memory for this object
|
|
5
|
+
* will be moved to the target thread once the object is sent.
|
|
6
|
+
*
|
|
7
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Transferable_objects
|
|
8
|
+
*/
|
|
9
|
+
function markAsTransferable(value) {
|
|
10
|
+
Object.assign(value, {
|
|
11
|
+
[TRANSFERABLE]: true
|
|
12
|
+
});
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { markAsTransferable };
|
|
17
|
+
//# sourceMappingURL=transfer.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transfer.mjs","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"],"names":[],"mappings":";;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,kBAAkB,CAAC,KAAK,EAAE;AACnC,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE;AACvB,IAAI,CAAC,YAAY,GAAG;AACpB,GAAG,CAAC;AACJ,EAAE,OAAO,KAAK;AACd;;;;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Version } from './types.mjs';
|
|
2
|
+
import { RemoteError } from '../error.mjs';
|
|
3
|
+
import { FlowThreadSerialization } from '../serialization/FlowThreadSerialization.mjs';
|
|
4
|
+
import '@mittwald/remote-dom-core/elements';
|
|
5
|
+
import { ThreadNestedIframe } from '../../../../node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/ThreadNestedIframe.mjs';
|
|
6
|
+
|
|
7
|
+
const incompatibleParentFrameError = () => new RemoteError("Could not find any compatible parent frame");
|
|
8
|
+
const connectRemoteReceiver = (root, receiverConnection) => import('@mittwald/remote-dom-core/elements').then(
|
|
9
|
+
({ RemoteMutationObserver }) => {
|
|
10
|
+
const observer = new RemoteMutationObserver(receiverConnection);
|
|
11
|
+
observer.observe(root);
|
|
12
|
+
}
|
|
13
|
+
);
|
|
14
|
+
const connectHostRenderRoot = async (options) => {
|
|
15
|
+
const { root, onPathnameChanged, onHostError, packageVersion } = options;
|
|
16
|
+
const connection = new ThreadNestedIframe({
|
|
17
|
+
serialization: new FlowThreadSerialization(),
|
|
18
|
+
exports: {
|
|
19
|
+
render: (connection2) => connectRemoteReceiver(root, connection2),
|
|
20
|
+
setPathname: async (pathname) => {
|
|
21
|
+
onPathnameChanged?.(pathname);
|
|
22
|
+
},
|
|
23
|
+
setHostError: async (error) => {
|
|
24
|
+
onHostError?.(error);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
if (connection.parent === window) {
|
|
29
|
+
throw incompatibleParentFrameError();
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
await connection.imports.setIsReady({
|
|
33
|
+
version: Version.v5,
|
|
34
|
+
packageVersion
|
|
35
|
+
});
|
|
36
|
+
if (typeof mwExtBridge !== "undefined") {
|
|
37
|
+
mwExtBridge.connection = connection.imports;
|
|
38
|
+
await mwExtBridge.readiness.setIsReady();
|
|
39
|
+
}
|
|
40
|
+
return connection;
|
|
41
|
+
} catch (error) {
|
|
42
|
+
if (error instanceof Error && /No '.*' method is exported from this thread/.test(error.message)) {
|
|
43
|
+
throw incompatibleParentFrameError();
|
|
44
|
+
}
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const connectHostRenderRootRef = (opts) => (ref) => {
|
|
49
|
+
if (ref === null) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if ("__remoteConnection" in ref) {
|
|
53
|
+
return ref["__remoteConnection"];
|
|
54
|
+
}
|
|
55
|
+
const connection = connectHostRenderRoot({
|
|
56
|
+
root: ref,
|
|
57
|
+
...opts
|
|
58
|
+
});
|
|
59
|
+
Object.assign(ref, { __remoteConnection: connection });
|
|
60
|
+
return connection;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export { connectHostRenderRoot, connectHostRenderRootRef, connectRemoteReceiver };
|
|
64
|
+
//# sourceMappingURL=connectHostRenderRoot.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connectHostRenderRoot.mjs","sources":["../../../../../../src/connection/connectHostRenderRoot.ts"],"sourcesContent":["import {\n Version,\n type HostExports,\n type RemoteExports,\n type RemoteToHostConnection,\n} from \"@/connection/types\";\nimport { RemoteError } from \"@/error\";\nimport { FlowThreadSerialization } from \"@/serialization/FlowThreadSerialization\";\nimport { type RemoteConnection } from \"@mittwald/remote-dom-core/elements\";\nimport { ThreadNestedIframe } from \"@quilted/threads\";\n\ninterface Options {\n root: HTMLDivElement;\n onPathnameChanged?: (pathname: string) => void;\n onHostError?: (error: string) => void;\n packageVersion?: string;\n}\n\nconst incompatibleParentFrameError = () =>\n new RemoteError(\"Could not find any compatible parent frame\");\n\nexport const connectRemoteReceiver = (\n root: HTMLDivElement,\n receiverConnection: RemoteConnection,\n) =>\n import(\"@mittwald/remote-dom-core/elements\").then(\n ({ RemoteMutationObserver }) => {\n const observer = new RemoteMutationObserver(receiverConnection);\n observer.observe(root);\n },\n );\n\nexport const connectHostRenderRoot = async (\n options: Options,\n): Promise<RemoteToHostConnection> => {\n const { root, onPathnameChanged, onHostError, packageVersion } = options;\n\n const connection = new ThreadNestedIframe<HostExports, RemoteExports>({\n serialization: new FlowThreadSerialization(),\n exports: {\n render: (connection: RemoteConnection) =>\n connectRemoteReceiver(root, connection),\n setPathname: async (pathname) => {\n onPathnameChanged?.(pathname);\n },\n setHostError: async (error) => {\n onHostError?.(error);\n },\n },\n });\n\n if (connection.parent === window) {\n throw incompatibleParentFrameError();\n }\n\n try {\n await connection.imports.setIsReady({\n version: Version.v5,\n packageVersion,\n });\n\n if (typeof mwExtBridge !== \"undefined\") {\n mwExtBridge.connection = connection.imports;\n await mwExtBridge.readiness.setIsReady();\n }\n\n return connection;\n } catch (error) {\n if (\n error instanceof Error &&\n /No '.*' method is exported from this thread/.test(error.message)\n ) {\n throw incompatibleParentFrameError();\n }\n throw error;\n }\n};\n\nexport const connectHostRenderRootRef =\n (opts: Omit<Options, \"root\">) => (ref: HTMLDivElement | null) => {\n if (ref === null) {\n return;\n }\n if (\"__remoteConnection\" in ref) {\n return ref[\"__remoteConnection\"] as Promise<RemoteToHostConnection>;\n }\n\n const connection = connectHostRenderRoot({\n root: ref,\n ...opts,\n });\n Object.assign(ref, { __remoteConnection: connection });\n return connection;\n };\n"],"names":["connection"],"mappings":";;;;;;AAkBA,MAAM,4BAAA,GAA+B,MACnC,IAAI,WAAA,CAAY,4CAA4C,CAAA;AAEvD,MAAM,wBAAwB,CACnC,IAAA,EACA,kBAAA,KAEA,OAAO,oCAAoC,CAAA,CAAE,IAAA;AAAA,EAC3C,CAAC,EAAE,sBAAA,EAAuB,KAAM;AAC9B,IAAA,MAAM,QAAA,GAAW,IAAI,sBAAA,CAAuB,kBAAkB,CAAA;AAC9D,IAAA,QAAA,CAAS,QAAQ,IAAI,CAAA;AAAA,EACvB;AACF;AAEK,MAAM,qBAAA,GAAwB,OACnC,OAAA,KACoC;AACpC,EAAA,MAAM,EAAE,IAAA,EAAM,iBAAA,EAAmB,WAAA,EAAa,gBAAe,GAAI,OAAA;AAEjE,EAAA,MAAM,UAAA,GAAa,IAAI,kBAAA,CAA+C;AAAA,IACpE,aAAA,EAAe,IAAI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;AAAA,GACJ,CAAA;AACD,EAAA,MAAA,CAAO,MAAA,CAAO,GAAA,EAAK,EAAE,kBAAA,EAAoB,YAAY,CAAA;AACrD,EAAA,OAAO,UAAA;AACT;;;;"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Version } from './types.mjs';
|
|
2
|
+
import { getWithMergedHostConfig } from '../ext-bridge/getWithMergedHostConfig.mjs';
|
|
3
|
+
import { emptyImplementation } from '../ext-bridge/implementation.mjs';
|
|
4
|
+
import { FlowThreadSerialization } from '../serialization/FlowThreadSerialization.mjs';
|
|
5
|
+
import { ThreadIframe } from '../../../../node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/ThreadIframe.mjs';
|
|
6
|
+
|
|
7
|
+
const normalizeReadyEvent = (event) => {
|
|
8
|
+
if (typeof event === "number") {
|
|
9
|
+
return {
|
|
10
|
+
version: event
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
return event ?? {
|
|
14
|
+
version: Version.v1
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
const connectRemoteIframe = (opts) => {
|
|
18
|
+
const {
|
|
19
|
+
connection,
|
|
20
|
+
iframe,
|
|
21
|
+
onReady,
|
|
22
|
+
onLoadingChanged,
|
|
23
|
+
onError,
|
|
24
|
+
onNavigationStateChanged,
|
|
25
|
+
onDeprecation,
|
|
26
|
+
extBridgeImplementation: extBridgeImplementationProp = emptyImplementation,
|
|
27
|
+
hostConfig
|
|
28
|
+
} = opts;
|
|
29
|
+
const extBridgeImplementation = {
|
|
30
|
+
...extBridgeImplementationProp,
|
|
31
|
+
getConfig: getWithMergedHostConfig(extBridgeImplementationProp, hostConfig)
|
|
32
|
+
};
|
|
33
|
+
const result = {
|
|
34
|
+
thread: new ThreadIframe(iframe, {
|
|
35
|
+
serialization: new FlowThreadSerialization(),
|
|
36
|
+
exports: {
|
|
37
|
+
...extBridgeImplementation,
|
|
38
|
+
setIsReady: async (event) => {
|
|
39
|
+
const readyEvent = normalizeReadyEvent(event);
|
|
40
|
+
result.version = readyEvent.version;
|
|
41
|
+
onReady?.({
|
|
42
|
+
connection: result,
|
|
43
|
+
remoteReadyEvent: readyEvent
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
setIsLoading: async (isLoading) => {
|
|
47
|
+
onLoadingChanged?.(isLoading);
|
|
48
|
+
},
|
|
49
|
+
setError: async (error) => {
|
|
50
|
+
onError?.(error);
|
|
51
|
+
},
|
|
52
|
+
setNavigationState: async (state) => {
|
|
53
|
+
onNavigationStateChanged?.(state);
|
|
54
|
+
},
|
|
55
|
+
reportDeprecation: async (message) => {
|
|
56
|
+
onDeprecation?.(message);
|
|
57
|
+
},
|
|
58
|
+
getHostConfig: async () => {
|
|
59
|
+
return hostConfig;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}),
|
|
63
|
+
updateHostPathname: (hostPathname) => {
|
|
64
|
+
if (hostPathname === void 0) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (result.version >= Version.v2) {
|
|
68
|
+
result.thread.imports.setPathname(hostPathname);
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
reportHostError: async (error) => {
|
|
72
|
+
if (result.version >= Version.v5) {
|
|
73
|
+
await result.thread.imports.setHostError(error);
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
version: 0
|
|
77
|
+
};
|
|
78
|
+
result.thread.imports.render(connection);
|
|
79
|
+
return result;
|
|
80
|
+
};
|
|
81
|
+
const connectRemoteIframeRef = (opts) => (ref) => {
|
|
82
|
+
if (!ref) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if ("__remoteConnection" in ref) {
|
|
86
|
+
return ref["__remoteConnection"];
|
|
87
|
+
}
|
|
88
|
+
const connection = connectRemoteIframe({
|
|
89
|
+
iframe: ref,
|
|
90
|
+
...opts
|
|
91
|
+
});
|
|
92
|
+
Object.assign(ref, { __remoteConnection: connection });
|
|
93
|
+
return connection;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export { connectRemoteIframe, connectRemoteIframeRef };
|
|
97
|
+
//# sourceMappingURL=connectRemoteIframe.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connectRemoteIframe.mjs","sources":["../../../../../../src/connection/connectRemoteIframe.ts"],"sourcesContent":["import {\n Version,\n type HostExports,\n type HostToRemoteConnection,\n type HostToRemoteConnectionReadyEvent,\n type NavigationState,\n type RemoteExports,\n type RemoteExtBridgeConnectionApi,\n type RemoteReadyEvent,\n type RemoteReadyEventInput,\n} from \"@/connection/types\";\nimport { getWithMergedHostConfig } from \"@/ext-bridge/getWithMergedHostConfig\";\nimport { emptyImplementation } from \"@/ext-bridge/implementation\";\nimport { FlowThreadSerialization } from \"@/serialization/FlowThreadSerialization\";\nimport { type HostConfig } from \"@mittwald/flow-core\";\nimport type { RemoteConnection } from \"@mittwald/remote-dom-core/elements\";\nimport { ThreadIframe } from \"@quilted/threads\";\n\ninterface Options {\n connection: RemoteConnection;\n iframe: HTMLIFrameElement;\n hostConfig: HostConfig;\n onReady?: (event: HostToRemoteConnectionReadyEvent) => void;\n onLoadingChanged?: (isLoading: boolean) => void;\n onError?: (error: string) => void;\n onNavigationStateChanged?: (state: NavigationState) => void;\n onDeprecation?: (message: string) => void;\n extBridgeImplementation?: RemoteExtBridgeConnectionApi;\n}\n\nconst normalizeReadyEvent = (\n event?: RemoteReadyEventInput,\n): RemoteReadyEvent => {\n if (typeof event === \"number\") {\n return {\n version: event,\n };\n }\n\n return (\n event ?? {\n version: Version.v1,\n }\n );\n};\n\nexport const connectRemoteIframe = (opts: Options): HostToRemoteConnection => {\n const {\n connection,\n iframe,\n onReady,\n onLoadingChanged,\n onError,\n onNavigationStateChanged,\n onDeprecation,\n extBridgeImplementation: extBridgeImplementationProp = emptyImplementation,\n hostConfig,\n } = opts;\n\n const extBridgeImplementation = {\n ...extBridgeImplementationProp,\n getConfig: getWithMergedHostConfig(extBridgeImplementationProp, hostConfig),\n };\n\n const result: HostToRemoteConnection = {\n thread: new ThreadIframe<RemoteExports, HostExports>(iframe, {\n serialization: new FlowThreadSerialization(),\n exports: {\n ...extBridgeImplementation,\n setIsReady: async (event) => {\n const readyEvent = normalizeReadyEvent(event);\n result.version = readyEvent.version;\n onReady?.({\n connection: result,\n remoteReadyEvent: readyEvent,\n });\n },\n setIsLoading: async (isLoading: boolean) => {\n onLoadingChanged?.(isLoading);\n },\n setError: async (error: string) => {\n onError?.(error);\n },\n setNavigationState: async (state) => {\n onNavigationStateChanged?.(state);\n },\n reportDeprecation: async (message: string) => {\n onDeprecation?.(message);\n },\n getHostConfig: async () => {\n return hostConfig;\n },\n },\n }),\n updateHostPathname: (hostPathname?: string) => {\n if (hostPathname === undefined) {\n return;\n }\n\n if (result.version >= Version.v2) {\n result.thread.imports.setPathname(hostPathname);\n }\n },\n reportHostError: async (error) => {\n if (result.version >= Version.v5) {\n await result.thread.imports.setHostError(error);\n }\n },\n version: 0,\n };\n\n result.thread.imports.render(connection);\n return result;\n};\n\nexport const connectRemoteIframeRef =\n (opts: Omit<Options, \"iframe\">) => (ref: HTMLIFrameElement | null) => {\n if (!ref) {\n return;\n }\n\n if (\"__remoteConnection\" in ref) {\n return ref[\"__remoteConnection\"] as HostToRemoteConnection;\n }\n\n const connection = connectRemoteIframe({\n iframe: ref,\n ...opts,\n });\n Object.assign(ref, { __remoteConnection: connection });\n return connection;\n };\n"],"names":[],"mappings":";;;;;;AA8BA,MAAM,mBAAA,GAAsB,CAC1B,KAAA,KACqB;AACrB,EAAA,IAAI,OAAO,UAAU,QAAA,EAAU;AAC7B,IAAA,OAAO;AAAA,MACL,OAAA,EAAS;AAAA,KACX;AAAA,EACF;AAEA,EAAA,OACE,KAAA,IAAS;AAAA,IACP,SAAS,OAAA,CAAQ;AAAA,GACnB;AA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
Version2[Version2["vUnknown"] = 0] = "vUnknown";
|
|
3
|
+
Version2[Version2["v1"] = 1] = "v1";
|
|
4
|
+
Version2[Version2["v2"] = 2] = "v2";
|
|
5
|
+
Version2[Version2["v3"] = 3] = "v3";
|
|
6
|
+
Version2[Version2["v4"] = 4] = "v4";
|
|
7
|
+
Version2[Version2["v5"] = 5] = "v5";
|
|
8
|
+
return Version2;
|
|
9
|
+
})(Version || {});
|
|
10
|
+
|
|
11
|
+
export { Version };
|
|
12
|
+
//# sourceMappingURL=types.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.mjs","sources":["../../../../../../src/connection/types.ts"],"sourcesContent":["import type {\n ExtBridgeConfigInput,\n ExtBridgeConnectionApi,\n} from \"@mittwald/ext-bridge\";\nimport type { HostConfig } from \"@mittwald/flow-core\";\nimport type { RemoteConnection } from \"@mittwald/remote-dom-core\";\nimport type { ThreadIframe, ThreadNestedIframe } from \"@quilted/threads\";\nexport type { RemoteConnection } from \"@mittwald/remote-dom-core\";\n\nexport interface NavigationState {\n pathname: string;\n isPending: boolean;\n}\n\nexport interface RemoteReadyEvent {\n version: Version;\n packageVersion?: string;\n}\n\nexport type RemoteReadyEventInput = Version | RemoteReadyEvent;\n\nexport type RemoteExtBridgeConfig = Omit<\n ExtBridgeConfigInput,\n keyof HostConfig\n>;\n\nexport interface RemoteExtBridgeConnectionApi extends Omit<\n ExtBridgeConnectionApi,\n \"getConfig\"\n> {\n getConfig: () => Promise<RemoteExtBridgeConfig>;\n}\n\n/**\n * Breaking Change warning: Do not remove/rename/modify existing properties of\n * this interface, as they might be used by existing extensions.\n *\n * When addding properties, make sure to release the host before all clients.\n */\nexport interface HostExports extends ExtBridgeConnectionApi {\n setIsReady: (event?: RemoteReadyEventInput) => Promise<void>;\n setIsLoading: (isLoading: boolean) => Promise<void>;\n setError: (error: string) => Promise<void>;\n setNavigationState: (state: NavigationState) => Promise<void>;\n getHostConfig: () => Promise<HostConfig>;\n reportDeprecation: (message: string) => Promise<void>;\n}\n\nexport interface RemoteExports {\n render: (connection: RemoteConnection) => Promise<void>;\n setPathname: (pathname: string) => Promise<void>;\n setHostError: (error: string) => Promise<void>;\n}\n\nexport type RemoteToHostConnection = ThreadNestedIframe<\n HostExports,\n RemoteExports\n>;\n\nexport interface HostToRemoteConnection {\n version: Version;\n thread: ThreadIframe<RemoteExports, HostExports>;\n updateHostPathname: (hostPathname?: string) => void;\n reportHostError: (error: string) => Promise<void>;\n}\n\nexport interface HostToRemoteConnectionReadyEvent {\n connection: HostToRemoteConnection;\n remoteReadyEvent: RemoteReadyEvent;\n}\n\nexport enum Version {\n vUnknown = 0,\n v1 = 1,\n v2 = 2,\n v3 = 3,\n v4 = 4,\n v5 = 5,\n}\n"],"names":["Version"],"mappings":"AAuEO,IAAK,OAAA,qBAAAA,QAAAA,KAAL;AACL,EAAAA,QAAAA,CAAAA,QAAAA,CAAA,cAAW,CAAA,CAAA,GAAX,UAAA;AACA,EAAAA,QAAAA,CAAAA,QAAAA,CAAA,QAAK,CAAA,CAAA,GAAL,IAAA;AACA,EAAAA,QAAAA,CAAAA,QAAAA,CAAA,QAAK,CAAA,CAAA,GAAL,IAAA;AACA,EAAAA,QAAAA,CAAAA,QAAAA,CAAA,QAAK,CAAA,CAAA,GAAL,IAAA;AACA,EAAAA,QAAAA,CAAAA,QAAAA,CAAA,QAAK,CAAA,CAAA,GAAL,IAAA;AACA,EAAAA,QAAAA,CAAAA,QAAAA,CAAA,QAAK,CAAA,CAAA,GAAL,IAAA;AANU,EAAA,OAAAA,QAAAA;AAAA,CAAA,EAAA,OAAA,IAAA,EAAA;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.mjs","sources":["../../../../../src/error.ts"],"sourcesContent":["export class RemoteError extends Error {\n constructor(message: string) {\n super(message);\n this.message = message;\n }\n}\n\nRemoteError.prototype.name = \"RemoteError\";\n"],"names":[],"mappings":"AAAO,MAAM,oBAAoB,KAAA,CAAM;AAAA,EACrC,YAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,OAAA,GAAU,OAAA;AAAA,EACjB;AACF;AAEA,WAAA,CAAY,UAAU,IAAA,GAAO,aAAA;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const getWithMergedHostConfig = (extBridgeConnection, hostConfig) => async () => {
|
|
2
|
+
const baseConfig = await extBridgeConnection.getConfig();
|
|
3
|
+
return {
|
|
4
|
+
...hostConfig,
|
|
5
|
+
...baseConfig
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export { getWithMergedHostConfig };
|
|
10
|
+
//# sourceMappingURL=getWithMergedHostConfig.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getWithMergedHostConfig.mjs","sources":["../../../../../../src/ext-bridge/getWithMergedHostConfig.ts"],"sourcesContent":["import type { RemoteExtBridgeConnectionApi } from \"@/connection\";\nimport type { ExtBridgeConfigInput } from \"@mittwald/ext-bridge\";\nimport type { HostConfig } from \"@mittwald/flow-core\";\n\nexport const getWithMergedHostConfig =\n (extBridgeConnection: RemoteExtBridgeConnectionApi, hostConfig: HostConfig) =>\n async (): Promise<ExtBridgeConfigInput> => {\n const baseConfig = await extBridgeConnection.getConfig();\n\n return {\n ...hostConfig,\n ...baseConfig,\n };\n };\n"],"names":[],"mappings":"AAIO,MAAM,uBAAA,GACX,CAAC,mBAAA,EAAmD,UAAA,KACpD,YAA2C;AACzC,EAAA,MAAM,UAAA,GAAa,MAAM,mBAAA,CAAoB,SAAA,EAAU;AAEvD,EAAA,OAAO;AAAA,IACL,GAAG,UAAA;AAAA,IACH,GAAG;AAAA,GACL;AACF;;;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RemoteError } from '../error.mjs';
|
|
2
|
+
|
|
3
|
+
const emptyImplementation = new Proxy(
|
|
4
|
+
{},
|
|
5
|
+
{
|
|
6
|
+
get() {
|
|
7
|
+
throw new RemoteError("Missing implementation for mittwald.extBridge");
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
export { emptyImplementation };
|
|
13
|
+
//# sourceMappingURL=implementation.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"implementation.mjs","sources":["../../../../../../src/ext-bridge/implementation.ts"],"sourcesContent":["import { RemoteError } from \"@/error\";\nimport type { ExtBridgeConnectionApi } from \"@mittwald/ext-bridge\";\n\nexport const emptyImplementation = new Proxy(\n {},\n {\n get() {\n throw new RemoteError(\"Missing implementation for mittwald.extBridge\");\n },\n },\n) as ExtBridgeConnectionApi;\n"],"names":[],"mappings":";;AAGO,MAAM,sBAAsB,IAAI,KAAA;AAAA,EACrC,EAAC;AAAA,EACD;AAAA,IACE,GAAA,GAAM;AACJ,MAAA,MAAM,IAAI,YAAY,+CAA+C,CAAA;AAAA,IACvE;AAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import * as index from './serializers/index.mjs';
|
|
2
|
+
import { isObjectType } from 'remeda';
|
|
3
|
+
import { Serializer } from './Serializer.mjs';
|
|
4
|
+
import { ThreadSerializationStructuredClone } from '../../../../node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/serialization/ThreadSerializationStructuredClone.mjs';
|
|
5
|
+
import { TRANSFERABLE } from '../../../../node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/constants.mjs';
|
|
6
|
+
|
|
7
|
+
const serializers = Object.values(index).filter(
|
|
8
|
+
(val) => val instanceof Serializer
|
|
9
|
+
);
|
|
10
|
+
class FlowThreadSerialization extends ThreadSerializationStructuredClone {
|
|
11
|
+
constructor() {
|
|
12
|
+
const options = {
|
|
13
|
+
serialize: async (val, serialize) => {
|
|
14
|
+
try {
|
|
15
|
+
if (this.isSerializableByBase(val)) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (this.omitSerialization(val)) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
for (const serializer of serializers) {
|
|
22
|
+
const serialization = await serializer.serialize(val);
|
|
23
|
+
if (serialization.applied) {
|
|
24
|
+
return await serialize(serialization.result);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (isObjectType(val)) {
|
|
28
|
+
return await serialize({ ...val });
|
|
29
|
+
}
|
|
30
|
+
return void 0;
|
|
31
|
+
} catch (error) {
|
|
32
|
+
console.error("Error while serializing", error);
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
deserialize: async (val, deserialize) => {
|
|
37
|
+
try {
|
|
38
|
+
for (const serializer of serializers) {
|
|
39
|
+
const deserialization = await serializer.deserialize(val);
|
|
40
|
+
if (deserialization.applied) {
|
|
41
|
+
return deserialization.result.value;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return await deserialize(val);
|
|
45
|
+
} catch (error) {
|
|
46
|
+
console.error("Error while deserializing", error);
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
super(options);
|
|
52
|
+
}
|
|
53
|
+
isSerializableByBase(val) {
|
|
54
|
+
return val instanceof Map || val instanceof Set || Array.isArray(val) || typeof val === "function" || isObjectType(val) && TRANSFERABLE in val;
|
|
55
|
+
}
|
|
56
|
+
omitSerialization(val) {
|
|
57
|
+
return val instanceof HTMLElement || val === window;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export { FlowThreadSerialization };
|
|
62
|
+
//# sourceMappingURL=FlowThreadSerialization.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FlowThreadSerialization.mjs","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"],"names":["serializerModules"],"mappings":";;;;;;AASA,MAAM,WAAA,GAAc,MAAA,CAAO,MAAA,CAAOA,KAAiB,CAAA,CAAE,MAAA;AAAA,EACnD,CAAC,QAAQ,GAAA,YAAe;AAC1B,CAAA;AAEO,MAAM,gCAAgC,kCAAA,CAAmC;AAAA,EACvE,WAAA,GAAc;AACn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