@mittwald/flow-remote-core 1.6.0-next.9 → 1.6.1
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/_virtual/_rolldown/runtime.mjs +1 -2
- package/dist/js/index-node.mjs +5 -3
- package/dist/js/index-node.mjs.map +1 -1
- package/dist/js/index.mjs +5 -3
- package/dist/js/index.mjs.map +1 -1
- package/dist/js/node_modules/.pnpm/@quilted_events@2.1.5/node_modules/@quilted/events/build/esm/abort/NestedAbortController.mjs +1 -2
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/Thread.mjs +1 -2
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/constants.mjs +1 -2
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/errors.mjs +1 -2
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/functions/ThreadFunctionsAutomatic.mjs +1 -2
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/nanoid.mjs +1 -2
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/serialization/ThreadSerializationStructuredClone.mjs +1 -2
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/serialization/shared.mjs +1 -2
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/transfer.mjs +1 -2
- package/dist/js/packages/remote-core/src/connection/allowedHostOrigins.mjs +6 -0
- package/dist/js/packages/remote-core/src/connection/allowedHostOrigins.mjs.map +1 -0
- package/dist/js/packages/remote-core/src/connection/connectHostRenderRoot.mjs +9 -7
- package/dist/js/packages/remote-core/src/connection/connectHostRenderRoot.mjs.map +1 -1
- package/dist/js/packages/remote-core/src/connection/connectRemoteIframe.mjs +52 -27
- package/dist/js/packages/remote-core/src/connection/connectRemoteIframe.mjs.map +1 -1
- package/dist/js/packages/remote-core/src/connection/hostOriginPatterns.mjs +69 -0
- package/dist/js/packages/remote-core/src/connection/hostOriginPatterns.mjs.map +1 -0
- package/dist/js/packages/remote-core/src/connection/index.mjs +4 -1
- package/dist/js/packages/remote-core/src/connection/originThreads.mjs +168 -0
- package/dist/js/packages/remote-core/src/connection/originThreads.mjs.map +1 -0
- package/dist/js/packages/remote-core/src/connection/toRelativePathname.mjs +20 -0
- package/dist/js/packages/remote-core/src/connection/toRelativePathname.mjs.map +1 -0
- package/dist/js/packages/remote-core/src/connection/types.mjs +3 -2
- package/dist/js/packages/remote-core/src/connection/types.mjs.map +1 -1
- package/dist/js/packages/remote-core/src/error.mjs +1 -2
- package/dist/js/packages/remote-core/src/events/remoteEvents.mjs +1 -2
- package/dist/js/packages/remote-core/src/ext-bridge/getWithMergedHostConfig.mjs +1 -2
- package/dist/js/packages/remote-core/src/ext-bridge/implementation.mjs +1 -2
- package/dist/js/packages/remote-core/src/serialization/FlowThreadSerialization.mjs +1 -2
- package/dist/js/packages/remote-core/src/serialization/Serializer.mjs +1 -2
- package/dist/js/packages/remote-core/src/serialization/serializers/dataTransferText.mjs +1 -2
- package/dist/js/packages/remote-core/src/serialization/serializers/date.mjs +1 -2
- package/dist/js/packages/remote-core/src/serialization/serializers/file.mjs +1 -2
- package/dist/js/packages/remote-core/src/serialization/serializers/fileList.mjs +1 -2
- package/dist/js/packages/remote-core/src/serialization/serializers/formData.mjs +1 -2
- package/dist/js/packages/remote-core/src/serialization/serializers/index.mjs +1 -2
- package/dist/js/packages/remote-core/src/serialization/serializers/passwordPolicy.mjs +1 -2
- package/dist/js/packages/remote-core/src/shim.mjs +1 -2
- package/dist/types/connection/allowedHostOrigins.d.ts +2 -0
- package/dist/types/connection/connectHostRenderRoot.d.ts +5 -4
- package/dist/types/connection/connectRemoteIframe.d.ts +8 -5
- package/dist/types/connection/hostOriginPatterns.d.ts +4 -0
- package/dist/types/connection/index.d.ts +3 -0
- package/dist/types/connection/originThreads.d.ts +21 -0
- package/dist/types/connection/toRelativePathname.d.ts +2 -0
- package/dist/types/connection/types.d.ts +10 -4
- package/package.json +8 -8
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/threads/ThreadIframe.mjs +0 -154
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/threads/ThreadIframe.mjs.map +0 -1
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/threads/ThreadNestedIframe.mjs +0 -78
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/threads/ThreadNestedIframe.mjs.map +0 -1
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/threads/window/ThreadNestedWindow.mjs +0 -120
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/threads/window/ThreadNestedWindow.mjs.map +0 -1
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/threads/window/ThreadWindow.mjs +0 -192
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/threads/window/ThreadWindow.mjs.map +0 -1
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/threads/window/shared.mjs +0 -7
- package/dist/js/node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/threads/window/shared.mjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// \0rolldown/runtime.js
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __exportAll = (all, no_symbols) => {
|
|
4
4
|
let target = {};
|
|
@@ -9,5 +9,4 @@ var __exportAll = (all, no_symbols) => {
|
|
|
9
9
|
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
10
10
|
return target;
|
|
11
11
|
};
|
|
12
|
-
//#endregion
|
|
13
12
|
export { __exportAll };
|
package/dist/js/index-node.mjs
CHANGED
|
@@ -7,15 +7,17 @@ import { dataTransferTextSerializer } from "./packages/remote-core/src/serializa
|
|
|
7
7
|
import { formDataSerializer } from "./packages/remote-core/src/serialization/serializers/formData.mjs";
|
|
8
8
|
import { passwordPolicySerializer } from "./packages/remote-core/src/serialization/serializers/passwordPolicy.mjs";
|
|
9
9
|
import { FlowThreadSerialization } from "./packages/remote-core/src/serialization/FlowThreadSerialization.mjs";
|
|
10
|
+
import { DEFAULT_ALLOWED_HOST_ORIGINS } from "./packages/remote-core/src/connection/allowedHostOrigins.mjs";
|
|
10
11
|
import { Version } from "./packages/remote-core/src/connection/types.mjs";
|
|
12
|
+
import { createAllowedHostOriginMatcher } from "./packages/remote-core/src/connection/hostOriginPatterns.mjs";
|
|
11
13
|
import { RemoteError } from "./packages/remote-core/src/error.mjs";
|
|
14
|
+
import { toRelativePathname } from "./packages/remote-core/src/connection/toRelativePathname.mjs";
|
|
12
15
|
import { connectHostRenderRoot, connectHostRenderRootRef, connectRemoteReceiver } from "./packages/remote-core/src/connection/connectHostRenderRoot.mjs";
|
|
13
16
|
import { componentRenderedEventSchema, parseReportedEvent, reportedEventSchema } from "./packages/remote-core/src/events/remoteEvents.mjs";
|
|
14
17
|
import { connectRemoteIframe, connectRemoteIframeRef } from "./packages/remote-core/src/connection/connectRemoteIframe.mjs";
|
|
15
18
|
import { RemoteElement, RemoteEvent, RemoteReceiver } from "./index.mjs";
|
|
16
|
-
|
|
19
|
+
// src/index-node.ts
|
|
17
20
|
if (!domShimApplied) throw new Error("remote-core DOM shim failed to initialize");
|
|
18
|
-
|
|
19
|
-
export { FlowThreadSerialization, RemoteElement, RemoteError, RemoteEvent, RemoteReceiver, Serializer, Version, calendarDateSerializer, componentRenderedEventSchema, connectHostRenderRoot, connectHostRenderRootRef, connectRemoteIframe, connectRemoteIframeRef, connectRemoteReceiver, dataTransferTextSerializer, fileDeSerialize, fileListSerializer, fileSerialize, fileSerializer, formDataSerializer, isSerializedFile, parseReportedEvent, passwordPolicySerializer, reportedEventSchema };
|
|
21
|
+
export { DEFAULT_ALLOWED_HOST_ORIGINS, FlowThreadSerialization, RemoteElement, RemoteError, RemoteEvent, RemoteReceiver, Serializer, Version, calendarDateSerializer, componentRenderedEventSchema, connectHostRenderRoot, connectHostRenderRootRef, connectRemoteIframe, connectRemoteIframeRef, connectRemoteReceiver, createAllowedHostOriginMatcher, dataTransferTextSerializer, fileDeSerialize, fileListSerializer, fileSerialize, fileSerializer, formDataSerializer, isSerializedFile, parseReportedEvent, passwordPolicySerializer, reportedEventSchema, toRelativePathname };
|
|
20
22
|
|
|
21
23
|
//# sourceMappingURL=index-node.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-node.mjs","names":[],"sources":["../../src/index-node.ts"],"sourcesContent":["// The `node` export condition resolves here. The shim must be the very first\n// import so the DOM globals exist before any sibling module transitively pulls\n// in RemoteElement (which subclasses HTMLElement). Do NOT simplify this to a\n// bare `import \"./shim\"` or a plain `export * from \"./index\"`: Rollup then hoists\n// the remote-dom import ahead of the shim and SSR breaks with \"HTMLElement is\n// not defined\". Importing the shim as a used binding keeps it first.\nimport { domShimApplied } from \"./shim\";\nif (!domShimApplied) {\n throw new Error(\"remote-core DOM shim failed to initialize\");\n}\nexport * from \"./index\";\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index-node.mjs","names":[],"sources":["../../src/index-node.ts"],"sourcesContent":["// The `node` export condition resolves here. The shim must be the very first\n// import so the DOM globals exist before any sibling module transitively pulls\n// in RemoteElement (which subclasses HTMLElement). Do NOT simplify this to a\n// bare `import \"./shim\"` or a plain `export * from \"./index\"`: Rollup then hoists\n// the remote-dom import ahead of the shim and SSR breaks with \"HTMLElement is\n// not defined\". Importing the shim as a used binding keeps it first.\nimport { domShimApplied } from \"./shim\";\nif (!domShimApplied) {\n throw new Error(\"remote-core DOM shim failed to initialize\");\n}\nexport * from \"./index\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAOA,IAAI,CAAC,gBACH,MAAM,IAAI,MAAM,2CAA2C"}
|
package/dist/js/index.mjs
CHANGED
|
@@ -8,17 +8,19 @@ import { formDataSerializer } from "./packages/remote-core/src/serialization/ser
|
|
|
8
8
|
import { passwordPolicySerializer } from "./packages/remote-core/src/serialization/serializers/passwordPolicy.mjs";
|
|
9
9
|
import { FlowThreadSerialization } from "./packages/remote-core/src/serialization/FlowThreadSerialization.mjs";
|
|
10
10
|
import "./packages/remote-core/src/serialization/index.mjs";
|
|
11
|
+
import { DEFAULT_ALLOWED_HOST_ORIGINS } from "./packages/remote-core/src/connection/allowedHostOrigins.mjs";
|
|
11
12
|
import { Version } from "./packages/remote-core/src/connection/types.mjs";
|
|
13
|
+
import { createAllowedHostOriginMatcher } from "./packages/remote-core/src/connection/hostOriginPatterns.mjs";
|
|
12
14
|
import { RemoteError } from "./packages/remote-core/src/error.mjs";
|
|
15
|
+
import { toRelativePathname } from "./packages/remote-core/src/connection/toRelativePathname.mjs";
|
|
13
16
|
import { connectHostRenderRoot, connectHostRenderRootRef, connectRemoteReceiver } from "./packages/remote-core/src/connection/connectHostRenderRoot.mjs";
|
|
14
17
|
import { componentRenderedEventSchema, parseReportedEvent, reportedEventSchema } from "./packages/remote-core/src/events/remoteEvents.mjs";
|
|
15
18
|
import { connectRemoteIframe, connectRemoteIframeRef } from "./packages/remote-core/src/connection/connectRemoteIframe.mjs";
|
|
16
19
|
import "./packages/remote-core/src/connection/index.mjs";
|
|
17
20
|
import { RemoteReceiver } from "@mittwald/remote-dom-core/receivers";
|
|
18
21
|
import { RemoteElement, RemoteEvent } from "@mittwald/remote-dom-core/elements";
|
|
19
|
-
|
|
22
|
+
// src/index.ts
|
|
20
23
|
if (!domShimApplied) throw new Error("remote-core DOM shim failed to initialize");
|
|
21
|
-
|
|
22
|
-
export { FlowThreadSerialization, RemoteElement, RemoteError, RemoteEvent, RemoteReceiver, Serializer, Version, calendarDateSerializer, componentRenderedEventSchema, connectHostRenderRoot, connectHostRenderRootRef, connectRemoteIframe, connectRemoteIframeRef, connectRemoteReceiver, dataTransferTextSerializer, fileDeSerialize, fileListSerializer, fileSerialize, fileSerializer, formDataSerializer, isSerializedFile, parseReportedEvent, passwordPolicySerializer, reportedEventSchema };
|
|
24
|
+
export { DEFAULT_ALLOWED_HOST_ORIGINS, FlowThreadSerialization, RemoteElement, RemoteError, RemoteEvent, RemoteReceiver, Serializer, Version, calendarDateSerializer, componentRenderedEventSchema, connectHostRenderRoot, connectHostRenderRootRef, connectRemoteIframe, connectRemoteIframeRef, connectRemoteReceiver, createAllowedHostOriginMatcher, dataTransferTextSerializer, fileDeSerialize, fileListSerializer, fileSerialize, fileSerializer, formDataSerializer, isSerializedFile, parseReportedEvent, passwordPolicySerializer, reportedEventSchema, toRelativePathname };
|
|
23
25
|
|
|
24
26
|
//# sourceMappingURL=index.mjs.map
|
package/dist/js/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/index.ts"],"sourcesContent":["import { domShimApplied } from \"./shim\";\n\nexport { RemoteReceiver } from \"@mittwald/remote-dom-core/receivers\";\nexport {\n RemoteElement,\n RemoteEvent,\n type RemoteElementConstructor,\n} from \"@mittwald/remote-dom-core/elements\";\nexport * from \"./serialization\";\nexport * from \"./connection\";\nexport * from \"./error\";\nexport * from \"./events/remoteEvents\";\n\n// The DOM shim above must be evaluated before RemoteElement (which subclasses\n// HTMLElement) is imported. Referencing the binding keeps the import from being\n// tree-shaken or reordered after the remote-dom re-export.\nif (!domShimApplied) {\n throw new Error(\"remote-core DOM shim failed to initialize\");\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/index.ts"],"sourcesContent":["import { domShimApplied } from \"./shim\";\n\nexport { RemoteReceiver } from \"@mittwald/remote-dom-core/receivers\";\nexport {\n RemoteElement,\n RemoteEvent,\n type RemoteElementConstructor,\n} from \"@mittwald/remote-dom-core/elements\";\nexport * from \"./serialization\";\nexport * from \"./connection\";\nexport * from \"./error\";\nexport * from \"./events/remoteEvents\";\n\n// The DOM shim above must be evaluated before RemoteElement (which subclasses\n// HTMLElement) is imported. Referencing the binding keeps the import from being\n// tree-shaken or reordered after the remote-dom re-export.\nif (!domShimApplied) {\n throw new Error(\"remote-core DOM shim failed to initialize\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAgBA,IAAI,CAAC,gBACH,MAAM,IAAI,MAAM,2CAA2C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// ../../node_modules/.pnpm/@quilted+events@2.1.5/node_modules/@quilted/events/build/esm/abort/NestedAbortController.mjs
|
|
2
2
|
/**
|
|
3
3
|
* An `AbortController` that will automatically abort when any of
|
|
4
4
|
* its "parent" `AbortController`s abort. This is useful for when
|
|
@@ -29,7 +29,6 @@ var NestedAbortController = class extends AbortController {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
|
-
//#endregion
|
|
33
32
|
export { NestedAbortController };
|
|
34
33
|
|
|
35
34
|
//# sourceMappingURL=NestedAbortController.mjs.map
|
|
@@ -3,7 +3,7 @@ import { ThreadClosedError } from "./errors.mjs";
|
|
|
3
3
|
import { nanoid } from "./nanoid.mjs";
|
|
4
4
|
import { ThreadFunctionsAutomatic } from "./functions/ThreadFunctionsAutomatic.mjs";
|
|
5
5
|
import { ThreadSerializationStructuredClone } from "./serialization/ThreadSerializationStructuredClone.mjs";
|
|
6
|
-
|
|
6
|
+
// ../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/Thread.mjs
|
|
7
7
|
/**
|
|
8
8
|
* A thread represents a target JavaScript environment that exposes a set
|
|
9
9
|
* of callable, asynchronous methods. The thread takes care of automatically
|
|
@@ -185,7 +185,6 @@ function createThreadImports(handlerForImport, imported) {
|
|
|
185
185
|
function missingThreadFunction() {
|
|
186
186
|
throw new Error(`You attempted to call a function that is not stored. It may have already been released.`);
|
|
187
187
|
}
|
|
188
|
-
//#endregion
|
|
189
188
|
export { Thread };
|
|
190
189
|
|
|
191
190
|
//# sourceMappingURL=Thread.mjs.map
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
// ../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/constants.mjs
|
|
2
2
|
var SERIALIZE_METHOD = Symbol.for("quilt.threads.serialize");
|
|
3
3
|
var TRANSFERABLE = Symbol.for("quilt.threads.transferable");
|
|
4
|
-
//#endregion
|
|
5
4
|
export { SERIALIZE_METHOD, TRANSFERABLE };
|
|
6
5
|
|
|
7
6
|
//# sourceMappingURL=constants.mjs.map
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
// ../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/errors.mjs
|
|
2
2
|
var ThreadClosedError = class extends Error {
|
|
3
3
|
constructor() {
|
|
4
4
|
super("You attempted to call a function on a closed thread.");
|
|
5
5
|
}
|
|
6
6
|
};
|
|
7
|
-
//#endregion
|
|
8
7
|
export { ThreadClosedError };
|
|
9
8
|
|
|
10
9
|
//# sourceMappingURL=errors.mjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { nanoid } from "../nanoid.mjs";
|
|
2
|
-
|
|
2
|
+
// ../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/functions/ThreadFunctionsAutomatic.mjs
|
|
3
3
|
/**
|
|
4
4
|
* A strategy for managing functions across threads that automatically releases
|
|
5
5
|
* functions when they are no longer needed. This is done by deserializing functions
|
|
@@ -64,7 +64,6 @@ var ThreadFunctionsAutomatic = class {
|
|
|
64
64
|
return finalization;
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
|
-
//#endregion
|
|
68
67
|
export { ThreadFunctionsAutomatic };
|
|
69
68
|
|
|
70
69
|
//# sourceMappingURL=ThreadFunctionsAutomatic.mjs.map
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
// ../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/nanoid.mjs
|
|
2
2
|
var a = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
3
3
|
function nanoid(e = 21) {
|
|
4
4
|
let t = "", r = crypto.getRandomValues(new Uint8Array(e));
|
|
5
5
|
for (let n = 0; n < e; n++) t += a[63 & r[n]];
|
|
6
6
|
return t;
|
|
7
7
|
}
|
|
8
|
-
//#endregion
|
|
9
8
|
export { nanoid };
|
|
10
9
|
|
|
11
10
|
//# sourceMappingURL=nanoid.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SERIALIZE_METHOD, TRANSFERABLE } from "../constants.mjs";
|
|
2
2
|
import { isBasicObject, isIterator } from "./shared.mjs";
|
|
3
|
-
|
|
3
|
+
// ../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/serialization/ThreadSerializationStructuredClone.mjs
|
|
4
4
|
var FUNCTION = "_@f";
|
|
5
5
|
var ASYNC_ITERATOR = "_@i";
|
|
6
6
|
/**
|
|
@@ -127,7 +127,6 @@ var ThreadSerializationStructuredClone = class {
|
|
|
127
127
|
return value;
|
|
128
128
|
}
|
|
129
129
|
};
|
|
130
|
-
//#endregion
|
|
131
130
|
export { ThreadSerializationStructuredClone };
|
|
132
131
|
|
|
133
132
|
//# sourceMappingURL=ThreadSerializationStructuredClone.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// ../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/serialization/shared.mjs
|
|
2
2
|
function isIterator(value) {
|
|
3
3
|
return value != null && (Symbol.asyncIterator in value || Symbol.iterator in value) && typeof value.next === "function";
|
|
4
4
|
}
|
|
@@ -7,7 +7,6 @@ function isBasicObject(value) {
|
|
|
7
7
|
const prototype = Object.getPrototypeOf(value);
|
|
8
8
|
return prototype == null || prototype === Object.prototype;
|
|
9
9
|
}
|
|
10
|
-
//#endregion
|
|
11
10
|
export { isBasicObject, isIterator };
|
|
12
11
|
|
|
13
12
|
//# sourceMappingURL=shared.mjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TRANSFERABLE } from "./constants.mjs";
|
|
2
|
-
|
|
2
|
+
// ../../node_modules/.pnpm/@quilted+threads@3.3.1_patch_hash=fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/transfer.mjs
|
|
3
3
|
/**
|
|
4
4
|
* Marks the value as being transferable between threads. The memory for this object
|
|
5
5
|
* will be moved to the target thread once the object is sent.
|
|
@@ -10,7 +10,6 @@ function markAsTransferable(value) {
|
|
|
10
10
|
Object.assign(value, { [TRANSFERABLE]: true });
|
|
11
11
|
return value;
|
|
12
12
|
}
|
|
13
|
-
//#endregion
|
|
14
13
|
export { markAsTransferable };
|
|
15
14
|
|
|
16
15
|
//# sourceMappingURL=transfer.mjs.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// src/connection/allowedHostOrigins.ts
|
|
2
|
+
/** Entries are exact origins or patterns in the form `https://*.<domain>`. */
|
|
3
|
+
var DEFAULT_ALLOWED_HOST_ORIGINS = ["https://*.mittwald.de", "https://*.mittwald.systems"];
|
|
4
|
+
export { DEFAULT_ALLOWED_HOST_ORIGINS };
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=allowedHostOrigins.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"allowedHostOrigins.mjs","names":[],"sources":["../../../../../../src/connection/allowedHostOrigins.ts"],"sourcesContent":["/** Entries are exact origins or patterns in the form `https://*.<domain>`. */\nexport const DEFAULT_ALLOWED_HOST_ORIGINS: readonly string[] = [\n \"https://*.mittwald.de\",\n \"https://*.mittwald.systems\",\n];\n"],"mappings":";;AACA,IAAa,+BAAkD,CAC7D,yBACA,4BACF"}
|
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
import { ThreadNestedIframe } from "../../../../node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/threads/ThreadNestedIframe.mjs";
|
|
2
1
|
import { FlowThreadSerialization } from "../serialization/FlowThreadSerialization.mjs";
|
|
3
2
|
import { Version } from "./types.mjs";
|
|
4
3
|
import { RemoteError } from "../error.mjs";
|
|
4
|
+
import { HostOriginThread } from "./originThreads.mjs";
|
|
5
|
+
import { toRelativePathname } from "./toRelativePathname.mjs";
|
|
5
6
|
import "@mittwald/remote-dom-core/elements";
|
|
6
|
-
|
|
7
|
+
// src/connection/connectHostRenderRoot.ts
|
|
7
8
|
var incompatibleParentFrameError = () => new RemoteError("Could not find any compatible parent frame");
|
|
8
9
|
var connectRemoteReceiver = (root, receiverConnection) => import("@mittwald/remote-dom-core/elements").then(({ RemoteMutationObserver }) => {
|
|
9
10
|
new RemoteMutationObserver(receiverConnection).observe(root);
|
|
10
11
|
});
|
|
11
12
|
var connectHostRenderRoot = async (options) => {
|
|
12
|
-
const { root, onPathnameChanged, onHostError, packageVersion } = options;
|
|
13
|
-
const connection = new
|
|
13
|
+
const { root, onPathnameChanged, onHostError, packageVersion, allowedHostOrigins } = options;
|
|
14
|
+
const connection = new HostOriginThread({
|
|
15
|
+
allowedHostOrigins,
|
|
14
16
|
serialization: new FlowThreadSerialization(),
|
|
15
17
|
exports: {
|
|
16
18
|
render: (connection) => connectRemoteReceiver(root, connection),
|
|
17
19
|
setPathname: async (pathname) => {
|
|
18
|
-
|
|
20
|
+
const relativePathname = toRelativePathname(pathname);
|
|
21
|
+
if (relativePathname !== void 0) onPathnameChanged?.(relativePathname);
|
|
19
22
|
},
|
|
20
23
|
setHostError: async (error) => {
|
|
21
24
|
onHostError?.(error);
|
|
@@ -25,7 +28,7 @@ var connectHostRenderRoot = async (options) => {
|
|
|
25
28
|
if (connection.parent === window) throw incompatibleParentFrameError();
|
|
26
29
|
try {
|
|
27
30
|
await connection.imports.setIsReady({
|
|
28
|
-
version: Version.
|
|
31
|
+
version: Version.v6,
|
|
29
32
|
packageVersion
|
|
30
33
|
});
|
|
31
34
|
if (typeof mwExtBridge !== "undefined") {
|
|
@@ -48,7 +51,6 @@ var connectHostRenderRootRef = (opts) => (ref) => {
|
|
|
48
51
|
Object.assign(ref, { __remoteConnection: connection });
|
|
49
52
|
return connection;
|
|
50
53
|
};
|
|
51
|
-
//#endregion
|
|
52
54
|
export { connectHostRenderRoot, connectHostRenderRootRef, connectRemoteReceiver };
|
|
53
55
|
|
|
54
56
|
//# sourceMappingURL=connectHostRenderRoot.mjs.map
|
|
@@ -1 +1 @@
|
|
|
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\";\
|
|
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 { HostOriginThread } from \"@/connection/originThreads\";\nimport { toRelativePathname } from \"@/connection/toRelativePathname\";\nimport { RemoteError } from \"@/error\";\nimport { FlowThreadSerialization } from \"@/serialization/FlowThreadSerialization\";\nimport { type RemoteConnection } from \"@mittwald/remote-dom-core/elements\";\n\nexport interface ConnectHostRenderRootOptions {\n root: HTMLDivElement;\n onPathnameChanged?: (pathname: string) => void;\n onHostError?: (error: string) => void;\n packageVersion?: string;\n /** Additional host origins accepted by the remote app. */\n allowedHostOrigins?: 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: ConnectHostRenderRootOptions,\n): Promise<RemoteToHostConnection> => {\n const {\n root,\n onPathnameChanged,\n onHostError,\n packageVersion,\n allowedHostOrigins,\n } = options;\n\n const connection = new HostOriginThread<HostExports, RemoteExports>({\n allowedHostOrigins,\n serialization: new FlowThreadSerialization(),\n exports: {\n render: (connection: RemoteConnection) =>\n connectRemoteReceiver(root, connection),\n setPathname: async (pathname) => {\n const relativePathname = toRelativePathname(pathname);\n if (relativePathname !== undefined) {\n onPathnameChanged?.(relativePathname);\n }\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.v6,\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<ConnectHostRenderRootOptions, \"root\">) =>\n (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":";;;;;;;AAqBA,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,EACJ,MACA,mBACA,aACA,gBACA,uBACE;CAEJ,MAAM,aAAa,IAAI,iBAA6C;EAClE;EACA,eAAe,IAAI,wBAAwB;EAC3C,SAAS;GACP,SAAS,eACP,sBAAsB,MAAM,UAAU;GACxC,aAAa,OAAO,aAAa;IAC/B,MAAM,mBAAmB,mBAAmB,QAAQ;IACpD,IAAI,qBAAqB,KAAA,GACvB,oBAAoB,gBAAgB;GAExC;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,UACA,QAA+B;CAC9B,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,51 +1,74 @@
|
|
|
1
|
-
import { ThreadIframe } from "../../../../node_modules/.pnpm/@quilted_threads@3.3.1_patch_hash_fa797cdfb8346ba050fd5d6367ccd451df47806c6ea34421e45e8_e52b779d86bc12aeba80f9d7805f6a15/node_modules/@quilted/threads/build/esm/threads/ThreadIframe.mjs";
|
|
2
1
|
import { FlowThreadSerialization } from "../serialization/FlowThreadSerialization.mjs";
|
|
3
2
|
import { Version } from "./types.mjs";
|
|
3
|
+
import { RemoteError } from "../error.mjs";
|
|
4
|
+
import { RemoteOriginThread } from "./originThreads.mjs";
|
|
4
5
|
import { parseReportedEvent } from "../events/remoteEvents.mjs";
|
|
5
6
|
import { getWithMergedHostConfig } from "../ext-bridge/getWithMergedHostConfig.mjs";
|
|
6
7
|
import { emptyImplementation } from "../ext-bridge/implementation.mjs";
|
|
7
|
-
|
|
8
|
+
// src/connection/connectRemoteIframe.ts
|
|
8
9
|
var normalizeReadyEvent = (event) => {
|
|
9
10
|
if (typeof event === "number") return { version: event };
|
|
10
11
|
return event ?? { version: Version.v1 };
|
|
11
12
|
};
|
|
13
|
+
var guardedHostExports = (exports, isReady, minRemoteVersion) => new Proxy(exports, { get(target, property, receiver) {
|
|
14
|
+
const value = Reflect.get(target, property, receiver);
|
|
15
|
+
if (typeof value !== "function") return value;
|
|
16
|
+
return async (...args) => {
|
|
17
|
+
if (!isReady()) throw new RemoteError(`Remote has not reported the required version ${minRemoteVersion}`);
|
|
18
|
+
return Reflect.apply(value, target, args);
|
|
19
|
+
};
|
|
20
|
+
} });
|
|
12
21
|
var connectRemoteIframe = (opts) => {
|
|
13
|
-
const { connection, iframe, onReady, onLoadingChanged, onError, onNavigationStateChanged, onDeprecation, onEvent, extBridgeImplementation: extBridgeImplementationProp = emptyImplementation, hostConfig } = opts;
|
|
22
|
+
const { connection, iframe, onReady, onLoadingChanged, onError, onNavigationStateChanged, onDeprecation, onEvent, extBridgeImplementation: extBridgeImplementationProp = emptyImplementation, hostConfig, remoteOrigin, minRemoteVersion } = opts;
|
|
14
23
|
const extBridgeImplementation = {
|
|
15
|
-
|
|
24
|
+
getSessionToken: () => extBridgeImplementationProp.getSessionToken(),
|
|
16
25
|
getConfig: getWithMergedHostConfig(extBridgeImplementationProp, hostConfig)
|
|
17
26
|
};
|
|
27
|
+
let isRequiredVersionReady = minRemoteVersion === void 0;
|
|
28
|
+
let hasRendered = false;
|
|
29
|
+
const hostExportsWithoutReady = {
|
|
30
|
+
...extBridgeImplementation,
|
|
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 () => hostConfig
|
|
48
|
+
};
|
|
49
|
+
const exportsWithVersionRequirement = minRemoteVersion === void 0 ? hostExportsWithoutReady : guardedHostExports(hostExportsWithoutReady, () => isRequiredVersionReady, minRemoteVersion);
|
|
18
50
|
const result = {
|
|
19
|
-
thread: new
|
|
51
|
+
thread: new RemoteOriginThread(iframe, {
|
|
52
|
+
remoteOrigin,
|
|
20
53
|
serialization: new FlowThreadSerialization(),
|
|
21
54
|
exports: {
|
|
22
|
-
...
|
|
55
|
+
...exportsWithVersionRequirement,
|
|
23
56
|
setIsReady: async (event) => {
|
|
24
57
|
const readyEvent = normalizeReadyEvent(event);
|
|
58
|
+
if (minRemoteVersion !== void 0 && readyEvent.version < minRemoteVersion) {
|
|
59
|
+
onError?.(`Remote version ${readyEvent.version} is lower than the required version ${minRemoteVersion}`);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
25
62
|
result.version = readyEvent.version;
|
|
63
|
+
isRequiredVersionReady = true;
|
|
26
64
|
onReady?.({
|
|
27
65
|
connection: result,
|
|
28
66
|
remoteReadyEvent: readyEvent
|
|
29
67
|
});
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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;
|
|
68
|
+
if (minRemoteVersion !== void 0 && !hasRendered) {
|
|
69
|
+
hasRendered = true;
|
|
70
|
+
result.thread.imports.render(connection);
|
|
71
|
+
}
|
|
49
72
|
}
|
|
50
73
|
}
|
|
51
74
|
}),
|
|
@@ -58,7 +81,10 @@ var connectRemoteIframe = (opts) => {
|
|
|
58
81
|
},
|
|
59
82
|
version: 0
|
|
60
83
|
};
|
|
61
|
-
|
|
84
|
+
if (minRemoteVersion === void 0) {
|
|
85
|
+
hasRendered = true;
|
|
86
|
+
result.thread.imports.render(connection);
|
|
87
|
+
}
|
|
62
88
|
return result;
|
|
63
89
|
};
|
|
64
90
|
var connectRemoteIframeRef = (opts) => (ref) => {
|
|
@@ -71,7 +97,6 @@ var connectRemoteIframeRef = (opts) => (ref) => {
|
|
|
71
97
|
Object.assign(ref, { __remoteConnection: connection });
|
|
72
98
|
return connection;
|
|
73
99
|
};
|
|
74
|
-
//#endregion
|
|
75
100
|
export { connectRemoteIframe, connectRemoteIframeRef };
|
|
76
101
|
|
|
77
102
|
//# sourceMappingURL=connectRemoteIframe.mjs.map
|
|
@@ -1 +1 @@
|
|
|
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\";\
|
|
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 { RemoteOriginThread } from \"@/connection/originThreads\";\nimport { RemoteError } from \"@/error\";\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\";\n\nexport interface ConnectRemoteIframeOptions {\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 /** Expected origin of the remote iframe. Defaults to the iframe URL origin. */\n remoteOrigin?: string;\n /** Minimum communication version required before rendering the remote app. */\n minRemoteVersion?: Version;\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\nconst guardedHostExports = <Exports extends object>(\n exports: Exports,\n isReady: () => boolean,\n minRemoteVersion: Version,\n): Exports =>\n new Proxy(exports, {\n get(target, property, receiver) {\n const value = Reflect.get(target, property, receiver);\n\n if (typeof value !== \"function\") {\n return value;\n }\n\n return async (...args: unknown[]) => {\n if (!isReady()) {\n throw new RemoteError(\n `Remote has not reported the required version ${minRemoteVersion}`,\n );\n }\n\n return Reflect.apply(value, target, args);\n };\n },\n });\n\nexport const connectRemoteIframe = (\n opts: ConnectRemoteIframeOptions,\n): 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 remoteOrigin,\n minRemoteVersion,\n } = opts;\n\n const extBridgeImplementation = {\n getSessionToken: () => extBridgeImplementationProp.getSessionToken(),\n getConfig: getWithMergedHostConfig(extBridgeImplementationProp, hostConfig),\n };\n\n let isRequiredVersionReady = minRemoteVersion === undefined;\n let hasRendered = false;\n\n const hostExportsWithoutReady = {\n ...extBridgeImplementation,\n setIsLoading: async (isLoading: boolean) => {\n onLoadingChanged?.(isLoading);\n },\n setError: async (error: string) => {\n onError?.(error);\n },\n setNavigationState: async (state: NavigationState) => {\n onNavigationStateChanged?.(state);\n },\n reportDeprecation: async (message: string) => {\n onDeprecation?.(message);\n },\n reportEvent: async (event: ReportedEvent) => {\n const parsed = parseReportedEvent(event);\n if (parsed) {\n onEvent?.(parsed);\n }\n },\n getHostConfig: async () => hostConfig,\n };\n\n const exportsWithVersionRequirement =\n minRemoteVersion === undefined\n ? hostExportsWithoutReady\n : guardedHostExports(\n hostExportsWithoutReady,\n () => isRequiredVersionReady,\n minRemoteVersion,\n );\n\n const result: HostToRemoteConnection = {\n thread: new RemoteOriginThread<RemoteExports, HostExports>(iframe, {\n remoteOrigin,\n serialization: new FlowThreadSerialization(),\n exports: {\n ...exportsWithVersionRequirement,\n setIsReady: async (event) => {\n const readyEvent = normalizeReadyEvent(event);\n\n if (\n minRemoteVersion !== undefined &&\n readyEvent.version < minRemoteVersion\n ) {\n onError?.(\n `Remote version ${readyEvent.version} is lower than the required version ${minRemoteVersion}`,\n );\n return;\n }\n\n result.version = readyEvent.version;\n isRequiredVersionReady = true;\n onReady?.({\n connection: result,\n remoteReadyEvent: readyEvent,\n });\n\n if (minRemoteVersion !== undefined && !hasRendered) {\n hasRendered = true;\n void result.thread.imports.render(connection);\n }\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 if (minRemoteVersion === undefined) {\n hasRendered = true;\n void result.thread.imports.render(connection);\n }\n return result;\n};\n\nexport const connectRemoteIframeRef =\n (opts: Omit<ConnectRemoteIframeOptions, \"iframe\">) =>\n (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":";;;;;;;;AAqCA,IAAM,uBACJ,UACqB;CACrB,IAAI,OAAO,UAAU,UACnB,OAAO,EACL,SAAS,MACX;CAGF,OACE,SAAS,EACP,SAAS,QAAQ,GACnB;AAEJ;AAEA,IAAM,sBACJ,SACA,SACA,qBAEA,IAAI,MAAM,SAAS,EACjB,IAAI,QAAQ,UAAU,UAAU;CAC9B,MAAM,QAAQ,QAAQ,IAAI,QAAQ,UAAU,QAAQ;CAEpD,IAAI,OAAO,UAAU,YACnB,OAAO;CAGT,OAAO,OAAO,GAAG,SAAoB;EACnC,IAAI,CAAC,QAAQ,GACX,MAAM,IAAI,YACR,gDAAgD,kBAClD;EAGF,OAAO,QAAQ,MAAM,OAAO,QAAQ,IAAI;CAC1C;AACF,EACF,CAAC;AAEH,IAAa,uBACX,SAC2B;CAC3B,MAAM,EACJ,YACA,QACA,SACA,kBACA,SACA,0BACA,eACA,SACA,yBAAyB,8BAA8B,qBACvD,YACA,cACA,qBACE;CAEJ,MAAM,0BAA0B;EAC9B,uBAAuB,4BAA4B,gBAAgB;EACnE,WAAW,wBAAwB,6BAA6B,UAAU;CAC5E;CAEA,IAAI,yBAAyB,qBAAqB,KAAA;CAClD,IAAI,cAAc;CAElB,MAAM,0BAA0B;EAC9B,GAAG;EACH,cAAc,OAAO,cAAuB;GAC1C,mBAAmB,SAAS;EAC9B;EACA,UAAU,OAAO,UAAkB;GACjC,UAAU,KAAK;EACjB;EACA,oBAAoB,OAAO,UAA2B;GACpD,2BAA2B,KAAK;EAClC;EACA,mBAAmB,OAAO,YAAoB;GAC5C,gBAAgB,OAAO;EACzB;EACA,aAAa,OAAO,UAAyB;GAC3C,MAAM,SAAS,mBAAmB,KAAK;GACvC,IAAI,QACF,UAAU,MAAM;EAEpB;EACA,eAAe,YAAY;CAC7B;CAEA,MAAM,gCACJ,qBAAqB,KAAA,IACjB,0BACA,mBACE,+BACM,wBACN,gBACF;CAEN,MAAM,SAAiC;EACrC,QAAQ,IAAI,mBAA+C,QAAQ;GACjE;GACA,eAAe,IAAI,wBAAwB;GAC3C,SAAS;IACP,GAAG;IACH,YAAY,OAAO,UAAU;KAC3B,MAAM,aAAa,oBAAoB,KAAK;KAE5C,IACE,qBAAqB,KAAA,KACrB,WAAW,UAAU,kBACrB;MACA,UACE,kBAAkB,WAAW,QAAQ,sCAAsC,kBAC7E;MACA;KACF;KAEA,OAAO,UAAU,WAAW;KAC5B,yBAAyB;KACzB,UAAU;MACR,YAAY;MACZ,kBAAkB;KACpB,CAAC;KAED,IAAI,qBAAqB,KAAA,KAAa,CAAC,aAAa;MAClD,cAAc;MACd,OAAY,OAAO,QAAQ,OAAO,UAAU;KAC9C;IACF;GACF;EACF,CAAC;EACD,qBAAqB,iBAA0B;GAC7C,IAAI,iBAAiB,KAAA,GACnB;GAGF,IAAI,OAAO,WAAW,QAAQ,IAC5B,OAAO,OAAO,QAAQ,YAAY,YAAY;EAElD;EACA,iBAAiB,OAAO,UAAU;GAChC,IAAI,OAAO,WAAW,QAAQ,IAC5B,MAAM,OAAO,OAAO,QAAQ,aAAa,KAAK;EAElD;EACA,SAAS;CACX;CAEA,IAAI,qBAAqB,KAAA,GAAW;EAClC,cAAc;EACd,OAAY,OAAO,QAAQ,OAAO,UAAU;CAC9C;CACA,OAAO;AACT;AAEA,IAAa,0BACV,UACA,QAAkC;CACjC,IAAI,CAAC,KACH;CAGF,IAAI,wBAAwB,KAC1B,OAAO,IAAI;CAGb,MAAM,aAAa,oBAAoB;EACrC,QAAQ;EACR,GAAG;CACL,CAAC;CACD,OAAO,OAAO,KAAK,EAAE,oBAAoB,WAAW,CAAC;CACrD,OAAO;AACT"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// src/connection/hostOriginPatterns.ts
|
|
2
|
+
var WILDCARD_LABEL = "wildcard";
|
|
3
|
+
var WILDCARD_PATTERN = /^([a-zA-Z][a-zA-Z\d+.-]*):\/\/\*\.([^/:?#\\@]+)(?::(\d+))?$/;
|
|
4
|
+
var parseOrigin = (value) => {
|
|
5
|
+
try {
|
|
6
|
+
const url = new URL(value);
|
|
7
|
+
if (url.origin === "null") return;
|
|
8
|
+
return {
|
|
9
|
+
origin: url.origin,
|
|
10
|
+
protocol: url.protocol,
|
|
11
|
+
hostname: url.hostname.toLowerCase(),
|
|
12
|
+
port: url.port
|
|
13
|
+
};
|
|
14
|
+
} catch {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
var parseWildcardPattern = (value) => {
|
|
19
|
+
if (value !== value.trim()) return;
|
|
20
|
+
const match = WILDCARD_PATTERN.exec(value);
|
|
21
|
+
if (!match) return;
|
|
22
|
+
const [, scheme, domain, port] = match;
|
|
23
|
+
if (!scheme || !domain) return;
|
|
24
|
+
try {
|
|
25
|
+
const url = new URL(`${scheme}://${WILDCARD_LABEL}.${domain}${port ? `:${port}` : ""}`);
|
|
26
|
+
const hostnamePrefix = `${WILDCARD_LABEL}.`;
|
|
27
|
+
if (url.origin === "null" || url.username || url.password || !url.hostname.toLowerCase().startsWith(hostnamePrefix)) return;
|
|
28
|
+
const hostname = url.hostname.toLowerCase().slice(hostnamePrefix.length);
|
|
29
|
+
if (!hostname || hostname.includes("*")) return;
|
|
30
|
+
return {
|
|
31
|
+
protocol: url.protocol,
|
|
32
|
+
hostname,
|
|
33
|
+
port: url.port
|
|
34
|
+
};
|
|
35
|
+
} catch {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
var matchesWildcardPattern = (candidate, pattern) => {
|
|
40
|
+
if (candidate.protocol !== pattern.protocol || candidate.port !== pattern.port) return false;
|
|
41
|
+
const hostnameSuffix = `.${pattern.hostname}`;
|
|
42
|
+
if (!candidate.hostname.endsWith(hostnameSuffix)) return false;
|
|
43
|
+
return candidate.hostname.slice(0, -hostnameSuffix.length).split(".").every((label) => label.length > 0);
|
|
44
|
+
};
|
|
45
|
+
/** Normalizes a non-opaque host origin. */
|
|
46
|
+
var normalizeHostOrigin = (value) => parseOrigin(value)?.origin;
|
|
47
|
+
/** Creates a matcher for exact and wildcard allowed host origins. */
|
|
48
|
+
var createAllowedHostOriginMatcher = (allowedHostOrigins) => {
|
|
49
|
+
const exactOrigins = /* @__PURE__ */ new Set();
|
|
50
|
+
const wildcardPatterns = [];
|
|
51
|
+
for (const value of allowedHostOrigins) {
|
|
52
|
+
if (value.includes("*")) {
|
|
53
|
+
const pattern = parseWildcardPattern(value);
|
|
54
|
+
if (pattern) wildcardPatterns.push(pattern);
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
const origin = normalizeHostOrigin(value);
|
|
58
|
+
if (origin) exactOrigins.add(origin);
|
|
59
|
+
}
|
|
60
|
+
return (candidateOrigin) => {
|
|
61
|
+
const candidate = parseOrigin(candidateOrigin);
|
|
62
|
+
if (!candidate) return false;
|
|
63
|
+
if (exactOrigins.has(candidate.origin)) return true;
|
|
64
|
+
return wildcardPatterns.some((pattern) => matchesWildcardPattern(candidate, pattern));
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
export { createAllowedHostOriginMatcher, normalizeHostOrigin };
|
|
68
|
+
|
|
69
|
+
//# sourceMappingURL=hostOriginPatterns.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hostOriginPatterns.mjs","names":[],"sources":["../../../../../../src/connection/hostOriginPatterns.ts"],"sourcesContent":["interface ParsedOrigin {\n origin: string;\n protocol: string;\n hostname: string;\n port: string;\n}\n\ninterface WildcardOriginPattern {\n protocol: string;\n hostname: string;\n port: string;\n}\n\nconst WILDCARD_LABEL = \"wildcard\";\nconst WILDCARD_PATTERN =\n /^([a-zA-Z][a-zA-Z\\d+.-]*):\\/\\/\\*\\.([^/:?#\\\\@]+)(?::(\\d+))?$/;\n\nconst parseOrigin = (value: string): ParsedOrigin | undefined => {\n try {\n const url = new URL(value);\n if (url.origin === \"null\") {\n return undefined;\n }\n\n return {\n origin: url.origin,\n protocol: url.protocol,\n hostname: url.hostname.toLowerCase(),\n port: url.port,\n };\n } catch {\n return undefined;\n }\n};\n\nconst parseWildcardPattern = (\n value: string,\n): WildcardOriginPattern | undefined => {\n if (value !== value.trim()) {\n return undefined;\n }\n\n const match = WILDCARD_PATTERN.exec(value);\n if (!match) {\n return undefined;\n }\n\n const [, scheme, domain, port] = match;\n if (!scheme || !domain) {\n return undefined;\n }\n\n try {\n const url = new URL(\n `${scheme}://${WILDCARD_LABEL}.${domain}${port ? `:${port}` : \"\"}`,\n );\n const hostnamePrefix = `${WILDCARD_LABEL}.`;\n\n if (\n url.origin === \"null\" ||\n url.username ||\n url.password ||\n !url.hostname.toLowerCase().startsWith(hostnamePrefix)\n ) {\n return undefined;\n }\n\n const hostname = url.hostname.toLowerCase().slice(hostnamePrefix.length);\n if (!hostname || hostname.includes(\"*\")) {\n return undefined;\n }\n\n return {\n protocol: url.protocol,\n hostname,\n port: url.port,\n };\n } catch {\n return undefined;\n }\n};\n\nconst matchesWildcardPattern = (\n candidate: ParsedOrigin,\n pattern: WildcardOriginPattern,\n): boolean => {\n if (\n candidate.protocol !== pattern.protocol ||\n candidate.port !== pattern.port\n ) {\n return false;\n }\n\n const hostnameSuffix = `.${pattern.hostname}`;\n if (!candidate.hostname.endsWith(hostnameSuffix)) {\n return false;\n }\n\n const subdomain = candidate.hostname.slice(0, -hostnameSuffix.length);\n return subdomain.split(\".\").every((label) => label.length > 0);\n};\n\n/** Normalizes a non-opaque host origin. */\nexport const normalizeHostOrigin = (value: string): string | undefined =>\n parseOrigin(value)?.origin;\n\n/** Creates a matcher for exact and wildcard allowed host origins. */\nexport const createAllowedHostOriginMatcher = (\n allowedHostOrigins: readonly string[],\n) => {\n const exactOrigins = new Set<string>();\n const wildcardPatterns: WildcardOriginPattern[] = [];\n\n for (const value of allowedHostOrigins) {\n if (value.includes(\"*\")) {\n const pattern = parseWildcardPattern(value);\n if (pattern) {\n wildcardPatterns.push(pattern);\n }\n continue;\n }\n\n const origin = normalizeHostOrigin(value);\n if (origin) {\n exactOrigins.add(origin);\n }\n }\n\n return (candidateOrigin: string): boolean => {\n const candidate = parseOrigin(candidateOrigin);\n if (!candidate) {\n return false;\n }\n\n if (exactOrigins.has(candidate.origin)) {\n return true;\n }\n\n return wildcardPatterns.some((pattern) =>\n matchesWildcardPattern(candidate, pattern),\n );\n };\n};\n"],"mappings":";AAaA,IAAM,iBAAiB;AACvB,IAAM,mBACJ;AAEF,IAAM,eAAe,UAA4C;CAC/D,IAAI;EACF,MAAM,MAAM,IAAI,IAAI,KAAK;EACzB,IAAI,IAAI,WAAW,QACjB;EAGF,OAAO;GACL,QAAQ,IAAI;GACZ,UAAU,IAAI;GACd,UAAU,IAAI,SAAS,YAAY;GACnC,MAAM,IAAI;EACZ;CACF,QAAQ;EACN;CACF;AACF;AAEA,IAAM,wBACJ,UACsC;CACtC,IAAI,UAAU,MAAM,KAAK,GACvB;CAGF,MAAM,QAAQ,iBAAiB,KAAK,KAAK;CACzC,IAAI,CAAC,OACH;CAGF,MAAM,GAAG,QAAQ,QAAQ,QAAQ;CACjC,IAAI,CAAC,UAAU,CAAC,QACd;CAGF,IAAI;EACF,MAAM,MAAM,IAAI,IACd,GAAG,OAAO,KAAK,eAAe,GAAG,SAAS,OAAO,IAAI,SAAS,IAChE;EACA,MAAM,iBAAiB,GAAG,eAAe;EAEzC,IACE,IAAI,WAAW,UACf,IAAI,YACJ,IAAI,YACJ,CAAC,IAAI,SAAS,YAAY,CAAC,CAAC,WAAW,cAAc,GAErD;EAGF,MAAM,WAAW,IAAI,SAAS,YAAY,CAAC,CAAC,MAAM,eAAe,MAAM;EACvE,IAAI,CAAC,YAAY,SAAS,SAAS,GAAG,GACpC;EAGF,OAAO;GACL,UAAU,IAAI;GACd;GACA,MAAM,IAAI;EACZ;CACF,QAAQ;EACN;CACF;AACF;AAEA,IAAM,0BACJ,WACA,YACY;CACZ,IACE,UAAU,aAAa,QAAQ,YAC/B,UAAU,SAAS,QAAQ,MAE3B,OAAO;CAGT,MAAM,iBAAiB,IAAI,QAAQ;CACnC,IAAI,CAAC,UAAU,SAAS,SAAS,cAAc,GAC7C,OAAO;CAIT,OADkB,UAAU,SAAS,MAAM,GAAG,CAAC,eAAe,MACvD,CAAA,CAAU,MAAM,GAAG,CAAC,CAAC,OAAO,UAAU,MAAM,SAAS,CAAC;AAC/D;;AAGA,IAAa,uBAAuB,UAClC,YAAY,KAAK,CAAC,EAAE;;AAGtB,IAAa,kCACX,uBACG;CACH,MAAM,+BAAe,IAAI,IAAY;CACrC,MAAM,mBAA4C,CAAC;CAEnD,KAAK,MAAM,SAAS,oBAAoB;EACtC,IAAI,MAAM,SAAS,GAAG,GAAG;GACvB,MAAM,UAAU,qBAAqB,KAAK;GAC1C,IAAI,SACF,iBAAiB,KAAK,OAAO;GAE/B;EACF;EAEA,MAAM,SAAS,oBAAoB,KAAK;EACxC,IAAI,QACF,aAAa,IAAI,MAAM;CAE3B;CAEA,QAAQ,oBAAqC;EAC3C,MAAM,YAAY,YAAY,eAAe;EAC7C,IAAI,CAAC,WACH,OAAO;EAGT,IAAI,aAAa,IAAI,UAAU,MAAM,GACnC,OAAO;EAGT,OAAO,iBAAiB,MAAM,YAC5B,uBAAuB,WAAW,OAAO,CAC3C;CACF;AACF"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { DEFAULT_ALLOWED_HOST_ORIGINS } from "./allowedHostOrigins.mjs";
|
|
1
2
|
import { Version } from "./types.mjs";
|
|
3
|
+
import { createAllowedHostOriginMatcher } from "./hostOriginPatterns.mjs";
|
|
4
|
+
import { toRelativePathname } from "./toRelativePathname.mjs";
|
|
2
5
|
import { connectHostRenderRoot, connectHostRenderRootRef, connectRemoteReceiver } from "./connectHostRenderRoot.mjs";
|
|
3
6
|
import { connectRemoteIframe, connectRemoteIframeRef } from "./connectRemoteIframe.mjs";
|
|
4
|
-
export { Version, connectHostRenderRoot, connectHostRenderRootRef, connectRemoteIframe, connectRemoteIframeRef, connectRemoteReceiver };
|
|
7
|
+
export { DEFAULT_ALLOWED_HOST_ORIGINS, Version, connectHostRenderRoot, connectHostRenderRootRef, connectRemoteIframe, connectRemoteIframeRef, connectRemoteReceiver, createAllowedHostOriginMatcher, toRelativePathname };
|