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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/dist/js/_virtual/_rolldown/runtime.mjs +13 -0
  2. package/dist/js/index-node.mjs +21 -17
  3. package/dist/js/index-node.mjs.map +1 -1
  4. package/dist/js/index.mjs +24 -16
  5. package/dist/js/index.mjs.map +1 -1
  6. package/dist/js/node_modules/.pnpm/@quilted_events@2.1.5/node_modules/@quilted/events/build/esm/abort/NestedAbortController.mjs +33 -36
  7. package/dist/js/node_modules/.pnpm/@quilted_events@2.1.5/node_modules/@quilted/events/build/esm/abort/NestedAbortController.mjs.map +1 -1
  8. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/Thread.mjs +167 -225
  9. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/Thread.mjs.map +1 -1
  10. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/constants.mjs +6 -9
  11. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/constants.mjs.map +1 -1
  12. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/errors.mjs +9 -7
  13. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/errors.mjs.map +1 -1
  14. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/functions/ThreadFunctionsAutomatic.mjs +68 -67
  15. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/functions/ThreadFunctionsAutomatic.mjs.map +1 -1
  16. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/nanoid.mjs +8 -8
  17. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/nanoid.mjs.map +1 -1
  18. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/serialization/ThreadSerializationStructuredClone.mjs +130 -210
  19. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/serialization/ThreadSerializationStructuredClone.mjs.map +1 -1
  20. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/serialization/shared.mjs +8 -6
  21. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/serialization/shared.mjs.map +1 -1
  22. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/ThreadIframe.mjs +152 -159
  23. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/ThreadIframe.mjs.map +1 -1
  24. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/ThreadNestedIframe.mjs +76 -84
  25. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/ThreadNestedIframe.mjs.map +1 -1
  26. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/window/ThreadNestedWindow.mjs +117 -137
  27. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/window/ThreadNestedWindow.mjs.map +1 -1
  28. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/window/ThreadWindow.mjs +189 -208
  29. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/window/ThreadWindow.mjs.map +1 -1
  30. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/window/shared.mjs +6 -4
  31. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/window/shared.mjs.map +1 -1
  32. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/transfer.mjs +12 -13
  33. package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/transfer.mjs.map +1 -1
  34. package/dist/js/packages/remote-core/src/connection/connectHostRenderRoot.mjs +51 -61
  35. package/dist/js/packages/remote-core/src/connection/connectHostRenderRoot.mjs.map +1 -1
  36. package/dist/js/packages/remote-core/src/connection/connectRemoteIframe.mjs +73 -101
  37. package/dist/js/packages/remote-core/src/connection/connectRemoteIframe.mjs.map +1 -1
  38. package/dist/js/packages/remote-core/src/connection/index.mjs +4 -0
  39. package/dist/js/packages/remote-core/src/connection/types.mjs +13 -11
  40. package/dist/js/packages/remote-core/src/connection/types.mjs.map +1 -1
  41. package/dist/js/packages/remote-core/src/error.mjs +10 -8
  42. package/dist/js/packages/remote-core/src/error.mjs.map +1 -1
  43. package/dist/js/packages/remote-core/src/events/remoteEvents.mjs +14 -16
  44. package/dist/js/packages/remote-core/src/events/remoteEvents.mjs.map +1 -1
  45. package/dist/js/packages/remote-core/src/ext-bridge/getWithMergedHostConfig.mjs +10 -8
  46. package/dist/js/packages/remote-core/src/ext-bridge/getWithMergedHostConfig.mjs.map +1 -1
  47. package/dist/js/packages/remote-core/src/ext-bridge/implementation.mjs +8 -12
  48. package/dist/js/packages/remote-core/src/ext-bridge/implementation.mjs.map +1 -1
  49. package/dist/js/packages/remote-core/src/serialization/FlowThreadSerialization.mjs +49 -61
  50. package/dist/js/packages/remote-core/src/serialization/FlowThreadSerialization.mjs.map +1 -1
  51. package/dist/js/packages/remote-core/src/serialization/Serializer.mjs +31 -31
  52. package/dist/js/packages/remote-core/src/serialization/Serializer.mjs.map +1 -1
  53. package/dist/js/packages/remote-core/src/serialization/index.mjs +10 -0
  54. package/dist/js/packages/remote-core/src/serialization/serializers/dataTransferText.mjs +20 -21
  55. package/dist/js/packages/remote-core/src/serialization/serializers/dataTransferText.mjs.map +1 -1
  56. package/dist/js/packages/remote-core/src/serialization/serializers/date.mjs +13 -14
  57. package/dist/js/packages/remote-core/src/serialization/serializers/date.mjs.map +1 -1
  58. package/dist/js/packages/remote-core/src/serialization/serializers/file.mjs +27 -28
  59. package/dist/js/packages/remote-core/src/serialization/serializers/file.mjs.map +1 -1
  60. package/dist/js/packages/remote-core/src/serialization/serializers/fileList.mjs +18 -22
  61. package/dist/js/packages/remote-core/src/serialization/serializers/fileList.mjs.map +1 -1
  62. package/dist/js/packages/remote-core/src/serialization/serializers/formData.mjs +27 -34
  63. package/dist/js/packages/remote-core/src/serialization/serializers/formData.mjs.map +1 -1
  64. package/dist/js/packages/remote-core/src/serialization/serializers/index.mjs +23 -7
  65. package/dist/js/packages/remote-core/src/serialization/serializers/index.mjs.map +1 -1
  66. package/dist/js/packages/remote-core/src/serialization/serializers/passwordPolicy.mjs +13 -14
  67. package/dist/js/packages/remote-core/src/serialization/serializers/passwordPolicy.mjs.map +1 -1
  68. package/dist/js/packages/remote-core/src/shim.mjs +32 -15
  69. package/dist/js/packages/remote-core/src/shim.mjs.map +1 -1
  70. package/dist/types/index-node.d.ts.map +1 -1
  71. package/dist/types/index.d.ts.map +1 -1
  72. package/dist/types/shim.d.ts +13 -1
  73. package/dist/types/shim.d.ts.map +1 -1
  74. package/package.json +9 -11
@@ -1 +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,uBAAA,EAAwB;AAAA,IAC3C,OAAA,EA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AAO,MAAA,CAAO,GAAA,EAAK,EAAE,kBAAA,EAAoB,YAAY,CAAA;AACrD,EAAA,OAAO,UAAA;AACT;;;;"}
1
+ {"version":3,"file":"connectHostRenderRoot.mjs","names":[],"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"],"mappings":";;;;;;AAkBA,IAAM,qCACJ,IAAI,YAAY,4CAA4C;AAE9D,IAAa,yBACX,MACA,uBAEA,OAAO,qCAAqC,CAAC,MAC1C,EAAE,6BAA6B;CAE9B,IADqB,uBAAuB,kBAC5C,CAAA,CAAS,QAAQ,IAAI;AACvB,CACF;AAEF,IAAa,wBAAwB,OACnC,YACoC;CACpC,MAAM,EAAE,MAAM,mBAAmB,aAAa,mBAAmB;CAEjE,MAAM,aAAa,IAAI,mBAA+C;EACpE,eAAe,IAAI,wBAAwB;EAC3C,SAAS;GACP,SAAS,eACP,sBAAsB,MAAM,UAAU;GACxC,aAAa,OAAO,aAAa;IAC/B,oBAAoB,QAAQ;GAC9B;GACA,cAAc,OAAO,UAAU;IAC7B,cAAc,KAAK;GACrB;EACF;CACF,CAAC;CAED,IAAI,WAAW,WAAW,QACxB,MAAM,6BAA6B;CAGrC,IAAI;EACF,MAAM,WAAW,QAAQ,WAAW;GAClC,SAAS,QAAQ;GACjB;EACF,CAAC;EAED,IAAI,OAAO,gBAAgB,aAAa;GACtC,YAAY,aAAa,WAAW;GACpC,MAAM,YAAY,UAAU,WAAW;EACzC;EAEA,OAAO;CACT,SAAS,OAAO;EACd,IACE,iBAAiB,SACjB,8CAA8C,KAAK,MAAM,OAAO,GAEhE,MAAM,6BAA6B;EAErC,MAAM;CACR;AACF;AAEA,IAAa,4BACV,UAAiC,QAA+B;CAC/D,IAAI,QAAQ,MACV;CAEF,IAAI,wBAAwB,KAC1B,OAAO,IAAI;CAGb,MAAM,aAAa,sBAAsB;EACvC,MAAM;EACN,GAAG;CACL,CAAC;CACD,OAAO,OAAO,KAAK,EAAE,oBAAoB,WAAW,CAAC;CACrD,OAAO;AACT"}
@@ -1,105 +1,77 @@
1
- import { Version } from './types.mjs';
2
- import { parseReportedEvent } from '../events/remoteEvents.mjs';
3
- import { getWithMergedHostConfig } from '../ext-bridge/getWithMergedHostConfig.mjs';
4
- import { emptyImplementation } from '../ext-bridge/implementation.mjs';
5
- import { FlowThreadSerialization } from '../serialization/FlowThreadSerialization.mjs';
6
- import { ThreadIframe } from '../../../../node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_df15ead5d86def314ee16ab6a48f9e4faa765b52aa161b10d2848_aa11bff1669c76d0bae25976909ea4eb/node_modules/@quilted/threads/build/esm/threads/ThreadIframe.mjs';
7
-
8
- const normalizeReadyEvent = (event) => {
9
- if (typeof event === "number") {
10
- return {
11
- version: event
12
- };
13
- }
14
- return event ?? {
15
- version: Version.v1
16
- };
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";
2
+ import { FlowThreadSerialization } from "../serialization/FlowThreadSerialization.mjs";
3
+ import { Version } from "./types.mjs";
4
+ import { parseReportedEvent } from "../events/remoteEvents.mjs";
5
+ import { getWithMergedHostConfig } from "../ext-bridge/getWithMergedHostConfig.mjs";
6
+ import { emptyImplementation } from "../ext-bridge/implementation.mjs";
7
+ //#region src/connection/connectRemoteIframe.ts
8
+ var normalizeReadyEvent = (event) => {
9
+ if (typeof event === "number") return { version: event };
10
+ return event ?? { version: Version.v1 };
17
11
  };
18
- const connectRemoteIframe = (opts) => {
19
- const {
20
- connection,
21
- iframe,
22
- onReady,
23
- onLoadingChanged,
24
- onError,
25
- onNavigationStateChanged,
26
- onDeprecation,
27
- onEvent,
28
- extBridgeImplementation: extBridgeImplementationProp = emptyImplementation,
29
- hostConfig
30
- } = opts;
31
- const extBridgeImplementation = {
32
- ...extBridgeImplementationProp,
33
- getConfig: getWithMergedHostConfig(extBridgeImplementationProp, hostConfig)
34
- };
35
- const result = {
36
- thread: new ThreadIframe(iframe, {
37
- serialization: new FlowThreadSerialization(),
38
- exports: {
39
- ...extBridgeImplementation,
40
- setIsReady: async (event) => {
41
- const readyEvent = normalizeReadyEvent(event);
42
- result.version = readyEvent.version;
43
- onReady?.({
44
- connection: result,
45
- remoteReadyEvent: readyEvent
46
- });
47
- },
48
- setIsLoading: async (isLoading) => {
49
- onLoadingChanged?.(isLoading);
50
- },
51
- setError: async (error) => {
52
- onError?.(error);
53
- },
54
- setNavigationState: async (state) => {
55
- onNavigationStateChanged?.(state);
56
- },
57
- reportDeprecation: async (message) => {
58
- onDeprecation?.(message);
59
- },
60
- reportEvent: async (event) => {
61
- const parsed = parseReportedEvent(event);
62
- if (parsed) {
63
- onEvent?.(parsed);
64
- }
65
- },
66
- getHostConfig: async () => {
67
- return hostConfig;
68
- }
69
- }
70
- }),
71
- updateHostPathname: (hostPathname) => {
72
- if (hostPathname === void 0) {
73
- return;
74
- }
75
- if (result.version >= Version.v2) {
76
- result.thread.imports.setPathname(hostPathname);
77
- }
78
- },
79
- reportHostError: async (error) => {
80
- if (result.version >= Version.v5) {
81
- await result.thread.imports.setHostError(error);
82
- }
83
- },
84
- version: 0
85
- };
86
- result.thread.imports.render(connection);
87
- return result;
12
+ var connectRemoteIframe = (opts) => {
13
+ const { connection, iframe, onReady, onLoadingChanged, onError, onNavigationStateChanged, onDeprecation, onEvent, extBridgeImplementation: extBridgeImplementationProp = emptyImplementation, hostConfig } = opts;
14
+ const extBridgeImplementation = {
15
+ ...extBridgeImplementationProp,
16
+ getConfig: getWithMergedHostConfig(extBridgeImplementationProp, hostConfig)
17
+ };
18
+ const result = {
19
+ thread: new ThreadIframe(iframe, {
20
+ serialization: new FlowThreadSerialization(),
21
+ exports: {
22
+ ...extBridgeImplementation,
23
+ setIsReady: async (event) => {
24
+ const readyEvent = normalizeReadyEvent(event);
25
+ result.version = readyEvent.version;
26
+ onReady?.({
27
+ connection: result,
28
+ remoteReadyEvent: readyEvent
29
+ });
30
+ },
31
+ setIsLoading: async (isLoading) => {
32
+ onLoadingChanged?.(isLoading);
33
+ },
34
+ setError: async (error) => {
35
+ onError?.(error);
36
+ },
37
+ setNavigationState: async (state) => {
38
+ onNavigationStateChanged?.(state);
39
+ },
40
+ reportDeprecation: async (message) => {
41
+ onDeprecation?.(message);
42
+ },
43
+ reportEvent: async (event) => {
44
+ const parsed = parseReportedEvent(event);
45
+ if (parsed) onEvent?.(parsed);
46
+ },
47
+ getHostConfig: async () => {
48
+ return hostConfig;
49
+ }
50
+ }
51
+ }),
52
+ updateHostPathname: (hostPathname) => {
53
+ if (hostPathname === void 0) return;
54
+ if (result.version >= Version.v2) result.thread.imports.setPathname(hostPathname);
55
+ },
56
+ reportHostError: async (error) => {
57
+ if (result.version >= Version.v5) await result.thread.imports.setHostError(error);
58
+ },
59
+ version: 0
60
+ };
61
+ result.thread.imports.render(connection);
62
+ return result;
88
63
  };
89
- const connectRemoteIframeRef = (opts) => (ref) => {
90
- if (!ref) {
91
- return;
92
- }
93
- if ("__remoteConnection" in ref) {
94
- return ref["__remoteConnection"];
95
- }
96
- const connection = connectRemoteIframe({
97
- iframe: ref,
98
- ...opts
99
- });
100
- Object.assign(ref, { __remoteConnection: connection });
101
- return connection;
64
+ var connectRemoteIframeRef = (opts) => (ref) => {
65
+ if (!ref) return;
66
+ if ("__remoteConnection" in ref) return ref["__remoteConnection"];
67
+ const connection = connectRemoteIframe({
68
+ iframe: ref,
69
+ ...opts
70
+ });
71
+ Object.assign(ref, { __remoteConnection: connection });
72
+ return connection;
102
73
  };
103
-
74
+ //#endregion
104
75
  export { connectRemoteIframe, connectRemoteIframeRef };
105
- //# sourceMappingURL=connectRemoteIframe.mjs.map
76
+
77
+ //# sourceMappingURL=connectRemoteIframe.mjs.map
@@ -1 +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 { parseReportedEvent, type ReportedEvent } from \"@/events/remoteEvents\";\nimport { getWithMergedHostConfig } from \"@/ext-bridge/getWithMergedHostConfig\";\nimport { emptyImplementation } from \"@/ext-bridge/implementation\";\nimport { FlowThreadSerialization } from \"@/serialization/FlowThreadSerialization\";\nimport type { HostConfig } from \"@mittwald/ext-bridge\";\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 onEvent?: (event: ReportedEvent) => 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 onEvent,\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 reportEvent: async (event) => {\n const parsed = parseReportedEvent(event);\n if (parsed) {\n onEvent?.(parsed);\n }\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":";;;;;;;AAgCA,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;AAEJ,CAAA;AAEO,MAAM,mBAAA,GAAsB,C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,CAAO,GAAA,EAAK,EAAE,kBAAA,EAAoB,YAAY,CAAA;AACrD,EAAA,OAAO,UAAA;AACT;;;;"}
1
+ {"version":3,"file":"connectRemoteIframe.mjs","names":[],"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 { parseReportedEvent, type ReportedEvent } from \"@/events/remoteEvents\";\nimport { getWithMergedHostConfig } from \"@/ext-bridge/getWithMergedHostConfig\";\nimport { emptyImplementation } from \"@/ext-bridge/implementation\";\nimport { FlowThreadSerialization } from \"@/serialization/FlowThreadSerialization\";\nimport type { HostConfig } from \"@mittwald/ext-bridge\";\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 onEvent?: (event: ReportedEvent) => 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 onEvent,\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 reportEvent: async (event) => {\n const parsed = parseReportedEvent(event);\n if (parsed) {\n onEvent?.(parsed);\n }\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"],"mappings":";;;;;;;AAgCA,IAAM,uBACJ,UACqB;CACrB,IAAI,OAAO,UAAU,UACnB,OAAO,EACL,SAAS,MACX;CAGF,OACE,SAAS,EACP,SAAS,QAAQ,GACnB;AAEJ;AAEA,IAAa,uBAAuB,SAA0C;CAC5E,MAAM,EACJ,YACA,QACA,SACA,kBACA,SACA,0BACA,eACA,SACA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 -0,0 +1,4 @@
1
+ import { Version } from "./types.mjs";
2
+ import { connectHostRenderRoot, connectHostRenderRootRef, connectRemoteReceiver } from "./connectHostRenderRoot.mjs";
3
+ import { connectRemoteIframe, connectRemoteIframeRef } from "./connectRemoteIframe.mjs";
4
+ export { Version, connectHostRenderRoot, connectHostRenderRootRef, connectRemoteIframe, connectRemoteIframeRef, connectRemoteReceiver };
@@ -1,12 +1,14 @@
1
- var Version = /* @__PURE__ */ ((Version2) => {
2
- 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
-
1
+ //#region src/connection/types.ts
2
+ var Version = /* @__PURE__ */ function(Version) {
3
+ Version[Version["vUnknown"] = 0] = "vUnknown";
4
+ Version[Version["v1"] = 1] = "v1";
5
+ Version[Version["v2"] = 2] = "v2";
6
+ Version[Version["v3"] = 3] = "v3";
7
+ Version[Version["v4"] = 4] = "v4";
8
+ Version[Version["v5"] = 5] = "v5";
9
+ return Version;
10
+ }({});
11
+ //#endregion
11
12
  export { Version };
12
- //# sourceMappingURL=types.mjs.map
13
+
14
+ //# sourceMappingURL=types.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.mjs","sources":["../../../../../../src/connection/types.ts"],"sourcesContent":["import type {\n ExtBridgeConfigInput,\n ExtBridgeConnectionApi,\n HostConfig,\n} from \"@mittwald/ext-bridge\";\nimport type { ReportedEvent } from \"@/events/remoteEvents\";\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 reportEvent: (event: ReportedEvent) => 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":"AAyEO,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;;;;"}
1
+ {"version":3,"file":"types.mjs","names":[],"sources":["../../../../../../src/connection/types.ts"],"sourcesContent":["import type {\n ExtBridgeConfigInput,\n ExtBridgeConnectionApi,\n HostConfig,\n} from \"@mittwald/ext-bridge\";\nimport type { ReportedEvent } from \"@/events/remoteEvents\";\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 reportEvent: (event: ReportedEvent) => 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"],"mappings":";AAyEA,IAAY,UAAL,yBAAA,SAAA;CACL,QAAA,QAAA,cAAA,KAAA;CACA,QAAA,QAAA,QAAA,KAAA;CACA,QAAA,QAAA,QAAA,KAAA;CACA,QAAA,QAAA,QAAA,KAAA;CACA,QAAA,QAAA,QAAA,KAAA;CACA,QAAA,QAAA,QAAA,KAAA;;AACF,EAAA,CAAA,CAAA"}
@@ -1,10 +1,12 @@
1
- class RemoteError extends Error {
2
- constructor(message) {
3
- super(message);
4
- this.message = message;
5
- }
6
- }
1
+ //#region src/error.ts
2
+ var RemoteError = class extends Error {
3
+ constructor(message) {
4
+ super(message);
5
+ this.message = message;
6
+ }
7
+ };
7
8
  RemoteError.prototype.name = "RemoteError";
8
-
9
+ //#endregion
9
10
  export { RemoteError };
10
- //# sourceMappingURL=error.mjs.map
11
+
12
+ //# sourceMappingURL=error.mjs.map
@@ -1 +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;;;;"}
1
+ {"version":3,"file":"error.mjs","names":[],"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"],"mappings":";AAAA,IAAa,cAAb,cAAiC,MAAM;CACrC,YAAY,SAAiB;EAC3B,MAAM,OAAO;EACb,KAAK,UAAU;CACjB;AACF;AAEA,YAAY,UAAU,OAAO"}
@@ -1,19 +1,17 @@
1
- import { z } from 'zod';
2
-
3
- const componentRenderedEventSchema = z.object({
4
- event: z.literal("ComponentRendered"),
5
- data: z.object({
6
- /** Display name of the Flow component the extension rendered. */
7
- component: z.string()
8
- })
1
+ import { z } from "zod";
2
+ //#region src/events/remoteEvents.ts
3
+ var componentRenderedEventSchema = z.object({
4
+ event: z.literal("ComponentRendered"),
5
+ data: z.object({
6
+ /** Display name of the Flow component the extension rendered. */
7
+ component: z.string() })
9
8
  });
10
- const reportedEventSchema = z.discriminatedUnion("event", [
11
- componentRenderedEventSchema
12
- ]);
13
- const parseReportedEvent = (event) => {
14
- const result = reportedEventSchema.safeParse(event);
15
- return result.success ? result.data : void 0;
9
+ var reportedEventSchema = z.discriminatedUnion("event", [componentRenderedEventSchema]);
10
+ var parseReportedEvent = (event) => {
11
+ const result = reportedEventSchema.safeParse(event);
12
+ return result.success ? result.data : void 0;
16
13
  };
17
-
14
+ //#endregion
18
15
  export { componentRenderedEventSchema, parseReportedEvent, reportedEventSchema };
19
- //# sourceMappingURL=remoteEvents.mjs.map
16
+
17
+ //# sourceMappingURL=remoteEvents.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"remoteEvents.mjs","sources":["../../../../../../src/events/remoteEvents.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const componentRenderedEventSchema = z.object({\n event: z.literal(\"ComponentRendered\"),\n data: z.object({\n /** Display name of the Flow component the extension rendered. */\n component: z.string(),\n }),\n});\n\nexport const reportedEventSchema = z.discriminatedUnion(\"event\", [\n componentRenderedEventSchema,\n]);\n\nexport type ComponentRenderedEvent = z.infer<\n typeof componentRenderedEventSchema\n>;\n\nexport type ReportedEvent = z.infer<typeof reportedEventSchema>;\n\nexport const parseReportedEvent = (\n event: unknown,\n): ReportedEvent | undefined => {\n const result = reportedEventSchema.safeParse(event);\n return result.success ? result.data : undefined;\n};\n"],"names":[],"mappings":";;AAEO,MAAM,4BAAA,GAA+B,EAAE,MAAA,CAAO;AAAA,EACnD,KAAA,EAAO,CAAA,CAAE,OAAA,CAAQ,mBAAmB,CAAA;AAAA,EACpC,IAAA,EAAM,EAAE,MAAA,CAAO;AAAA;AAAA,IAEb,SAAA,EAAW,EAAE,MAAA;AAAO,GACrB;AACH,CAAC;AAEM,MAAM,mBAAA,GAAsB,CAAA,CAAE,kBAAA,CAAmB,OAAA,EAAS;AAAA,EAC/D;AACF,CAAC;AAQM,MAAM,kBAAA,GAAqB,CAChC,KAAA,KAC8B;AAC9B,EAAA,MAAM,MAAA,GAAS,mBAAA,CAAoB,SAAA,CAAU,KAAK,CAAA;AAClD,EAAA,OAAO,MAAA,CAAO,OAAA,GAAU,MAAA,CAAO,IAAA,GAAO,MAAA;AACxC;;;;"}
1
+ {"version":3,"file":"remoteEvents.mjs","names":[],"sources":["../../../../../../src/events/remoteEvents.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const componentRenderedEventSchema = z.object({\n event: z.literal(\"ComponentRendered\"),\n data: z.object({\n /** Display name of the Flow component the extension rendered. */\n component: z.string(),\n }),\n});\n\nexport const reportedEventSchema = z.discriminatedUnion(\"event\", [\n componentRenderedEventSchema,\n]);\n\nexport type ComponentRenderedEvent = z.infer<\n typeof componentRenderedEventSchema\n>;\n\nexport type ReportedEvent = z.infer<typeof reportedEventSchema>;\n\nexport const parseReportedEvent = (\n event: unknown,\n): ReportedEvent | undefined => {\n const result = reportedEventSchema.safeParse(event);\n return result.success ? result.data : undefined;\n};\n"],"mappings":";;AAEA,IAAa,+BAA+B,EAAE,OAAO;CACnD,OAAO,EAAE,QAAQ,mBAAmB;CACpC,MAAM,EAAE,OAAO;;AAEb,WAAW,EAAE,OAAO,EACtB,CAAC;AACH,CAAC;AAED,IAAa,sBAAsB,EAAE,mBAAmB,SAAS,CAC/D,4BACF,CAAC;AAQD,IAAa,sBACX,UAC8B;CAC9B,MAAM,SAAS,oBAAoB,UAAU,KAAK;CAClD,OAAO,OAAO,UAAU,OAAO,OAAO,KAAA;AACxC"}
@@ -1,10 +1,12 @@
1
- const getWithMergedHostConfig = (extBridgeConnection, hostConfig) => async () => {
2
- const baseConfig = await extBridgeConnection.getConfig();
3
- return {
4
- ...hostConfig,
5
- ...baseConfig
6
- };
1
+ //#region src/ext-bridge/getWithMergedHostConfig.ts
2
+ var getWithMergedHostConfig = (extBridgeConnection, hostConfig) => async () => {
3
+ const baseConfig = await extBridgeConnection.getConfig();
4
+ return {
5
+ ...hostConfig,
6
+ ...baseConfig
7
+ };
7
8
  };
8
-
9
+ //#endregion
9
10
  export { getWithMergedHostConfig };
10
- //# sourceMappingURL=getWithMergedHostConfig.mjs.map
11
+
12
+ //# sourceMappingURL=getWithMergedHostConfig.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getWithMergedHostConfig.mjs","sources":["../../../../../../src/ext-bridge/getWithMergedHostConfig.ts"],"sourcesContent":["import type { RemoteExtBridgeConnectionApi } from \"@/connection\";\nimport type { ExtBridgeConfigInput, HostConfig } from \"@mittwald/ext-bridge\";\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":"AAGO,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;;;;"}
1
+ {"version":3,"file":"getWithMergedHostConfig.mjs","names":[],"sources":["../../../../../../src/ext-bridge/getWithMergedHostConfig.ts"],"sourcesContent":["import type { RemoteExtBridgeConnectionApi } from \"@/connection\";\nimport type { ExtBridgeConfigInput, HostConfig } from \"@mittwald/ext-bridge\";\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"],"mappings":";AAGA,IAAa,2BACV,qBAAmD,eACpD,YAA2C;CACzC,MAAM,aAAa,MAAM,oBAAoB,UAAU;CAEvD,OAAO;EACL,GAAG;EACH,GAAG;CACL;AACF"}
@@ -1,13 +1,9 @@
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
-
1
+ import { RemoteError } from "../error.mjs";
2
+ //#region src/ext-bridge/implementation.ts
3
+ var emptyImplementation = new Proxy({}, { get() {
4
+ throw new RemoteError("Missing implementation for mittwald.extBridge");
5
+ } });
6
+ //#endregion
12
7
  export { emptyImplementation };
13
- //# sourceMappingURL=implementation.mjs.map
8
+
9
+ //# sourceMappingURL=implementation.mjs.map
@@ -1 +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;;;;"}
1
+ {"version":3,"file":"implementation.mjs","names":[],"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"],"mappings":";;AAGA,IAAa,sBAAsB,IAAI,MACrC,CAAC,GACD,EACE,MAAM;CACJ,MAAM,IAAI,YAAY,+CAA+C;AACvE,EACF,CACF"}
@@ -1,62 +1,50 @@
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
-
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";
4
+ import { serializers_exports } from "./serializers/index.mjs";
5
+ import { isObjectType } from "remeda";
6
+ //#region src/serialization/FlowThreadSerialization.ts
7
+ var serializers = Object.values(serializers_exports).filter((val) => val instanceof Serializer);
8
+ var FlowThreadSerialization = class extends ThreadSerializationStructuredClone {
9
+ constructor() {
10
+ super({
11
+ serialize: async (val, serialize) => {
12
+ try {
13
+ if (this.isSerializableByBase(val)) return;
14
+ if (this.omitSerialization(val)) return null;
15
+ for (const serializer of serializers) {
16
+ const serialization = await serializer.serialize(val);
17
+ if (serialization.applied) return await serialize(serialization.result);
18
+ }
19
+ if (isObjectType(val)) return await serialize({ ...val });
20
+ return;
21
+ } catch (error) {
22
+ console.error("Error while serializing", error);
23
+ throw error;
24
+ }
25
+ },
26
+ deserialize: async (val, deserialize) => {
27
+ try {
28
+ for (const serializer of serializers) {
29
+ const deserialization = await serializer.deserialize(val);
30
+ if (deserialization.applied) return deserialization.result.value;
31
+ }
32
+ return await deserialize(val);
33
+ } catch (error) {
34
+ console.error("Error while deserializing", error);
35
+ throw error;
36
+ }
37
+ }
38
+ });
39
+ }
40
+ isSerializableByBase(val) {
41
+ return val instanceof Map || val instanceof Set || Array.isArray(val) || typeof val === "function" || isObjectType(val) && TRANSFERABLE in val;
42
+ }
43
+ omitSerialization(val) {
44
+ return val instanceof HTMLElement || val === window;
45
+ }
46
+ };
47
+ //#endregion
61
48
  export { FlowThreadSerialization };
62
- //# sourceMappingURL=FlowThreadSerialization.mjs.map
49
+
50
+ //# sourceMappingURL=FlowThreadSerialization.mjs.map
@@ -1 +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;AACnB,IAAA,MAAM,OAAA,GAAsC;AAAA,MAC1C,SAAA,EAAW,OAAO,GAAA,EAAK,SAAA,KAAc;AACnC,QAAA,IAAI;AACF,UAAA,IAAI,IAAA,CAAK,oBAAA,CAAqB,GAAG,CAAA,EAAG;AAClC,YAAA;AAAA,UACF;AACA,UAAA,IAAI,IAAA,CAAK,iBAAA,CAAkB,GAAG,CAAA,EAAG;AAC/B,YAAA,OAAO,IAAA;AAAA,UACT;AACA,UAAA,KAAA,MAAW,cAAc,WAAA,EAAa;AACpC,YAAA,MAAM,aAAA,GAAgB,MAAM,UAAA,CAAW,SAAA,CAAU,GAAG,CAAA;AAEpD,YAAA,IAAI,cAAc,OAAA,EAAS;AACzB,cAAA,OAAO,MAAM,SAAA,CA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.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"}