@mittwald/flow-remote-core 0.2.0-alpha.783 → 0.2.0-alpha.785
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/js/core/src/file.mjs +12 -10
- package/dist/js/core/src/file.mjs.map +1 -1
- package/dist/js/index-node.mjs +16 -15
- package/dist/js/index-node.mjs.map +1 -0
- package/dist/js/index.mjs +15 -17
- package/dist/js/index.mjs.map +1 -0
- package/dist/js/remote-core/src/connection/connectHostRenderRoot.mjs +55 -45
- package/dist/js/remote-core/src/connection/connectHostRenderRoot.mjs.map +1 -1
- package/dist/js/remote-core/src/connection/connectRemoteIframe.mjs +62 -47
- package/dist/js/remote-core/src/connection/connectRemoteIframe.mjs.map +1 -1
- package/dist/js/remote-core/src/connection/types.mjs +9 -11
- package/dist/js/remote-core/src/connection/types.mjs.map +1 -1
- package/dist/js/remote-core/src/error.mjs +8 -10
- package/dist/js/remote-core/src/error.mjs.map +1 -1
- package/dist/js/remote-core/src/ext-bridge/implementation.mjs +12 -8
- package/dist/js/remote-core/src/ext-bridge/implementation.mjs.map +1 -1
- package/dist/js/remote-core/src/serialization/FlowThreadSerialization.mjs +59 -47
- package/dist/js/remote-core/src/serialization/FlowThreadSerialization.mjs.map +1 -1
- package/dist/js/remote-core/src/serialization/Serializer.mjs +35 -33
- package/dist/js/remote-core/src/serialization/Serializer.mjs.map +1 -1
- package/dist/js/remote-core/src/serialization/serializers/dataTransferText.mjs +21 -20
- package/dist/js/remote-core/src/serialization/serializers/dataTransferText.mjs.map +1 -1
- package/dist/js/remote-core/src/serialization/serializers/date.mjs +14 -13
- package/dist/js/remote-core/src/serialization/serializers/date.mjs.map +1 -1
- package/dist/js/remote-core/src/serialization/serializers/file.mjs +29 -29
- package/dist/js/remote-core/src/serialization/serializers/file.mjs.map +1 -1
- package/dist/js/remote-core/src/serialization/serializers/fileList.mjs +22 -20
- package/dist/js/remote-core/src/serialization/serializers/fileList.mjs.map +1 -1
- package/dist/js/remote-core/src/serialization/serializers/formData.mjs +34 -27
- package/dist/js/remote-core/src/serialization/serializers/formData.mjs.map +1 -1
- package/dist/js/remote-core/src/serialization/serializers/index.mjs +7 -23
- package/dist/js/remote-core/src/serialization/serializers/index.mjs.map +1 -1
- package/dist/js/remote-core/src/serialization/serializers/passwordPolicy.mjs +14 -13
- package/dist/js/remote-core/src/serialization/serializers/passwordPolicy.mjs.map +1 -1
- package/dist/js/remote-core/src/shim.mjs +12 -11
- package/dist/js/remote-core/src/shim.mjs.map +1 -1
- package/package.json +8 -8
- package/dist/js/_virtual/_rolldown/runtime.mjs +0 -13
- package/dist/js/core/src/index.mjs +0 -1
- package/dist/js/remote-core/src/connection/index.mjs +0 -3
- package/dist/js/remote-core/src/serialization/index.mjs +0 -9
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import invariant from
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import invariant from 'invariant';
|
|
2
|
+
|
|
3
|
+
const Key = "mittwald.flow-core.file.awaitedArrayBuffer";
|
|
4
4
|
function isFileWithAwaitedArrayBuffer(file) {
|
|
5
|
-
|
|
5
|
+
return Key in file && file[Key] instanceof ArrayBuffer && !file[Key].detached;
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const getAwaitArrayBuffer = (file) => {
|
|
8
|
+
invariant(
|
|
9
|
+
isFileWithAwaitedArrayBuffer(file),
|
|
10
|
+
"Could not get awaited ArrayBuffer from file"
|
|
11
|
+
);
|
|
12
|
+
return file[Key];
|
|
10
13
|
};
|
|
11
|
-
//#endregion
|
|
12
|
-
export { getAwaitArrayBuffer, isFileWithAwaitedArrayBuffer };
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
export { getAwaitArrayBuffer, isFileWithAwaitedArrayBuffer };
|
|
16
|
+
//# sourceMappingURL=file.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.mjs","
|
|
1
|
+
{"version":3,"file":"file.mjs","sources":["../../../../../core/src/file.ts"],"sourcesContent":["import invariant from \"invariant\";\n\nconst Key = \"mittwald.flow-core.file.awaitedArrayBuffer\";\n\nexport type FileWithAwaitedArrayBuffer = File & {\n [Key]: ArrayBuffer;\n};\n\nexport function isFileWithAwaitedArrayBuffer(\n file: File | FileWithAwaitedArrayBuffer,\n): file is FileWithAwaitedArrayBuffer {\n return Key in file && file[Key] instanceof ArrayBuffer && !file[Key].detached;\n}\n\nexport const addAwaitedArrayBuffer = async (file: File) => {\n if (isFileWithAwaitedArrayBuffer(file)) {\n return file;\n }\n\n const arrayBuffer = await file.arrayBuffer();\n Object.assign(file, { [Key]: arrayBuffer });\n\n return file;\n};\n\nexport const getAwaitArrayBuffer = (\n file: File | FileWithAwaitedArrayBuffer,\n) => {\n invariant(\n isFileWithAwaitedArrayBuffer(file),\n \"Could not get awaited ArrayBuffer from file\",\n );\n return file[Key];\n};\n"],"names":[],"mappings":";;AAEA,MAAM,GAAA,GAAM,4CAAA;AAML,SAAS,6BACd,IAAA,EACoC;AACpC,EAAA,OAAO,GAAA,IAAO,QAAQ,IAAA,CAAK,GAAG,aAAa,WAAA,IAAe,CAAC,IAAA,CAAK,GAAG,CAAA,CAAE,QAAA;AACvE;AAaO,MAAM,mBAAA,GAAsB,CACjC,IAAA,KACG;AACH,EAAA,SAAA;AAAA,IACE,6BAA6B,IAAI,CAAA;AAAA,IACjC;AAAA,GACF;AACA,EAAA,OAAO,KAAK,GAAG,CAAA;AACjB;;;;"}
|
package/dist/js/index-node.mjs
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export {
|
|
1
|
+
import './remote-core/src/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 './remote-core/src/serialization/serializers/date.mjs';
|
|
5
|
+
export { fileDeSerialize, fileSerialize, fileSerializer, isSerializedFile } from './remote-core/src/serialization/serializers/file.mjs';
|
|
6
|
+
export { fileListSerializer } from './remote-core/src/serialization/serializers/fileList.mjs';
|
|
7
|
+
export { dataTransferTextSerializer } from './remote-core/src/serialization/serializers/dataTransferText.mjs';
|
|
8
|
+
export { formDataSerializer } from './remote-core/src/serialization/serializers/formData.mjs';
|
|
9
|
+
export { passwordPolicySerializer } from './remote-core/src/serialization/serializers/passwordPolicy.mjs';
|
|
10
|
+
export { FlowThreadSerialization } from './remote-core/src/serialization/FlowThreadSerialization.mjs';
|
|
11
|
+
export { Serializer } from './remote-core/src/serialization/Serializer.mjs';
|
|
12
|
+
export { connectHostRenderRoot, connectHostRenderRootRef, connectRemoteReceiver } from './remote-core/src/connection/connectHostRenderRoot.mjs';
|
|
13
|
+
export { connectRemoteIframe, connectRemoteIframeRef } from './remote-core/src/connection/connectRemoteIframe.mjs';
|
|
14
|
+
export { Version } from './remote-core/src/connection/types.mjs';
|
|
15
|
+
export { RemoteError } from './remote-core/src/error.mjs';
|
|
16
|
+
//# sourceMappingURL=index-node.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-node.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;"}
|
package/dist/js/index.mjs
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
import { RemoteElement, RemoteEvent } from "@mittwald/remote-dom-core/elements";
|
|
17
|
-
export { FlowThreadSerialization, RemoteElement, RemoteError, RemoteEvent, RemoteReceiver, Serializer, Version, calendarDateSerializer, connectHostRenderRoot, connectHostRenderRootRef, connectRemoteIframe, connectRemoteIframeRef, connectRemoteReceiver, dataTransferTextSerializer, fileDeSerialize, fileListSerializer, fileSerialize, fileSerializer, formDataSerializer, isSerializedFile, passwordPolicySerializer };
|
|
1
|
+
export { RemoteReceiver } from '@mittwald/remote-dom-core/receivers';
|
|
2
|
+
export { RemoteElement, RemoteEvent } from '@mittwald/remote-dom-core/elements';
|
|
3
|
+
export { calendarDateSerializer } from './remote-core/src/serialization/serializers/date.mjs';
|
|
4
|
+
export { fileDeSerialize, fileSerialize, fileSerializer, isSerializedFile } from './remote-core/src/serialization/serializers/file.mjs';
|
|
5
|
+
export { fileListSerializer } from './remote-core/src/serialization/serializers/fileList.mjs';
|
|
6
|
+
export { dataTransferTextSerializer } from './remote-core/src/serialization/serializers/dataTransferText.mjs';
|
|
7
|
+
export { formDataSerializer } from './remote-core/src/serialization/serializers/formData.mjs';
|
|
8
|
+
export { passwordPolicySerializer } from './remote-core/src/serialization/serializers/passwordPolicy.mjs';
|
|
9
|
+
export { FlowThreadSerialization } from './remote-core/src/serialization/FlowThreadSerialization.mjs';
|
|
10
|
+
export { Serializer } from './remote-core/src/serialization/Serializer.mjs';
|
|
11
|
+
export { connectHostRenderRoot, connectHostRenderRootRef, connectRemoteReceiver } from './remote-core/src/connection/connectHostRenderRoot.mjs';
|
|
12
|
+
export { connectRemoteIframe, connectRemoteIframeRef } from './remote-core/src/connection/connectRemoteIframe.mjs';
|
|
13
|
+
export { Version } from './remote-core/src/connection/types.mjs';
|
|
14
|
+
export { RemoteError } from './remote-core/src/error.mjs';
|
|
15
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
|
|
@@ -1,48 +1,58 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import { ThreadNestedIframe } from
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
+
}
|
|
34
41
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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;
|
|
44
55
|
};
|
|
45
|
-
//#endregion
|
|
46
|
-
export { connectHostRenderRoot, connectHostRenderRootRef, connectRemoteReceiver };
|
|
47
56
|
|
|
48
|
-
|
|
57
|
+
export { connectHostRenderRoot, connectHostRenderRootRef, connectRemoteReceiver };
|
|
58
|
+
//# sourceMappingURL=connectHostRenderRoot.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connectHostRenderRoot.mjs","
|
|
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,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,EAAkB,GAAI,OAAA;AAEpC,EAAA,MAAM,UAAA,GAAa,IAAI,kBAAA,CAA+C;AAAA,IACpE,aAAA,EAAe,IAAI,uBAAA,EAAwB;AAAA,IAC3C,OAAA,EAAS;AAAA,MACP,MAAA,EAAQ,CAACA,WAAAA,KACP,qBAAA,CAAsB,MAAMA,WAAU,CAAA;AAAA,MACxC,WAAA,EAAa,OAAO,QAAA,KAAa;AAC/B,QAAA,iBAAA,GAAoB,QAAQ,CAAA;AAAA,MAC9B;AAAA;AACF,GACD,CAAA;AAED,EAAA,IAAI,UAAA,CAAW,WAAW,MAAA,EAAQ;AAChC,IAAA,MAAM,4BAAA,EAA6B;AAAA,EACrC;AAEA,EAAA,IAAI;AACF,IAAA,MAAM,UAAA,CAAW,OAAA,CAAQ,UAAA,CAAW,OAAA,CAAQ,EAAE,CAAA;AAE9C,IAAA,IAAI,OAAO,gBAAgB,WAAA,EAAa;AACtC,MAAA,WAAA,CAAY,aAAa,UAAA,CAAW,OAAA;AACpC,MAAA,MAAM,WAAA,CAAY,UAAU,UAAA,EAAW;AAAA,IACzC;AAEA,IAAA,OAAO,UAAA;AAAA,EACT,SAAS,KAAA,EAAO;AACd,IAAA,IACE,iBAAiB,KAAA,IACjB,6CAAA,CAA8C,IAAA,CAAK,KAAA,CAAM,OAAO,CAAA,EAChE;AACA,MAAA,MAAM,4BAAA,EAA6B;AAAA,IACrC;AACA,IAAA,MAAM,KAAA;AAAA,EACR;AACF;AAEO,MAAM,wBAAA,GACX,CAAC,IAAA,KAAgC,CAAC,GAAA,KAA+B;AAC/D,EAAA,IAAI,QAAQ,IAAA,EAAM;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;;;;"}
|
|
@@ -1,50 +1,65 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { ThreadIframe } from
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
1
|
+
import { Version } from './types.mjs';
|
|
2
|
+
import { emptyImplementation } from '../ext-bridge/implementation.mjs';
|
|
3
|
+
import { FlowThreadSerialization } from '../serialization/FlowThreadSerialization.mjs';
|
|
4
|
+
import { ThreadIframe } from '@quilted/threads';
|
|
5
|
+
|
|
6
|
+
const connectRemoteIframe = (opts) => {
|
|
7
|
+
const {
|
|
8
|
+
connection,
|
|
9
|
+
iframe,
|
|
10
|
+
onReady,
|
|
11
|
+
onLoadingChanged,
|
|
12
|
+
onError,
|
|
13
|
+
onNavigationStateChanged,
|
|
14
|
+
extBridgeImplementation = emptyImplementation
|
|
15
|
+
} = opts;
|
|
16
|
+
const result = {
|
|
17
|
+
thread: new ThreadIframe(iframe, {
|
|
18
|
+
serialization: new FlowThreadSerialization(),
|
|
19
|
+
exports: {
|
|
20
|
+
...extBridgeImplementation,
|
|
21
|
+
setIsReady: async (version = 1) => {
|
|
22
|
+
result.version = version;
|
|
23
|
+
onReady?.(result);
|
|
24
|
+
},
|
|
25
|
+
setIsLoading: async (isLoading) => {
|
|
26
|
+
onLoadingChanged?.(isLoading);
|
|
27
|
+
},
|
|
28
|
+
setError: async (error) => {
|
|
29
|
+
onError?.(error);
|
|
30
|
+
},
|
|
31
|
+
setNavigationState: async (state) => {
|
|
32
|
+
onNavigationStateChanged?.(state);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}),
|
|
36
|
+
version: 0,
|
|
37
|
+
updateHostPathname: (hostPathname) => {
|
|
38
|
+
if (hostPathname === void 0) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (result.version >= Version.v2) {
|
|
42
|
+
result.thread.imports.setPathname(hostPathname);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
result.thread.imports.render(connection);
|
|
47
|
+
return result;
|
|
36
48
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
const connectRemoteIframeRef = (opts) => (ref) => {
|
|
50
|
+
if (!ref) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if ("__remoteConnection" in ref) {
|
|
54
|
+
return ref["__remoteConnection"];
|
|
55
|
+
}
|
|
56
|
+
const connection = connectRemoteIframe({
|
|
57
|
+
iframe: ref,
|
|
58
|
+
...opts
|
|
59
|
+
});
|
|
60
|
+
Object.assign(ref, { __remoteConnection: connection });
|
|
61
|
+
return connection;
|
|
46
62
|
};
|
|
47
|
-
//#endregion
|
|
48
|
-
export { connectRemoteIframe, connectRemoteIframeRef };
|
|
49
63
|
|
|
50
|
-
|
|
64
|
+
export { connectRemoteIframe, connectRemoteIframeRef };
|
|
65
|
+
//# sourceMappingURL=connectRemoteIframe.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connectRemoteIframe.mjs","
|
|
1
|
+
{"version":3,"file":"connectRemoteIframe.mjs","sources":["../../../../../src/connection/connectRemoteIframe.ts"],"sourcesContent":["import {\n type HostExports,\n type HostToRemoteConnection,\n type NavigationState,\n type RemoteExports,\n Version,\n} from \"@/connection/types\";\nimport { emptyImplementation } from \"@/ext-bridge/implementation\";\nimport { FlowThreadSerialization } from \"@/serialization/FlowThreadSerialization\";\nimport type { ExtBridgeConnectionApi } 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 onReady?: (connection: HostToRemoteConnection) => void;\n onLoadingChanged?: (isLoading: boolean) => void;\n onError?: (error: string) => void;\n onNavigationStateChanged?: (state: NavigationState) => void;\n extBridgeImplementation?: ExtBridgeConnectionApi;\n}\n\nexport const connectRemoteIframe = (opts: Options): HostToRemoteConnection => {\n const {\n connection,\n iframe,\n onReady,\n onLoadingChanged,\n onError,\n onNavigationStateChanged,\n extBridgeImplementation = emptyImplementation,\n } = opts;\n\n const result = {\n thread: new ThreadIframe<RemoteExports, HostExports>(iframe, {\n serialization: new FlowThreadSerialization(),\n exports: {\n ...extBridgeImplementation,\n setIsReady: async (version = 1) => {\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 },\n }),\n version: 0,\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 };\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":";;;;;AAuBO,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,uBAAA,GAA0B;AAAA,GAC5B,GAAI,IAAA;AAEJ,EAAA,MAAM,MAAA,GAAS;AAAA,IACb,MAAA,EAAQ,IAAI,YAAA,CAAyC,MAAA,EAAQ;AAAA,MAC3D,aAAA,EAAe,IAAI,uBAAA,EAAwB;AAAA,MAC3C,OAAA,EAAS;AAAA,QACP,GAAG,uBAAA;AAAA,QACH,UAAA,EAAY,OAAO,OAAA,GAAU,CAAA,KAAM;AACjC,UAAA,MAAA,CAAO,OAAA,GAAU,OAAA;AACjB,UAAA,OAAA,GAAU,MAAM,CAAA;AAAA,QAClB,CAAA;AAAA,QACA,YAAA,EAAc,OAAO,SAAA,KAAuB;AAC1C,UAAA,gBAAA,GAAmB,SAAS,CAAA;AAAA,QAC9B,CAAA;AAAA,QACA,QAAA,EAAU,OAAO,KAAA,KAAkB;AACjC,UAAA,OAAA,GAAU,KAAK,CAAA;AAAA,QACjB,CAAA;AAAA,QACA,kBAAA,EAAoB,OAAO,KAAA,KAAU;AACnC,UAAA,wBAAA,GAA2B,KAAK,CAAA;AAAA,QAClC;AAAA;AACF,KACD,CAAA;AAAA,IACD,OAAA,EAAS,CAAA;AAAA,IACT,kBAAA,EAAoB,CAAC,YAAA,KAA0B;AAC7C,MAAA,IAAI,iBAAiB,MAAA,EAAW;AAC9B,QAAA;AAAA,MACF;AAEA,MAAA,IAAI,MAAA,CAAO,OAAA,IAAW,OAAA,CAAQ,EAAA,EAAI;AAChC,QAAA,MAAA,CAAO,MAAA,CAAO,OAAA,CAAQ,WAAA,CAAY,YAAY,CAAA;AAAA,MAChD;AAAA,IACF;AAAA,GACF;AAEA,EAAA,MAAA,CAAO,MAAA,CAAO,OAAA,CAAQ,MAAA,CAAO,UAAU,CAAA;AACvC,EAAA,OAAO,MAAA;AACT;AAEO,MAAM,sBAAA,GACX,CAAC,IAAA,KAAkC,CAAC,GAAA,KAAkC;AACpE,EAAA,IAAI,CAAC,GAAA,EAAK;AACR,IAAA;AAAA,EACF;AAEA,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;;;;"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}({});
|
|
9
|
-
//#endregion
|
|
10
|
-
export { Version };
|
|
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 || {});
|
|
11
8
|
|
|
12
|
-
|
|
9
|
+
export { Version };
|
|
10
|
+
//# sourceMappingURL=types.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","
|
|
1
|
+
{"version":3,"file":"types.mjs","sources":["../../../../../src/connection/types.ts"],"sourcesContent":["import type { ExtBridgeConnectionApi } from \"@mittwald/ext-bridge\";\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 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}\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":"AAiCO,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;;;;"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
1
|
+
class RemoteError extends Error {
|
|
2
|
+
constructor(message) {
|
|
3
|
+
super(message);
|
|
4
|
+
this.message = message;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
8
7
|
RemoteError.prototype.name = "RemoteError";
|
|
9
|
-
//#endregion
|
|
10
|
-
export { RemoteError };
|
|
11
8
|
|
|
12
|
-
|
|
9
|
+
export { RemoteError };
|
|
10
|
+
//# sourceMappingURL=error.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.mjs","
|
|
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,9 +1,13 @@
|
|
|
1
|
-
import { RemoteError } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
+
);
|
|
8
11
|
|
|
9
|
-
|
|
12
|
+
export { emptyImplementation };
|
|
13
|
+
//# sourceMappingURL=implementation.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"implementation.mjs","
|
|
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,48 +1,60 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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: (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 = serializer.serialize(val);
|
|
22
|
+
if (serialization.applied) {
|
|
23
|
+
return serialize(serialization.result);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (isObjectType(val)) {
|
|
27
|
+
return serialize({ ...val });
|
|
28
|
+
}
|
|
29
|
+
} catch (error) {
|
|
30
|
+
console.error("Error while serializing", error);
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
deserialize: (val, serialize) => {
|
|
35
|
+
try {
|
|
36
|
+
for (const serializer of serializers) {
|
|
37
|
+
const deserialization = serializer.deserialize(val);
|
|
38
|
+
if (deserialization.applied) {
|
|
39
|
+
return deserialization.result.value;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return serialize(val);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
console.error("Error while deserializing", error);
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
super(options);
|
|
50
|
+
}
|
|
51
|
+
isSerializableByBase(val) {
|
|
52
|
+
return val instanceof Map || val instanceof Set || Array.isArray(val) || typeof val === "function" || isObjectType(val) && TRANSFERABLE in val;
|
|
53
|
+
}
|
|
54
|
+
omitSerialization(val) {
|
|
55
|
+
return val instanceof HTMLElement || val === window;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
47
58
|
|
|
48
|
-
|
|
59
|
+
export { FlowThreadSerialization };
|
|
60
|
+
//# sourceMappingURL=FlowThreadSerialization.mjs.map
|