@altertable/data-app 0.61.0 → 0.63.0
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/AGENTS.md +4 -32
- package/CONTRIBUTING.md +63 -72
- package/README.md +14 -38
- package/dist/chunks/{contract-d9skd1n7.js → contract-8wdybxj7.js} +163 -16
- package/dist/chunks/contract-8wdybxj7.js.map +13 -0
- package/dist/chunks/{contract-ryyf6dme.js → contract-cxr9t12b.js} +2 -5
- package/dist/chunks/contract-cxr9t12b.js.map +10 -0
- package/dist/chunks/{contract-14vxdcrs.js → contract-farfe948.js} +17 -21
- package/dist/chunks/contract-farfe948.js.map +10 -0
- package/dist/chunks/contract-mev09s5v.js.map +2 -2
- package/dist/chunks/{contract-ehk50k7e.js → contract-tf8c3qpv.js} +34 -4
- package/dist/chunks/contract-tf8c3qpv.js.map +11 -0
- package/dist/chunks/{contract-zr4s2g7m.js → contract-tkc552ze.js} +75 -36
- package/dist/chunks/contract-tkc552ze.js.map +12 -0
- package/dist/chunks/{contract-nt819swq.js → contract-wd8qe3mt.js} +6 -1
- package/dist/chunks/{contract-nt819swq.js.map → contract-wd8qe3mt.js.map} +3 -3
- package/dist/chunks/contract-wz59z8pq.js.map +1 -1
- package/dist/chunks/{contract-7gpsee0v.js → contract-zr3jd7mr.js} +51 -22
- package/dist/chunks/contract-zr3jd7mr.js.map +12 -0
- package/dist/client/index.js +7 -6
- package/dist/client/index.js.map +1 -1
- package/dist/core/appearance.js +1 -1
- package/dist/core/contract.js +6 -4
- package/dist/core/contract.js.map +1 -1
- package/dist/embed/index.js +41 -9
- package/dist/embed/index.js.map +5 -4
- package/dist/local.js +172 -84
- package/dist/local.js.map +7 -8
- package/dist/react/embed/index.js +83 -99
- package/dist/react/embed/index.js.map +4 -5
- package/dist/react/index.js +5701 -324
- package/dist/react/index.js.map +74 -65
- package/dist/server.js +153 -81
- package/dist/server.js.map +6 -7
- package/dist/types/client/data-client.d.ts +33 -0
- package/dist/types/client/iframe.d.ts +14 -0
- package/dist/types/client/index.d.ts +4 -34
- package/dist/types/client/location.d.ts +4 -6
- package/dist/types/client/navigation.d.ts +2 -1
- package/dist/types/core/appearance.d.ts +7 -6
- package/dist/types/core/bridge.d.ts +2 -8
- package/dist/types/core/config.d.ts +1 -1
- package/dist/types/core/contract.d.ts +9 -56
- package/dist/types/core/format.d.ts +0 -1
- package/dist/types/core/messages.d.ts +11 -30
- package/dist/types/core/navigation.d.ts +11 -0
- package/dist/types/core/operation-types.d.ts +76 -0
- package/dist/types/core/operation.d.ts +21 -0
- package/dist/types/core/presentation.d.ts +7 -0
- package/dist/types/core/variables.d.ts +2 -2
- package/dist/types/embed/bridge.d.ts +12 -0
- package/dist/types/embed/host.d.ts +14 -5
- package/dist/types/embed/index.d.ts +6 -4
- package/dist/types/embed/source.d.ts +15 -0
- package/dist/types/embed/sql.d.ts +4 -0
- package/dist/types/react/content.d.ts +3 -3
- package/dist/types/react/embed/bridge.d.ts +19 -10
- package/dist/types/react/embed/index.d.ts +0 -2
- package/dist/types/react/hooks.d.ts +65 -64
- package/dist/types/react/index.d.ts +135 -2
- package/dist/types/react/injectStyles.d.ts +7 -0
- package/dist/types/react/shellStyles.d.ts +3 -0
- package/dist/types/react/styles.d.ts +8 -0
- package/dist/types/react/ui/AboutData.d.ts +0 -1
- package/dist/types/react/ui/AppFooter.d.ts +0 -1
- package/dist/types/react/ui/AppHeader.d.ts +0 -1
- package/dist/types/react/ui/AppLayout.d.ts +0 -1
- package/dist/types/react/ui/AppScope.d.ts +0 -1
- package/dist/types/react/ui/AppToolbar.d.ts +0 -1
- package/dist/types/react/ui/Breakdown.d.ts +0 -1
- package/dist/types/react/ui/Button.d.ts +0 -1
- package/dist/types/react/ui/Checkbox.d.ts +0 -1
- package/dist/types/react/ui/Combobox.d.ts +0 -1
- package/dist/types/react/ui/ComparisonVisual.d.ts +0 -1
- package/dist/types/react/ui/ContentSkeleton.d.ts +2 -5
- package/dist/types/react/ui/DataApp.d.ts +2 -2
- package/dist/types/react/ui/DataAppSkeleton.d.ts +7 -0
- package/dist/types/react/ui/DataBoundary.d.ts +0 -1
- package/dist/types/react/ui/DataSection.d.ts +2 -4
- package/dist/types/react/ui/DataTable.d.ts +2 -3
- package/dist/types/react/ui/DataViewToast.d.ts +0 -1
- package/dist/types/react/ui/DataWidget.d.ts +4 -14
- package/dist/types/react/ui/DateRangePicker.d.ts +0 -1
- package/dist/types/react/ui/DateTimeTooltip.d.ts +0 -1
- package/dist/types/react/ui/EmptyState.d.ts +2 -5
- package/dist/types/react/ui/GettingStarted.d.ts +0 -1
- package/dist/types/react/ui/GlossaryDefinition.d.ts +0 -1
- package/dist/types/react/ui/GlossaryExplanation.d.ts +0 -1
- package/dist/types/react/ui/GradientScroll.d.ts +0 -1
- package/dist/types/react/ui/Grid.d.ts +0 -1
- package/dist/types/react/ui/HelpPopover.d.ts +0 -2
- package/dist/types/react/ui/Kbd.d.ts +0 -1
- package/dist/types/react/ui/LiveControl.d.ts +0 -1
- package/dist/types/react/ui/MetricWidget.d.ts +0 -2
- package/dist/types/react/ui/PeriodSummary.d.ts +0 -1
- package/dist/types/react/ui/PresentStory.d.ts +0 -1
- package/dist/types/react/ui/QueryList.d.ts +0 -1
- package/dist/types/react/ui/Ranking.d.ts +0 -1
- package/dist/types/react/ui/RefreshControl.d.ts +0 -1
- package/dist/types/react/ui/RefreshRegion.d.ts +0 -1
- package/dist/types/react/ui/RequestHint.d.ts +0 -1
- package/dist/types/react/ui/SearchField.d.ts +0 -1
- package/dist/types/react/ui/SearchInput.d.ts +1 -2
- package/dist/types/react/ui/SearchMatch.d.ts +0 -1
- package/dist/types/react/ui/SelectableBarChart.d.ts +0 -1
- package/dist/types/react/ui/SelectionMark.d.ts +0 -1
- package/dist/types/react/ui/Sheet.d.ts +0 -1
- package/dist/types/react/ui/Skeleton.d.ts +0 -1
- package/dist/types/react/ui/Stack.d.ts +0 -1
- package/dist/types/react/ui/StatusPanel.d.ts +0 -1
- package/dist/types/react/ui/TableWidget.d.ts +2 -3
- package/dist/types/react/ui/Tabs.d.ts +0 -1
- package/dist/types/react/ui/TextContent.d.ts +4 -0
- package/dist/types/react/ui/TextWidget.d.ts +19 -0
- package/dist/types/react/ui/ThemeSelector.d.ts +0 -1
- package/dist/types/react/ui/Tooltip.d.ts +0 -1
- package/dist/types/react/ui/UpdatedAt.d.ts +0 -1
- package/dist/types/react/ui/VariableBar.d.ts +0 -1
- package/dist/types/react/ui/VisualizationWidget.d.ts +5 -13
- package/dist/types/react/ui/WidgetDisclosure.d.ts +0 -1
- package/dist/types/react/ui/WidgetViewTabs.d.ts +2 -3
- package/dist/types/react/ui/data-identifiers.d.ts +0 -1
- package/dist/types/react/ui/presentation.d.ts +19 -0
- package/dist/types/react/ui/useAppAppearance.d.ts +3 -0
- package/dist/types/react/ui/useDataAppPresentation.d.ts +3 -0
- package/dist/types/react/view-controls.d.ts +2 -2
- package/dist/types/react/view.d.ts +2 -2
- package/dist/{bootstrap.js → worker.js} +144 -12
- package/docs/app-authoring.md +60 -24
- package/docs/client.md +48 -19
- package/docs/contract.md +10 -10
- package/docs/embed.md +94 -26
- package/docs/hosted-apps.md +39 -0
- package/docs/local-data-apps.md +14 -0
- package/docs/react-embed.md +75 -24
- package/docs/react.md +118 -93
- package/docs/server-bun.md +4 -1
- package/docs/server.md +2 -2
- package/docs/worker.md +55 -0
- package/examples/starter-data-app/index.tsx +159 -0
- package/package.json +18 -12
- package/dist/chunks/contract-14vxdcrs.js.map +0 -10
- package/dist/chunks/contract-7gpsee0v.js.map +0 -11
- package/dist/chunks/contract-d9skd1n7.js.map +0 -12
- package/dist/chunks/contract-ehk50k7e.js.map +0 -10
- package/dist/chunks/contract-ryyf6dme.js.map +0 -10
- package/dist/chunks/contract-zr4s2g7m.js.map +0 -12
- package/dist/react/index.css +0 -4478
- package/dist/react.css.d.ts +0 -1
- package/dist/types/embed/shell.d.ts +0 -21
- package/dist/types/embed/standalone.d.ts +0 -1
- package/dist/types/react/embed/shell.d.ts +0 -10
- package/dist/types/react/ui/index.d.ts +0 -129
- package/docs/appearance.md +0 -30
- package/docs/bootstrap.md +0 -76
- package/docs/config.md +0 -21
- package/docs/format.md +0 -29
- package/docs/react-styles.md +0 -17
- package/docs/starter-agent-instructions.md +0 -53
|
@@ -1,32 +1,57 @@
|
|
|
1
|
-
import"../../chunks/contract-ehk50k7e.js";
|
|
2
1
|
import {
|
|
3
|
-
attachDataAppBridge2
|
|
4
|
-
|
|
5
|
-
} from "../../chunks/contract-7gpsee0v.js";
|
|
2
|
+
attachDataAppBridge2
|
|
3
|
+
} from "../../chunks/contract-zr3jd7mr.js";
|
|
6
4
|
|
|
7
5
|
// src/react/embed/bridge.tsx
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
import {
|
|
7
|
+
useRef,
|
|
8
|
+
useLayoutEffect,
|
|
9
|
+
useEffect,
|
|
10
|
+
useState
|
|
11
|
+
} from "react";
|
|
12
|
+
import { jsx } from "react/jsx-runtime";
|
|
13
|
+
function DataAppBridge(props) {
|
|
14
|
+
if (props.source) {
|
|
15
|
+
const source = props.source;
|
|
16
|
+
const identity = JSON.stringify(source.type === "url" ? [source.type, source.url] : [source.type, source.bootstrapUrl, source.javascript]);
|
|
17
|
+
return /* @__PURE__ */ jsx(SourceBridge, {
|
|
18
|
+
...props
|
|
19
|
+
}, identity);
|
|
20
|
+
}
|
|
21
|
+
return /* @__PURE__ */ jsx(ConnectionBridge, {
|
|
22
|
+
...props
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function useBridgeState(props) {
|
|
26
|
+
const hostRef = useRef(undefined);
|
|
27
|
+
const handlers = useRef(props);
|
|
17
28
|
useLayoutEffect(() => {
|
|
18
|
-
handlers.current =
|
|
29
|
+
handlers.current = props;
|
|
19
30
|
});
|
|
20
|
-
const identity = connection.type === "origin" ? connection.origin : connection.token;
|
|
21
|
-
const type = connection.type;
|
|
22
31
|
useEffect(() => {
|
|
23
|
-
|
|
24
|
-
|
|
32
|
+
hostRef.current?.setPresentation(props.presentation);
|
|
33
|
+
});
|
|
34
|
+
return { hostRef, handlers };
|
|
35
|
+
}
|
|
36
|
+
function SourceBridge(props) {
|
|
37
|
+
const { source, title, iframeProps, startupTimeoutMs } = props;
|
|
38
|
+
const [iframe, setIframe] = useState(null);
|
|
39
|
+
const { hostRef, handlers } = useBridgeState(props);
|
|
40
|
+
const type = source.type;
|
|
41
|
+
const url = source.type === "url" ? source.url : source.bootstrapUrl;
|
|
42
|
+
const javascript = source.type === "bundle" ? source.javascript : undefined;
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (!iframe)
|
|
25
45
|
return;
|
|
26
|
-
|
|
46
|
+
const bridge = attachDataAppBridge2({
|
|
27
47
|
iframe,
|
|
28
|
-
|
|
29
|
-
|
|
48
|
+
source: type === "url" ? { type, url } : {
|
|
49
|
+
type,
|
|
50
|
+
bootstrapUrl: url,
|
|
51
|
+
javascript
|
|
52
|
+
},
|
|
53
|
+
startupTimeoutMs,
|
|
54
|
+
presentation: handlers.current.presentation,
|
|
30
55
|
onMessage(request, context) {
|
|
31
56
|
return handlers.current.onMessage(request, context);
|
|
32
57
|
},
|
|
@@ -37,94 +62,53 @@ function DataAppBridge({
|
|
|
37
62
|
return handlers.current.onDiagnostic?.(event);
|
|
38
63
|
}
|
|
39
64
|
});
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
52
|
-
function DataAppShell({
|
|
53
|
-
source,
|
|
54
|
-
title,
|
|
55
|
-
onMessage,
|
|
56
|
-
onStatusChange,
|
|
57
|
-
onDiagnostic,
|
|
58
|
-
startupTimeoutMs,
|
|
59
|
-
loading,
|
|
60
|
-
renderError
|
|
61
|
-
}) {
|
|
62
|
-
const [iframe, setIframe] = useState(null);
|
|
63
|
-
const [attempt, bumpAttempt] = useReducer((value) => value + 1, 0);
|
|
64
|
-
const [status, setStatus] = useState("connecting");
|
|
65
|
-
const handlers = useRef2({ onMessage, onStatusChange, onDiagnostic });
|
|
66
|
-
useLayoutEffect2(() => {
|
|
67
|
-
handlers.current = { onMessage, onStatusChange, onDiagnostic };
|
|
65
|
+
hostRef.current = bridge;
|
|
66
|
+
return () => {
|
|
67
|
+
hostRef.current = undefined;
|
|
68
|
+
bridge.dispose();
|
|
69
|
+
};
|
|
70
|
+
}, [iframe, type, url, javascript, startupTimeoutMs, hostRef, handlers]);
|
|
71
|
+
return /* @__PURE__ */ jsx("iframe", {
|
|
72
|
+
...iframeProps,
|
|
73
|
+
loading: "eager",
|
|
74
|
+
ref: setIframe,
|
|
75
|
+
title
|
|
68
76
|
});
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
77
|
+
}
|
|
78
|
+
function ConnectionBridge(props) {
|
|
79
|
+
const { iframe, connection } = props;
|
|
80
|
+
const { hostRef, handlers } = useBridgeState(props);
|
|
81
|
+
const identity = connection.type === "origin" ? connection.origin : connection.token;
|
|
82
|
+
const type = connection.type;
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
const host = iframe?.ownerDocument.defaultView;
|
|
85
|
+
if (!iframe || !host)
|
|
76
86
|
return;
|
|
77
|
-
|
|
87
|
+
const bridge = attachDataAppBridge2({
|
|
78
88
|
iframe,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
89
|
+
connection: type === "origin" ? { type, origin: identity } : { type, token: identity },
|
|
90
|
+
window: host,
|
|
91
|
+
presentation: handlers.current.presentation,
|
|
92
|
+
onMessage(request, context) {
|
|
93
|
+
return handlers.current.onMessage(request, context);
|
|
84
94
|
},
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
return handlers.current.onMessage(message, context);
|
|
95
|
+
onStatusChange(status) {
|
|
96
|
+
return handlers.current.onStatusChange?.(status);
|
|
88
97
|
},
|
|
89
98
|
onDiagnostic(event) {
|
|
90
99
|
return handlers.current.onDiagnostic?.(event);
|
|
91
|
-
},
|
|
92
|
-
onStatusChange(value) {
|
|
93
|
-
setStatus(value);
|
|
94
|
-
handlers.current.onStatusChange?.(value);
|
|
95
100
|
}
|
|
96
101
|
});
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
status !== "ready" && status !== "failed" && loading && /* @__PURE__ */ jsx("output", {
|
|
105
|
-
children: loading
|
|
106
|
-
}),
|
|
107
|
-
status === "failed" && (renderError?.(retry) ?? /* @__PURE__ */ jsxs("div", {
|
|
108
|
-
role: "alert",
|
|
109
|
-
children: [
|
|
110
|
-
"Could not load the data app. ",
|
|
111
|
-
/* @__PURE__ */ jsx("button", {
|
|
112
|
-
onClick: retry,
|
|
113
|
-
children: "Retry"
|
|
114
|
-
})
|
|
115
|
-
]
|
|
116
|
-
})),
|
|
117
|
-
/* @__PURE__ */ jsx("iframe", {
|
|
118
|
-
ref: setIframe,
|
|
119
|
-
title,
|
|
120
|
-
hidden: status !== "ready"
|
|
121
|
-
}, key)
|
|
122
|
-
]
|
|
123
|
-
});
|
|
102
|
+
hostRef.current = bridge;
|
|
103
|
+
return () => {
|
|
104
|
+
hostRef.current = undefined;
|
|
105
|
+
bridge.dispose();
|
|
106
|
+
};
|
|
107
|
+
}, [iframe, type, identity, hostRef, handlers]);
|
|
108
|
+
return null;
|
|
124
109
|
}
|
|
125
110
|
export {
|
|
126
|
-
DataAppBridge
|
|
127
|
-
DataAppShell
|
|
111
|
+
DataAppBridge
|
|
128
112
|
};
|
|
129
113
|
|
|
130
|
-
//# debugId=
|
|
114
|
+
//# debugId=E8F422449EF0920064756E2164756E21
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/react/embed/bridge.tsx"
|
|
3
|
+
"sources": ["../src/react/embed/bridge.tsx"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import {
|
|
6
|
-
"import {\n useEffect,\n useLayoutEffect,\n useRef,\n useReducer,\n useState,\n type ComponentRef,\n type ReactNode,\n} from 'react';\nimport {\n attachDataAppShell,\n type DataAppSource,\n type DataAppShellOptions,\n} from '@/src/embed/shell';\nimport type { DataAppStatus } from '@/src/embed/host';\n\nexport type DataAppShellProps = Pick<\n DataAppShellOptions,\n 'onMessage' | 'onStatusChange' | 'onDiagnostic' | 'startupTimeoutMs'\n> & {\n source: DataAppSource;\n title: string;\n loading?: ReactNode;\n renderError?: (retry: () => void) => ReactNode;\n};\n\n/** Source changes and retries replace the entire frame; handler changes retain its session. */\nexport function DataAppShell({\n source,\n title,\n onMessage,\n onStatusChange,\n onDiagnostic,\n startupTimeoutMs,\n loading,\n renderError,\n}: DataAppShellProps) {\n const [iframe, setIframe] = useState<ComponentRef<'iframe'> | null>(null);\n const [attempt, bumpAttempt] = useReducer(value => value + 1, 0);\n const [status, setStatus] = useState<DataAppStatus>('connecting');\n const handlers = useRef({ onMessage, onStatusChange, onDiagnostic });\n\n useLayoutEffect(() => {\n handlers.current = { onMessage, onStatusChange, onDiagnostic };\n });\n\n const url = source.type === 'url' ? source.url : source.bootstrapUrl;\n const javascript = source.type === 'bundle' ? source.javascript : undefined;\n const revision = source.type === 'bundle' ? source.revision : undefined;\n const type = source.type;\n const key = JSON.stringify([type, url, revision, javascript, attempt]);\n\n useEffect(() => {\n if (!iframe) return;\n\n return attachDataAppShell({\n iframe,\n source:\n type === 'url'\n ? { type, url }\n : {\n type,\n bootstrapUrl: url,\n javascript: javascript!,\n revision: revision!,\n },\n startupTimeoutMs,\n onMessage(message, context) {\n return handlers.current.onMessage(message, context);\n },\n onDiagnostic(event) {\n return handlers.current.onDiagnostic?.(event);\n },\n onStatusChange(value) {\n setStatus(value);\n handlers.current.onStatusChange?.(value);\n },\n });\n }, [iframe, type, url, javascript, revision, startupTimeoutMs]);\n\n function retry() {\n setStatus('connecting');\n bumpAttempt();\n }\n\n return (\n <>\n {status !== 'ready' && status !== 'failed' && loading && (\n <output>{loading}</output>\n )}\n {status === 'failed' &&\n (renderError?.(retry) ?? (\n <div role=\"alert\">\n Could not load the data app. <button onClick={retry}>Retry</button>\n </div>\n ))}\n <iframe\n key={key}\n ref={setIframe}\n title={title}\n hidden={status !== 'ready'}\n />\n </>\n );\n}\n"
|
|
5
|
+
"import {\n useRef,\n useLayoutEffect,\n useEffect,\n useState,\n type ComponentRef,\n type ComponentPropsWithoutRef,\n} from 'react';\nimport {\n attachDataAppBridge,\n type DataAppBridgeOptions,\n} from '@/src/embed/bridge';\nimport type { DataAppConnection, DataAppHost } from '@/src/embed/host';\nimport type { DataAppSource } from '@/src/embed/source';\n\nexport type DataAppBridgeProps = Pick<\n DataAppBridgeOptions,\n 'onMessage' | 'onStatusChange' | 'onDiagnostic' | 'presentation'\n> &\n (\n | {\n source: DataAppSource;\n title: string;\n startupTimeoutMs?: number;\n iframeProps?: Omit<\n ComponentPropsWithoutRef<'iframe'>,\n | 'src'\n | 'srcDoc'\n | 'sandbox'\n | 'referrerPolicy'\n | 'loading'\n | 'children'\n | 'title'\n >;\n iframe?: never;\n connection?: never;\n }\n | {\n iframe: ComponentRef<'iframe'> | null;\n connection: DataAppConnection;\n source?: never;\n title?: never;\n startupTimeoutMs?: never;\n iframeProps?: never;\n }\n );\n\n/** Owns iframe setup and delivery. The consuming shell owns loading, error UI, and retries. */\nexport function DataAppBridge(props: DataAppBridgeProps) {\n if (props.source) {\n const source = props.source;\n const identity = JSON.stringify(\n source.type === 'url'\n ? [source.type, source.url]\n : [source.type, source.bootstrapUrl, source.javascript]\n );\n\n return <SourceBridge key={identity} {...props} />;\n }\n\n return <ConnectionBridge {...props} />;\n}\n\ntype SourceBridgeProps = Extract<DataAppBridgeProps, { source: DataAppSource }>;\ntype ConnectionBridgeProps = Extract<\n DataAppBridgeProps,\n { connection: DataAppConnection }\n>;\n\nfunction useBridgeState(props: DataAppBridgeProps) {\n const hostRef = useRef<DataAppHost | undefined>(undefined);\n const handlers = useRef(props);\n\n useLayoutEffect(() => {\n handlers.current = props;\n });\n\n useEffect(() => {\n hostRef.current?.setPresentation(props.presentation);\n });\n\n return { hostRef, handlers };\n}\n\nfunction SourceBridge(props: SourceBridgeProps) {\n const { source, title, iframeProps, startupTimeoutMs } = props;\n const [iframe, setIframe] = useState<ComponentRef<'iframe'> | null>(null);\n const { hostRef, handlers } = useBridgeState(props);\n const type = source.type;\n const url = source.type === 'url' ? source.url : source.bootstrapUrl;\n const javascript = source.type === 'bundle' ? source.javascript : undefined;\n\n useEffect(() => {\n if (!iframe) return;\n\n const bridge = attachDataAppBridge({\n iframe,\n source:\n type === 'url'\n ? { type, url }\n : {\n type,\n bootstrapUrl: url,\n javascript: javascript!,\n },\n startupTimeoutMs,\n presentation: handlers.current.presentation,\n onMessage(request, context) {\n return handlers.current.onMessage(request, context);\n },\n onStatusChange(status) {\n return handlers.current.onStatusChange?.(status);\n },\n onDiagnostic(event) {\n return handlers.current.onDiagnostic?.(event);\n },\n });\n hostRef.current = bridge;\n\n return () => {\n hostRef.current = undefined;\n bridge.dispose();\n };\n }, [iframe, type, url, javascript, startupTimeoutMs, hostRef, handlers]);\n\n return (\n <iframe {...iframeProps} loading=\"eager\" ref={setIframe} title={title} />\n );\n}\n\nfunction ConnectionBridge(props: ConnectionBridgeProps) {\n const { iframe, connection } = props;\n const { hostRef, handlers } = useBridgeState(props);\n const identity =\n connection.type === 'origin' ? connection.origin : connection.token;\n const type = connection.type;\n\n useEffect(() => {\n const host = iframe?.ownerDocument.defaultView;\n if (!iframe || !host) return;\n\n const bridge = attachDataAppBridge({\n iframe,\n connection:\n type === 'origin'\n ? { type, origin: identity }\n : { type, token: identity },\n window: host,\n presentation: handlers.current.presentation,\n onMessage(request, context) {\n return handlers.current.onMessage(request, context);\n },\n onStatusChange(status) {\n return handlers.current.onStatusChange?.(status);\n },\n onDiagnostic(event) {\n return handlers.current.onDiagnostic?.(event);\n },\n });\n hostRef.current = bridge;\n\n return () => {\n hostRef.current = undefined;\n bridge.dispose();\n };\n }, [iframe, type, identity, hostRef, handlers]);\n\n return null;\n}\n"
|
|
7
6
|
],
|
|
8
|
-
"mappings": "
|
|
9
|
-
"debugId": "
|
|
7
|
+
"mappings": ";;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAgDO,SAAS,aAAa,CAAC,OAA2B;AAAA,EACvD,IAAI,MAAM,QAAQ;AAAA,IAChB,MAAM,SAAS,MAAM;AAAA,IACrB,MAAM,WAAW,KAAK,UACpB,OAAO,SAAS,QACZ,CAAC,OAAO,MAAM,OAAO,GAAG,IACxB,CAAC,OAAO,MAAM,OAAO,cAAc,OAAO,UAAU,CAC1D;AAAA,IAEA,uBAAO,IAAC,cAAD;AAAA,SAAiC;AAAA,OAAd,QAAqB;AAAA,EACjD;AAAA,EAEA,uBAAO,IAAC,kBAAD;AAAA,OAAsB;AAAA,GAAO;AAAA;AAStC,SAAS,cAAc,CAAC,OAA2B;AAAA,EACjD,MAAM,UAAU,OAAgC,SAAS;AAAA,EACzD,MAAM,WAAW,OAAO,KAAK;AAAA,EAE7B,gBAAgB,MAAM;AAAA,IACpB,SAAS,UAAU;AAAA,GACpB;AAAA,EAED,UAAU,MAAM;AAAA,IACd,QAAQ,SAAS,gBAAgB,MAAM,YAAY;AAAA,GACpD;AAAA,EAED,OAAO,EAAE,SAAS,SAAS;AAAA;AAG7B,SAAS,YAAY,CAAC,OAA0B;AAAA,EAC9C,QAAQ,QAAQ,OAAO,aAAa,qBAAqB;AAAA,EACzD,OAAO,QAAQ,aAAa,SAAwC,IAAI;AAAA,EACxE,QAAQ,SAAS,aAAa,eAAe,KAAK;AAAA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