@mittwald/flow-remote-core 0.2.0-alpha.16 → 0.2.0-alpha.160
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/js/connection/connectHostRenderRoot.mjs +47 -0
- package/dist/js/connection/connectHostRenderRoot.mjs.map +1 -0
- package/dist/js/connection/connectRemoteIframe.mjs +42 -0
- package/dist/js/connection/connectRemoteIframe.mjs.map +1 -0
- package/dist/js/error.mjs +10 -0
- package/dist/js/error.mjs.map +1 -0
- package/dist/js/events/FlowRemoteEvent.mjs +10 -0
- package/dist/js/events/FlowRemoteEvent.mjs.map +1 -0
- package/dist/js/events/index.mjs +9 -0
- package/dist/js/events/index.mjs.map +1 -0
- package/dist/js/events/serializers.mjs +12 -0
- package/dist/js/events/serializers.mjs.map +1 -0
- package/dist/js/ext-bridge/implementation.mjs +13 -0
- package/dist/js/ext-bridge/implementation.mjs.map +1 -0
- package/dist/js/index-node.mjs +9 -0
- package/dist/js/index-node.mjs.map +1 -0
- package/dist/js/index.mjs +8 -0
- package/dist/js/index.mjs.map +1 -0
- package/dist/js/shim.mjs +16 -0
- package/dist/js/shim.mjs.map +1 -0
- package/dist/types/connection/connectHostRenderRoot.d.ts +4 -0
- package/dist/types/connection/connectHostRenderRoot.d.ts.map +1 -0
- package/dist/types/connection/connectRemoteIframe.d.ts +8 -7
- package/dist/types/connection/connectRemoteIframe.d.ts.map +1 -1
- package/dist/types/connection/index.d.ts +4 -0
- package/dist/types/connection/index.d.ts.map +1 -0
- package/dist/types/connection/types.d.ts +13 -0
- package/dist/types/connection/types.d.ts.map +1 -0
- package/dist/types/error.d.ts +4 -0
- package/dist/types/error.d.ts.map +1 -0
- package/dist/types/events/index.d.ts.map +1 -1
- package/dist/types/events/serializers.d.ts.map +1 -1
- package/dist/types/ext-bridge/implementation.d.ts +3 -0
- package/dist/types/ext-bridge/implementation.d.ts.map +1 -0
- package/dist/types/index-node.d.ts +2 -0
- package/dist/types/index-node.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/shim.d.ts +2 -0
- package/dist/types/shim.d.ts.map +1 -0
- package/package.json +29 -21
- package/dist/index.js +0 -47
- package/dist/polyfill.js +0 -1
- package/dist/types/connection/connectHostIframe.d.ts +0 -3
- package/dist/types/connection/connectHostIframe.d.ts.map +0 -1
- package/dist/types/polyfill.d.ts +0 -1
- package/dist/types/polyfill.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { RemoteError } from '../error.mjs';
|
|
2
|
+
import '@mittwald/remote-dom-core/elements';
|
|
3
|
+
import { ThreadNestedIframe } from '@quilted/threads';
|
|
4
|
+
|
|
5
|
+
const incompatibleParentFrameError = () => new RemoteError("Could not find any compatible parent frame");
|
|
6
|
+
const connectHostRenderRoot = async (div) => {
|
|
7
|
+
const connection = new ThreadNestedIframe({
|
|
8
|
+
exports: {
|
|
9
|
+
render: (connection2) => import('@mittwald/remote-dom-core/elements').then(
|
|
10
|
+
({ RemoteMutationObserver }) => {
|
|
11
|
+
const observer = new RemoteMutationObserver(connection2);
|
|
12
|
+
observer.observe(div);
|
|
13
|
+
}
|
|
14
|
+
)
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
if (connection.parent === window) {
|
|
18
|
+
throw incompatibleParentFrameError();
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
await connection.imports.setIsReady();
|
|
22
|
+
if (typeof mwExtBridge !== "undefined") {
|
|
23
|
+
mwExtBridge.connection = connection.imports;
|
|
24
|
+
await mwExtBridge.readiness.setIsReady();
|
|
25
|
+
}
|
|
26
|
+
return connection;
|
|
27
|
+
} catch (error) {
|
|
28
|
+
if (error instanceof Error && /No '.*' method is exported from this thread/.test(error.message)) {
|
|
29
|
+
throw incompatibleParentFrameError();
|
|
30
|
+
}
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const connectHostRenderRootRef = (ref) => {
|
|
35
|
+
if (ref === null) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if ("__remoteConnection" in ref) {
|
|
39
|
+
return ref["__remoteConnection"];
|
|
40
|
+
}
|
|
41
|
+
const connection = connectHostRenderRoot(ref);
|
|
42
|
+
Object.assign(ref, { __remoteConnection: connection });
|
|
43
|
+
return connection;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export { connectHostRenderRoot, connectHostRenderRootRef };
|
|
47
|
+
//# sourceMappingURL=connectHostRenderRoot.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connectHostRenderRoot.mjs","sources":["../../../src/connection/connectHostRenderRoot.ts"],"sourcesContent":["import type {\n HostExports,\n RemoteExports,\n RemoteToHostConnection,\n} from \"@/connection/types\";\nimport { RemoteError } from \"@/error\";\nimport { type RemoteConnection } from \"@mittwald/remote-dom-core/elements\";\nimport { ThreadNestedIframe } from \"@quilted/threads\";\n\nconst incompatibleParentFrameError = () =>\n new RemoteError(\"Could not find any compatible parent frame\");\n\nexport const connectHostRenderRoot = async (\n div: HTMLDivElement,\n): Promise<RemoteToHostConnection> => {\n const connection = new ThreadNestedIframe<HostExports, RemoteExports>({\n exports: {\n render: (connection: RemoteConnection) =>\n import(\"@mittwald/remote-dom-core/elements\").then(\n ({ RemoteMutationObserver }) => {\n const observer = new RemoteMutationObserver(connection);\n observer.observe(div);\n },\n ),\n },\n });\n\n if (connection.parent === window) {\n throw incompatibleParentFrameError();\n }\n\n try {\n await connection.imports.setIsReady();\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 = (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(ref);\n Object.assign(ref, { __remoteConnection: connection });\n return connection;\n};\n"],"names":["connection"],"mappings":";;;;AASA,MAAM,4BAA+B,GAAA,MACnC,IAAI,WAAA,CAAY,4CAA4C,CAAA;AAEjD,MAAA,qBAAA,GAAwB,OACnC,GACoC,KAAA;AACpC,EAAM,MAAA,UAAA,GAAa,IAAI,kBAA+C,CAAA;AAAA,IACpE,OAAS,EAAA;AAAA,MACP,MAAQ,EAAA,CAACA,WACP,KAAA,OAAO,oCAAoC,CAAE,CAAA,IAAA;AAAA,QAC3C,CAAC,EAAE,sBAAA,EAA6B,KAAA;AAC9B,UAAM,MAAA,QAAA,GAAW,IAAI,sBAAA,CAAuBA,WAAU,CAAA;AACtD,UAAA,QAAA,CAAS,QAAQ,GAAG,CAAA;AAAA;AACtB;AACF;AACJ,GACD,CAAA;AAED,EAAI,IAAA,UAAA,CAAW,WAAW,MAAQ,EAAA;AAChC,IAAA,MAAM,4BAA6B,EAAA;AAAA;AAGrC,EAAI,IAAA;AACF,IAAM,MAAA,UAAA,CAAW,QAAQ,UAAW,EAAA;AAEpC,IAAI,IAAA,OAAO,gBAAgB,WAAa,EAAA;AACtC,MAAA,WAAA,CAAY,aAAa,UAAW,CAAA,OAAA;AACpC,MAAM,MAAA,WAAA,CAAY,UAAU,UAAW,EAAA;AAAA;AAGzC,IAAO,OAAA,UAAA;AAAA,WACA,KAAO,EAAA;AACd,IAAA,IACE,iBAAiB,KACjB,IAAA,6CAAA,CAA8C,IAAK,CAAA,KAAA,CAAM,OAAO,CAChE,EAAA;AACA,MAAA,MAAM,4BAA6B,EAAA;AAAA;AAErC,IAAM,MAAA,KAAA;AAAA;AAEV;AAEa,MAAA,wBAAA,GAA2B,CAAC,GAA+B,KAAA;AACtE,EAAA,IAAI,QAAQ,IAAM,EAAA;AAChB,IAAA;AAAA;AAEF,EAAA,IAAI,wBAAwB,GAAK,EAAA;AAC/B,IAAA,OAAO,IAAI,oBAAoB,CAAA;AAAA;AAGjC,EAAM,MAAA,UAAA,GAAa,sBAAsB,GAAG,CAAA;AAC5C,EAAA,MAAA,CAAO,MAAO,CAAA,GAAA,EAAK,EAAE,kBAAA,EAAoB,YAAY,CAAA;AACrD,EAAO,OAAA,UAAA;AACT;;;;"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { emptyImplementation } from '../ext-bridge/implementation.mjs';
|
|
2
|
+
import { ThreadIframe } from '@quilted/threads';
|
|
3
|
+
|
|
4
|
+
const connectRemoteIframe = (opts) => {
|
|
5
|
+
const {
|
|
6
|
+
connection,
|
|
7
|
+
iframe,
|
|
8
|
+
onReady,
|
|
9
|
+
onError,
|
|
10
|
+
extBridgeImplementation = emptyImplementation
|
|
11
|
+
} = opts;
|
|
12
|
+
const thread = new ThreadIframe(iframe, {
|
|
13
|
+
exports: {
|
|
14
|
+
...extBridgeImplementation,
|
|
15
|
+
setIsReady: async () => {
|
|
16
|
+
onReady?.();
|
|
17
|
+
},
|
|
18
|
+
setError: async (error) => {
|
|
19
|
+
onError?.(error);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
thread.imports.render(connection);
|
|
24
|
+
return thread;
|
|
25
|
+
};
|
|
26
|
+
const connectRemoteIframeRef = (opts) => (ref) => {
|
|
27
|
+
if (!ref) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if ("__remoteConnection" in ref) {
|
|
31
|
+
return ref["__remoteConnection"];
|
|
32
|
+
}
|
|
33
|
+
const connection = connectRemoteIframe({
|
|
34
|
+
iframe: ref,
|
|
35
|
+
...opts
|
|
36
|
+
});
|
|
37
|
+
Object.assign(ref, { __remoteConnection: connection });
|
|
38
|
+
return connection;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export { connectRemoteIframe, connectRemoteIframeRef };
|
|
42
|
+
//# sourceMappingURL=connectRemoteIframe.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connectRemoteIframe.mjs","sources":["../../../src/connection/connectRemoteIframe.ts"],"sourcesContent":["import type {\n HostExports,\n HostToRemoteConnection,\n RemoteExports,\n} from \"@/connection/types\";\nimport { emptyImplementation } from \"@/ext-bridge/implementation\";\nimport type { ExtBridgeConnectionApi } from \"@mittwald/ext-bridge\";\nimport type { RemoteConnection } from \"@mittwald/remote-dom-core/elements\";\nimport { ThreadIframe } from \"@quilted/threads\";\n\ninterface Opts {\n connection: RemoteConnection;\n iframe: HTMLIFrameElement;\n onReady?: () => void;\n onError?: (error: string) => void;\n extBridgeImplementation?: ExtBridgeConnectionApi;\n}\n\nexport const connectRemoteIframe = (opts: Opts): HostToRemoteConnection => {\n const {\n connection,\n iframe,\n onReady,\n onError,\n extBridgeImplementation = emptyImplementation,\n } = opts;\n\n const thread = new ThreadIframe<RemoteExports, HostExports>(iframe, {\n exports: {\n ...extBridgeImplementation,\n setIsReady: async () => {\n onReady?.();\n },\n setError: async (error: string) => {\n onError?.(error);\n },\n },\n });\n\n thread.imports.render(connection);\n return thread;\n};\n\nexport const connectRemoteIframeRef =\n (opts: Omit<Opts, \"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":";;;AAkBa,MAAA,mBAAA,GAAsB,CAAC,IAAuC,KAAA;AACzE,EAAM,MAAA;AAAA,IACJ,UAAA;AAAA,IACA,MAAA;AAAA,IACA,OAAA;AAAA,IACA,OAAA;AAAA,IACA,uBAA0B,GAAA;AAAA,GACxB,GAAA,IAAA;AAEJ,EAAM,MAAA,MAAA,GAAS,IAAI,YAAA,CAAyC,MAAQ,EAAA;AAAA,IAClE,OAAS,EAAA;AAAA,MACP,GAAG,uBAAA;AAAA,MACH,YAAY,YAAY;AACtB,QAAU,OAAA,IAAA;AAAA,OACZ;AAAA,MACA,QAAA,EAAU,OAAO,KAAkB,KAAA;AACjC,QAAA,OAAA,GAAU,KAAK,CAAA;AAAA;AACjB;AACF,GACD,CAAA;AAED,EAAO,MAAA,CAAA,OAAA,CAAQ,OAAO,UAAU,CAAA;AAChC,EAAO,OAAA,MAAA;AACT;AAEO,MAAM,sBACX,GAAA,CAAC,IAA+B,KAAA,CAAC,GAAkC,KAAA;AACjE,EAAA,IAAI,CAAC,GAAK,EAAA;AACR,IAAA;AAAA;AAGF,EAAA,IAAI,wBAAwB,GAAK,EAAA;AAC/B,IAAA,OAAO,IAAI,oBAAoB,CAAA;AAAA;AAGjC,EAAA,MAAM,aAAa,mBAAoB,CAAA;AAAA,IACrC,MAAQ,EAAA,GAAA;AAAA,IACR,GAAG;AAAA,GACJ,CAAA;AACD,EAAA,MAAA,CAAO,MAAO,CAAA,GAAA,EAAK,EAAE,kBAAA,EAAoB,YAAY,CAAA;AACrD,EAAO,OAAA,UAAA;AACT;;;;"}
|
|
@@ -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,KAAM,CAAA;AAAA,EACrC,YAAY,OAAiB,EAAA;AAC3B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,OAAU,GAAA,OAAA;AAAA;AAEnB;AAEA,WAAA,CAAY,UAAU,IAAO,GAAA,aAAA;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FlowRemoteEvent.mjs","sources":["../../../src/events/FlowRemoteEvent.ts"],"sourcesContent":["export class FlowRemoteEvent<T> extends CustomEvent<T> {\n public constructor(type: string, detail: T) {\n super(type, {\n detail,\n });\n }\n}\n"],"names":[],"mappings":"AAAO,MAAM,wBAA2B,WAAe,CAAA;AAAA,EAC9C,WAAA,CAAY,MAAc,MAAW,EAAA;AAC1C,IAAA,KAAA,CAAM,IAAM,EAAA;AAAA,MACV;AAAA,KACD,CAAA;AAAA;AAEL;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { standard } from './serializers.mjs';
|
|
2
|
+
|
|
3
|
+
const mapEventHandler = (eventHandler, eventName, eventSerialization = {}) => (event) => {
|
|
4
|
+
const serialize = eventSerialization[eventName] ?? standard;
|
|
5
|
+
return eventHandler(serialize(event));
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export { mapEventHandler };
|
|
9
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../src/events/index.ts"],"sourcesContent":["import { standard } from \"@/events/serializers\";\n\nexport type EventHandler = (event: unknown) => void;\n\nexport const mapEventHandler =\n (\n eventHandler: EventHandler,\n eventName: string,\n eventSerialization: EventSerializationMap = {},\n ) =>\n (event: unknown) => {\n const serialize = eventSerialization[eventName] ?? standard;\n return eventHandler(serialize(event));\n };\n\nexport type EventSerialization = (event: unknown) => unknown;\nexport type EventSerializationMap = Record<string, EventSerialization>;\n"],"names":[],"mappings":";;AAIa,MAAA,eAAA,GACX,CACE,YACA,EAAA,SAAA,EACA,qBAA4C,EAAC,KAE/C,CAAC,KAAmB,KAAA;AAClB,EAAM,MAAA,SAAA,GAAY,kBAAmB,CAAA,SAAS,CAAK,IAAA,QAAA;AACnD,EAAO,OAAA,YAAA,CAAa,SAAU,CAAA,KAAK,CAAC,CAAA;AACtC;;;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as r from 'remeda';
|
|
2
|
+
import { isObjectType, isString, isNumber, isBoolean } from 'remeda';
|
|
3
|
+
|
|
4
|
+
const isPrimitive = (something) => isString(something) || isNumber(something) || isBoolean(something) || r.isArray(something) && something.every(isPrimitive);
|
|
5
|
+
const primitiveFlat = (event) => r.isArray(event) ? event.map(primitiveFlat) : isObjectType(event) ? r.pickBy(event, isPrimitive) : event;
|
|
6
|
+
const pick = (...props) => (event) => {
|
|
7
|
+
return r.pick(event, props);
|
|
8
|
+
};
|
|
9
|
+
const standard = primitiveFlat;
|
|
10
|
+
|
|
11
|
+
export { pick, primitiveFlat, standard };
|
|
12
|
+
//# sourceMappingURL=serializers.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializers.mjs","sources":["../../../src/events/serializers.ts"],"sourcesContent":["import type { EventSerialization } from \"@/events/index\";\nimport * as r from \"remeda\";\nimport { isBoolean, isNumber, isObjectType, isString } from \"remeda\";\n\nconst isPrimitive = (something: unknown) =>\n isString(something) ||\n isNumber(something) ||\n isBoolean(something) ||\n (r.isArray(something) && something.every(isPrimitive));\n\nexport const primitiveFlat: EventSerialization = (event) =>\n r.isArray(event)\n ? event.map(primitiveFlat)\n : isObjectType(event)\n ? r.pickBy(event as never, isPrimitive)\n : event;\n\nexport const pick =\n (...props: string[]): EventSerialization =>\n (event) => {\n return r.pick(event as never, props);\n };\n\nexport const standard = primitiveFlat;\n"],"names":[],"mappings":";;;AAIA,MAAM,cAAc,CAAC,SAAA,KACnB,SAAS,SAAS,CAAA,IAClB,SAAS,SAAS,CAAA,IAClB,SAAU,CAAA,SAAS,KAClB,CAAE,CAAA,OAAA,CAAQ,SAAS,CAAK,IAAA,SAAA,CAAU,MAAM,WAAW,CAAA;AAE/C,MAAM,gBAAoC,CAAC,KAAA,KAChD,EAAE,OAAQ,CAAA,KAAK,IACX,KAAM,CAAA,GAAA,CAAI,aAAa,CAAA,GACvB,aAAa,KAAK,CAAA,GAChB,EAAE,MAAO,CAAA,KAAA,EAAgB,WAAW,CACpC,GAAA;AAED,MAAM,IACX,GAAA,CAAA,GAAI,KACJ,KAAA,CAAC,KAAU,KAAA;AACT,EAAO,OAAA,CAAA,CAAE,IAAK,CAAA,KAAA,EAAgB,KAAK,CAAA;AACrC;AAEK,MAAM,QAAW,GAAA;;;;"}
|
|
@@ -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,GAAM,GAAA;AACJ,MAAM,MAAA,IAAI,YAAY,+CAA+C,CAAA;AAAA;AACvE;AAEJ;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import './shim.mjs';
|
|
2
|
+
export { RemoteElement, RemoteEvent } from '@mittwald/remote-dom-core/elements';
|
|
3
|
+
export { connectHostRenderRoot, connectHostRenderRootRef } from './connection/connectHostRenderRoot.mjs';
|
|
4
|
+
export { connectRemoteIframe, connectRemoteIframeRef } from './connection/connectRemoteIframe.mjs';
|
|
5
|
+
export { RemoteError } from './error.mjs';
|
|
6
|
+
export { mapEventHandler } from './events/index.mjs';
|
|
7
|
+
export { FlowRemoteEvent } from './events/FlowRemoteEvent.mjs';
|
|
8
|
+
export { pick, primitiveFlat, standard } from './events/serializers.mjs';
|
|
9
|
+
//# sourceMappingURL=index-node.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-node.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { RemoteElement, RemoteEvent } from '@mittwald/remote-dom-core/elements';
|
|
2
|
+
export { connectHostRenderRoot, connectHostRenderRootRef } from './connection/connectHostRenderRoot.mjs';
|
|
3
|
+
export { connectRemoteIframe, connectRemoteIframeRef } from './connection/connectRemoteIframe.mjs';
|
|
4
|
+
export { RemoteError } from './error.mjs';
|
|
5
|
+
export { mapEventHandler } from './events/index.mjs';
|
|
6
|
+
export { FlowRemoteEvent } from './events/FlowRemoteEvent.mjs';
|
|
7
|
+
export { pick, primitiveFlat, standard } from './events/serializers.mjs';
|
|
8
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
package/dist/js/shim.mjs
ADDED
|
@@ -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,WAAc,GAAA,WAAA;AACzB,UAAA,CAAW,cAAiB,GAAA,cAAA;AAC5B,UAAW,CAAA,gBAAA,GAAmB,MAAM,gBAAiB,CAAA;AAAA,EAC5C,WAAc,GAAA;AAAA;AAErB,EACO,UAAa,GAAA;AAAA;AAEpB,EACO,OAAU,GAAA;AAAA;AAEjB,EACO,WAAc,GAAA;AACnB,IAAA,OAAO,EAAC;AAAA;AAEZ,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { RemoteToHostConnection } from './types';
|
|
2
|
+
export declare const connectHostRenderRoot: (div: HTMLDivElement) => Promise<RemoteToHostConnection>;
|
|
3
|
+
export declare const connectHostRenderRootRef: (ref: HTMLDivElement | null) => Promise<RemoteToHostConnection> | undefined;
|
|
4
|
+
//# sourceMappingURL=connectHostRenderRoot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connectHostRenderRoot.d.ts","sourceRoot":"","sources":["../../../src/connection/connectHostRenderRoot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,sBAAsB,EACvB,MAAM,oBAAoB,CAAC;AAQ5B,eAAO,MAAM,qBAAqB,GAChC,KAAK,cAAc,KAClB,OAAO,CAAC,sBAAsB,CAmChC,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAI,KAAK,cAAc,GAAG,IAAI,gDAWlE,CAAC"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { HostToRemoteConnection } from './types';
|
|
2
|
+
import { ExtBridgeConnectionApi } from '@mittwald/ext-bridge';
|
|
3
|
+
import { RemoteConnection } from '@mittwald/remote-dom-core/elements';
|
|
3
4
|
interface Opts {
|
|
4
5
|
connection: RemoteConnection;
|
|
5
6
|
iframe: HTMLIFrameElement;
|
|
7
|
+
onReady?: () => void;
|
|
8
|
+
onError?: (error: string) => void;
|
|
9
|
+
extBridgeImplementation?: ExtBridgeConnectionApi;
|
|
6
10
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
export declare const connectRemoteIframe: (opts: Opts) => ThreadIframe<ThreadIframeTarget, Record<string, never>>;
|
|
11
|
-
export declare const connectRemoteIframeRef: (connection: RemoteConnection) => (ref: HTMLIFrameElement | null) => void;
|
|
11
|
+
export declare const connectRemoteIframe: (opts: Opts) => HostToRemoteConnection;
|
|
12
|
+
export declare const connectRemoteIframeRef: (opts: Omit<Opts, "iframe">) => (ref: HTMLIFrameElement | null) => HostToRemoteConnection | undefined;
|
|
12
13
|
export {};
|
|
13
14
|
//# sourceMappingURL=connectRemoteIframe.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connectRemoteIframe.d.ts","sourceRoot":"","sources":["../../../src/connection/connectRemoteIframe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"connectRemoteIframe.d.ts","sourceRoot":"","sources":["../../../src/connection/connectRemoteIframe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,sBAAsB,EAEvB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAG3E,UAAU,IAAI;IACZ,UAAU,EAAE,gBAAgB,CAAC;IAC7B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,uBAAuB,CAAC,EAAE,sBAAsB,CAAC;CAClD;AAED,eAAO,MAAM,mBAAmB,GAAI,MAAM,IAAI,KAAG,sBAuBhD,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAChC,MAAM,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,KAAK,iBAAiB,GAAG,IAAI,uCAe7D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/connection/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ExtBridgeConnectionApi } from '@mittwald/ext-bridge';
|
|
2
|
+
import { RemoteConnection } from '@mittwald/remote-dom-core';
|
|
3
|
+
import { ThreadIframe, ThreadNestedIframe } from '@quilted/threads';
|
|
4
|
+
export interface HostExports extends ExtBridgeConnectionApi {
|
|
5
|
+
setIsReady: () => Promise<void>;
|
|
6
|
+
setError: (error: string) => Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export interface RemoteExports {
|
|
9
|
+
render: (connection: RemoteConnection) => Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export type RemoteToHostConnection = ThreadNestedIframe<HostExports, RemoteExports>;
|
|
12
|
+
export type HostToRemoteConnection = ThreadIframe<RemoteExports, HostExports>;
|
|
13
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/connection/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEzE,MAAM,WAAW,WAAY,SAAQ,sBAAsB;IACzD,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5C;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,CAAC,UAAU,EAAE,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACzD;AAED,MAAM,MAAM,sBAAsB,GAAG,kBAAkB,CACrD,WAAW,EACX,aAAa,CACd,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,YAAY,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/error.ts"],"names":[],"mappings":"AAAA,qBAAa,WAAY,SAAQ,KAAK;gBACxB,OAAO,EAAE,MAAM;CAI5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/events/index.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;AAEpD,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/events/index.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;AAEpD,eAAO,MAAM,eAAe,GAExB,cAAc,YAAY,EAC1B,WAAW,MAAM,EACjB,qBAAoB,qBAA0B,MAE/C,OAAO,OAAO,SAGd,CAAC;AAEJ,MAAM,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC;AAC7D,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializers.d.ts","sourceRoot":"","sources":["../../../src/events/serializers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"serializers.d.ts","sourceRoot":"","sources":["../../../src/events/serializers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAUzD,eAAO,MAAM,aAAa,EAAE,kBAKf,CAAC;AAEd,eAAO,MAAM,IAAI,GACd,GAAG,OAAO,MAAM,EAAE,KAAG,kBAGrB,CAAC;AAEJ,eAAO,MAAM,QAAQ,oBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"implementation.d.ts","sourceRoot":"","sources":["../../../src/ext-bridge/implementation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAEnE,eAAO,MAAM,mBAAmB,EAO3B,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-node.d.ts","sourceRoot":"","sources":["../../src/index-node.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,CAAC;AAChB,cAAc,SAAS,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from './connection
|
|
1
|
+
export { RemoteElement, RemoteEvent, type RemoteElementConstructor, } from '@mittwald/remote-dom-core/elements';
|
|
2
|
+
export * from './connection';
|
|
3
|
+
export * from './error';
|
|
3
4
|
export * from './events';
|
|
4
5
|
export * from './events/FlowRemoteEvent';
|
|
5
6
|
export * from './events/serializers';
|
|
6
|
-
export { RemoteElement, RemoteEvent, type RemoteElementConstructor, } from '@remote-dom/core/elements';
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,WAAW,EACX,KAAK,wBAAwB,GAC9B,MAAM,oCAAoC,CAAC;AAC5C,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shim.d.ts","sourceRoot":"","sources":["../../src/shim.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mittwald/flow-remote-core",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.160",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Core functionality to setup a remote/host environment",
|
|
6
6
|
"homepage": "https://mittwald.github.io/flow",
|
|
@@ -8,11 +8,8 @@
|
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"types": "./dist/types/index.d.ts",
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
"./polyfill": {
|
|
14
|
-
"types": "./dist/types/polyfill.d.ts",
|
|
15
|
-
"default": "./dist/polyfill.js"
|
|
11
|
+
"node": "./dist/js/index-node.mjs",
|
|
12
|
+
"default": "./dist/js/index.mjs"
|
|
16
13
|
}
|
|
17
14
|
},
|
|
18
15
|
"files": [
|
|
@@ -22,27 +19,38 @@
|
|
|
22
19
|
"node": ">=20.11"
|
|
23
20
|
},
|
|
24
21
|
"scripts": {
|
|
25
|
-
"build": "
|
|
22
|
+
"build": "vite build --config vite.build.config.ts",
|
|
26
23
|
"clean": "rimraf dist",
|
|
27
|
-
"test": "",
|
|
28
|
-
"test:compile": "
|
|
24
|
+
"test": "exit 0",
|
|
25
|
+
"test:compile": "tsc --noEmit"
|
|
29
26
|
},
|
|
30
27
|
"dependencies": {
|
|
31
|
-
"@
|
|
32
|
-
"@remote-dom
|
|
33
|
-
"
|
|
28
|
+
"@lit-labs/ssr-dom-shim": "^1.3.0",
|
|
29
|
+
"@mittwald/remote-dom-core": "1.7.0-mittwald.3",
|
|
30
|
+
"@quilted/threads": "^3.1.3",
|
|
31
|
+
"remeda": "^2.21.1"
|
|
34
32
|
},
|
|
35
33
|
"devDependencies": {
|
|
36
|
-
"@mittwald/
|
|
37
|
-
"@
|
|
38
|
-
"
|
|
39
|
-
"
|
|
34
|
+
"@mittwald/ext-bridge": "0.2.0-alpha.160",
|
|
35
|
+
"@mittwald/typescript-config": "",
|
|
36
|
+
"@types/node": "^22.13.10",
|
|
37
|
+
"nx": "^20.5.0",
|
|
38
|
+
"prettier": "^3.5.3",
|
|
40
39
|
"rimraf": "^6.0.1",
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"vite
|
|
44
|
-
"vite-plugin-
|
|
40
|
+
"rollup-preserve-directives": "^1.1.3",
|
|
41
|
+
"typescript": "^5.8.2",
|
|
42
|
+
"vite": "^6.2.1",
|
|
43
|
+
"vite-plugin-checker": "^0.9.0",
|
|
44
|
+
"vite-plugin-dts": "^4.5.3",
|
|
45
45
|
"vite-plugin-externalize-deps": "^0.9.0"
|
|
46
46
|
},
|
|
47
|
-
"
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"@mittwald/ext-bridge": "*"
|
|
49
|
+
},
|
|
50
|
+
"peerDependenciesMeta": {
|
|
51
|
+
"@mittwald/ext-bridge": {
|
|
52
|
+
"optional": true
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"gitHead": "26ace20488aa0e330d4885b769123bd9905479ae"
|
|
48
56
|
}
|
package/dist/index.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { ThreadIframe as i, ThreadNestedIframe as c } from "@quilted/threads";
|
|
2
|
-
import { RemoteMutationObserver as m } from "@remote-dom/core/elements";
|
|
3
|
-
import { RemoteElement as H, RemoteEvent as T } from "@remote-dom/core/elements";
|
|
4
|
-
import * as n from "remeda";
|
|
5
|
-
import { isObjectType as a, isString as d, isNumber as p, isBoolean as b } from "remeda";
|
|
6
|
-
const f = (e) => {
|
|
7
|
-
const t = new i(e.iframe);
|
|
8
|
-
return t.imports.render(e.connection), t;
|
|
9
|
-
}, h = (e) => (t) => {
|
|
10
|
-
t && !("__remoteConnectionEstablished" in t) && (Object.assign(t, { __remoteConnectionEstablished: !0 }), f({
|
|
11
|
-
iframe: t,
|
|
12
|
-
connection: e
|
|
13
|
-
}));
|
|
14
|
-
}, l = (e) => {
|
|
15
|
-
new c({
|
|
16
|
-
exports: {
|
|
17
|
-
render: (t) => {
|
|
18
|
-
new m(t).observe(e);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
}, C = (e) => {
|
|
23
|
-
e && !("__remoteConnectionEstablished" in e) && (Object.assign(e, { __remoteConnectionEstablished: !0 }), l(e));
|
|
24
|
-
}, u = (e) => d(e) || p(e) || b(e), E = (e) => a(e) ? n.pickBy(e, u) : e, w = (...e) => (t) => n.pick(t, e), v = E, x = (e, t, o = {}) => (r) => {
|
|
25
|
-
const s = o[t] ?? v;
|
|
26
|
-
return e(s(r));
|
|
27
|
-
};
|
|
28
|
-
class O extends CustomEvent {
|
|
29
|
-
constructor(t, o) {
|
|
30
|
-
super(t, {
|
|
31
|
-
detail: o
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
export {
|
|
36
|
-
O as FlowRemoteEvent,
|
|
37
|
-
H as RemoteElement,
|
|
38
|
-
T as RemoteEvent,
|
|
39
|
-
l as connectHostIframe,
|
|
40
|
-
C as connectHostIframeRef,
|
|
41
|
-
f as connectRemoteIframe,
|
|
42
|
-
h as connectRemoteIframeRef,
|
|
43
|
-
x as mapEventHandler,
|
|
44
|
-
w as pick,
|
|
45
|
-
E as primitiveFlat,
|
|
46
|
-
v as standard
|
|
47
|
-
};
|
package/dist/polyfill.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "@remote-dom/core/polyfill";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connectHostIframe.d.ts","sourceRoot":"","sources":["../../../src/connection/connectHostIframe.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,iBAAiB,WAAY,iBAAiB,SAS1D,CAAC;AAEF,eAAO,MAAM,oBAAoB,QAAS,iBAAiB,GAAG,IAAI,SAKjE,CAAC"}
|
package/dist/types/polyfill.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=polyfill.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"polyfill.d.ts","sourceRoot":"","sources":["../../src/polyfill.ts"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC"}
|