@mittwald/flow-remote-react-components 1.5.63 → 1.5.65

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/USAGE.md CHANGED
@@ -47,6 +47,13 @@ initializes the extension bridge:
47
47
  import { RemoteRoot } from "@mittwald/flow-remote-react-components/RemoteRoot";
48
48
  ```
49
49
 
50
+ `RemoteRoot` talks only to a host on an mStudio origin or on your app's own
51
+ origin. To develop against another host, add its origin with
52
+ `allowedHostOrigins={["http://localhost:3000"]}`. `onHostPathnameChanged`
53
+ receives relative app paths only. Your frontend must also send a
54
+ `frame-ancestors` CSP header — see the
55
+ [ext-bridge USAGE.md](https://github.com/mittwald/flow/blob/main/packages/ext-bridge/USAGE.md).
56
+
50
57
  The full explainer:
51
58
  <https://github.com/mittwald/flow/blob/main/docs/remote-ui.md>.
52
59
 
@@ -11,7 +11,7 @@ import { useWatchPathname } from "./hooks/useWatchPathname.mjs";
11
11
  import { stringifyError } from "./lib/stringifyError.mjs";
12
12
  import { ComponentUsageProvider, ViewComponentContextProvider, markViewComponents } from "@mittwald/flow-react-components/internal";
13
13
  import { Suspense, useCallback, useLayoutEffect, useRef, useState, useTransition } from "react";
14
- import { connectHostRenderRootRef, connectRemoteReceiver } from "@mittwald/flow-remote-core";
14
+ import { connectHostRenderRootRef, connectRemoteReceiver, toRelativePathname } from "@mittwald/flow-remote-core";
15
15
  import { DeprecationWarningProvider, IntlProvider, useLanguage } from "@mittwald/flow-react-components/flr-universal";
16
16
  import { jsx } from "react/jsx-runtime";
17
17
  import { ErrorBoundary } from "react-error-boundary";
@@ -31,7 +31,7 @@ var hiddenStyle = {
31
31
  marginLeft: "-9999px"
32
32
  };
33
33
  var RemoteRoot = (props) => {
34
- const { children, onHostPathnameChanged, isLoading, __remoteReceiver: remoteReceiver } = props;
34
+ const { children, onHostPathnameChanged, isLoading, allowedHostOrigins, __remoteReceiver: remoteReceiver } = props;
35
35
  if (remoteReceiver) return /* @__PURE__ */ jsx(RemoteReceiverRoot, {
36
36
  remoteReceiver,
37
37
  children
@@ -39,6 +39,7 @@ var RemoteRoot = (props) => {
39
39
  return /* @__PURE__ */ jsx(RemoteConnectionRoot, {
40
40
  onHostPathnameChanged,
41
41
  isLoading,
42
+ allowedHostOrigins,
42
43
  children
43
44
  });
44
45
  };
@@ -53,7 +54,7 @@ var RemoteReceiverRoot = ({ remoteReceiver, children }) => /* @__PURE__ */ jsx("
53
54
  })
54
55
  });
55
56
  var RemoteConnectionRoot = (props) => {
56
- const { children, onHostPathnameChanged, isLoading: isLoadingFromProps } = props;
57
+ const { children, onHostPathnameChanged, isLoading: isLoadingFromProps, allowedHostOrigins } = props;
57
58
  const connectionRef = useRef(void 0);
58
59
  const hostConfigRef = useRef(void 0);
59
60
  const isConnectionInitialized = useRef(false);
@@ -93,9 +94,13 @@ var RemoteConnectionRoot = (props) => {
93
94
  if (connectionError) throw connectionError;
94
95
  if (hostError) throw new Error(hostError);
95
96
  const connect = connectHostRenderRootRef({
96
- onPathnameChanged: (pathname) => startPathnameChangedTransition(() => onHostPathnameChanged?.(pathname)),
97
+ onPathnameChanged: (pathname) => {
98
+ const relativePathname = toRelativePathname(pathname);
99
+ if (relativePathname !== void 0) startPathnameChangedTransition(() => onHostPathnameChanged?.(relativePathname));
100
+ },
97
101
  onHostError: (error) => setHostError(error),
98
- packageVersion
102
+ packageVersion,
103
+ allowedHostOrigins
99
104
  });
100
105
  /** Is wrapped in Div to resolve render awaiter in <RemoteRenderer /> */
101
106
  const loadingFallback = /* @__PURE__ */ jsx(LoadingFallbackDiv, { children: /* @__PURE__ */ jsx(LoadingFallbackTrigger, {}) });
@@ -1 +1 @@
1
- {"version":3,"file":"RemoteRoot.mjs","names":["remoteComponents","customViewComponents","remoteComponents.Div"],"sources":["../../src/components/RemoteRoot.tsx"],"sourcesContent":["\"use client\";\nimport * as remoteComponents from \"@/auto-generated\";\nimport * as customViewComponents from \"@/views\";\nimport { useWatchPathname } from \"@/hooks/useWatchPathname\";\nimport { stringifyError } from \"@/lib/stringifyError\";\nimport { packageVersion } from \"@/version\";\nimport {\n ComponentUsageProvider,\n markViewComponents,\n ViewComponentContextProvider,\n type ComponentUsageHandler,\n} from \"@mittwald/flow-react-components/internal\";\nimport {\n connectHostRenderRootRef,\n connectRemoteReceiver,\n type RemoteReceiver,\n type RemoteToHostConnection,\n} from \"@mittwald/flow-remote-core\";\nimport {\n Suspense,\n useCallback,\n useLayoutEffect,\n useRef,\n useState,\n useTransition,\n type CSSProperties,\n type FC,\n type PropsWithChildren,\n} from \"react\";\nimport { ErrorBoundary, type FallbackProps } from \"react-error-boundary\";\nimport { RemoteContextProvider } from \"@/components/RemoteContextProvider\";\nimport { LoadingFallbackTrigger } from \"@/components/LoadingFallbackTrigger\";\nimport {\n DeprecationWarningProvider,\n type DeprecationWarningHandler,\n IntlProvider,\n useLanguage,\n} from \"@mittwald/flow-react-components/flr-universal\";\nimport type { HostConfig } from \"@mittwald/ext-bridge\";\nimport { initExtBridge } from \"@mittwald/ext-bridge/browser\";\n\nconst viewComponents = {\n ...remoteComponents,\n ...customViewComponents,\n} as FlowViewComponents;\n\nconst { Div: LoadingFallbackDiv } = markViewComponents({\n Div: remoteComponents.Div,\n});\n\nexport interface RemoteRootProps extends PropsWithChildren {\n onHostPathnameChanged?: (pathname: string) => void;\n isLoading?: boolean;\n /** Internal use only */\n __remoteReceiver?: RemoteReceiver;\n}\n\nconst hiddenStyle: CSSProperties = {\n visibility: \"hidden\",\n height: 0,\n width: 0,\n border: \"none\",\n position: \"absolute\",\n marginLeft: \"-9999px\",\n};\n\nexport const RemoteRoot: FC<RemoteRootProps> = (props) => {\n const {\n children,\n onHostPathnameChanged,\n isLoading,\n __remoteReceiver: remoteReceiver,\n } = props;\n\n // The two branches use disjoint sets of hooks, so they live in dedicated\n // components. This keeps each component's hook order stable (Rules of Hooks)\n // while preserving the exact rendering of both paths.\n if (remoteReceiver) {\n return (\n <RemoteReceiverRoot remoteReceiver={remoteReceiver}>\n {children}\n </RemoteReceiverRoot>\n );\n }\n\n return (\n <RemoteConnectionRoot\n onHostPathnameChanged={onHostPathnameChanged}\n isLoading={isLoading}\n >\n {children}\n </RemoteConnectionRoot>\n );\n};\n\ninterface RemoteReceiverRootProps extends PropsWithChildren {\n remoteReceiver: RemoteReceiver;\n}\n\nconst RemoteReceiverRoot: FC<RemoteReceiverRootProps> = ({\n remoteReceiver,\n children,\n}) => (\n <div\n style={hiddenStyle}\n ref={(div) => {\n if (div) {\n connectRemoteReceiver(div, remoteReceiver.connection);\n }\n }}\n >\n <ViewComponentContextProvider components={viewComponents}>\n {children}\n </ViewComponentContextProvider>\n </div>\n);\n\ntype RemoteConnectionRootProps = Omit<RemoteRootProps, \"__remoteReceiver\">;\n\nconst RemoteConnectionRoot: FC<RemoteConnectionRootProps> = (props) => {\n const {\n children,\n onHostPathnameChanged,\n isLoading: isLoadingFromProps,\n } = props;\n\n const connectionRef = useRef<RemoteToHostConnection>(undefined);\n const hostConfigRef = useRef<HostConfig | undefined>(undefined);\n const isConnectionInitialized = useRef(false);\n const [connectionError, setConnectionError] = useState(null);\n const [hostError, setHostError] = useState<string | undefined>(undefined);\n const [isConnected, setIsConnected] = useState(false);\n\n const fallbackLanguage = useLanguage();\n const language =\n hostConfigRef.current?.language === undefined ||\n hostConfigRef.current?.language?.trim() === \"\"\n ? fallbackLanguage\n : hostConfigRef.current.language;\n\n const [pathnameChangedPending, startPathnameChangedTransition] =\n useTransition();\n\n const renderErrorRef = useRef<unknown>(undefined);\n\n const handleRenderError = (error: unknown) => {\n renderErrorRef.current = error;\n connectionRef.current?.imports.setError(stringifyError(error));\n };\n\n const forwardDeprecationWarning: DeprecationWarningHandler = (message) => {\n void connectionRef.current?.imports\n .reportDeprecation?.(message)\n ?.catch(() => {\n // ignore: host does not support deprecation reporting\n });\n };\n\n const reportedComponentUsage = useRef(new Set<string>());\n\n const forwardComponentUsage: ComponentUsageHandler = ({ component }) => {\n if (reportedComponentUsage.current.has(component)) {\n return;\n }\n reportedComponentUsage.current.add(component);\n\n void connectionRef.current?.imports\n .reportEvent?.({\n event: \"ComponentRendered\",\n data: { component },\n })\n ?.catch(() => {\n // ignore: host does not support event reporting\n });\n };\n\n const setIsLoadingFromProps = useCallback(() => {\n if (isLoadingFromProps !== undefined) {\n connectionRef.current?.imports.setIsLoading(isLoadingFromProps);\n }\n }, [isLoadingFromProps]);\n\n useLayoutEffect(() => {\n setIsLoadingFromProps();\n }, [setIsLoadingFromProps]);\n\n useWatchPathname((pathname) =>\n connectionRef.current?.imports.setNavigationState({\n pathname,\n isPending: pathnameChangedPending,\n }),\n );\n\n if (connectionError) {\n throw connectionError;\n }\n\n if (hostError) {\n throw new Error(hostError);\n }\n\n const connect = connectHostRenderRootRef({\n onPathnameChanged: (pathname) =>\n startPathnameChangedTransition(() => onHostPathnameChanged?.(pathname)),\n onHostError: (error) => setHostError(error),\n packageVersion,\n });\n\n /** Is wrapped in Div to resolve render awaiter in <RemoteRenderer /> */\n const loadingFallback = (\n <LoadingFallbackDiv>\n <LoadingFallbackTrigger />\n </LoadingFallbackDiv>\n );\n\n const connectDiv = (div: HTMLDivElement) => {\n if (isConnectionInitialized.current) {\n return;\n }\n initExtBridge();\n isConnectionInitialized.current = true;\n connect(div)\n ?.then((connection) => {\n connectionRef.current = connection;\n setIsLoadingFromProps();\n return connection.imports.getHostConfig();\n })\n .then((hostConfig) => {\n hostConfigRef.current = hostConfig;\n setIsConnected(true);\n })\n .catch((error) => {\n setConnectionError(error);\n });\n\n if (renderErrorRef.current) {\n handleRenderError(renderErrorRef.current);\n }\n };\n\n const ErrorFallbackComponent: FC<FallbackProps> = (props) => {\n handleRenderError(props.error);\n return null;\n };\n\n return (\n <div ref={connectDiv}>\n <ErrorBoundary FallbackComponent={ErrorFallbackComponent}>\n {isConnected && connectionRef.current && (\n <RemoteContextProvider\n value={{\n connection: connectionRef.current,\n }}\n >\n <IntlProvider locale={language}>\n <DeprecationWarningProvider onWarning={forwardDeprecationWarning}>\n <ComponentUsageProvider onUsage={forwardComponentUsage}>\n <Suspense fallback={loadingFallback}>\n <ViewComponentContextProvider components={viewComponents}>\n {children}\n </ViewComponentContextProvider>\n </Suspense>\n </ComponentUsageProvider>\n </DeprecationWarningProvider>\n </IntlProvider>\n </RemoteContextProvider>\n )}\n </ErrorBoundary>\n </div>\n );\n};\n\nexport default RemoteRoot;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAyCA,IAAM,iBAAiB;CACrB,GAAGA;CACH,GAAGC;AACL;AAEA,IAAM,EAAE,KAAK,uBAAuB,mBAAmB,EAChDC,IACP,CAAC;AASD,IAAM,cAA6B;CACjC,YAAY;CACZ,QAAQ;CACR,OAAO;CACP,QAAQ;CACR,UAAU;CACV,YAAY;AACd;AAEA,IAAa,cAAmC,UAAU;CACxD,MAAM,EACJ,UACA,uBACA,WACA,kBAAkB,mBAChB;CAKJ,IAAI,gBACF,OACE,oBAAC,oBAAD;EAAoC;EACjC;CACiB,CAAA;CAIxB,OACE,oBAAC,sBAAD;EACyB;EACZ;EAEV;CACmB,CAAA;AAE1B;AAMA,IAAM,sBAAmD,EACvD,gBACA,eAEA,oBAAC,OAAD;CACE,OAAO;CACP,MAAM,QAAQ;EACZ,IAAI,KACF,sBAAsB,KAAK,eAAe,UAAU;CAExD;CAEA,UAAA,oBAAC,8BAAD;EAA8B,YAAY;EACvC;CAC2B,CAAA;AAC3B,CAAA;AAKP,IAAM,wBAAuD,UAAU;CACrE,MAAM,EACJ,UACA,uBACA,WAAW,uBACT;CAEJ,MAAM,gBAAgB,OAA+B,KAAA,CAAS;CAC9D,MAAM,gBAAgB,OAA+B,KAAA,CAAS;CAC9D,MAAM,0BAA0B,OAAO,KAAK;CAC5C,MAAM,CAAC,iBAAiB,sBAAsB,SAAS,IAAI;CAC3D,MAAM,CAAC,WAAW,gBAAgB,SAA6B,KAAA,CAAS;CACxE,MAAM,CAAC,aAAa,kBAAkB,SAAS,KAAK;CAEpD,MAAM,mBAAmB,YAAY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AAc,QAAwB;EAC1C,IAAI,wBAAwB,SAC1B;EAEF,cAAc;EACd,wBAAwB,UAAU;EAClC,QAAQ,GAAG,CAAC,EACR,MAAM,eAAe;GACrB,cAAc,UAAU;GACxB,sBAAsB;GACtB,OAAO,WAAW,QAAQ,cAAc;EAC1C,CAAC,CAAC,CACD,MAAM,eAAe;GACpB,cAAc,UAAU;GACxB,eAAe,IAAI;EACrB,CAAC,CAAC,CACD,OAAO,UAAU;GAChB,mBAAmB,KAAK;EAC1B,CAAC;EAEH,IAAI,eAAe,SACjB,kBAAkB,eAAe,OAAO;CAE5C;CAEA,MAAM,0BAA6C,UAAU;EAC3D,kBAAkB,MAAM,KAAK;EAC7B,OAAO;CACT;CAEA,OACE,oBAAC,OAAD;EAAK,KAAK;EACR,UAAA,oBAAC,eAAD;GAAe,mBAAmB;GAC/B,UAAA,eAAe,cAAc,WAC5B,oBAAC,uBAAD;IACE,OAAO,EACL,YAAY,cAAc,QAC5B;IAEA,UAAA,oBAAC,cAAD;KAAc,QAAQ;KACpB,UAAA,oBAAC,4BAAD;MAA4B,WAAW;MACrC,UAAA,oBAAC,wBAAD;OAAwB,SAAS;OAC/B,UAAA,oBAAC,UAAD;QAAU,UAAU;QAClB,UAAA,oBAAC,8BAAD;SAA8B,YAAY;SACvC;QAC2B,CAAA;OACtB,CAAA;MACY,CAAA;KACE,CAAA;IAChB,CAAA;GACO,CAAA;EAEZ,CAAA;CACZ,CAAA;AAET"}
1
+ {"version":3,"file":"RemoteRoot.mjs","names":["remoteComponents","customViewComponents","remoteComponents.Div"],"sources":["../../src/components/RemoteRoot.tsx"],"sourcesContent":["\"use client\";\nimport * as remoteComponents from \"@/auto-generated\";\nimport * as customViewComponents from \"@/views\";\nimport { useWatchPathname } from \"@/hooks/useWatchPathname\";\nimport { stringifyError } from \"@/lib/stringifyError\";\nimport { packageVersion } from \"@/version\";\nimport {\n ComponentUsageProvider,\n markViewComponents,\n ViewComponentContextProvider,\n type ComponentUsageHandler,\n} from \"@mittwald/flow-react-components/internal\";\nimport {\n connectHostRenderRootRef,\n connectRemoteReceiver,\n toRelativePathname,\n type RemoteReceiver,\n type RemoteToHostConnection,\n} from \"@mittwald/flow-remote-core\";\nimport {\n Suspense,\n useCallback,\n useLayoutEffect,\n useRef,\n useState,\n useTransition,\n type CSSProperties,\n type FC,\n type PropsWithChildren,\n} from \"react\";\nimport { ErrorBoundary, type FallbackProps } from \"react-error-boundary\";\nimport { RemoteContextProvider } from \"@/components/RemoteContextProvider\";\nimport { LoadingFallbackTrigger } from \"@/components/LoadingFallbackTrigger\";\nimport {\n DeprecationWarningProvider,\n type DeprecationWarningHandler,\n IntlProvider,\n useLanguage,\n} from \"@mittwald/flow-react-components/flr-universal\";\nimport type { HostConfig } from \"@mittwald/ext-bridge\";\nimport { initExtBridge } from \"@mittwald/ext-bridge/browser\";\n\nconst viewComponents = {\n ...remoteComponents,\n ...customViewComponents,\n} as FlowViewComponents;\n\nconst { Div: LoadingFallbackDiv } = markViewComponents({\n Div: remoteComponents.Div,\n});\n\nexport interface RemoteRootProps extends PropsWithChildren {\n onHostPathnameChanged?: (pathname: string) => void;\n isLoading?: boolean;\n /**\n * Additional host origins the remote app accepts, e.g. for local development.\n * The mStudio origins and the app's own origin are always allowed.\n */\n allowedHostOrigins?: string[];\n /** Internal use only */\n __remoteReceiver?: RemoteReceiver;\n}\n\nconst hiddenStyle: CSSProperties = {\n visibility: \"hidden\",\n height: 0,\n width: 0,\n border: \"none\",\n position: \"absolute\",\n marginLeft: \"-9999px\",\n};\n\nexport const RemoteRoot: FC<RemoteRootProps> = (props) => {\n const {\n children,\n onHostPathnameChanged,\n isLoading,\n allowedHostOrigins,\n __remoteReceiver: remoteReceiver,\n } = props;\n\n // The two branches use disjoint sets of hooks, so they live in dedicated\n // components. This keeps each component's hook order stable (Rules of Hooks)\n // while preserving the exact rendering of both paths.\n if (remoteReceiver) {\n return (\n <RemoteReceiverRoot remoteReceiver={remoteReceiver}>\n {children}\n </RemoteReceiverRoot>\n );\n }\n\n return (\n <RemoteConnectionRoot\n onHostPathnameChanged={onHostPathnameChanged}\n isLoading={isLoading}\n allowedHostOrigins={allowedHostOrigins}\n >\n {children}\n </RemoteConnectionRoot>\n );\n};\n\ninterface RemoteReceiverRootProps extends PropsWithChildren {\n remoteReceiver: RemoteReceiver;\n}\n\nconst RemoteReceiverRoot: FC<RemoteReceiverRootProps> = ({\n remoteReceiver,\n children,\n}) => (\n <div\n style={hiddenStyle}\n ref={(div) => {\n if (div) {\n connectRemoteReceiver(div, remoteReceiver.connection);\n }\n }}\n >\n <ViewComponentContextProvider components={viewComponents}>\n {children}\n </ViewComponentContextProvider>\n </div>\n);\n\ntype RemoteConnectionRootProps = Omit<RemoteRootProps, \"__remoteReceiver\">;\n\nconst RemoteConnectionRoot: FC<RemoteConnectionRootProps> = (props) => {\n const {\n children,\n onHostPathnameChanged,\n isLoading: isLoadingFromProps,\n allowedHostOrigins,\n } = props;\n\n const connectionRef = useRef<RemoteToHostConnection>(undefined);\n const hostConfigRef = useRef<HostConfig | undefined>(undefined);\n const isConnectionInitialized = useRef(false);\n const [connectionError, setConnectionError] = useState(null);\n const [hostError, setHostError] = useState<string | undefined>(undefined);\n const [isConnected, setIsConnected] = useState(false);\n\n const fallbackLanguage = useLanguage();\n const language =\n hostConfigRef.current?.language === undefined ||\n hostConfigRef.current?.language?.trim() === \"\"\n ? fallbackLanguage\n : hostConfigRef.current.language;\n\n const [pathnameChangedPending, startPathnameChangedTransition] =\n useTransition();\n\n const renderErrorRef = useRef<unknown>(undefined);\n\n const handleRenderError = (error: unknown) => {\n renderErrorRef.current = error;\n connectionRef.current?.imports.setError(stringifyError(error));\n };\n\n const forwardDeprecationWarning: DeprecationWarningHandler = (message) => {\n void connectionRef.current?.imports\n .reportDeprecation?.(message)\n ?.catch(() => {\n // ignore: host does not support deprecation reporting\n });\n };\n\n const reportedComponentUsage = useRef(new Set<string>());\n\n const forwardComponentUsage: ComponentUsageHandler = ({ component }) => {\n if (reportedComponentUsage.current.has(component)) {\n return;\n }\n reportedComponentUsage.current.add(component);\n\n void connectionRef.current?.imports\n .reportEvent?.({\n event: \"ComponentRendered\",\n data: { component },\n })\n ?.catch(() => {\n // ignore: host does not support event reporting\n });\n };\n\n const setIsLoadingFromProps = useCallback(() => {\n if (isLoadingFromProps !== undefined) {\n connectionRef.current?.imports.setIsLoading(isLoadingFromProps);\n }\n }, [isLoadingFromProps]);\n\n useLayoutEffect(() => {\n setIsLoadingFromProps();\n }, [setIsLoadingFromProps]);\n\n useWatchPathname((pathname) =>\n connectionRef.current?.imports.setNavigationState({\n pathname,\n isPending: pathnameChangedPending,\n }),\n );\n\n if (connectionError) {\n throw connectionError;\n }\n\n if (hostError) {\n throw new Error(hostError);\n }\n\n const connect = connectHostRenderRootRef({\n onPathnameChanged: (pathname) => {\n const relativePathname = toRelativePathname(pathname);\n if (relativePathname !== undefined) {\n startPathnameChangedTransition(() =>\n onHostPathnameChanged?.(relativePathname),\n );\n }\n },\n onHostError: (error) => setHostError(error),\n packageVersion,\n allowedHostOrigins,\n });\n\n /** Is wrapped in Div to resolve render awaiter in <RemoteRenderer /> */\n const loadingFallback = (\n <LoadingFallbackDiv>\n <LoadingFallbackTrigger />\n </LoadingFallbackDiv>\n );\n\n const connectDiv = (div: HTMLDivElement) => {\n if (isConnectionInitialized.current) {\n return;\n }\n initExtBridge();\n isConnectionInitialized.current = true;\n connect(div)\n ?.then((connection) => {\n connectionRef.current = connection;\n setIsLoadingFromProps();\n return connection.imports.getHostConfig();\n })\n .then((hostConfig) => {\n hostConfigRef.current = hostConfig;\n setIsConnected(true);\n })\n .catch((error) => {\n setConnectionError(error);\n });\n\n if (renderErrorRef.current) {\n handleRenderError(renderErrorRef.current);\n }\n };\n\n const ErrorFallbackComponent: FC<FallbackProps> = (props) => {\n handleRenderError(props.error);\n return null;\n };\n\n return (\n <div ref={connectDiv}>\n <ErrorBoundary FallbackComponent={ErrorFallbackComponent}>\n {isConnected && connectionRef.current && (\n <RemoteContextProvider\n value={{\n connection: connectionRef.current,\n }}\n >\n <IntlProvider locale={language}>\n <DeprecationWarningProvider onWarning={forwardDeprecationWarning}>\n <ComponentUsageProvider onUsage={forwardComponentUsage}>\n <Suspense fallback={loadingFallback}>\n <ViewComponentContextProvider components={viewComponents}>\n {children}\n </ViewComponentContextProvider>\n </Suspense>\n </ComponentUsageProvider>\n </DeprecationWarningProvider>\n </IntlProvider>\n </RemoteContextProvider>\n )}\n </ErrorBoundary>\n </div>\n );\n};\n\nexport default RemoteRoot;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA0CA,IAAM,iBAAiB;CACrB,GAAGA;CACH,GAAGC;AACL;AAEA,IAAM,EAAE,KAAK,uBAAuB,mBAAmB,EAChDC,IACP,CAAC;AAcD,IAAM,cAA6B;CACjC,YAAY;CACZ,QAAQ;CACR,OAAO;CACP,QAAQ;CACR,UAAU;CACV,YAAY;AACd;AAEA,IAAa,cAAmC,UAAU;CACxD,MAAM,EACJ,UACA,uBACA,WACA,oBACA,kBAAkB,mBAChB;CAKJ,IAAI,gBACF,OACE,oBAAC,oBAAD;EAAoC;EACjC;CACiB,CAAA;CAIxB,OACE,oBAAC,sBAAD;EACyB;EACZ;EACS;EAEnB;CACmB,CAAA;AAE1B;AAMA,IAAM,sBAAmD,EACvD,gBACA,eAEA,oBAAC,OAAD;CACE,OAAO;CACP,MAAM,QAAQ;EACZ,IAAI,KACF,sBAAsB,KAAK,eAAe,UAAU;CAExD;CAEA,UAAA,oBAAC,8BAAD;EAA8B,YAAY;EACvC;CAC2B,CAAA;AAC3B,CAAA;AAKP,IAAM,wBAAuD,UAAU;CACrE,MAAM,EACJ,UACA,uBACA,WAAW,oBACX,uBACE;CAEJ,MAAM,gBAAgB,OAA+B,KAAA,CAAS;CAC9D,MAAM,gBAAgB,OAA+B,KAAA,CAAS;CAC9D,MAAM,0BAA0B,OAAO,KAAK;CAC5C,MAAM,CAAC,iBAAiB,sBAAsB,SAAS,IAAI;CAC3D,MAAM,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vB,qCACE,wBAAwB,gBAAgB,CAC1C;EAEJ;EACA,cAAc,UAAU,aAAa,KAAK;EAC1C;EACA;CACF,CAAC;;CAGD,MAAM,kBACJ,oBAAC,oBAAD,EAAA,UACE,oBAAC,wBAAD,CAAyB,CAAA,EACP,CAAA;CAGtB,MAAM,cAAc,QAAwB;EAC1C,IAAI,wBAAwB,SAC1B;EAEF,cAAc;EACd,wBAAwB,UAAU;EAClC,QAAQ,GAAG,CAAC,EACR,MAAM,eAAe;GACrB,cAAc,UAAU;GACxB,sBAAsB;GACtB,OAAO,WAAW,QAAQ,cAAc;EAC1C,CAAC,CAAC,CACD,MAAM,eAAe;GACpB,cAAc,UAAU;GACxB,eAAe,IAAI;EACrB,CAAC,CAAC,CACD,OAAO,UAAU;GAChB,mBAAmB,KAAK;EAC1B,CAAC;EAEH,IAAI,eAAe,SACjB,kBAAkB,eAAe,OAAO;CAE5C;CAEA,MAAM,0BAA6C,UAAU;EAC3D,kBAAkB,MAAM,KAAK;EAC7B,OAAO;CACT;CAEA,OACE,oBAAC,OAAD;EAAK,KAAK;EACR,UAAA,oBAAC,eAAD;GAAe,mBAAmB;GAC/B,UAAA,eAAe,cAAc,WAC5B,oBAAC,uBAAD;IACE,OAAO,EACL,YAAY,cAAc,QAC5B;IAEA,UAAA,oBAAC,cAAD;KAAc,QAAQ;KACpB,UAAA,oBAAC,4BAAD;MAA4B,WAAW;MACrC,UAAA,oBAAC,wBAAD;OAAwB,SAAS;OAC/B,UAAA,oBAAC,UAAD;QAAU,UAAU;QAClB,UAAA,oBAAC,8BAAD;SAA8B,YAAY;SACvC;QAC2B,CAAA;OACtB,CAAA;MACY,CAAA;KACE,CAAA;IAChB,CAAA;GACO,CAAA;EAEZ,CAAA;CACZ,CAAA;AAET"}
@@ -2,8 +2,8 @@
2
2
  /* */
3
3
  import { Version } from "@mittwald/flow-remote-core";
4
4
  // src/version.ts
5
- var communicationVersion = Version.v5;
6
- var packageVersion = "1.5.63";
5
+ var communicationVersion = Version.v6;
6
+ var packageVersion = "1.5.65";
7
7
  var version = communicationVersion;
8
8
  export { communicationVersion, packageVersion, version };
9
9
 
@@ -1 +1 @@
1
- {"version":3,"file":"version.mjs","names":[],"sources":["../../src/version.ts"],"sourcesContent":["import { Version } from \"@mittwald/flow-remote-core\";\n\nexport const communicationVersion = Version.v5;\nexport const packageVersion = __FLOW_REMOTE_REACT_COMPONENTS_PACKAGE_VERSION__;\n\nexport const version = communicationVersion;\n"],"mappings":";;;;AAEA,IAAa,uBAAuB,QAAQ;AAC5C,IAAa,iBAAA;AAEb,IAAa,UAAU"}
1
+ {"version":3,"file":"version.mjs","names":[],"sources":["../../src/version.ts"],"sourcesContent":["import { Version } from \"@mittwald/flow-remote-core\";\n\nexport const communicationVersion = Version.v6;\nexport const packageVersion = __FLOW_REMOTE_REACT_COMPONENTS_PACKAGE_VERSION__;\n\nexport const version = communicationVersion;\n"],"mappings":";;;;AAEA,IAAa,uBAAuB,QAAQ;AAC5C,IAAa,iBAAA;AAEb,IAAa,UAAU"}
@@ -3,6 +3,11 @@ import { FC, PropsWithChildren } from 'react';
3
3
  export interface RemoteRootProps extends PropsWithChildren {
4
4
  onHostPathnameChanged?: (pathname: string) => void;
5
5
  isLoading?: boolean;
6
+ /**
7
+ * Additional host origins the remote app accepts, e.g. for local development.
8
+ * The mStudio origins and the app's own origin are always allowed.
9
+ */
10
+ allowedHostOrigins?: string[];
6
11
  /** Internal use only */
7
12
  __remoteReceiver?: RemoteReceiver;
8
13
  }
@@ -1,4 +1,4 @@
1
1
  import { Version } from '@mittwald/flow-remote-core';
2
- export declare const communicationVersion = Version.v5;
2
+ export declare const communicationVersion = Version.v6;
3
3
  export declare const packageVersion: string;
4
- export declare const version = Version.v5;
4
+ export declare const version = Version.v6;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mittwald/flow-remote-react-components",
3
- "version": "1.5.63",
3
+ "version": "1.5.65",
4
4
  "type": "module",
5
5
  "description": "React components that can be used in a remote environment",
6
6
  "homepage": "https://flow.mittwald.de",
@@ -53,19 +53,19 @@
53
53
  "test:visual:update": "vitest run --project=visual --browser.headless --update=true"
54
54
  },
55
55
  "dependencies": {
56
- "@mittwald/flow-react-components": "1.5.63",
57
- "@mittwald/flow-remote-core": "1.5.63",
58
- "@mittwald/flow-remote-elements": "1.5.63",
56
+ "@mittwald/flow-react-components": "1.5.65",
57
+ "@mittwald/flow-remote-core": "1.5.65",
58
+ "@mittwald/flow-remote-elements": "1.5.65",
59
59
  "@mittwald/remote-dom-react": "1.2.2-mittwald.10",
60
60
  "@types/react": "^19.2",
61
61
  "react-error-boundary": "^6.1.3"
62
62
  },
63
63
  "devDependencies": {
64
64
  "@internationalized/date": "^3.12.3",
65
- "@mittwald/ext-bridge": "1.5.63",
66
- "@mittwald/flow-core": "1.5.63",
67
- "@mittwald/flow-remote-react-renderer": "1.5.63",
68
- "@mittwald/typescript-config": "1.5.63",
65
+ "@mittwald/ext-bridge": "1.5.65",
66
+ "@mittwald/flow-core": "1.5.65",
67
+ "@mittwald/flow-remote-react-renderer": "1.5.65",
68
+ "@mittwald/typescript-config": "1.5.65",
69
69
  "@quilted/threads": "^3.3.1",
70
70
  "@tabler/icons-react": "^3.44.0",
71
71
  "@types/node": "^25.9.3",
@@ -91,7 +91,7 @@
91
91
  },
92
92
  "peerDependencies": {
93
93
  "@internationalized/date": "^3.12.2",
94
- "@mittwald/ext-bridge": "1.5.63",
94
+ "@mittwald/ext-bridge": "1.5.65",
95
95
  "react": "^19.2.0",
96
96
  "react-hook-form": "^7.65.0"
97
97
  },
@@ -106,5 +106,5 @@
106
106
  "optional": true
107
107
  }
108
108
  },
109
- "gitHead": "7e12b303d48d8e2de40fa685e84044139da95c5d"
109
+ "gitHead": "6cdfe310f6aaa92f93b0f0492c576f88fd21f277"
110
110
  }