@mittwald/flow-remote-react-components 0.2.0-alpha.102 → 0.2.0-alpha.111
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/components/Preview.mjs +4 -9
- package/dist/js/components/Preview.mjs.map +1 -1
- package/dist/js/components/RemoteRootClient.mjs +35 -6
- package/dist/js/components/RemoteRootClient.mjs.map +1 -1
- package/dist/js/lib/stringifyError.mjs +7 -0
- package/dist/js/lib/stringifyError.mjs.map +1 -0
- package/dist/types/components/Preview.d.ts +3 -2
- package/dist/types/components/Preview.d.ts.map +1 -1
- package/dist/types/components/RemoteRootClient.d.ts +2 -0
- package/dist/types/components/RemoteRootClient.d.ts.map +1 -1
- package/dist/types/lib/stringifyError.d.ts +2 -0
- package/dist/types/lib/stringifyError.d.ts.map +1 -0
- package/package.json +14 -8
|
@@ -2,18 +2,13 @@
|
|
|
2
2
|
/* */
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
import React from "react";
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return await import("@mittwald/flow-remote-react-renderer/RemoteRenderer");
|
|
9
|
-
} catch {
|
|
10
|
-
return { default: Fallback };
|
|
11
|
-
}
|
|
12
|
-
});
|
|
5
|
+
const LazyRemoteRenderer = React.lazy(
|
|
6
|
+
() => import("@mittwald/flow-remote-react-renderer/RemoteRenderer")
|
|
7
|
+
);
|
|
13
8
|
const Preview = (props) => {
|
|
14
9
|
const previewUrl = new URL(document.location.href);
|
|
15
10
|
previewUrl.searchParams.set("preview", "");
|
|
16
|
-
return /* @__PURE__ */ jsx(
|
|
11
|
+
return /* @__PURE__ */ jsx(LazyRemoteRenderer, { src: previewUrl.toString(), ...props });
|
|
17
12
|
};
|
|
18
13
|
export {
|
|
19
14
|
Preview,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Preview.mjs","sources":["../../../src/components/Preview.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"Preview.mjs","sources":["../../../src/components/Preview.tsx"],"sourcesContent":["import type { ExtBridgeRemoteApi } from \"@mittwald/ext-bridge\";\nimport React, { type FC } from \"react\";\n\nconst LazyRemoteRenderer = React.lazy(\n () => import(\"@mittwald/flow-remote-react-renderer/RemoteRenderer\"),\n);\n\ninterface Props {\n extBridgeImplementation?: ExtBridgeRemoteApi;\n}\n\nexport const Preview: FC<Props> = (props) => {\n const previewUrl = new URL(document.location.href);\n previewUrl.searchParams.set(\"preview\", \"\");\n return <LazyRemoteRenderer src={previewUrl.toString()} {...props} />;\n};\n\nexport default Preview;\n"],"names":[],"mappings":";;AAGA,MAAM,qBAAqB,MAAM;AAAA,EAC/B,MAAM,OAAO,qDAAqD;AACpE;AAMa,MAAA,UAAqB,CAAC,UAAU;AAC3C,QAAM,aAAa,IAAI,IAAI,SAAS,SAAS,IAAI;AACtC,aAAA,aAAa,IAAI,WAAW,EAAE;AACzC,6BAAQ,oBAAmB,EAAA,KAAK,WAAW,SAAS,GAAI,GAAG,OAAO;AACpE;"}
|
|
@@ -4,20 +4,49 @@
|
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
import * as index from "../auto-generated/index.mjs";
|
|
6
6
|
import { Preview } from "./Preview.mjs";
|
|
7
|
+
import { stringifyError } from "../lib/stringifyError.mjs";
|
|
7
8
|
import { ViewComponentContextProvider } from "@mittwald/flow-react-components/internal";
|
|
8
9
|
import { connectHostRenderRootRef } from "@mittwald/flow-remote-core";
|
|
9
|
-
import "react";
|
|
10
|
+
import { useRef, Suspense } from "react";
|
|
11
|
+
import { ErrorBoundary } from "react-error-boundary";
|
|
10
12
|
const RemoteRootClient = (props) => {
|
|
11
13
|
const { children, showPreview = false, ...previewProps } = props;
|
|
12
14
|
const params = new URLSearchParams(document.location.search);
|
|
13
15
|
const isInPreviewFrame = params.has("preview");
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
+
const connectionRef = useRef(void 0);
|
|
17
|
+
const errorRef = useRef(void 0);
|
|
18
|
+
const handleRenderError = (error) => {
|
|
19
|
+
var _a;
|
|
20
|
+
errorRef.current = error;
|
|
21
|
+
(_a = connectionRef.current) == null ? void 0 : _a.imports.setError(stringifyError(error));
|
|
22
|
+
};
|
|
23
|
+
const root = /* @__PURE__ */ jsx(
|
|
24
|
+
"div",
|
|
16
25
|
{
|
|
17
|
-
|
|
18
|
-
|
|
26
|
+
ref: (div) => {
|
|
27
|
+
connectionRef.current = connectHostRenderRootRef(div);
|
|
28
|
+
if (errorRef.current) {
|
|
29
|
+
handleRenderError(errorRef.current);
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
children: /* @__PURE__ */ jsx(
|
|
33
|
+
ErrorBoundary,
|
|
34
|
+
{
|
|
35
|
+
fallbackRender: ({ error }) => {
|
|
36
|
+
handleRenderError(error);
|
|
37
|
+
return null;
|
|
38
|
+
},
|
|
39
|
+
children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(
|
|
40
|
+
ViewComponentContextProvider,
|
|
41
|
+
{
|
|
42
|
+
components: index,
|
|
43
|
+
children
|
|
44
|
+
}
|
|
45
|
+
) })
|
|
46
|
+
}
|
|
47
|
+
)
|
|
19
48
|
}
|
|
20
|
-
)
|
|
49
|
+
);
|
|
21
50
|
if (isInPreviewFrame || !showPreview) {
|
|
22
51
|
return root;
|
|
23
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RemoteRootClient.mjs","sources":["../../../src/components/RemoteRootClient.tsx"],"sourcesContent":["\"use client\";\nimport * as viewComponents from \"@/auto-generated\";\nimport Preview from \"@/components/Preview\";\nimport { ViewComponentContextProvider } from \"@mittwald/flow-react-components/internal\";\nimport {
|
|
1
|
+
{"version":3,"file":"RemoteRootClient.mjs","sources":["../../../src/components/RemoteRootClient.tsx"],"sourcesContent":["\"use client\";\nimport * as viewComponents from \"@/auto-generated\";\nimport Preview from \"@/components/Preview\";\nimport { stringifyError } from \"@/lib/stringifyError\";\nimport type { ExtBridgeRemoteApi } from \"@mittwald/ext-bridge\";\nimport { ViewComponentContextProvider } from \"@mittwald/flow-react-components/internal\";\nimport {\n connectHostRenderRootRef,\n type RemoteToHostConnection,\n} from \"@mittwald/flow-remote-core\";\nimport { Suspense, useRef, type FC, type PropsWithChildren } from \"react\";\nimport { ErrorBoundary } from \"react-error-boundary\";\n\nexport interface RootClientProps extends PropsWithChildren {\n showPreview?: boolean;\n extBridgeImplementation?: ExtBridgeRemoteApi;\n}\n\nexport const RemoteRootClient: FC<RootClientProps> = (props) => {\n const { children, showPreview = false, ...previewProps } = props;\n\n const params = new URLSearchParams(document.location.search);\n const isInPreviewFrame = params.has(\"preview\");\n const connectionRef = useRef<RemoteToHostConnection>(undefined);\n const errorRef = useRef<unknown>(undefined);\n\n const handleRenderError = (error: unknown) => {\n errorRef.current = error;\n connectionRef.current?.imports.setError(stringifyError(error));\n };\n\n const root = (\n <div\n ref={(div) => {\n connectionRef.current = connectHostRenderRootRef(div);\n if (errorRef.current) {\n handleRenderError(errorRef.current);\n }\n }}\n >\n <ErrorBoundary\n fallbackRender={({ error }) => {\n handleRenderError(error);\n return null;\n }}\n >\n <Suspense>\n <ViewComponentContextProvider\n components={viewComponents as FlowViewComponents}\n >\n {children}\n </ViewComponentContextProvider>\n </Suspense>\n </ErrorBoundary>\n </div>\n );\n\n if (isInPreviewFrame || !showPreview) {\n return root;\n }\n\n return <Preview {...previewProps} />;\n};\n\nexport default RemoteRootClient;\n"],"names":["viewComponents"],"mappings":";;;;;;;;;AAkBa,MAAA,mBAAwC,CAAC,UAAU;AAC9D,QAAM,EAAE,UAAU,cAAc,OAAO,GAAG,aAAiB,IAAA;AAE3D,QAAM,SAAS,IAAI,gBAAgB,SAAS,SAAS,MAAM;AACrD,QAAA,mBAAmB,OAAO,IAAI,SAAS;AACvC,QAAA,gBAAgB,OAA+B,MAAS;AACxD,QAAA,WAAW,OAAgB,MAAS;AAEpC,QAAA,oBAAoB,CAAC,UAAmB;;AAC5C,aAAS,UAAU;AACnB,wBAAc,YAAd,mBAAuB,QAAQ,SAAS,eAAe,KAAK;AAAA,EAC9D;AAEA,QAAM,OACJ;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAK,CAAC,QAAQ;AACE,sBAAA,UAAU,yBAAyB,GAAG;AACpD,YAAI,SAAS,SAAS;AACpB,4BAAkB,SAAS,OAAO;AAAA,QAAA;AAAA,MAEtC;AAAA,MAEA,UAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,gBAAgB,CAAC,EAAE,YAAY;AAC7B,8BAAkB,KAAK;AAChB,mBAAA;AAAA,UACT;AAAA,UAEA,8BAAC,UACC,EAAA,UAAA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,YAAYA;AAAAA,cAEX;AAAA,YAAA;AAAA,UAAA,EAEL,CAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACF;AAAA,EACF;AAGE,MAAA,oBAAoB,CAAC,aAAa;AAC7B,WAAA;AAAA,EAAA;AAGF,SAAA,oBAAC,SAAS,EAAA,GAAG,aAAc,CAAA;AACpC;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stringifyError.mjs","sources":["../../../src/lib/stringifyError.ts"],"sourcesContent":["export const stringifyError = (error: unknown) =>\n typeof error === \"object\" && error instanceof Error\n ? error.message\n : String(error);\n"],"names":[],"mappings":"AAAa,MAAA,iBAAiB,CAAC,UAC7B,OAAO,UAAU,YAAY,iBAAiB,QAC1C,MAAM,UACN,OAAO,KAAK;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ExtBridgeRemoteApi } from '@mittwald/ext-bridge';
|
|
2
|
+
import { FC } from 'react';
|
|
2
3
|
interface Props {
|
|
3
|
-
|
|
4
|
+
extBridgeImplementation?: ExtBridgeRemoteApi;
|
|
4
5
|
}
|
|
5
6
|
export declare const Preview: FC<Props>;
|
|
6
7
|
export default Preview;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Preview.d.ts","sourceRoot":"","sources":["../../../src/components/Preview.tsx"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"Preview.d.ts","sourceRoot":"","sources":["../../../src/components/Preview.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAc,EAAE,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAMvC,UAAU,KAAK;IACb,uBAAuB,CAAC,EAAE,kBAAkB,CAAC;CAC9C;AAED,eAAO,MAAM,OAAO,EAAE,EAAE,CAAC,KAAK,CAI7B,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { ExtBridgeRemoteApi } from '@mittwald/ext-bridge';
|
|
1
2
|
import { FC, PropsWithChildren } from 'react';
|
|
2
3
|
export interface RootClientProps extends PropsWithChildren {
|
|
3
4
|
showPreview?: boolean;
|
|
5
|
+
extBridgeImplementation?: ExtBridgeRemoteApi;
|
|
4
6
|
}
|
|
5
7
|
export declare const RemoteRootClient: FC<RootClientProps>;
|
|
6
8
|
export default RemoteRootClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RemoteRootClient.d.ts","sourceRoot":"","sources":["../../../src/components/RemoteRootClient.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RemoteRootClient.d.ts","sourceRoot":"","sources":["../../../src/components/RemoteRootClient.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAM/D,OAAO,EAAoB,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAG1E,MAAM,WAAW,eAAgB,SAAQ,iBAAiB;IACxD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,uBAAuB,CAAC,EAAE,kBAAkB,CAAC;CAC9C;AAED,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,eAAe,CA4ChD,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stringifyError.d.ts","sourceRoot":"","sources":["../../../src/lib/stringifyError.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,WAG1B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mittwald/flow-remote-react-components",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.111",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "React components that can be used in a remote environment",
|
|
6
6
|
"homepage": "https://mittwald.github.io/flow",
|
|
@@ -33,18 +33,20 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@mfalkenberg/remote-dom-react": "1.2.3",
|
|
36
|
-
"@mittwald/flow-react-components": "0.2.0-alpha.
|
|
37
|
-
"@mittwald/flow-remote-core": "0.2.0-alpha.
|
|
38
|
-
"@mittwald/flow-remote-elements": "0.2.0-alpha.
|
|
39
|
-
"@types/react": "^19
|
|
36
|
+
"@mittwald/flow-react-components": "0.2.0-alpha.111",
|
|
37
|
+
"@mittwald/flow-remote-core": "0.2.0-alpha.111",
|
|
38
|
+
"@mittwald/flow-remote-elements": "0.2.0-alpha.111",
|
|
39
|
+
"@types/react": "^19",
|
|
40
|
+
"react-error-boundary": "^5.0.0"
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|
|
42
|
-
"@mittwald/
|
|
43
|
+
"@mittwald/ext-bridge": "0.2.0-alpha.111",
|
|
44
|
+
"@mittwald/flow-remote-react-renderer": "0.2.0-alpha.111",
|
|
43
45
|
"@mittwald/typescript-config": "",
|
|
44
46
|
"@types/node": "^22.13.10",
|
|
45
47
|
"nx": "^20.5.0",
|
|
46
48
|
"prettier": "^3.5.3",
|
|
47
|
-
"react": "^19
|
|
49
|
+
"react": "^19",
|
|
48
50
|
"react-hook-form": "^7.54.2",
|
|
49
51
|
"rimraf": "^6.0.1",
|
|
50
52
|
"rollup-plugin-auto-named-exports": "1.0.0-beta.3",
|
|
@@ -57,11 +59,15 @@
|
|
|
57
59
|
"vite-plugin-externalize-deps": "^0.9.0"
|
|
58
60
|
},
|
|
59
61
|
"peerDependencies": {
|
|
62
|
+
"@mittwald/ext-bridge": "*",
|
|
60
63
|
"@mittwald/flow-remote-react-renderer": "*",
|
|
61
64
|
"react": "^19",
|
|
62
65
|
"react-hook-form": "*"
|
|
63
66
|
},
|
|
64
67
|
"peerDependenciesMeta": {
|
|
68
|
+
"@mittwald/ext-bridge": {
|
|
69
|
+
"optional": true
|
|
70
|
+
},
|
|
65
71
|
"@mittwald/flow-remote-react-renderer": {
|
|
66
72
|
"optional": true
|
|
67
73
|
},
|
|
@@ -69,5 +75,5 @@
|
|
|
69
75
|
"optional": true
|
|
70
76
|
}
|
|
71
77
|
},
|
|
72
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "66ecd717fb7169d9c5985ffc0e995198a988f0a4"
|
|
73
79
|
}
|