@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.
Files changed (159) hide show
  1. package/AGENTS.md +4 -32
  2. package/CONTRIBUTING.md +63 -72
  3. package/README.md +14 -38
  4. package/dist/chunks/{contract-d9skd1n7.js → contract-8wdybxj7.js} +163 -16
  5. package/dist/chunks/contract-8wdybxj7.js.map +13 -0
  6. package/dist/chunks/{contract-ryyf6dme.js → contract-cxr9t12b.js} +2 -5
  7. package/dist/chunks/contract-cxr9t12b.js.map +10 -0
  8. package/dist/chunks/{contract-14vxdcrs.js → contract-farfe948.js} +17 -21
  9. package/dist/chunks/contract-farfe948.js.map +10 -0
  10. package/dist/chunks/contract-mev09s5v.js.map +2 -2
  11. package/dist/chunks/{contract-ehk50k7e.js → contract-tf8c3qpv.js} +34 -4
  12. package/dist/chunks/contract-tf8c3qpv.js.map +11 -0
  13. package/dist/chunks/{contract-zr4s2g7m.js → contract-tkc552ze.js} +75 -36
  14. package/dist/chunks/contract-tkc552ze.js.map +12 -0
  15. package/dist/chunks/{contract-nt819swq.js → contract-wd8qe3mt.js} +6 -1
  16. package/dist/chunks/{contract-nt819swq.js.map → contract-wd8qe3mt.js.map} +3 -3
  17. package/dist/chunks/contract-wz59z8pq.js.map +1 -1
  18. package/dist/chunks/{contract-7gpsee0v.js → contract-zr3jd7mr.js} +51 -22
  19. package/dist/chunks/contract-zr3jd7mr.js.map +12 -0
  20. package/dist/client/index.js +7 -6
  21. package/dist/client/index.js.map +1 -1
  22. package/dist/core/appearance.js +1 -1
  23. package/dist/core/contract.js +6 -4
  24. package/dist/core/contract.js.map +1 -1
  25. package/dist/embed/index.js +41 -9
  26. package/dist/embed/index.js.map +5 -4
  27. package/dist/local.js +172 -84
  28. package/dist/local.js.map +7 -8
  29. package/dist/react/embed/index.js +83 -99
  30. package/dist/react/embed/index.js.map +4 -5
  31. package/dist/react/index.js +5701 -324
  32. package/dist/react/index.js.map +74 -65
  33. package/dist/server.js +153 -81
  34. package/dist/server.js.map +6 -7
  35. package/dist/types/client/data-client.d.ts +33 -0
  36. package/dist/types/client/iframe.d.ts +14 -0
  37. package/dist/types/client/index.d.ts +4 -34
  38. package/dist/types/client/location.d.ts +4 -6
  39. package/dist/types/client/navigation.d.ts +2 -1
  40. package/dist/types/core/appearance.d.ts +7 -6
  41. package/dist/types/core/bridge.d.ts +2 -8
  42. package/dist/types/core/config.d.ts +1 -1
  43. package/dist/types/core/contract.d.ts +9 -56
  44. package/dist/types/core/format.d.ts +0 -1
  45. package/dist/types/core/messages.d.ts +11 -30
  46. package/dist/types/core/navigation.d.ts +11 -0
  47. package/dist/types/core/operation-types.d.ts +76 -0
  48. package/dist/types/core/operation.d.ts +21 -0
  49. package/dist/types/core/presentation.d.ts +7 -0
  50. package/dist/types/core/variables.d.ts +2 -2
  51. package/dist/types/embed/bridge.d.ts +12 -0
  52. package/dist/types/embed/host.d.ts +14 -5
  53. package/dist/types/embed/index.d.ts +6 -4
  54. package/dist/types/embed/source.d.ts +15 -0
  55. package/dist/types/embed/sql.d.ts +4 -0
  56. package/dist/types/react/content.d.ts +3 -3
  57. package/dist/types/react/embed/bridge.d.ts +19 -10
  58. package/dist/types/react/embed/index.d.ts +0 -2
  59. package/dist/types/react/hooks.d.ts +65 -64
  60. package/dist/types/react/index.d.ts +135 -2
  61. package/dist/types/react/injectStyles.d.ts +7 -0
  62. package/dist/types/react/shellStyles.d.ts +3 -0
  63. package/dist/types/react/styles.d.ts +8 -0
  64. package/dist/types/react/ui/AboutData.d.ts +0 -1
  65. package/dist/types/react/ui/AppFooter.d.ts +0 -1
  66. package/dist/types/react/ui/AppHeader.d.ts +0 -1
  67. package/dist/types/react/ui/AppLayout.d.ts +0 -1
  68. package/dist/types/react/ui/AppScope.d.ts +0 -1
  69. package/dist/types/react/ui/AppToolbar.d.ts +0 -1
  70. package/dist/types/react/ui/Breakdown.d.ts +0 -1
  71. package/dist/types/react/ui/Button.d.ts +0 -1
  72. package/dist/types/react/ui/Checkbox.d.ts +0 -1
  73. package/dist/types/react/ui/Combobox.d.ts +0 -1
  74. package/dist/types/react/ui/ComparisonVisual.d.ts +0 -1
  75. package/dist/types/react/ui/ContentSkeleton.d.ts +2 -5
  76. package/dist/types/react/ui/DataApp.d.ts +2 -2
  77. package/dist/types/react/ui/DataAppSkeleton.d.ts +7 -0
  78. package/dist/types/react/ui/DataBoundary.d.ts +0 -1
  79. package/dist/types/react/ui/DataSection.d.ts +2 -4
  80. package/dist/types/react/ui/DataTable.d.ts +2 -3
  81. package/dist/types/react/ui/DataViewToast.d.ts +0 -1
  82. package/dist/types/react/ui/DataWidget.d.ts +4 -14
  83. package/dist/types/react/ui/DateRangePicker.d.ts +0 -1
  84. package/dist/types/react/ui/DateTimeTooltip.d.ts +0 -1
  85. package/dist/types/react/ui/EmptyState.d.ts +2 -5
  86. package/dist/types/react/ui/GettingStarted.d.ts +0 -1
  87. package/dist/types/react/ui/GlossaryDefinition.d.ts +0 -1
  88. package/dist/types/react/ui/GlossaryExplanation.d.ts +0 -1
  89. package/dist/types/react/ui/GradientScroll.d.ts +0 -1
  90. package/dist/types/react/ui/Grid.d.ts +0 -1
  91. package/dist/types/react/ui/HelpPopover.d.ts +0 -2
  92. package/dist/types/react/ui/Kbd.d.ts +0 -1
  93. package/dist/types/react/ui/LiveControl.d.ts +0 -1
  94. package/dist/types/react/ui/MetricWidget.d.ts +0 -2
  95. package/dist/types/react/ui/PeriodSummary.d.ts +0 -1
  96. package/dist/types/react/ui/PresentStory.d.ts +0 -1
  97. package/dist/types/react/ui/QueryList.d.ts +0 -1
  98. package/dist/types/react/ui/Ranking.d.ts +0 -1
  99. package/dist/types/react/ui/RefreshControl.d.ts +0 -1
  100. package/dist/types/react/ui/RefreshRegion.d.ts +0 -1
  101. package/dist/types/react/ui/RequestHint.d.ts +0 -1
  102. package/dist/types/react/ui/SearchField.d.ts +0 -1
  103. package/dist/types/react/ui/SearchInput.d.ts +1 -2
  104. package/dist/types/react/ui/SearchMatch.d.ts +0 -1
  105. package/dist/types/react/ui/SelectableBarChart.d.ts +0 -1
  106. package/dist/types/react/ui/SelectionMark.d.ts +0 -1
  107. package/dist/types/react/ui/Sheet.d.ts +0 -1
  108. package/dist/types/react/ui/Skeleton.d.ts +0 -1
  109. package/dist/types/react/ui/Stack.d.ts +0 -1
  110. package/dist/types/react/ui/StatusPanel.d.ts +0 -1
  111. package/dist/types/react/ui/TableWidget.d.ts +2 -3
  112. package/dist/types/react/ui/Tabs.d.ts +0 -1
  113. package/dist/types/react/ui/TextContent.d.ts +4 -0
  114. package/dist/types/react/ui/TextWidget.d.ts +19 -0
  115. package/dist/types/react/ui/ThemeSelector.d.ts +0 -1
  116. package/dist/types/react/ui/Tooltip.d.ts +0 -1
  117. package/dist/types/react/ui/UpdatedAt.d.ts +0 -1
  118. package/dist/types/react/ui/VariableBar.d.ts +0 -1
  119. package/dist/types/react/ui/VisualizationWidget.d.ts +5 -13
  120. package/dist/types/react/ui/WidgetDisclosure.d.ts +0 -1
  121. package/dist/types/react/ui/WidgetViewTabs.d.ts +2 -3
  122. package/dist/types/react/ui/data-identifiers.d.ts +0 -1
  123. package/dist/types/react/ui/presentation.d.ts +19 -0
  124. package/dist/types/react/ui/useAppAppearance.d.ts +3 -0
  125. package/dist/types/react/ui/useDataAppPresentation.d.ts +3 -0
  126. package/dist/types/react/view-controls.d.ts +2 -2
  127. package/dist/types/react/view.d.ts +2 -2
  128. package/dist/{bootstrap.js → worker.js} +144 -12
  129. package/docs/app-authoring.md +60 -24
  130. package/docs/client.md +48 -19
  131. package/docs/contract.md +10 -10
  132. package/docs/embed.md +94 -26
  133. package/docs/hosted-apps.md +39 -0
  134. package/docs/local-data-apps.md +14 -0
  135. package/docs/react-embed.md +75 -24
  136. package/docs/react.md +118 -93
  137. package/docs/server-bun.md +4 -1
  138. package/docs/server.md +2 -2
  139. package/docs/worker.md +55 -0
  140. package/examples/starter-data-app/index.tsx +159 -0
  141. package/package.json +18 -12
  142. package/dist/chunks/contract-14vxdcrs.js.map +0 -10
  143. package/dist/chunks/contract-7gpsee0v.js.map +0 -11
  144. package/dist/chunks/contract-d9skd1n7.js.map +0 -12
  145. package/dist/chunks/contract-ehk50k7e.js.map +0 -10
  146. package/dist/chunks/contract-ryyf6dme.js.map +0 -10
  147. package/dist/chunks/contract-zr4s2g7m.js.map +0 -12
  148. package/dist/react/index.css +0 -4478
  149. package/dist/react.css.d.ts +0 -1
  150. package/dist/types/embed/shell.d.ts +0 -21
  151. package/dist/types/embed/standalone.d.ts +0 -1
  152. package/dist/types/react/embed/shell.d.ts +0 -10
  153. package/dist/types/react/ui/index.d.ts +0 -129
  154. package/docs/appearance.md +0 -30
  155. package/docs/bootstrap.md +0 -76
  156. package/docs/config.md +0 -21
  157. package/docs/format.md +0 -29
  158. package/docs/react-styles.md +0 -17
  159. package/docs/starter-agent-instructions.md +0 -53
@@ -1,32 +1,57 @@
1
- import"../../chunks/contract-ehk50k7e.js";
2
1
  import {
3
- attachDataAppBridge2,
4
- attachDataAppShell2
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 { useRef, useLayoutEffect, useEffect } from "react";
9
- function DataAppBridge({
10
- iframe,
11
- connection,
12
- onMessage,
13
- onStatusChange,
14
- onDiagnostic
15
- }) {
16
- const handlers = useRef({ onMessage, onStatusChange, onDiagnostic });
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 = { onMessage, onStatusChange, onDiagnostic };
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
- const host = iframe?.ownerDocument.defaultView;
24
- if (!iframe || !host)
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
- return attachDataAppBridge2({
46
+ const bridge = attachDataAppBridge2({
27
47
  iframe,
28
- connection: type === "origin" ? { type, origin: identity } : { type, token: identity },
29
- window: host,
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
- }, [iframe, type, identity]);
41
- return null;
42
- }
43
- // src/react/embed/shell.tsx
44
- import {
45
- useEffect as useEffect2,
46
- useLayoutEffect as useLayoutEffect2,
47
- useRef as useRef2,
48
- useReducer,
49
- useState
50
- } from "react";
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
- const url = source.type === "url" ? source.url : source.bootstrapUrl;
70
- const javascript = source.type === "bundle" ? source.javascript : undefined;
71
- const revision = source.type === "bundle" ? source.revision : undefined;
72
- const type = source.type;
73
- const key = JSON.stringify([type, url, revision, javascript, attempt]);
74
- useEffect2(() => {
75
- if (!iframe)
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
- return attachDataAppShell2({
87
+ const bridge = attachDataAppBridge2({
78
88
  iframe,
79
- source: type === "url" ? { type, url } : {
80
- type,
81
- bootstrapUrl: url,
82
- javascript,
83
- revision
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
- startupTimeoutMs,
86
- onMessage(message, context) {
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
- }, [iframe, type, url, javascript, revision, startupTimeoutMs]);
98
- function retry() {
99
- setStatus("connecting");
100
- bumpAttempt();
101
- }
102
- return /* @__PURE__ */ jsxs(Fragment, {
103
- children: [
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=9408E7ADA67D784E64756E2164756E21
114
+ //# debugId=E8F422449EF0920064756E2164756E21
@@ -1,11 +1,10 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/react/embed/bridge.tsx", "../src/react/embed/shell.tsx"],
3
+ "sources": ["../src/react/embed/bridge.tsx"],
4
4
  "sourcesContent": [
5
- "import { useRef, useLayoutEffect, useEffect, type ComponentRef } from 'react';\nimport {\n attachDataAppBridge,\n type DataAppConnection,\n type DataAppStatus,\n type DataAppDiagnostic,\n} from '@/src/embed/host';\nimport type { MessageDispatcher } from '@/src/core/messages';\n\nexport type DataAppBridgeProps = {\n iframe: ComponentRef<'iframe'> | null;\n connection: DataAppConnection;\n onMessage: MessageDispatcher;\n onStatusChange?: (status: DataAppStatus) => void;\n onDiagnostic?: (event: DataAppDiagnostic) => void;\n};\n\n/** Delivery only; the host owns the iframe and route handlers, including navigation. */\nexport function DataAppBridge({\n iframe,\n connection,\n onMessage,\n onStatusChange,\n onDiagnostic,\n}: DataAppBridgeProps) {\n const handlers = useRef({ onMessage, onStatusChange, onDiagnostic });\n\n useLayoutEffect(() => {\n handlers.current = { onMessage, onStatusChange, onDiagnostic };\n });\n\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 return attachDataAppBridge({\n iframe,\n connection:\n type === 'origin'\n ? { type, origin: identity }\n : { type, token: identity },\n window: host,\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 }, [iframe, type, identity]);\n\n return null;\n}\n",
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": ";;;;;;;AAAA;AAkBO,SAAS,aAAa;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,GACqB;AAAA,EACrB,MAAM,WAAW,OAAO,EAAE,WAAW,gBAAgB,aAAa,CAAC;AAAA,EAEnE,gBAAgB,MAAM;AAAA,IACpB,SAAS,UAAU,EAAE,WAAW,gBAAgB,aAAa;AAAA,GAC9D;AAAA,EAED,MAAM,WACJ,WAAW,SAAS,WAAW,WAAW,SAAS,WAAW;AAAA,EAChE,MAAM,OAAO,WAAW;AAAA,EAExB,UAAU,MAAM;AAAA,IACd,MAAM,OAAO,QAAQ,cAAc;AAAA,IACnC,IAAI,CAAC,UAAU,CAAC;AAAA,MAAM;AAAA,IAEtB,OAAO,qBAAoB;AAAA,MACzB;AAAA,MACA,YACE,SAAS,WACL,EAAE,MAAM,QAAQ,SAAS,IACzB,EAAE,MAAM,OAAO,SAAS;AAA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