@altertable/data-app 0.64.0 → 0.66.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 (157) hide show
  1. package/AGENTS.md +40 -0
  2. package/CONTRIBUTING.md +37 -3
  3. package/README.md +2 -2
  4. package/dist/chunks/{contract-mwe7gnmh.js → contract-13j5zb3c.js} +110 -216
  5. package/dist/chunks/contract-13j5zb3c.js.map +13 -0
  6. package/dist/chunks/contract-19ckn3n7.js +78 -0
  7. package/dist/chunks/contract-19ckn3n7.js.map +10 -0
  8. package/dist/chunks/contract-awa2d5b1.js +272 -0
  9. package/dist/chunks/contract-awa2d5b1.js.map +12 -0
  10. package/dist/chunks/{contract-xtxza1fy.js → contract-e11m4y7f.js} +35 -71
  11. package/dist/chunks/contract-e11m4y7f.js.map +12 -0
  12. package/dist/chunks/{contract-zr3jd7mr.js → contract-h8a6f559.js} +100 -75
  13. package/dist/chunks/contract-h8a6f559.js.map +12 -0
  14. package/dist/chunks/contract-havnjmdr.js +13011 -0
  15. package/dist/chunks/contract-havnjmdr.js.map +99 -0
  16. package/dist/chunks/{contract-txjy0en2.js → contract-m6n8ctfc.js} +64 -72
  17. package/dist/chunks/contract-m6n8ctfc.js.map +10 -0
  18. package/dist/chunks/contract-pk603qj7.js +146 -0
  19. package/dist/chunks/contract-pk603qj7.js.map +10 -0
  20. package/dist/chunks/{contract-yxbjea23.js → contract-rfbakka4.js} +179 -2
  21. package/dist/chunks/contract-rfbakka4.js.map +13 -0
  22. package/dist/client/index.js +11 -6
  23. package/dist/client/index.js.map +1 -1
  24. package/dist/core/appearance.js +1 -1
  25. package/dist/core/contract.js +13 -3
  26. package/dist/core/contract.js.map +1 -1
  27. package/dist/embed/index.js +25 -13
  28. package/dist/embed/index.js.map +3 -3
  29. package/dist/local.js +1 -1
  30. package/dist/local.js.map +2 -2
  31. package/dist/react/embed/index.js +5 -2
  32. package/dist/react/embed/index.js.map +3 -3
  33. package/dist/react/index.js +2532 -11273
  34. package/dist/react/index.js.map +16 -88
  35. package/dist/react/ui/index.js +1614 -0
  36. package/dist/react/ui/index.js.map +22 -0
  37. package/dist/server.js +1 -1
  38. package/dist/server.js.map +2 -2
  39. package/dist/types/client/annotations.d.ts +23 -0
  40. package/dist/types/client/iframe.d.ts +2 -0
  41. package/dist/types/client/index.d.ts +2 -0
  42. package/dist/types/client/logger.d.ts +6 -0
  43. package/dist/types/core/annotations.d.ts +92 -0
  44. package/dist/types/core/appearance.d.ts +2 -2
  45. package/dist/types/core/bridge-endpoint.d.ts +21 -0
  46. package/dist/types/core/bridge.d.ts +137 -16
  47. package/dist/types/core/contract.d.ts +2 -0
  48. package/dist/types/core/logger.d.ts +12 -0
  49. package/dist/types/core/presentation.d.ts +2 -0
  50. package/dist/types/core/variables.d.ts +2 -5
  51. package/dist/types/embed/host.d.ts +6 -2
  52. package/dist/types/embed/index.d.ts +1 -0
  53. package/dist/types/embed/source.d.ts +1 -1
  54. package/dist/types/react/annotations/AnnotationBar.d.ts +24 -0
  55. package/dist/types/react/annotations/AnnotationControls.d.ts +10 -0
  56. package/dist/types/react/annotations/AnnotationEditor.d.ts +15 -0
  57. package/dist/types/react/annotations/AnnotationMarkers.d.ts +19 -0
  58. package/dist/types/react/annotations/AnnotationSelectionLayer.d.ts +12 -0
  59. package/dist/types/react/annotations/AnnotationTarget.d.ts +9 -0
  60. package/dist/types/react/annotations/AnnotationTooltip.d.ts +9 -0
  61. package/dist/types/react/annotations/AnnotationTrigger.d.ts +10 -0
  62. package/dist/types/react/annotations/annotation-editor-state.d.ts +56 -0
  63. package/dist/types/react/annotations/annotation-screenshot.d.ts +4 -0
  64. package/dist/types/react/annotations/annotation-targets.d.ts +33 -0
  65. package/dist/types/react/annotations/getAnnotationProps.d.ts +15 -0
  66. package/dist/types/react/annotations/styles.d.ts +3 -0
  67. package/dist/types/react/annotations/useAnnotationGeometry.d.ts +22 -0
  68. package/dist/types/react/annotations/useDataAppAnnotations.d.ts +19 -0
  69. package/dist/types/react/bindings.d.ts +110 -0
  70. package/dist/types/react/content.d.ts +24 -11
  71. package/dist/types/react/embed/bridge.d.ts +1 -1
  72. package/dist/types/react/hooks.d.ts +29 -787
  73. package/dist/types/react/index.d.ts +30 -104
  74. package/dist/types/react/source-owner.d.ts +2 -0
  75. package/dist/types/react/style-contract.d.ts +60 -0
  76. package/dist/types/react/style-validation.d.ts +2 -0
  77. package/dist/types/react/ui/AboutData.d.ts +9 -1
  78. package/dist/types/react/ui/AppHeader.d.ts +1 -2
  79. package/dist/types/react/ui/AppLayout.d.ts +3 -9
  80. package/dist/types/react/ui/AppToolbar.d.ts +6 -7
  81. package/dist/types/react/ui/AreaChart.d.ts +7 -0
  82. package/dist/types/react/ui/BarChart.d.ts +6 -0
  83. package/dist/types/react/ui/{ComparisonVisual.d.ts → Comparison.d.ts} +3 -3
  84. package/dist/types/react/ui/ContentSkeleton.d.ts +2 -0
  85. package/dist/types/react/ui/DataApp.d.ts +17 -53
  86. package/dist/types/react/ui/DataAppFrame.d.ts +42 -0
  87. package/dist/types/react/ui/DataBoundary.d.ts +4 -5
  88. package/dist/types/react/ui/DataSection.d.ts +6 -18
  89. package/dist/types/react/ui/DataSectionBoundary.d.ts +30 -0
  90. package/dist/types/react/ui/DataValue.d.ts +9 -0
  91. package/dist/types/react/ui/DataWidget.d.ts +2 -1
  92. package/dist/types/react/ui/DateTimeTooltip.d.ts +1 -1
  93. package/dist/types/react/ui/ExportControl.d.ts +4 -0
  94. package/dist/types/react/ui/HelpPopover.d.ts +3 -4
  95. package/dist/types/react/ui/InspectionContext.d.ts +2 -0
  96. package/dist/types/react/ui/InspectionProvider.d.ts +29 -0
  97. package/dist/types/react/ui/LineChart.d.ts +7 -0
  98. package/dist/types/react/ui/MetricWidget.d.ts +4 -3
  99. package/dist/types/react/ui/PieChart.d.ts +8 -0
  100. package/dist/types/react/ui/PresentStory.d.ts +2 -5
  101. package/dist/types/react/ui/RefreshControl.d.ts +1 -2
  102. package/dist/types/react/ui/ScatterChart.d.ts +17 -0
  103. package/dist/types/react/ui/SearchField.d.ts +1 -2
  104. package/dist/types/react/ui/SearchInput.d.ts +3 -1
  105. package/dist/types/react/ui/Sheet.d.ts +2 -1
  106. package/dist/types/react/ui/Skeleton.d.ts +5 -2
  107. package/dist/types/react/ui/StaticDataApp.d.ts +4 -0
  108. package/dist/types/react/ui/TableWidget.d.ts +19 -16
  109. package/dist/types/react/ui/Tabs.d.ts +6 -2
  110. package/dist/types/react/ui/TextWidget.d.ts +2 -1
  111. package/dist/types/react/ui/Toast.d.ts +8 -0
  112. package/dist/types/react/ui/Tooltip.d.ts +4 -3
  113. package/dist/types/react/ui/TrendChart.d.ts +5 -0
  114. package/dist/types/react/ui/UpdatedAt.d.ts +1 -1
  115. package/dist/types/react/ui/VisualizationWidget.d.ts +12 -13
  116. package/dist/types/react/ui/WidgetViewTabs.d.ts +1 -1
  117. package/dist/types/react/ui/chart-data.d.ts +25 -0
  118. package/dist/types/react/ui/csv-export.d.ts +19 -0
  119. package/dist/types/react/ui/data-context.d.ts +18 -7
  120. package/dist/types/react/ui/icons.d.ts +2 -0
  121. package/dist/types/react/ui/index.d.ts +74 -0
  122. package/dist/types/react/ui/metric.d.ts +1 -1
  123. package/dist/types/react/ui/presentation.d.ts +5 -1
  124. package/dist/types/react/ui/shortcuts.d.ts +7 -1
  125. package/dist/types/react/view-runtime.d.ts +29 -0
  126. package/dist/types/react/view.d.ts +21 -4
  127. package/dist/types/react/widgets.d.ts +79 -0
  128. package/dist/worker.js +381 -79
  129. package/docs/app-authoring.md +64 -30
  130. package/docs/data-context.md +89 -0
  131. package/docs/embed.md +1 -1
  132. package/docs/formatting-and-appearance.md +52 -0
  133. package/docs/hosted-apps.md +2 -15
  134. package/docs/layout.md +33 -0
  135. package/docs/local-data-apps.md +1 -1
  136. package/docs/react-embed.md +2 -2
  137. package/docs/react.md +20 -254
  138. package/docs/stories-and-export.md +52 -0
  139. package/docs/styling.md +55 -0
  140. package/docs/ui-quality.md +20 -0
  141. package/docs/ui.md +41 -0
  142. package/docs/variables.md +98 -0
  143. package/docs/views.md +127 -0
  144. package/docs/widgets.md +142 -0
  145. package/examples/starter-data-app/index.tsx +89 -44
  146. package/package.json +13 -4
  147. package/dist/chunks/contract-cxr9t12b.js +0 -18
  148. package/dist/chunks/contract-cxr9t12b.js.map +0 -10
  149. package/dist/chunks/contract-mwe7gnmh.js.map +0 -13
  150. package/dist/chunks/contract-txjy0en2.js.map +0 -10
  151. package/dist/chunks/contract-xtxza1fy.js.map +0 -12
  152. package/dist/chunks/contract-yxbjea23.js.map +0 -12
  153. package/dist/chunks/contract-zr3jd7mr.js.map +0 -12
  154. package/dist/types/react/ui/RefreshRegion.d.ts +0 -9
  155. package/dist/types/react/ui/SelectableBarChart.d.ts +0 -15
  156. package/docs/releasing.md +0 -79
  157. /package/dist/types/react/ui/{comparison.d.ts → metric-comparison.d.ts} +0 -0
package/AGENTS.md CHANGED
@@ -3,5 +3,45 @@
3
3
  Build Altertable data apps with `@altertable/data-app`. They render in an iframe
4
4
  in Altertable, a chat app, or locally in a browser.
5
5
 
6
+ Every data app includes CSV export and a story in the built-in toolbar,
7
+ both derived from the displayed result. Setup and static screens may omit them.
8
+
6
9
  Follow [app authoring](docs/app-authoring.md) for the shared workflow, the data app
7
10
  and local data app paths, and task-specific documentation.
11
+
12
+ ## Styling
13
+
14
+ Use components and typed props first; customize through app-owned `className`
15
+ and public tokens. Follow [Styling](docs/styling.md)
16
+ and [UI quality](docs/ui-quality.md).
17
+ Do not copy package classes onto markup or select private descendants.
18
+
19
+ ## Documentation
20
+
21
+ Use `<Component>` notation for React components. Keep guidance concise; leave
22
+ prop details to TypeScript and JSDoc. Describe the current API without migration
23
+ or legacy instructions.
24
+
25
+ ## App authoring
26
+
27
+ Read the matching guide before generating an app. Package contributors follow
28
+ [Contributing](CONTRIBUTING.md).
29
+
30
+ | Task | Read |
31
+ | -------------------------------------- | -------------------------------------------------------------- |
32
+ | Choose hosted or local execution | [App authoring](docs/app-authoring.md) |
33
+ | Load data and compose loading states | [Views](docs/views.md) |
34
+ | Add filters | [Variables](docs/variables.md) |
35
+ | Compose visuals, tables, and narrative | [Widgets](docs/widgets.md), [layout](docs/layout.md) |
36
+ | Define sources and evidence | [Data context](docs/data-context.md) |
37
+ | Present findings and export results | [Stories and export](docs/stories-and-export.md) |
38
+ | Format values and appearance | [Formatting and appearance](docs/formatting-and-appearance.md) |
39
+
40
+ Use `/react` with declared views and bound widgets. `/react/ui` is for setup,
41
+ static displays, and deliberately custom UI; see [direct composition](docs/ui.md).
42
+ Prefer derivation over repeated configuration. Keep static context outside loading boundaries. Derive labels, findings, and
43
+ exports from the displayed result and its input. Edit app-owned files; installed
44
+ package files are dependencies.
45
+
46
+ Keep `docs/` focused on knowledge agents need to build data apps. Put package
47
+ implementation, testing, and release guidance in `CONTRIBUTING.md`.
package/CONTRIBUTING.md CHANGED
@@ -56,6 +56,7 @@ checks. Build before running consumer tests individually.
56
56
  | Command | Purpose |
57
57
  | ------------------------------ | --------------------------------------------------- |
58
58
  | `bun run build` | Build JavaScript, declarations, and injected styles |
59
+ | `bun run check:styles` | Validate authored styling hooks |
59
60
  | `bun run typecheck` | Check source, tests, and scripts |
60
61
  | `bun run lint` | Run type-aware lint checks |
61
62
  | `bun run lint:md` | Check Markdown structure and syntax |
@@ -79,9 +80,42 @@ validation. It stays outside required checks because third-party availability an
79
80
  rate limits can cause failures unrelated to a change.
80
81
 
81
82
  For browser changes, run `bash scripts/install-test-browser.sh` once, then
82
- `bun run test:browser`. Preview UI examples at `/gallery` with
83
- `bun browser-tests/server.ts`.
83
+ `bun run test:browser`.
84
+
85
+ Run `bun run dev` to preview UI examples at `http://127.0.0.1:27418/gallery`
86
+ and a playground at `/playground` (`dev/playground.tsx`, querying the demo
87
+ tables `scripts/dev.ts` seeds). It builds once, then rebuilds `dist` when `src`
88
+ changes; open pages reload on package, fixture, and playground edits. Restart it after changing
89
+ `browser-tests/server.ts`; rerun `bun run build` to refresh declarations. Add `?delay=2000` to a host page URL
90
+ to delay its SQL responses and inspect loading states. It needs Docker: SQL runs
91
+ against a mocked Altertable API
92
+ ([altertable-mock](https://github.com/altertable-ai/altertable-mock), DuckDB)
93
+ started with Testcontainers and stopped on exit. Browser tests keep fixtures.
94
+
95
+ Open the **Widgets** tab (`/gallery?view=widgets`) for one ready example of each
96
+ composable data display inside `<VisualizationWidget>`. The other tabs cover
97
+ composed apps, variants, and request states.
84
98
 
85
99
  Use Conventional Commits and describe behavior changes and verification in PRs.
86
100
  Flag breaking API changes. Release Please owns `CHANGELOG.md`; see
87
- [Releasing](docs/releasing.md) for release setup and recovery.
101
+ [Releasing](https://github.com/altertable-ai/data-app/blob/main/.github/RELEASING.md) for release setup and recovery.
102
+
103
+ ## Focused public API
104
+
105
+ Keep exports and options focused on concrete app needs. Prefer defaults and
106
+ derivation from existing state over new knobs; keep implementation details private.
107
+
108
+ For public changes, update the relevant guide, migrate callers and starters,
109
+ and verify published usage. Flag breaking changes in commits and PRs.
110
+
111
+ Docs help agents generate data apps: show current usage and focused examples.
112
+ Keep package architecture and contributor rules here.
113
+
114
+ ## Component CSS
115
+
116
+ Keep defaults in authored CSS: inherited values in `tokens.css`, presets in
117
+ `appearance.css`, and optional overrides in native `var()` fallbacks at use sites.
118
+ Use the four layers (`atbl.tokens`, `atbl.base`, `atbl.components`,
119
+ `atbl.interaction`) and shared focus/state rules rather than duplicate control
120
+ paint. Keep geometry local. Document public variables beside declarations or
121
+ consumption sites; update the name contract in `style-contract.ts` when adding hooks.
package/README.md CHANGED
@@ -21,7 +21,7 @@ bun add @altertable/data-app
21
21
  ## Build an app
22
22
 
23
23
  Apps render in an iframe in Altertable, a chat app, or locally in a browser.
24
- Follow [app authoring](docs/app-authoring.md) to explore data and present findings.
24
+ Follow [app authoring](docs/app-authoring.md) to explore data, export displayed results as CSV, and present findings.
25
25
 
26
26
  | App | Start here |
27
27
  | ---------------------------------- | ---------------------------------------- |
@@ -38,7 +38,7 @@ For integrating apps into a host, see [embedding](docs/embed.md).
38
38
  ## Development
39
39
 
40
40
  See [Contributing](CONTRIBUTING.md) for repository structure and focused checks.
41
- Releases use [Release Please and npm trusted publishing](docs/releasing.md).
41
+ Releases use [Release Please and npm trusted publishing](https://github.com/altertable-ai/data-app/blob/main/.github/RELEASING.md).
42
42
 
43
43
  ## License
44
44
 
@@ -1,14 +1,9 @@
1
1
  import {
2
- DataSourceError2
3
- } from "./contract-yxbjea23.js";
4
- import {
5
- BRIDGE,
6
2
  PARENT_PARAM,
7
3
  MAX_PENDING,
8
4
  REQUEST_TIMEOUT_MS,
9
- isBridgeMessage,
10
- validId
11
- } from "./contract-cxr9t12b.js";
5
+ createBridgeEndpoint
6
+ } from "./contract-awa2d5b1.js";
12
7
  import {
13
8
  MessageRoutingError2,
14
9
  defineDataQueryRoute2,
@@ -81,6 +76,46 @@ function createMessageClient2(routes, transport) {
81
76
  };
82
77
  }
83
78
 
79
+ // src/client/logger.ts
80
+ function createBridgeLogger(enabled, send) {
81
+ function resolve(args) {
82
+ if (args.length === 1 && typeof args[0] === "function") {
83
+ const value = args[0]();
84
+ return Array.isArray(value) ? value : [value];
85
+ }
86
+ return args.map((arg) => typeof arg === "function" ? arg() : arg);
87
+ }
88
+ function write(method, args) {
89
+ if (!enabled())
90
+ return;
91
+ try {
92
+ send({ method, args: resolve(args) });
93
+ } catch {}
94
+ }
95
+ return {
96
+ log: (...args) => write("log", args),
97
+ info: (...args) => write("info", args),
98
+ warn: (...args) => write("warn", args),
99
+ error: (...args) => write("error", args)
100
+ };
101
+ }
102
+ function logBridgeMessage(logger, message) {
103
+ if (message.type === "runtime:log")
104
+ return;
105
+ logger.log(() => {
106
+ const metadata = { type: message.type };
107
+ if ("id" in message)
108
+ metadata.id = message.id;
109
+ if (message.type === "bridge:request") {
110
+ metadata.route = message.route;
111
+ const payload = message.payload;
112
+ if (message.route === "data:query" && payload && typeof payload === "object" && "operation" in payload && typeof payload.operation === "string")
113
+ metadata.operation = payload.operation;
114
+ }
115
+ return ["Sending message to parent", metadata];
116
+ });
117
+ }
118
+
84
119
  // src/client/iframe.ts
85
120
  function rethrowDataMessageError(error) {
86
121
  if (error instanceof MessageRoutingError2)
@@ -103,67 +138,61 @@ function createIframeTransport2({
103
138
  const pending = new Map;
104
139
  let hostState;
105
140
  const stateListeners = new Set;
106
- function send(message) {
107
- frame.parent.postMessage({ channel: BRIDGE, version: 1, documentId, sessionId, token, ...message }, parentOrigin);
108
- }
141
+ const logger = createBridgeLogger(() => !disposed && !!sessionId && !!hostState && typeof hostState === "object" && ("logging" in hostState) && hostState.logging === true, (entry) => send("runtimeLog", { payload: entry }));
142
+ const endpoint = createBridgeEndpoint({
143
+ role: "app",
144
+ origin: parentOrigin,
145
+ source: () => frame.parent,
146
+ opaque: mode === "bundle",
147
+ context: () => ({ documentId, sessionId, token }),
148
+ post(message) {
149
+ frame.parent.postMessage(message, parentOrigin);
150
+ logBridgeMessage(logger, message);
151
+ },
152
+ handlers: {
153
+ connect(message) {
154
+ if (mode === "bundle")
155
+ token = message.token;
156
+ send("ready", {});
157
+ },
158
+ initialize(message) {
159
+ if (sessionId && sessionId !== message.sessionId) {
160
+ for (const entry of pending.values())
161
+ entry.reject(new DataAppError2("The preview reconnected. Retry the request.", "bridge_reset"));
162
+ }
163
+ const first = !sessionId;
164
+ sessionId = message.sessionId;
165
+ receiveState(message.state);
166
+ if (first)
167
+ for (const entry of pending.values())
168
+ entry.start();
169
+ if (disposed)
170
+ return;
171
+ if (mode === "url")
172
+ send("runtimeReady", {});
173
+ },
174
+ stateUpdate(message) {
175
+ receiveState(message.state);
176
+ },
177
+ scriptLoad(message) {
178
+ if (mode === "bundle")
179
+ loadScript?.(message.javascript);
180
+ },
181
+ result(message) {
182
+ pending.get(message.id)?.resolve(message.response);
183
+ },
184
+ error(message) {
185
+ pending.get(message.id)?.reject(new MessageRoutingError2(message.code, message.message, message.requestId));
186
+ }
187
+ }
188
+ });
189
+ const send = endpoint.send;
190
+ const receive = endpoint.receive;
109
191
  function receiveState(state) {
110
192
  hostState = state;
111
193
  for (const listener of stateListeners)
112
194
  listener(state);
113
195
  }
114
- function receive(event) {
115
- if (event.origin !== parentOrigin || event.source !== frame.parent || !isBridgeMessage(event.data))
116
- return;
117
- const message = event.data;
118
- if (message.type === "bridge:connect") {
119
- if (mode === "bundle") {
120
- if (!validId(message.token))
121
- return;
122
- token = message.token;
123
- }
124
- send({ type: "bridge:ready" });
125
- return;
126
- }
127
- if (mode === "bundle" && (!token || message.token !== token))
128
- return;
129
- if (message.documentId !== documentId)
130
- return;
131
- if (message.type === "bridge:initialize" && validId(message.sessionId)) {
132
- if (sessionId && sessionId !== message.sessionId) {
133
- for (const entry of pending.values())
134
- entry.reject(new DataAppError2("The preview reconnected. Retry the request.", "bridge_reset"));
135
- }
136
- const first = !sessionId;
137
- sessionId = message.sessionId;
138
- if (first)
139
- for (const entry of pending.values())
140
- entry.start();
141
- receiveState(message.state);
142
- if (mode === "url")
143
- send({ type: "runtime:ready" });
144
- return;
145
- }
146
- if (!sessionId || message.sessionId !== sessionId)
147
- return;
148
- if (message.type === "state:update") {
149
- receiveState(message.state);
150
- return;
151
- }
152
- if (message.type === "script:load" && mode === "bundle" && typeof message.javascript === "string") {
153
- loadScript?.(message.javascript);
154
- return;
155
- }
156
- if (typeof message.id !== "string")
157
- return;
158
- const entry = pending.get(message.id);
159
- if (!entry)
160
- return;
161
- if (message.type === "bridge:result" && "response" in message) {
162
- entry.resolve(message.response);
163
- } else if (message.type === "bridge:error" && typeof message.code === "string" && typeof message.message === "string") {
164
- entry.reject(new MessageRoutingError2(message.code, message.message, typeof message.requestId === "string" ? message.requestId : undefined));
165
- }
166
- }
167
196
  frame.addEventListener("message", receive);
168
197
  function requestMessage(message, signal) {
169
198
  return new Promise((resolve, reject) => {
@@ -182,13 +211,13 @@ function createIframeTransport2({
182
211
  }
183
212
  function abort() {
184
213
  if (sent)
185
- send({ type: "bridge:cancel", id });
214
+ send("cancel", { id });
186
215
  cleanup();
187
216
  reject(signal?.reason);
188
217
  }
189
218
  const timer = setTimeout(() => {
190
219
  if (sent)
191
- send({ type: "bridge:cancel", id });
220
+ send("cancel", { id });
192
221
  cleanup();
193
222
  reject(new DataAppError2(sessionId ? "The data request timed out." : "The preview shell is unavailable. Reload the preview.", sessionId ? "timeout" : "bridge_unavailable"));
194
223
  }, timeoutMs);
@@ -197,8 +226,7 @@ function createIframeTransport2({
197
226
  if (sent)
198
227
  return;
199
228
  try {
200
- send({
201
- type: "bridge:request",
229
+ send("request", {
202
230
  id,
203
231
  route: message.route,
204
232
  payload: message.payload
@@ -222,8 +250,8 @@ function createIframeTransport2({
222
250
  signal?.addEventListener("abort", abort, { once: true });
223
251
  if (sessionId)
224
252
  entry.start();
225
- else
226
- send({ type: "bridge:ready" });
253
+ else if (mode === "url" || token)
254
+ send("ready", {});
227
255
  });
228
256
  }
229
257
  const messages = createMessageClient2({ "data:query": defineDataQueryRoute2(), "data:sql": sqlQueryRoute2 }, requestMessage);
@@ -231,20 +259,22 @@ function createIframeTransport2({
231
259
  return messages.request("data:query", { operation, input }, { signal }).catch(rethrowDataMessageError);
232
260
  }
233
261
  function disconnect() {
234
- send({ type: "bridge:disconnect" });
262
+ if (sessionId)
263
+ send("disconnect", {});
235
264
  sessionId = undefined;
236
265
  for (const entry of pending.values())
237
266
  entry.reject(new DataAppError2("The preview has closed.", "bridge_closed"));
238
267
  }
239
268
  function resume(event) {
240
- if (event.persisted)
241
- send({ type: "bridge:ready" });
269
+ if (event.persisted && (mode === "url" || token))
270
+ send("ready", {});
242
271
  }
243
272
  function dispose() {
244
273
  if (disposed)
245
274
  return;
246
275
  disconnect();
247
276
  disposed = true;
277
+ endpoint.dispose();
248
278
  frame.removeEventListener("message", receive);
249
279
  frame.removeEventListener("pagehide", disconnect);
250
280
  frame.removeEventListener("pageshow", resume);
@@ -253,8 +283,9 @@ function createIframeTransport2({
253
283
  frame.addEventListener("pagehide", disconnect);
254
284
  frame.addEventListener("pageshow", resume);
255
285
  if (mode === "url")
256
- send({ type: "bridge:ready" });
286
+ send("ready", {});
257
287
  return {
288
+ logger,
258
289
  request: requestMessage,
259
290
  transport: queryOperation,
260
291
  lakehouse: {
@@ -274,10 +305,12 @@ function createIframeTransport2({
274
305
  };
275
306
  },
276
307
  ready() {
277
- send({ type: "runtime:ready" });
308
+ if (!disposed && sessionId)
309
+ send("runtimeReady", {});
278
310
  },
279
311
  fail() {
280
- send({ type: "runtime:error" });
312
+ if (!disposed && sessionId)
313
+ send("runtimeError", {});
281
314
  }
282
315
  };
283
316
  }
@@ -378,145 +411,6 @@ function getDataAppTransport2(frame = window) {
378
411
  return frame[installedKey];
379
412
  }
380
413
 
381
- // src/core/operation.ts
382
- async function executeDataOperation(operation, value, {
383
- operationName,
384
- lakehouse,
385
- signal: requestSignal,
386
- includeSql,
387
- requestId
388
- }) {
389
- requestSignal.throwIfAborted();
390
- let input;
391
- try {
392
- input = operation.input(value);
393
- } catch {
394
- throw new OperationInputError;
395
- }
396
- const signal = AbortSignal.any([
397
- requestSignal,
398
- AbortSignal.timeout(operation.policy.maxDurationMs)
399
- ]);
400
- const execution = createOperationLakehouse(operation, lakehouse, signal, operationName);
401
- try {
402
- const output = await runOperation(operation, input, {
403
- lakehouse: execution.lakehouse,
404
- signal
405
- });
406
- const body = {
407
- data: operation.output(output),
408
- requestId,
409
- queriedAt: new Date().toISOString(),
410
- queryIds: execution.queryIds,
411
- ...operation.policy.exposeSql && includeSql ? { queries: execution.queries } : {}
412
- };
413
- const serializedBody = JSON.stringify(body);
414
- const responseBytes = new TextEncoder().encode(serializedBody).byteLength;
415
- if (responseBytes > (operation.policy.maxResponseBytes ?? 1e6))
416
- throw new Error("Response exceeds byte limit.");
417
- return { body, serializedBody };
418
- } catch (error) {
419
- if (signal.aborted && !(error instanceof DataSourceError2))
420
- throw new OperationTimeoutError;
421
- throw error;
422
- }
423
- }
424
- function createOperationLakehouse(operation, source, signal, operationName) {
425
- const queryIds = [];
426
- const queries = [];
427
- const lakehouse = {
428
- async queryAll(statement, options) {
429
- if (!Number.isInteger(options.limit) || options.limit < 1)
430
- throw new Error("Query needs a positive row limit.");
431
- if (operation.queryNames && !Object.values(operation.queryNames).includes(options.name ?? ""))
432
- throw new Error(`Query name is not registered for operation ${operationName}.`);
433
- const query = {
434
- name: options.name ?? `Query ${queries.length + 1}`,
435
- statement
436
- };
437
- queries.push(query);
438
- const limit = Math.min(options.limit, operation.policy.maxQueryRows);
439
- let result;
440
- try {
441
- result = await source.queryAll(statement, {
442
- limit,
443
- signal: AbortSignal.any([signal, options.signal])
444
- });
445
- } catch (error) {
446
- if (error instanceof DataSourceError2)
447
- error.queryName = query.name;
448
- throw error;
449
- }
450
- if (result.rows.length > limit)
451
- throw new Error("Result exceeds row limit.");
452
- if (result.queryId) {
453
- query.queryId = result.queryId;
454
- queryIds.push(result.queryId);
455
- }
456
- return result;
457
- }
458
- };
459
- return { lakehouse, queries, queryIds };
460
- }
461
- async function runOperation(operation, input, { lakehouse, signal }) {
462
- let abort;
463
- try {
464
- signal.throwIfAborted();
465
- const cancelled = new Promise((_, reject) => {
466
- function rejectAborted() {
467
- reject(new Error("Request aborted."));
468
- }
469
- abort = rejectAborted;
470
- signal.addEventListener("abort", rejectAborted, { once: true });
471
- if (signal.aborted)
472
- rejectAborted();
473
- });
474
- return await Promise.race([
475
- cancelled,
476
- Promise.resolve().then(() => {
477
- signal.throwIfAborted();
478
- return operation.run({ lakehouse, signal }, input);
479
- })
480
- ]);
481
- } finally {
482
- if (abort)
483
- signal.removeEventListener("abort", abort);
484
- }
485
- }
486
-
487
- class OperationTimeoutError extends Error {
488
- }
489
-
490
- class OperationInputError extends Error {
491
- }
492
- var sourceErrorMessages = {
493
- unauthorized: "This app could not authenticate its data connection. Contact the app owner.",
494
- forbidden: "This app cannot access the requested data. Contact the app owner.",
495
- rate_limited: "The lakehouse is busy. Wait a moment and retry.",
496
- query_rejected: "A lakehouse query was rejected. Check the app's data operation.",
497
- unavailable: "The lakehouse is unavailable. Check the connection and retry."
498
- };
499
- function toDataOperationFailure(error, aborted = false) {
500
- if (error instanceof OperationInputError)
501
- return {
502
- status: 400,
503
- code: "invalid_input",
504
- message: "Check this operation's inputs."
505
- };
506
- if (error instanceof DataSourceError2)
507
- return {
508
- status: error.reason === "rate_limited" ? 429 : 502,
509
- code: `source_${error.reason}`,
510
- message: sourceErrorMessages[error.reason]
511
- };
512
- const timedOut = aborted || error instanceof OperationTimeoutError;
513
- return {
514
- status: timedOut ? 504 : 502,
515
- code: timedOut ? "timeout" : "query_failed",
516
- message: timedOut ? "The data request timed out." : "The data request failed."
517
- };
518
- }
519
-
520
- export { DataAppError2, createHttpTransport2, createMessageClient2, createIframeTransport2, localFrameBridge, installDataAppTransport2, getDataAppTransport2, executeDataOperation, toDataOperationFailure };
414
+ export { DataAppError2, createHttpTransport2, createMessageClient2, createIframeTransport2, localFrameBridge, installDataAppTransport2, getDataAppTransport2 };
521
415
 
522
- //# debugId=4AB92B621002707764756E2164756E21
416
+ //# debugId=F13D3D498CB70AA064756E2164756E21
@@ -0,0 +1,13 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/client/transport.ts", "../src/client/messages.ts", "../src/client/logger.ts", "../src/client/iframe.ts"],
4
+ "sourcesContent": [
5
+ "import type { TransportResponse } from '@/src/core/bridge';\n\nexport type DataTransport = (\n operation: string,\n input: unknown,\n signal?: AbortSignal\n) => Promise<TransportResponse>;\n\n// A bootstrap and its app may bundle independent copies in the same window.\nconst errorBrand = Symbol.for('@altertable/data-app/DataAppError');\n\nexport class DataAppError extends Error {\n readonly [errorBrand] = true;\n\n static [Symbol.hasInstance](value: unknown): boolean {\n return (\n value instanceof Error &&\n (value as { [errorBrand]?: unknown })[errorBrand] === true\n );\n }\n\n constructor(\n message: string,\n public readonly code: string,\n public readonly requestId?: string\n ) {\n super(message);\n this.name = 'DataAppError';\n }\n}\n\nexport function createHttpTransport({\n endpoint = '/api/data',\n fetch: request = globalThis.fetch,\n}: {\n endpoint?: string;\n fetch?: typeof fetch;\n} = {}): DataTransport {\n async function requestData(\n operation: string,\n input: unknown,\n signal?: AbortSignal\n ): Promise<TransportResponse> {\n const response = await request(\n `${endpoint.replace(/\\/$/, '')}/${encodeURIComponent(operation)}`,\n {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify(input),\n signal,\n }\n );\n try {\n return { status: response.status, body: await response.json() };\n } catch (error) {\n if (signal?.aborted) throw error;\n throw new DataAppError(\n response.ok ? 'The data response was invalid.' : 'Could not load data.',\n response.ok ? 'invalid_response' : 'request_failed'\n );\n }\n }\n\n return requestData;\n}\n",
6
+ "import {\n MessageRoutingError,\n type MessageInput,\n type MessageOutput,\n type MessageRoutes,\n type MessageTransport,\n} from '@/src/core/messages';\n\n/** Both ends validate using the same contracts; the transport owns delivery and cancellation. */\nexport function createMessageClient<const Routes extends MessageRoutes>(\n routes: Routes,\n transport: MessageTransport\n) {\n return {\n async request<\n Name extends keyof Routes & string,\n const Input extends MessageInput<NoInfer<Routes[Name]>>,\n >(\n route: Name,\n payload: Input,\n { signal }: { signal?: AbortSignal } = {}\n ): Promise<MessageOutput<Routes[Name], Input>> {\n signal?.throwIfAborted();\n if (!Object.hasOwn(routes, route))\n throw new MessageRoutingError(\n 'unknown_route',\n 'Unknown message route.'\n );\n const contract = routes[route]!;\n let input: unknown;\n try {\n input = contract.input(payload);\n } catch {\n throw new MessageRoutingError(\n 'invalid_payload',\n 'Invalid message payload.'\n );\n }\n const response = await transport({ route, payload: input }, signal);\n signal?.throwIfAborted();\n try {\n return contract.output(response, input as never) as MessageOutput<\n Routes[Name],\n Input\n >;\n } catch (error) {\n if (error instanceof MessageRoutingError) throw error;\n throw new MessageRoutingError(\n 'invalid_response',\n 'Invalid message response.'\n );\n }\n },\n };\n}\n",
7
+ "import type { BridgeMessage } from '@/src/core/bridge';\nimport { type DataAppLogger, type LogEntry } from '@/src/core/logger';\n\n/** Lazy arguments run in the iframe; only resolved values cross the bridge. */\nexport function createBridgeLogger(\n enabled: () => boolean,\n send: (entry: LogEntry) => void\n): DataAppLogger {\n function resolve(args: unknown[]): unknown[] {\n if (args.length === 1 && typeof args[0] === 'function') {\n const value: unknown = args[0]();\n return Array.isArray(value) ? value : [value];\n }\n return args.map(arg => (typeof arg === 'function' ? arg() : arg));\n }\n\n function write(method: keyof DataAppLogger, args: unknown[]) {\n if (!enabled()) return;\n try {\n send({ method, args: resolve(args) });\n } catch {\n // Logging must not interrupt the app or recursively log delivery failures.\n }\n }\n\n return {\n log: (...args) => write('log', args),\n info: (...args) => write('info', args),\n warn: (...args) => write('warn', args),\n error: (...args) => write('error', args),\n };\n}\n\n/** Log only delivery metadata; payloads and session credentials stay private. */\nexport function logBridgeMessage(\n logger: DataAppLogger,\n message: BridgeMessage\n) {\n if (message.type === 'runtime:log') return;\n logger.log(() => {\n const metadata: {\n type: BridgeMessage['type'];\n id?: string;\n route?: string;\n operation?: string;\n } = { type: message.type };\n if ('id' in message) metadata.id = message.id;\n if (message.type === 'bridge:request') {\n metadata.route = message.route;\n const payload = message.payload;\n if (\n message.route === 'data:query' &&\n payload &&\n typeof payload === 'object' &&\n 'operation' in payload &&\n typeof payload.operation === 'string'\n )\n metadata.operation = payload.operation;\n }\n return ['Sending message to parent', metadata];\n });\n}\n",
8
+ "import { createBridgeEndpoint } from '@/src/core/bridge-endpoint';\nimport {\n PARENT_PARAM,\n MAX_PENDING,\n REQUEST_TIMEOUT_MS,\n type TransportResponse,\n} from '@/src/core/bridge';\nimport {\n defineDataQueryRoute,\n sqlQueryRoute,\n MessageRoutingError,\n type RoutedMessage,\n} from '@/src/core/messages';\nimport type { Lakehouse } from '@/src/core/contract';\nimport { createMessageClient } from '@/src/client/messages';\nimport { DataAppError } from '@/src/client/transport';\nimport { createBridgeLogger, logBridgeMessage } from '@/src/client/logger';\n\ntype Pending = {\n start: () => void;\n reject: (error: unknown) => void;\n resolve: (value: unknown) => void;\n};\n\n/** Data clients expose one error type for HTTP and message delivery. */\nfunction rethrowDataMessageError(error: unknown): never {\n if (error instanceof MessageRoutingError)\n throw new DataAppError(error.message, error.code, error.requestId);\n throw error;\n}\n\n/** One bridge per document, shared by all clients and retained across module hot replacement. */\nexport function createIframeTransport({\n parentOrigin,\n window: frame = window,\n timeoutMs = REQUEST_TIMEOUT_MS,\n mode = 'url',\n loadScript,\n}: {\n parentOrigin: string;\n window?: Window;\n timeoutMs?: number;\n mode?: 'url' | 'bundle';\n loadScript?: (javascript: string) => void;\n}) {\n if (new URL(parentOrigin).origin !== parentOrigin)\n throw new Error('Expected an exact parent origin.');\n const documentId = crypto.randomUUID();\n let token: string | undefined;\n let sessionId: string | undefined;\n let disposed = false;\n const pending = new Map<string, Pending>();\n let hostState: unknown;\n const stateListeners = new Set<(state: unknown) => void>();\n const logger = createBridgeLogger(\n () =>\n !disposed &&\n !!sessionId &&\n !!hostState &&\n typeof hostState === 'object' &&\n 'logging' in hostState &&\n hostState.logging === true,\n entry => send('runtimeLog', { payload: entry })\n );\n\n const endpoint = createBridgeEndpoint({\n role: 'app',\n origin: parentOrigin,\n source: () => frame.parent,\n opaque: mode === 'bundle',\n context: () => ({ documentId, sessionId, token }),\n post(message) {\n frame.parent.postMessage(message, parentOrigin);\n logBridgeMessage(logger, message);\n },\n handlers: {\n connect(message) {\n if (mode === 'bundle') token = message.token;\n send('ready', {});\n },\n initialize(message) {\n if (sessionId && sessionId !== message.sessionId) {\n for (const entry of pending.values())\n entry.reject(\n new DataAppError(\n 'The preview reconnected. Retry the request.',\n 'bridge_reset'\n )\n );\n }\n const first = !sessionId;\n sessionId = message.sessionId;\n receiveState(message.state);\n if (first) for (const entry of pending.values()) entry.start();\n if (disposed) return;\n if (mode === 'url') send('runtimeReady', {});\n },\n stateUpdate(message) {\n receiveState(message.state);\n },\n scriptLoad(message) {\n if (mode === 'bundle') loadScript?.(message.javascript);\n },\n result(message) {\n pending.get(message.id)?.resolve(message.response);\n },\n error(message) {\n pending\n .get(message.id)\n ?.reject(\n new MessageRoutingError(\n message.code,\n message.message,\n message.requestId\n )\n );\n },\n },\n });\n const send = endpoint.send;\n const receive = endpoint.receive;\n\n function receiveState(state: unknown) {\n hostState = state;\n for (const listener of stateListeners) listener(state);\n }\n\n frame.addEventListener('message', receive);\n\n function requestMessage(\n message: RoutedMessage,\n signal?: AbortSignal\n ): Promise<unknown> {\n return new Promise((resolve, reject) => {\n if (disposed)\n return reject(\n new DataAppError('The preview has closed.', 'bridge_closed')\n );\n if (signal?.aborted) return reject(signal.reason);\n if (pending.size >= MAX_PENDING)\n return reject(\n new DataAppError('Too many pending data requests.', 'bridge_busy')\n );\n const id = crypto.randomUUID();\n let sent = false;\n\n function cleanup() {\n clearTimeout(timer);\n signal?.removeEventListener('abort', abort);\n pending.delete(id);\n }\n\n function abort() {\n if (sent) send('cancel', { id });\n cleanup();\n reject(signal?.reason);\n }\n\n const timer = setTimeout(() => {\n if (sent) send('cancel', { id });\n cleanup();\n reject(\n new DataAppError(\n sessionId\n ? 'The data request timed out.'\n : 'The preview shell is unavailable. Reload the preview.',\n sessionId ? 'timeout' : 'bridge_unavailable'\n )\n );\n }, timeoutMs);\n const entry: Pending = {\n start() {\n if (sent) return;\n try {\n send('request', {\n id,\n route: message.route,\n payload: message.payload,\n });\n sent = true;\n } catch {\n cleanup();\n reject(\n new DataAppError(\n 'The message payload could not be sent.',\n 'invalid_payload'\n )\n );\n }\n },\n resolve(value) {\n cleanup();\n resolve(value);\n },\n reject(error) {\n cleanup();\n reject(error);\n },\n };\n pending.set(id, entry);\n signal?.addEventListener('abort', abort, { once: true });\n if (sessionId) entry.start();\n else if (mode === 'url' || token) send('ready', {});\n });\n }\n\n const messages = createMessageClient(\n { 'data:query': defineDataQueryRoute(), 'data:sql': sqlQueryRoute },\n requestMessage\n );\n\n function queryOperation(\n operation: string,\n input: unknown,\n signal?: AbortSignal\n ): Promise<TransportResponse> {\n return messages\n .request('data:query', { operation, input }, { signal })\n .catch(rethrowDataMessageError);\n }\n\n function disconnect() {\n if (sessionId) send('disconnect', {});\n sessionId = undefined;\n for (const entry of pending.values())\n entry.reject(\n new DataAppError('The preview has closed.', 'bridge_closed')\n );\n }\n\n function resume(event: PageTransitionEvent) {\n if (event.persisted && (mode === 'url' || token)) send('ready', {});\n }\n\n function dispose() {\n if (disposed) return;\n disconnect();\n disposed = true;\n endpoint.dispose();\n frame.removeEventListener('message', receive);\n frame.removeEventListener('pagehide', disconnect);\n frame.removeEventListener('pageshow', resume);\n stateListeners.clear();\n }\n\n frame.addEventListener('pagehide', disconnect);\n frame.addEventListener('pageshow', resume);\n if (mode === 'url') send('ready', {});\n\n return {\n logger,\n request: requestMessage,\n transport: queryOperation,\n lakehouse: {\n queryAll(statement, { limit, signal }) {\n return messages\n .request('data:sql', { statement, limit }, { signal })\n .catch(rethrowDataMessageError);\n },\n } satisfies Lakehouse,\n dispose,\n mode,\n snapshot() {\n return hostState;\n },\n subscribe(listener: (state: unknown) => void) {\n stateListeners.add(listener);\n\n return () => {\n stateListeners.delete(listener);\n };\n },\n ready() {\n if (!disposed && sessionId) send('runtimeReady', {});\n },\n fail() {\n if (!disposed && sessionId) send('runtimeError', {});\n },\n };\n}\n\nexport type IframeTransport = ReturnType<typeof createIframeTransport>;\n\nconst bridgeKey = Symbol.for('altertable.localFrameBridge');\nconst installedKey = Symbol.for('altertable.installedTransport');\ntype LocalBridge = Pick<\n ReturnType<typeof createIframeTransport>,\n 'transport'\n> & { connect?: () => Promise<ReturnType<typeof createIframeTransport>> };\ntype FrameWindow = Window & {\n [bridgeKey]?: LocalBridge;\n [installedKey]?: ReturnType<typeof createIframeTransport>;\n};\n\n/** The URL opts into local preview; only same-origin server configuration establishes trust. */\nexport function localFrameBridge(window?: Window): LocalBridge | undefined {\n const activeWindow =\n window ??\n (typeof globalThis.window === 'undefined' ? undefined : globalThis.window);\n if (!activeWindow) return undefined;\n const frame = activeWindow as FrameWindow;\n if (frame[bridgeKey]) return frame[bridgeKey];\n const parentOrigin =\n new URL(frame.location.href).searchParams.get(PARENT_PARAM) ?? '';\n if (!parentOrigin) return undefined;\n\n async function connect(parentOrigin: string) {\n try {\n const response = await frame.fetch('/__altertable/parent', {\n signal: AbortSignal.timeout(5000),\n });\n const config = (await response.json()) as { origin?: unknown };\n if (\n !response.ok ||\n config.origin !== parentOrigin ||\n frame.parent === frame\n )\n throw new Error('Invalid local parent configuration.');\n // Another owner can install a trusted bridge while configuration is pending.\n if (frame[installedKey]) return frame[installedKey];\n if (frame[bridgeKey] !== proxy)\n throw new Error('Preview transport owner changed.');\n const bridge = createIframeTransport({ parentOrigin, window: frame });\n frame[bridgeKey] = bridge;\n frame[installedKey] = bridge;\n\n return bridge;\n } catch {\n throw new DataAppError(\n 'The preview shell could not be verified. Open the URL printed by altertable app dev.',\n 'bridge_unavailable'\n );\n }\n }\n\n let connection: Promise<ReturnType<typeof createIframeTransport>> | undefined;\n\n function getConnection() {\n const installed = frame[installedKey];\n if (installed) return Promise.resolve(installed);\n if (!connection) {\n const attempt = connect(parentOrigin);\n connection = attempt;\n // Clear only this failed attempt; retained proxy references can explicitly retry.\n void attempt.catch(() => {\n if (connection === attempt) connection = undefined;\n });\n }\n\n return connection;\n }\n\n const proxy: LocalBridge = {\n async transport(operation, input, signal) {\n signal?.throwIfAborted();\n const attempt = getConnection();\n let abort: (() => void) | undefined;\n try {\n const bridge = signal\n ? await Promise.race([\n attempt,\n new Promise<never>((_, reject) => {\n const requestSignal = signal;\n\n function handleAbort() {\n reject(requestSignal.reason);\n }\n\n abort = handleAbort;\n requestSignal.addEventListener('abort', handleAbort, {\n once: true,\n });\n }),\n ])\n : await attempt;\n signal?.throwIfAborted();\n\n return bridge.transport(operation, input, signal);\n } finally {\n if (abort) signal?.removeEventListener('abort', abort);\n }\n },\n connect: getConnection,\n };\n frame[bridgeKey] = proxy;\n // Static mounting still verifies eagerly, without an unhandled rejection.\n void getConnection().catch(() => {});\n\n return proxy;\n}\n\n/** Install an explicitly trusted transport for hosted apps and their URL-backed controls. */\nexport function installDataAppTransport(\n bridge: ReturnType<typeof createIframeTransport>,\n frame: Window = window\n) {\n const target = frame as FrameWindow;\n if (target[installedKey])\n throw new Error('A data app transport is already installed.');\n target[bridgeKey] = bridge;\n target[installedKey] = bridge;\n\n return () => {\n if (target[bridgeKey] === bridge) delete target[bridgeKey];\n if (target[installedKey] === bridge) delete target[installedKey];\n bridge.dispose();\n };\n}\n\n/** The bootstrap installs this before executing app code. URL apps can install an explicit connection. */\nexport function getDataAppTransport(frame: Window = window) {\n return (frame as FrameWindow)[installedKey];\n}\n"
9
+ ],
10
+ "mappings": ";;;;;;;;;;;;;AASA,IAAM,aAAa,OAAO,IAAI,mCAAmC;AAAA;AAE1D,MAAM,sBAAqB,MAAM;AAAA,EAYpB;AAAA,EACA;AAAA,GAZR,cAAc;AAAA,UAEhB,OAAO,YAAY,CAAC,OAAyB;AAAA,IACnD,OACE,iBAAiB,SAChB,MAAqC,gBAAgB;AAAA;AAAA,EAI1D,WAAW,CACT,SACgB,MACA,WAChB;AAAA,IACA,MAAM,OAAO;AAAA,IAHG;AAAA,IACA;AAAA,IAGhB,KAAK,OAAO;AAAA;AAEhB;AAEO,SAAS,oBAAmB;AAAA,EACjC,WAAW;AAAA,EACX,OAAO,UAAU,WAAW;AAAA,IAI1B,CAAC,GAAkB;AAAA,EACrB,eAAe,WAAW,CACxB,WACA,OACA,QAC4B;AAAA,IAC5B,MAAM,WAAW,MAAM,QACrB,GAAG,SAAS,QAAQ,OAAO,EAAE,KAAK,mBAAmB,SAAS,KAC9D;AAAA,MACE,QAAQ;AAAA,MACR,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,MAC9C,MAAM,KAAK,UAAU,KAAK;AAAA,MAC1B;AAAA,IACF,CACF;AAAA,IACA,IAAI;AAAA,MACF,OAAO,EAAE,QAAQ,SAAS,QAAQ,MAAM,MAAM,SAAS,KAAK,EAAE;AAAA,MAC9D,OAAO,OAAO;AAAA,MACd,IAAI,QAAQ;AAAA,QAAS,MAAM;AAAA,MAC3B,MAAM,IA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