@mittwald/flow-remote-core 0.2.0-alpha.89 → 0.2.0-alpha.890

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 (90) hide show
  1. package/dist/js/connection/connectHostRenderRoot.mjs +58 -0
  2. package/dist/js/connection/connectHostRenderRoot.mjs.map +1 -0
  3. package/dist/js/connection/connectRemoteIframe.mjs +74 -0
  4. package/dist/js/connection/connectRemoteIframe.mjs.map +1 -0
  5. package/dist/js/connection/types.mjs +10 -0
  6. package/dist/js/connection/types.mjs.map +1 -0
  7. package/dist/js/error.mjs +10 -0
  8. package/dist/js/error.mjs.map +1 -0
  9. package/dist/js/ext-bridge/getWithMergedHostConfig.mjs +10 -0
  10. package/dist/js/ext-bridge/getWithMergedHostConfig.mjs.map +1 -0
  11. package/dist/js/ext-bridge/implementation.mjs +13 -0
  12. package/dist/js/ext-bridge/implementation.mjs.map +1 -0
  13. package/dist/js/index-node.mjs +16 -0
  14. package/dist/js/index-node.mjs.map +1 -0
  15. package/dist/js/index.mjs +15 -0
  16. package/dist/js/index.mjs.map +1 -0
  17. package/dist/js/serialization/FlowThreadSerialization.mjs +61 -0
  18. package/dist/js/serialization/FlowThreadSerialization.mjs.map +1 -0
  19. package/dist/js/serialization/Serializer.mjs +32 -0
  20. package/dist/js/serialization/Serializer.mjs.map +1 -0
  21. package/dist/js/serialization/serializers/dataTransferText.mjs +23 -0
  22. package/dist/js/serialization/serializers/dataTransferText.mjs.map +1 -0
  23. package/dist/js/serialization/serializers/date.mjs +16 -0
  24. package/dist/js/serialization/serializers/date.mjs.map +1 -0
  25. package/dist/js/serialization/serializers/file.mjs +33 -0
  26. package/dist/js/serialization/serializers/file.mjs.map +1 -0
  27. package/dist/js/serialization/serializers/fileList.mjs +24 -0
  28. package/dist/js/serialization/serializers/fileList.mjs.map +1 -0
  29. package/dist/js/serialization/serializers/formData.mjs +36 -0
  30. package/dist/js/serialization/serializers/formData.mjs.map +1 -0
  31. package/dist/js/serialization/serializers/index.mjs +7 -0
  32. package/dist/js/serialization/serializers/index.mjs.map +1 -0
  33. package/dist/js/serialization/serializers/passwordPolicy.mjs +16 -0
  34. package/dist/js/serialization/serializers/passwordPolicy.mjs.map +1 -0
  35. package/dist/js/shim.mjs +16 -0
  36. package/dist/js/shim.mjs.map +1 -0
  37. package/dist/types/connection/connectHostRenderRoot.d.ts +10 -6
  38. package/dist/types/connection/connectHostRenderRoot.d.ts.map +1 -1
  39. package/dist/types/connection/connectRemoteIframe.d.ts +12 -9
  40. package/dist/types/connection/connectRemoteIframe.d.ts.map +1 -1
  41. package/dist/types/connection/index.d.ts +4 -0
  42. package/dist/types/connection/index.d.ts.map +1 -0
  43. package/dist/types/connection/types.d.ts +43 -0
  44. package/dist/types/connection/types.d.ts.map +1 -0
  45. package/dist/types/error.d.ts +4 -0
  46. package/dist/types/error.d.ts.map +1 -0
  47. package/dist/types/ext-bridge/getWithMergedHostConfig.d.ts +5 -0
  48. package/dist/types/ext-bridge/getWithMergedHostConfig.d.ts.map +1 -0
  49. package/dist/types/ext-bridge/implementation.d.ts +3 -0
  50. package/dist/types/ext-bridge/implementation.d.ts.map +1 -0
  51. package/dist/types/index-node.d.ts +2 -0
  52. package/dist/types/index-node.d.ts.map +1 -0
  53. package/dist/types/index.d.ts +5 -6
  54. package/dist/types/index.d.ts.map +1 -1
  55. package/dist/types/serialization/FlowThreadSerialization.d.ts +7 -0
  56. package/dist/types/serialization/FlowThreadSerialization.d.ts.map +1 -0
  57. package/dist/types/serialization/FlowThreadSerialization.test.d.ts +2 -0
  58. package/dist/types/serialization/FlowThreadSerialization.test.d.ts.map +1 -0
  59. package/dist/types/serialization/Serialization.test.d.ts +2 -0
  60. package/dist/types/serialization/Serialization.test.d.ts.map +1 -0
  61. package/dist/types/serialization/Serializer.d.ts +28 -0
  62. package/dist/types/serialization/Serializer.d.ts.map +1 -0
  63. package/dist/types/serialization/index.d.ts +4 -0
  64. package/dist/types/serialization/index.d.ts.map +1 -0
  65. package/dist/types/serialization/serializers/dataTransferText.d.ts +3 -0
  66. package/dist/types/serialization/serializers/dataTransferText.d.ts.map +1 -0
  67. package/dist/types/serialization/serializers/date.d.ts +4 -0
  68. package/dist/types/serialization/serializers/date.d.ts.map +1 -0
  69. package/dist/types/serialization/serializers/file.d.ts +12 -0
  70. package/dist/types/serialization/serializers/file.d.ts.map +1 -0
  71. package/dist/types/serialization/serializers/fileList.d.ts +4 -0
  72. package/dist/types/serialization/serializers/fileList.d.ts.map +1 -0
  73. package/dist/types/serialization/serializers/formData.d.ts +7 -0
  74. package/dist/types/serialization/serializers/formData.d.ts.map +1 -0
  75. package/dist/types/serialization/serializers/index.d.ts +7 -0
  76. package/dist/types/serialization/serializers/index.d.ts.map +1 -0
  77. package/dist/types/serialization/serializers/passwordPolicy.d.ts +4 -0
  78. package/dist/types/serialization/serializers/passwordPolicy.d.ts.map +1 -0
  79. package/dist/types/shim.d.ts +2 -0
  80. package/dist/types/shim.d.ts.map +1 -0
  81. package/dist/types/tests/utils.d.ts +2 -0
  82. package/dist/types/tests/utils.d.ts.map +1 -0
  83. package/package.json +37 -19
  84. package/dist/index.js +0 -48
  85. package/dist/types/events/FlowRemoteEvent.d.ts +0 -4
  86. package/dist/types/events/FlowRemoteEvent.d.ts.map +0 -1
  87. package/dist/types/events/index.d.ts +0 -5
  88. package/dist/types/events/index.d.ts.map +0 -1
  89. package/dist/types/events/serializers.d.ts +0 -5
  90. package/dist/types/events/serializers.d.ts.map +0 -1
@@ -0,0 +1,58 @@
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 '@quilted/threads';
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 } = 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
+ }
24
+ });
25
+ if (connection.parent === window) {
26
+ throw incompatibleParentFrameError();
27
+ }
28
+ try {
29
+ await connection.imports.setIsReady(Version.v3);
30
+ if (typeof mwExtBridge !== "undefined") {
31
+ mwExtBridge.connection = connection.imports;
32
+ await mwExtBridge.readiness.setIsReady();
33
+ }
34
+ return connection;
35
+ } catch (error) {
36
+ if (error instanceof Error && /No '.*' method is exported from this thread/.test(error.message)) {
37
+ throw incompatibleParentFrameError();
38
+ }
39
+ throw error;
40
+ }
41
+ };
42
+ const connectHostRenderRootRef = (opts) => (ref) => {
43
+ if (ref === null) {
44
+ return;
45
+ }
46
+ if ("__remoteConnection" in ref) {
47
+ return ref["__remoteConnection"];
48
+ }
49
+ const connection = connectHostRenderRoot({
50
+ root: ref,
51
+ ...opts
52
+ });
53
+ Object.assign(ref, { __remoteConnection: connection });
54
+ return connection;
55
+ };
56
+
57
+ export { connectHostRenderRoot, connectHostRenderRootRef, connectRemoteReceiver };
58
+ //# 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}\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 } = 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 },\n });\n\n if (connection.parent === window) {\n throw incompatibleParentFrameError();\n }\n\n try {\n await connection.imports.setIsReady(Version.v3);\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":";;;;;;AAgBA,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,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AM;AAChB,IAAA;AAAA,EACF;AACA,EAAA,IAAI,wBAAwB,GAAA,EAAK;AAC/B,IAAA,OAAO,IAAI,oBAAoB,CAAA;AAAA,EACjC;AAEA,EAAA,MAAM,aAAa,qBAAA,CAAsB;AAAA,IACvC,IAAA,EAAM,GAAA;AAAA,IACN,GAAG;AAAA,GACJ,CAAA;AACD,EAAA,MAAA,CAAO,MAAA,CAAO,GAAA,EAAK,EAAE,kBAAA,EAAoB,YAAY,CAAA;AACrD,EAAA,OAAO,UAAA;AACT;;;;"}
@@ -0,0 +1,74 @@
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 '@quilted/threads';
6
+
7
+ const connectRemoteIframe = (opts) => {
8
+ const {
9
+ connection,
10
+ iframe,
11
+ onReady,
12
+ onLoadingChanged,
13
+ onError,
14
+ onNavigationStateChanged,
15
+ extBridgeImplementation: extBridgeImplementationProp = emptyImplementation,
16
+ hostConfig
17
+ } = opts;
18
+ const extBridgeImplementation = {
19
+ ...extBridgeImplementationProp,
20
+ getConfig: getWithMergedHostConfig(extBridgeImplementationProp, hostConfig)
21
+ };
22
+ const result = {
23
+ thread: new ThreadIframe(iframe, {
24
+ serialization: new FlowThreadSerialization(),
25
+ exports: {
26
+ ...extBridgeImplementation,
27
+ setIsReady: async (version = Version.v1) => {
28
+ result.version = version;
29
+ onReady?.(result);
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
+ getHostConfig: async () => {
41
+ return hostConfig;
42
+ }
43
+ }
44
+ }),
45
+ updateHostPathname: (hostPathname) => {
46
+ if (hostPathname === void 0) {
47
+ return;
48
+ }
49
+ if (result.version >= Version.v2) {
50
+ result.thread.imports.setPathname(hostPathname);
51
+ }
52
+ },
53
+ version: 0
54
+ };
55
+ result.thread.imports.render(connection);
56
+ return result;
57
+ };
58
+ const connectRemoteIframeRef = (opts) => (ref) => {
59
+ if (!ref) {
60
+ return;
61
+ }
62
+ if ("__remoteConnection" in ref) {
63
+ return ref["__remoteConnection"];
64
+ }
65
+ const connection = connectRemoteIframe({
66
+ iframe: ref,
67
+ ...opts
68
+ });
69
+ Object.assign(ref, { __remoteConnection: connection });
70
+ return connection;
71
+ };
72
+
73
+ export { connectRemoteIframe, connectRemoteIframeRef };
74
+ //# 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 NavigationState,\n type RemoteExports,\n type RemoteExtBridgeConnectionApi,\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?: (connection: HostToRemoteConnection) => void;\n onLoadingChanged?: (isLoading: boolean) => void;\n onError?: (error: string) => void;\n onNavigationStateChanged?: (state: NavigationState) => void;\n extBridgeImplementation?: RemoteExtBridgeConnectionApi;\n}\n\nexport const connectRemoteIframe = (opts: Options): HostToRemoteConnection => {\n const {\n connection,\n iframe,\n onReady,\n onLoadingChanged,\n onError,\n onNavigationStateChanged,\n extBridgeImplementation: extBridgeImplementationProp = emptyImplementation,\n hostConfig,\n } = opts;\n\n const extBridgeImplementation = {\n ...extBridgeImplementationProp,\n getConfig: getWithMergedHostConfig(extBridgeImplementationProp, hostConfig),\n };\n\n const result = {\n thread: new ThreadIframe<RemoteExports, HostExports>(iframe, {\n serialization: new FlowThreadSerialization(),\n exports: {\n ...extBridgeImplementation,\n setIsReady: async (version = Version.v1) => {\n result.version = version;\n onReady?.(result);\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 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 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":";;;;;;AA0BO,MAAM,mBAAA,GAAsB,CAAC,IAAA,KAA0C;AAC5E,EAAA,MAAM;AAAA,IACJ,UAAA;AAAA,IACA,MAAA;AAAA,IACA,OAAA;AAAA,IACA,gBAAA;AAAA,IACA,OAAA;AAAA,IACA,wBAAA;AAAA,IACA,yBAAyB,2BAAA,GAA8B,mBAAA;AAAA,IACvD;AAAA,GACF,GAAI,IAAA;AAEJ,EAAA,MAAM,uBAAA,GAA0B;AAAA,IAC9B,GAAG,2BAAA;AAAA,IACH,SAAA,EAAW,uBAAA,CAAwB,2BAAA,EAA6B,UAAU;AAAA,GAC5E;AAEA,EAAA,MAAM,MAAA,GAAS;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EAAA,IAAI,wBAAwB,GAAA,EAAK;AAC/B,IAAA,OAAO,IAAI,oBAAoB,CAAA;AAAA,EACjC;AAEA,EAAA,MAAM,aAAa,mBAAA,CAAoB;AAAA,IACrC,MAAA,EAAQ,GAAA;AAAA,IACR,GAAG;AAAA,GACJ,CAAA;AACD,EAAA,MAAA,CAAO,MAAA,CAAO,GAAA,EAAK,EAAE,kBAAA,EAAoB,YAAY,CAAA;AACrD,EAAA,OAAO,UAAA;AACT;;;;"}
@@ -0,0 +1,10 @@
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
+ return Version2;
7
+ })(Version || {});
8
+
9
+ export { Version };
10
+ //# 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 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: (version?: Version) => 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}\n\nexport interface RemoteExports {\n render: (connection: RemoteConnection) => Promise<void>;\n setPathname: (pathname: 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}\n\nexport enum Version {\n vUnknown = 0,\n v1 = 1,\n v2 = 2,\n v3 = 3,\n}\n"],"names":["Version"],"mappings":"AAwDO,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;AAJU,EAAA,OAAAA,QAAAA;AAAA,CAAA,EAAA,OAAA,IAAA,EAAA;;;;"}
@@ -0,0 +1,10 @@
1
+ class RemoteError extends Error {
2
+ constructor(message) {
3
+ super(message);
4
+ this.message = message;
5
+ }
6
+ }
7
+ RemoteError.prototype.name = "RemoteError";
8
+
9
+ export { RemoteError };
10
+ //# sourceMappingURL=error.mjs.map
@@ -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,16 @@
1
+ import './shim.mjs';
2
+ export { RemoteReceiver } from '@mittwald/remote-dom-core/receivers';
3
+ export { RemoteElement, RemoteEvent } from '@mittwald/remote-dom-core/elements';
4
+ export { calendarDateSerializer } from './serialization/serializers/date.mjs';
5
+ export { fileDeSerialize, fileSerialize, fileSerializer, isSerializedFile } from './serialization/serializers/file.mjs';
6
+ export { fileListSerializer } from './serialization/serializers/fileList.mjs';
7
+ export { dataTransferTextSerializer } from './serialization/serializers/dataTransferText.mjs';
8
+ export { formDataSerializer } from './serialization/serializers/formData.mjs';
9
+ export { passwordPolicySerializer } from './serialization/serializers/passwordPolicy.mjs';
10
+ export { FlowThreadSerialization } from './serialization/FlowThreadSerialization.mjs';
11
+ export { Serializer } from './serialization/Serializer.mjs';
12
+ export { connectHostRenderRoot, connectHostRenderRootRef, connectRemoteReceiver } from './connection/connectHostRenderRoot.mjs';
13
+ export { connectRemoteIframe, connectRemoteIframeRef } from './connection/connectRemoteIframe.mjs';
14
+ export { Version } from './connection/types.mjs';
15
+ export { RemoteError } from './error.mjs';
16
+ //# sourceMappingURL=index-node.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-node.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;"}
@@ -0,0 +1,15 @@
1
+ export { RemoteReceiver } from '@mittwald/remote-dom-core/receivers';
2
+ export { RemoteElement, RemoteEvent } from '@mittwald/remote-dom-core/elements';
3
+ export { calendarDateSerializer } from './serialization/serializers/date.mjs';
4
+ export { fileDeSerialize, fileSerialize, fileSerializer, isSerializedFile } from './serialization/serializers/file.mjs';
5
+ export { fileListSerializer } from './serialization/serializers/fileList.mjs';
6
+ export { dataTransferTextSerializer } from './serialization/serializers/dataTransferText.mjs';
7
+ export { formDataSerializer } from './serialization/serializers/formData.mjs';
8
+ export { passwordPolicySerializer } from './serialization/serializers/passwordPolicy.mjs';
9
+ export { FlowThreadSerialization } from './serialization/FlowThreadSerialization.mjs';
10
+ export { Serializer } from './serialization/Serializer.mjs';
11
+ export { connectHostRenderRoot, connectHostRenderRootRef, connectRemoteReceiver } from './connection/connectHostRenderRoot.mjs';
12
+ export { connectRemoteIframe, connectRemoteIframeRef } from './connection/connectRemoteIframe.mjs';
13
+ export { Version } from './connection/types.mjs';
14
+ export { RemoteError } from './error.mjs';
15
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
@@ -0,0 +1,61 @@
1
+ import { ThreadSerializationStructuredClone, TRANSFERABLE } from '@quilted/threads';
2
+ import * as index from './serializers/index.mjs';
3
+ import { isObjectType } from 'remeda';
4
+ import { Serializer } from './Serializer.mjs';
5
+
6
+ const serializers = Object.values(index).filter(
7
+ (val) => val instanceof Serializer
8
+ );
9
+ class FlowThreadSerialization extends ThreadSerializationStructuredClone {
10
+ constructor() {
11
+ const options = {
12
+ serialize: async (val, serialize) => {
13
+ try {
14
+ if (this.isSerializableByBase(val)) {
15
+ return;
16
+ }
17
+ if (this.omitSerialization(val)) {
18
+ return null;
19
+ }
20
+ for (const serializer of serializers) {
21
+ const serialization = await serializer.serialize(val);
22
+ if (serialization.applied) {
23
+ return await serialize(serialization.result);
24
+ }
25
+ }
26
+ if (isObjectType(val)) {
27
+ return await serialize({ ...val });
28
+ }
29
+ return void 0;
30
+ } catch (error) {
31
+ console.error("Error while serializing", error);
32
+ throw error;
33
+ }
34
+ },
35
+ deserialize: async (val, deserialize) => {
36
+ try {
37
+ for (const serializer of serializers) {
38
+ const deserialization = await serializer.deserialize(val);
39
+ if (deserialization.applied) {
40
+ return deserialization.result.value;
41
+ }
42
+ }
43
+ return await deserialize(val);
44
+ } catch (error) {
45
+ console.error("Error while deserializing", error);
46
+ throw error;
47
+ }
48
+ }
49
+ };
50
+ super(options);
51
+ }
52
+ isSerializableByBase(val) {
53
+ return val instanceof Map || val instanceof Set || Array.isArray(val) || typeof val === "function" || isObjectType(val) && TRANSFERABLE in val;
54
+ }
55
+ omitSerialization(val) {
56
+ return val instanceof HTMLElement || val === window;
57
+ }
58
+ }
59
+
60
+ export { FlowThreadSerialization };
61
+ //# 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;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,CAAU,aAAA,CAAc,MAAM,CAAA;AAAA,YAC7C;AAAA,UACF;AAEA,UAAA,IAAI,YAAA,CAAa,GAAG,CAAA,EAAG;AACrB,YAAA,OAAO,MAAM,SAAA,CAAU,EAAE,GAAG,KAAK,CAAA;AAAA,UACnC;AAEA,UAAA,OAAO,KAAA,CAAA;AAAA,QACT,SAAS,KAAA,EAAO;AACd,UAAA,OAAA,CAAQ,KAAA,CAAM,2BAA2B,KAAK,CAAA;AAC9C,UAAA,MAAM,KAAA;AAAA,QACR;AAAA,MACF,CAAA;AAAA,MAEA,WAAA,EAAa,OAAO,GAAA,EAAK,WAAA,KAAgB;AACvC,QAAA,IAAI;AACF,UAAA,KAAA,MAAW,cAAc,WAAA,EAAa;AACpC,YAAA,MAAM,eAAA,GAAkB,MAAM,UAAA,CAAW,WAAA,CAAY,GAAG,CAAA;AAExD,YAAA,IAAI,gBAAgB,OAAA,EAAS;AAC3B,cAAA,OAAO,gBAAgB,MAAA,CAAO,KAAA;AAAA,YAChC;AAAA,UACF;AAEA,UAAA,OAAO,MAAM,YAAY,GAAG,CAAA;AAAA,QAC9B,SAAS,KAAA,EAAO;AACd,UAAA,OAAA,CAAQ,KAAA,CAAM,6BAA6B,KAAK,CAAA;AAChD,UAAA,MAAM,KAAA;AAAA,QACR;AAAA,MACF;AAAA,KACF;AAEA,IAAA,KAAA,CAAM,OAAO,CAAA;AAAA,EACf;AAAA,EAEQ,qBAAqB,GAAA,EAAc;AACzC,IAAA,OACE,GAAA,YAAe,GAAA,IACf,GAAA,YAAe,GAAA,IACf,MAAM,OAAA,CAAQ,GAAG,CAAA,IACjB,OAAO,GAAA,KAAQ,UAAA,IACd,YAAA,CAAa,GAAG,KAAK,YAAA,IAAgB,GAAA;AAAA,EAE1C;AAAA,EAEQ,kBAAkB,GAAA,EAAc;AACtC,IAAA,OAAO,GAAA,YAAe,eAAe,GAAA,KAAQ,MAAA;AAAA,EAC/C;AACF;;;;"}
@@ -0,0 +1,32 @@
1
+ const Key = "mittwald.flow-remote-core.serializer.name";
2
+ class Serializer {
3
+ constructor(options) {
4
+ this.options = options;
5
+ }
6
+ options;
7
+ async apply(val, strategy) {
8
+ if (!strategy.isApplicable(val)) {
9
+ return { applied: false };
10
+ }
11
+ const resolved = await strategy.apply(val);
12
+ return {
13
+ applied: true,
14
+ result: {
15
+ [Key]: this.options.name,
16
+ value: resolved
17
+ }
18
+ };
19
+ }
20
+ async serialize(val) {
21
+ return this.apply(val, this.options.serialize);
22
+ }
23
+ async deserialize(val) {
24
+ return this.apply(val, {
25
+ isApplicable: (candidate) => !!candidate && typeof candidate === "object" && Key in candidate && candidate[Key] === this.options.name,
26
+ apply: (serialization) => this.options.deserialize.apply(serialization.value)
27
+ });
28
+ }
29
+ }
30
+
31
+ export { Serializer };
32
+ //# sourceMappingURL=Serializer.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Serializer.mjs","sources":["../../../src/serialization/Serializer.ts"],"sourcesContent":["interface SerializationStrategy<TIn, TOut> {\n isApplicable: (val: unknown) => val is TIn;\n apply: (val: TIn) => TOut | Promise<TOut>;\n}\n\nconst Key = \"mittwald.flow-remote-core.serializer.name\";\n\nexport interface SuccessfulSerializationResult<T> {\n value: T;\n [Key]: string;\n}\n\nexport type SerializationResult<T> =\n | { applied: true; result: SuccessfulSerializationResult<T> }\n | { applied: false };\n\nexport class Serializer<TIn, TOut> {\n public constructor(\n private options: {\n name: string;\n serialize: SerializationStrategy<TIn, TOut>;\n deserialize: Pick<SerializationStrategy<TOut, TIn>, \"apply\">;\n },\n ) {}\n\n private async apply<TIn, TOut>(\n val: unknown,\n strategy: SerializationStrategy<TIn, TOut>,\n ): Promise<SerializationResult<TOut>> {\n if (!strategy.isApplicable(val)) {\n return { applied: false };\n }\n\n const resolved = await strategy.apply(val);\n\n return {\n applied: true,\n result: {\n [Key]: this.options.name,\n value: resolved,\n },\n };\n }\n\n public async serialize(val: unknown): Promise<SerializationResult<TOut>> {\n return this.apply<TIn, TOut>(val, this.options.serialize);\n }\n\n public async deserialize(val: unknown): Promise<SerializationResult<TIn>> {\n return this.apply(val, {\n isApplicable: (\n candidate,\n ): candidate is SuccessfulSerializationResult<TOut> =>\n !!candidate &&\n typeof candidate === \"object\" &&\n Key in candidate &&\n (candidate as never)[Key] === this.options.name,\n apply: (serialization) =>\n this.options.deserialize.apply(serialization.value),\n });\n }\n}\n"],"names":[],"mappings":"A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 isApplicable: (val) => {
7
+ return val instanceof DataTransfer && val.types.every((type) => type === "text/plain");
8
+ },
9
+ apply: (dataTransfer) => {
10
+ return dataTransfer.getData("text") || dataTransfer.getData("text/plain");
11
+ }
12
+ },
13
+ deserialize: {
14
+ apply: (asString) => {
15
+ const dataTransfer = new DataTransfer();
16
+ dataTransfer.setData("text", asString);
17
+ return dataTransfer;
18
+ }
19
+ }
20
+ });
21
+
22
+ export { dataTransferTextSerializer };
23
+ //# sourceMappingURL=dataTransferText.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dataTransferText.mjs","sources":["../../../../src/serialization/serializers/dataTransferText.ts"],"sourcesContent":["import { Serializer } from \"@/serialization/Serializer\";\n\nexport const dataTransferTextSerializer = new Serializer<DataTransfer, string>({\n name: \"DataTransferText\",\n serialize: {\n isApplicable: (val): val is DataTransfer => {\n return (\n val instanceof DataTransfer &&\n val.types.every((type) => type === \"text/plain\")\n );\n },\n apply: (dataTransfer) => {\n return dataTransfer.getData(\"text\") || dataTransfer.getData(\"text/plain\");\n },\n },\n deserialize: {\n apply: (asString) => {\n const dataTransfer = new DataTransfer();\n dataTransfer.setData(\"text\", asString);\n return dataTransfer;\n },\n },\n});\n"],"names":[],"mappings":";;AAEO,MAAM,0BAAA,GAA6B,IAAI,UAAA,CAAiC;AAAA,EAC7E,IAAA,EAAM,kBAAA;AAAA,EACN,SAAA,EAAW;AAAA,IACT,YAAA,EAAc,CAAC,GAAA,KAA6B;AAC1C,MAAA,OACE,GAAA,YAAe,gBACf,GAAA,CAAI,KAAA,CAAM,MAAM,CAAC,IAAA,KAAS,SAAS,YAAY,CAAA;AAAA,IAEnD,CAAA;AAAA,IACA,KAAA,EAAO,CAAC,YAAA,KAAiB;AACvB,MAAA,OAAO,aAAa,OAAA,CAAQ,MAAM,CAAA,IAAK,YAAA,CAAa,QAAQ,YAAY,CAAA;AAAA,IAC1E;AAAA,GACF;AAAA,EACA,WAAA,EAAa;AAAA,IACX,KAAA,EAAO,CAAC,QAAA,KAAa;AACnB,MAAA,MAAM,YAAA,GAAe,IAAI,YAAA,EAAa;AACtC,MAAA,YAAA,CAAa,OAAA,CAAQ,QAAQ,QAAQ,CAAA;AACrC,MAAA,OAAO,YAAA;AAAA,IACT;AAAA;AAEJ,CAAC;;;;"}
@@ -0,0 +1,16 @@
1
+ import { parseDate, CalendarDate } from '@internationalized/date';
2
+ import { Serializer } from '../Serializer.mjs';
3
+
4
+ const calendarDateSerializer = new Serializer({
5
+ name: "CalendarDate",
6
+ serialize: {
7
+ isApplicable: (val) => val instanceof CalendarDate,
8
+ apply: (date) => date.toString()
9
+ },
10
+ deserialize: {
11
+ apply: (asString) => parseDate(asString)
12
+ }
13
+ });
14
+
15
+ export { calendarDateSerializer };
16
+ //# sourceMappingURL=date.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date.mjs","sources":["../../../../src/serialization/serializers/date.ts"],"sourcesContent":["import { CalendarDate } from \"@internationalized/date\";\nimport { parseDate } from \"@internationalized/date\";\nimport { Serializer } from \"@/serialization/Serializer\";\n\nexport const calendarDateSerializer = new Serializer<CalendarDate, string>({\n name: \"CalendarDate\",\n serialize: {\n isApplicable: (val) => val instanceof CalendarDate,\n apply: (date) => date.toString(),\n },\n deserialize: {\n apply: (asString) => parseDate(asString),\n },\n});\n"],"names":[],"mappings":";;;AAIO,MAAM,sBAAA,GAAyB,IAAI,UAAA,CAAiC;AAAA,EACzE,IAAA,EAAM,cAAA;AAAA,EACN,SAAA,EAAW;AAAA,IACT,YAAA,EAAc,CAAC,GAAA,KAAQ,GAAA,YAAe,YAAA;AAAA,IACtC,KAAA,EAAO,CAAC,IAAA,KAAS,IAAA,CAAK,QAAA;AAAS,GACjC;AAAA,EACA,WAAA,EAAa;AAAA,IACX,KAAA,EAAO,CAAC,QAAA,KAAa,SAAA,CAAU,QAAQ;AAAA;AAE3C,CAAC;;;;"}
@@ -0,0 +1,33 @@
1
+ import { markAsTransferable } from '@quilted/threads';
2
+ import { Serializer } from '../Serializer.mjs';
3
+
4
+ const isSerializedFile = (value) => {
5
+ return !!(value && typeof value === "object" && "name" in value && "type" in value && "lastModified" in value && "content" in value);
6
+ };
7
+ const fileSerialize = async (file) => {
8
+ return {
9
+ name: file.name,
10
+ type: file.type,
11
+ lastModified: file.lastModified,
12
+ content: markAsTransferable(await file.arrayBuffer())
13
+ };
14
+ };
15
+ const fileDeSerialize = (file) => {
16
+ return new File([file.content], file.name, {
17
+ lastModified: file.lastModified,
18
+ type: file.type
19
+ });
20
+ };
21
+ const fileSerializer = new Serializer({
22
+ name: "File",
23
+ serialize: {
24
+ isApplicable: (something) => something instanceof File,
25
+ apply: fileSerialize
26
+ },
27
+ deserialize: {
28
+ apply: fileDeSerialize
29
+ }
30
+ });
31
+
32
+ export { fileDeSerialize, fileSerialize, fileSerializer, isSerializedFile };
33
+ //# sourceMappingURL=file.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file.mjs","sources":["../../../../src/serialization/serializers/file.ts"],"sourcesContent":["import { markAsTransferable } from \"@quilted/threads\";\nimport { Serializer } from \"@/serialization/Serializer\";\n\nexport interface SerializedFile {\n name: string;\n type: string;\n lastModified: number;\n content: ArrayBuffer;\n}\n\nexport const isSerializedFile = (value: unknown): value is SerializedFile => {\n return !!(\n value &&\n typeof value === \"object\" &&\n \"name\" in value &&\n \"type\" in value &&\n \"lastModified\" in value &&\n \"content\" in value\n );\n};\n\nexport const fileSerialize = async (file: File): Promise<SerializedFile> => {\n return {\n name: file.name,\n type: file.type,\n lastModified: file.lastModified,\n content: markAsTransferable(await file.arrayBuffer()),\n };\n};\n\nexport const fileDeSerialize = (file: SerializedFile) => {\n return new File([file.content], file.name, {\n lastModified: file.lastModified,\n type: file.type,\n });\n};\n\nexport const fileSerializer = new Serializer<File, SerializedFile>({\n name: \"File\",\n serialize: {\n isApplicable: (something) => something instanceof File,\n apply: fileSerialize,\n },\n deserialize: {\n apply: fileDeSerialize,\n },\n});\n"],"names":[],"mappings":";;;AAUO,MAAM,gBAAA,GAAmB,CAAC,KAAA,KAA4C;AAC3E,EAAA,OAAO,CAAC,EACN,KAAA,IACA,OAAO,KAAA,KAAU,QAAA,IACjB,MAAA,IAAU,KAAA,IACV,MAAA,IAAU,KAAA,IACV,cAAA,IAAkB,KAAA,IAClB,SAAA,IAAa,KAAA,CAAA;AAEjB;AAEO,MAAM,aAAA,GAAgB,OAAO,IAAA,KAAwC;AAC1E,EAAA,OAAO;AAAA,IACL,MAAM,IAAA,CAAK,IAAA;AAAA,IACX,MAAM,IAAA,CAAK,IAAA;AAAA,IACX,cAAc,IAAA,CAAK,YAAA;AAAA,IACnB,OAAA,EAAS,kBAAA,CAAmB,MAAM,IAAA,CAAK,aAAa;AAAA,GACtD;AACF;AAEO,MAAM,eAAA,GAAkB,CAAC,IAAA,KAAyB;AACvD,EAAA,OAAO,IAAI,IAAA,CAAK,CAAC,KAAK,OAAO,CAAA,EAAG,KAAK,IAAA,EAAM;AAAA,IACzC,cAAc,IAAA,CAAK,YAAA;AAAA,IACnB,MAAM,IAAA,CAAK;AAAA,GACZ,CAAA;AACH;AAEO,MAAM,cAAA,GAAiB,IAAI,UAAA,CAAiC;AAAA,EACjE,IAAA,EAAM,MAAA;AAAA,EACN,SAAA,EAAW;AAAA,IACT,YAAA,EAAc,CAAC,SAAA,KAAc,SAAA,YAAqB,IAAA;AAAA,IAClD,KAAA,EAAO;AAAA,GACT;AAAA,EACA,WAAA,EAAa;AAAA,IACX,KAAA,EAAO;AAAA;AAEX,CAAC;;;;"}
@@ -0,0 +1,24 @@
1
+ import { Serializer } from '../Serializer.mjs';
2
+ import '@internationalized/date';
3
+ import { fileDeSerialize, fileSerialize } from './file.mjs';
4
+ import '@mittwald/flow-react-components/mittwald-password-tools-js';
5
+
6
+ const fileListSerializer = new Serializer({
7
+ name: "FileList",
8
+ serialize: {
9
+ isApplicable: (something) => something instanceof FileList,
10
+ apply: async (fileList) => await Promise.all(Array.from(fileList, fileSerialize))
11
+ },
12
+ deserialize: {
13
+ apply: (arrayFiles) => {
14
+ const dataTransfer = new DataTransfer();
15
+ for (const file of arrayFiles) {
16
+ dataTransfer.items.add(fileDeSerialize(file));
17
+ }
18
+ return dataTransfer.files;
19
+ }
20
+ }
21
+ });
22
+
23
+ export { fileListSerializer };
24
+ //# sourceMappingURL=fileList.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileList.mjs","sources":["../../../../src/serialization/serializers/fileList.ts"],"sourcesContent":["import { Serializer } from \"@/serialization/Serializer\";\nimport {\n fileDeSerialize,\n fileSerialize,\n type SerializedFile,\n} from \"@/serialization/serializers\";\n\nexport const fileListSerializer = new Serializer<FileList, SerializedFile[]>({\n name: \"FileList\",\n serialize: {\n isApplicable: (something): something is FileList =>\n something instanceof FileList,\n apply: async (fileList) =>\n await Promise.all(Array.from(fileList, fileSerialize)),\n },\n deserialize: {\n apply: (arrayFiles) => {\n const dataTransfer = new DataTransfer();\n for (const file of arrayFiles) {\n dataTransfer.items.add(fileDeSerialize(file));\n }\n return dataTransfer.files;\n },\n },\n});\n"],"names":[],"mappings":";;;;;AAOO,MAAM,kBAAA,GAAqB,IAAI,UAAA,CAAuC;AAAA,EAC3E,IAAA,EAAM,UAAA;AAAA,EACN,SAAA,EAAW;AAAA,IACT,YAAA,EAAc,CAAC,SAAA,KACb,SAAA,YAAqB,QAAA;AAAA,IACvB,KAAA,EAAO,OAAO,QAAA,KACZ,MAAM,OAAA,CAAQ,IAAI,KAAA,CAAM,IAAA,CAAK,QAAA,EAAU,aAAa,CAAC;AAAA,GACzD;AAAA,EACA,WAAA,EAAa;AAAA,IACX,KAAA,EAAO,CAAC,UAAA,KAAe;AACrB,MAAA,MAAM,YAAA,GAAe,IAAI,YAAA,EAAa;AACtC,MAAA,KAAA,MAAW,QAAQ,UAAA,EAAY;AAC7B,QAAA,YAAA,CAAa,KAAA,CAAM,GAAA,CAAI,eAAA,CAAgB,IAAI,CAAC,CAAA;AAAA,MAC9C;AACA,MAAA,OAAO,YAAA,CAAa,KAAA;AAAA,IACtB;AAAA;AAEJ,CAAC;;;;"}
@@ -0,0 +1,36 @@
1
+ import { Serializer } from '../Serializer.mjs';
2
+ import '@internationalized/date';
3
+ import { isSerializedFile, fileDeSerialize, fileSerialize } from './file.mjs';
4
+ import '@mittwald/flow-react-components/mittwald-password-tools-js';
5
+
6
+ const formDataSerializer = new Serializer({
7
+ name: "FormData",
8
+ serialize: {
9
+ isApplicable: (val) => {
10
+ return val instanceof FormData;
11
+ },
12
+ apply: async (formData) => {
13
+ const out = [];
14
+ for (const [fieldName, fieldValue] of formData.entries()) {
15
+ out.push([
16
+ fieldName,
17
+ fieldValue instanceof File ? await fileSerialize(fieldValue) : fieldValue
18
+ ]);
19
+ }
20
+ return out;
21
+ }
22
+ },
23
+ deserialize: {
24
+ apply: (array) => {
25
+ const formData = new FormData();
26
+ for (const [name, value] of array) {
27
+ const deserializedValue = isSerializedFile(value) ? fileDeSerialize(value) : value;
28
+ formData.append(name, deserializedValue);
29
+ }
30
+ return formData;
31
+ }
32
+ }
33
+ });
34
+
35
+ export { formDataSerializer };
36
+ //# sourceMappingURL=formData.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formData.mjs","sources":["../../../../src/serialization/serializers/formData.ts"],"sourcesContent":["import { Serializer } from \"@/serialization/Serializer\";\nimport {\n fileDeSerialize,\n fileSerialize,\n isSerializedFile,\n} from \"@/serialization/serializers\";\n\ntype SerializedFormDataValue =\n | FormDataEntryValue\n | Awaited<ReturnType<typeof fileSerialize>>;\ntype SerializedFormDataEntries = [string, SerializedFormDataValue][];\n\nexport const formDataSerializer = new Serializer<\n FormData,\n SerializedFormDataEntries\n>({\n name: \"FormData\",\n serialize: {\n isApplicable: (val) => {\n return val instanceof FormData;\n },\n apply: async (formData) => {\n const out: SerializedFormDataEntries = [];\n\n for (const [fieldName, fieldValue] of formData.entries()) {\n out.push([\n fieldName,\n fieldValue instanceof File\n ? await fileSerialize(fieldValue)\n : fieldValue,\n ]);\n }\n\n return out;\n },\n },\n deserialize: {\n apply: (array) => {\n const formData = new FormData();\n\n for (const [name, value] of array) {\n const deserializedValue = isSerializedFile(value)\n ? fileDeSerialize(value)\n : value;\n\n formData.append(name, deserializedValue);\n }\n\n return formData;\n },\n },\n});\n"],"names":[],"mappings":";;;;;AAYO,MAAM,kBAAA,GAAqB,IAAI,UAAA,CAGpC;AAAA,EACA,IAAA,EAAM,UAAA;AAAA,EACN,SAAA,EAAW;AAAA,IACT,YAAA,EAAc,CAAC,GAAA,KAAQ;AACrB,MAAA,OAAO,GAAA,YAAe,QAAA;AAAA,IACxB,CAAA;AAAA,IACA,KAAA,EAAO,OAAO,QAAA,KAAa;AACzB,MAAA,MAAM,MAAiC,EAAC;AAExC,MAAA,KAAA,MAAW,CAAC,SAAA,EAAW,UAAU,CAAA,IAAK,QAAA,CAAS,SAAQ,EAAG;AACxD,QAAA,GAAA,CAAI,IAAA,CAAK;AAAA,UACP,SAAA;AAAA,UACA,UAAA,YAAsB,IAAA,GAClB,MAAM,aAAA,CAAc,UAAU,CAAA,GAC9B;AAAA,SACL,CAAA;AAAA,MACH;AAEA,MAAA,OAAO,GAAA;AAAA,IACT;AAAA,GACF;AAAA,EACA,WAAA,EAAa;AAAA,IACX,KAAA,EAAO,CAAC,KAAA,KAAU;AAChB,MAAA,MAAM,QAAA,GAAW,IAAI,QAAA,EAAS;AAE9B,MAAA,KAAA,MAAW,CAAC,IAAA,EAAM,KAAK,CAAA,IAAK,KAAA,EAAO;AACjC,QAAA,MAAM,oBAAoB,gBAAA,CAAiB,KAAK,CAAA,GAC5C,eAAA,CAAgB,KAAK,CAAA,GACrB,KAAA;AAEJ,QAAA,QAAA,CAAS,MAAA,CAAO,MAAM,iBAAiB,CAAA;AAAA,MACzC;AAEA,MAAA,OAAO,QAAA;AAAA,IACT;AAAA;AAEJ,CAAC;;;;"}
@@ -0,0 +1,7 @@
1
+ export { calendarDateSerializer } from './date.mjs';
2
+ export { fileDeSerialize, fileSerialize, fileSerializer, isSerializedFile } from './file.mjs';
3
+ export { fileListSerializer } from './fileList.mjs';
4
+ export { dataTransferTextSerializer } from './dataTransferText.mjs';
5
+ export { formDataSerializer } from './formData.mjs';
6
+ export { passwordPolicySerializer } from './passwordPolicy.mjs';
7
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
@@ -0,0 +1,16 @@
1
+ import { Serializer } from '../Serializer.mjs';
2
+ import { Policy } from '@mittwald/flow-react-components/mittwald-password-tools-js';
3
+
4
+ const passwordPolicySerializer = new Serializer({
5
+ name: "PasswordPolicy",
6
+ serialize: {
7
+ isApplicable: (val) => Policy.isPolicy(val),
8
+ apply: (policy) => policy.toDeclaration()
9
+ },
10
+ deserialize: {
11
+ apply: (policyDeclaration) => Policy.fromDeclaration(policyDeclaration)
12
+ }
13
+ });
14
+
15
+ export { passwordPolicySerializer };
16
+ //# sourceMappingURL=passwordPolicy.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"passwordPolicy.mjs","sources":["../../../../src/serialization/serializers/passwordPolicy.ts"],"sourcesContent":["import { Serializer } from \"@/serialization/Serializer\";\nimport {\n Policy,\n type PolicyDeclaration,\n} from \"@mittwald/flow-react-components/mittwald-password-tools-js\";\n\nexport const passwordPolicySerializer = new Serializer<\n Policy,\n PolicyDeclaration\n>({\n name: \"PasswordPolicy\",\n serialize: {\n isApplicable: (val) => Policy.isPolicy(val),\n apply: (policy) => policy.toDeclaration(),\n },\n deserialize: {\n apply: (policyDeclaration) => Policy.fromDeclaration(policyDeclaration),\n },\n});\n"],"names":[],"mappings":";;;AAMO,MAAM,wBAAA,GAA2B,IAAI,UAAA,CAG1C;AAAA,EACA,IAAA,EAAM,gBAAA;AAAA,EACN,SAAA,EAAW;AAAA,IACT,YAAA,EAAc,CAAC,GAAA,KAAQ,MAAA,CAAO,SAAS,GAAG,CAAA;AAAA,IAC1C,KAAA,EAAO,CAAC,MAAA,KAAW,MAAA,CAAO,aAAA;AAAc,GAC1C;AAAA,EACA,WAAA,EAAa;AAAA,IACX,KAAA,EAAO,CAAC,iBAAA,KAAsB,MAAA,CAAO,gBAAgB,iBAAiB;AAAA;AAE1E,CAAC;;;;"}
@@ -0,0 +1,16 @@
1
+ import { HTMLElement, customElements } from '@lit-labs/ssr-dom-shim';
2
+
3
+ globalThis.HTMLElement = HTMLElement;
4
+ globalThis.customElements = customElements;
5
+ globalThis.MutationObserver = class MutationObserver {
6
+ constructor() {
7
+ }
8
+ disconnect() {
9
+ }
10
+ observe() {
11
+ }
12
+ takeRecords() {
13
+ return [];
14
+ }
15
+ };
16
+ //# sourceMappingURL=shim.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shim.mjs","sources":["../../src/shim.ts"],"sourcesContent":["import { HTMLElement, customElements } from \"@lit-labs/ssr-dom-shim\";\n\nglobalThis.HTMLElement = HTMLElement;\nglobalThis.customElements = customElements;\nglobalThis.MutationObserver = class MutationObserver {\n public constructor() {\n // mocked\n }\n public disconnect() {\n // mocked\n }\n public observe() {\n // mocked\n }\n public takeRecords() {\n return [];\n }\n};\n"],"names":[],"mappings":";;AAEA,UAAA,CAAW,WAAA,GAAc,WAAA;AACzB,UAAA,CAAW,cAAA,GAAiB,cAAA;AAC5B,UAAA,CAAW,gBAAA,GAAmB,MAAM,gBAAA,CAAiB;AAAA,EAC5C,WAAA,GAAc;AAAA,EAErB;AAAA,EACO,UAAA,GAAa;AAAA,EAEpB;AAAA,EACO,OAAA,GAAU;AAAA,EAEjB;AAAA,EACO,WAAA,GAAc;AACnB,IAAA,OAAO,EAAC;AAAA,EACV;AACF,CAAA"}
@@ -1,7 +1,11 @@
1
- import { RemoteConnection } from '@mfalkenberg/remote-dom-core/elements';
2
- import { ThreadNestedIframe } from '@quilted/threads';
3
- export declare const connectHostRenderRoot: (div: HTMLDivElement) => ThreadNestedIframe<Record<string, never>, {
4
- render: (connection: RemoteConnection) => void;
5
- }>;
6
- export declare const connectHostRenderRootRef: (ref: HTMLDivElement | null) => void;
1
+ import { RemoteToHostConnection } from './types';
2
+ import { RemoteConnection } from '@mittwald/remote-dom-core/elements';
3
+ interface Options {
4
+ root: HTMLDivElement;
5
+ onPathnameChanged?: (pathname: string) => void;
6
+ }
7
+ export declare const connectRemoteReceiver: (root: HTMLDivElement, receiverConnection: RemoteConnection) => Promise<void>;
8
+ export declare const connectHostRenderRoot: (options: Options) => Promise<RemoteToHostConnection>;
9
+ export declare const connectHostRenderRootRef: (opts: Omit<Options, "root">) => (ref: HTMLDivElement | null) => Promise<RemoteToHostConnection> | undefined;
10
+ export {};
7
11
  //# sourceMappingURL=connectHostRenderRoot.d.ts.map