@altertable/data-app 0.66.0 → 0.67.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 (131) hide show
  1. package/CONTRIBUTING.md +22 -16
  2. package/dist/chunks/{contract-19ckn3n7.js → index-23dktynd.js} +8 -6
  3. package/dist/chunks/index-23dktynd.js.map +10 -0
  4. package/dist/chunks/{contract-havnjmdr.js → index-8qfxv0h5.js} +2272 -1123
  5. package/dist/chunks/index-8qfxv0h5.js.map +108 -0
  6. package/dist/chunks/{contract-rfbakka4.js → index-ag0cgnvq.js} +169 -35
  7. package/dist/chunks/index-ag0cgnvq.js.map +13 -0
  8. package/dist/chunks/index-dq7b35fn.js +307 -0
  9. package/dist/chunks/index-dq7b35fn.js.map +13 -0
  10. package/dist/chunks/{contract-e11m4y7f.js → index-ev2b5aaf.js} +11 -6
  11. package/dist/chunks/{contract-e11m4y7f.js.map → index-ev2b5aaf.js.map} +3 -3
  12. package/dist/chunks/{contract-awa2d5b1.js → index-f5cnbrjz.js} +19 -2
  13. package/dist/chunks/{contract-awa2d5b1.js.map → index-f5cnbrjz.js.map} +4 -3
  14. package/dist/chunks/{contract-13j5zb3c.js → index-ktmvs916.js} +8 -7
  15. package/dist/chunks/index-ktmvs916.js.map +13 -0
  16. package/dist/chunks/index-mt93ff2b.js +28 -0
  17. package/dist/chunks/index-mt93ff2b.js.map +10 -0
  18. package/dist/chunks/{contract-tf8c3qpv.js → index-qd5xgx6y.js} +46 -5
  19. package/dist/chunks/index-qd5xgx6y.js.map +13 -0
  20. package/dist/chunks/{contract-pk603qj7.js → index-x69p7cv7.js} +12 -9
  21. package/dist/chunks/index-x69p7cv7.js.map +10 -0
  22. package/dist/client/index.js +6 -6
  23. package/dist/core/appearance.js +1 -1
  24. package/dist/core/config.js +7 -3
  25. package/dist/core/config.js.map +1 -1
  26. package/dist/core/contract.js +14 -6
  27. package/dist/core/contract.js.map +1 -1
  28. package/dist/core/format.js +1 -1
  29. package/dist/embed/index.js +12 -10
  30. package/dist/embed/index.js.map +4 -4
  31. package/dist/index.js +12 -0
  32. package/dist/index.js.map +9 -0
  33. package/dist/local.js +20 -30
  34. package/dist/local.js.map +7 -8
  35. package/dist/react/embed/index.js +1 -1
  36. package/dist/react/embed/index.js.map +2 -2
  37. package/dist/react/index.js +57 -19
  38. package/dist/react/index.js.map +4 -4
  39. package/dist/react/ui/index.js +836 -178
  40. package/dist/react/ui/index.js.map +15 -9
  41. package/dist/server.js +13 -26
  42. package/dist/server.js.map +6 -7
  43. package/dist/types/client/annotations.d.ts +4 -0
  44. package/dist/types/client/data-client.d.ts +1 -2
  45. package/dist/types/client/iframe.d.ts +4 -2
  46. package/dist/types/core/annotations.d.ts +2 -0
  47. package/dist/types/core/config.d.ts +48 -4
  48. package/dist/types/core/contract.d.ts +20 -12
  49. package/dist/types/core/dimension.d.ts +6 -4
  50. package/dist/types/core/filters.d.ts +44 -0
  51. package/dist/types/core/messages.d.ts +2 -0
  52. package/dist/types/core/operation-types.d.ts +5 -2
  53. package/dist/types/core/operation.d.ts +3 -4
  54. package/dist/types/core/queries.d.ts +16 -0
  55. package/dist/types/core/uuid.d.ts +2 -0
  56. package/dist/types/core/variables.d.ts +32 -13
  57. package/dist/types/embed/runtime-html.d.ts +2 -0
  58. package/dist/types/embed/source.d.ts +2 -1
  59. package/dist/types/index.d.ts +3 -0
  60. package/dist/types/react/annotations/AnnotationBar.d.ts +7 -1
  61. package/dist/types/react/annotations/AnnotationEditor.d.ts +2 -1
  62. package/dist/types/react/annotations/useDataAppAnnotations.d.ts +3 -0
  63. package/dist/types/react/app-context.d.ts +3 -0
  64. package/dist/types/react/index.d.ts +3 -3
  65. package/dist/types/react/mount.d.ts +6 -4
  66. package/dist/types/react/style-contract.d.ts +22 -2
  67. package/dist/types/react/ui/Button.d.ts +3 -3
  68. package/dist/types/react/ui/ChartLegend.d.ts +31 -0
  69. package/dist/types/react/ui/Checkbox.d.ts +15 -4
  70. package/dist/types/react/ui/CheckboxGroup.d.ts +7 -0
  71. package/dist/types/react/ui/{Combobox.d.ts → ChoicePicker.d.ts} +10 -15
  72. package/dist/types/react/ui/ComposedChart.d.ts +41 -0
  73. package/dist/types/react/ui/ComposedChartLegend.d.ts +8 -0
  74. package/dist/types/react/ui/DataAppFrame.d.ts +1 -2
  75. package/dist/types/react/ui/DimensionPicker.d.ts +1 -1
  76. package/dist/types/react/ui/FilterActions.d.ts +10 -0
  77. package/dist/types/react/ui/FilterBar.d.ts +3 -0
  78. package/dist/types/react/ui/GettingStarted.d.ts +2 -4
  79. package/dist/types/react/ui/Menu.d.ts +12 -0
  80. package/dist/types/react/ui/NumberField.d.ts +27 -0
  81. package/dist/types/react/ui/NumberFilterPicker.d.ts +9 -0
  82. package/dist/types/react/ui/PieChart.d.ts +5 -2
  83. package/dist/types/react/ui/RadioGroup.d.ts +18 -0
  84. package/dist/types/react/ui/SearchInput.d.ts +2 -2
  85. package/dist/types/react/ui/Select.d.ts +14 -0
  86. package/dist/types/react/ui/SelectionMark.d.ts +2 -1
  87. package/dist/types/react/ui/TooltipSurface.d.ts +3 -0
  88. package/dist/types/react/ui/chart-data.d.ts +1 -1
  89. package/dist/types/react/ui/chart-primitives.d.ts +20 -0
  90. package/dist/types/react/ui/icons.d.ts +1 -0
  91. package/dist/types/react/ui/index.d.ts +26 -2
  92. package/dist/types/react/ui/keyboard.d.ts +6 -0
  93. package/dist/types/react/ui/shortcuts.d.ts +7 -0
  94. package/dist/types/react/ui/useAppAppearance.d.ts +1 -1
  95. package/dist/types/react/ui/variables.d.ts +4 -2
  96. package/dist/types/react/view-controls.d.ts +3 -1
  97. package/dist/types/server/handler.d.ts +4 -4
  98. package/dist/worker.js +20 -737
  99. package/docs/app-authoring.md +15 -1
  100. package/docs/client.md +8 -8
  101. package/docs/contract.md +42 -20
  102. package/docs/data-context.md +8 -6
  103. package/docs/embed.md +10 -2
  104. package/docs/formatting-and-appearance.md +23 -7
  105. package/docs/hosted-apps.md +9 -2
  106. package/docs/layout.md +1 -1
  107. package/docs/react-embed.md +3 -2
  108. package/docs/react.md +4 -3
  109. package/docs/server-bun.md +1 -1
  110. package/docs/server.md +4 -4
  111. package/docs/styling.md +10 -3
  112. package/docs/ui.md +158 -3
  113. package/docs/variables.md +80 -7
  114. package/docs/views.md +4 -8
  115. package/docs/widgets.md +16 -13
  116. package/examples/starter-data-app/index.tsx +34 -32
  117. package/package.json +16 -11
  118. package/dist/chunks/contract-13j5zb3c.js.map +0 -13
  119. package/dist/chunks/contract-19ckn3n7.js.map +0 -10
  120. package/dist/chunks/contract-h8a6f559.js +0 -286
  121. package/dist/chunks/contract-h8a6f559.js.map +0 -12
  122. package/dist/chunks/contract-havnjmdr.js.map +0 -99
  123. package/dist/chunks/contract-pk603qj7.js.map +0 -10
  124. package/dist/chunks/contract-rfbakka4.js.map +0 -13
  125. package/dist/chunks/contract-tf8c3qpv.js.map +0 -11
  126. package/dist/chunks/contract-wz59z8pq.js +0 -8
  127. package/dist/chunks/contract-wz59z8pq.js.map +0 -10
  128. /package/dist/chunks/{contract-m6n8ctfc.js → index-m6n8ctfc.js} +0 -0
  129. /package/dist/chunks/{contract-m6n8ctfc.js.map → index-m6n8ctfc.js.map} +0 -0
  130. /package/dist/chunks/{contract-mev09s5v.js → index-mev09s5v.js} +0 -0
  131. /package/dist/chunks/{contract-mev09s5v.js.map → index-mev09s5v.js.map} +0 -0
@@ -1,286 +0,0 @@
1
- import {
2
- PARENT_PARAM,
3
- MAX_PENDING,
4
- REQUEST_TIMEOUT_MS,
5
- validId,
6
- createBridgeEndpoint
7
- } from "./contract-awa2d5b1.js";
8
- import {
9
- MessageRoutingError2
10
- } from "./contract-tf8c3qpv.js";
11
-
12
- // src/embed/host.ts
13
- function attachDataAppConnection({
14
- iframe,
15
- connection,
16
- javascript,
17
- presentation,
18
- logger,
19
- onStatusChange,
20
- onDiagnostic,
21
- onMessage,
22
- window: host = window
23
- }) {
24
- const frameOrigin = connection.type === "origin" ? connection.origin : "null";
25
- if (connection.type === "origin" && new URL(frameOrigin).origin !== frameOrigin)
26
- throw new Error("Expected an exact frame origin.");
27
- if (connection.type === "opaque" && !validId(connection.token))
28
- throw new Error("Invalid sandbox token.");
29
- let token = connection.type === "opaque" ? connection.token : undefined;
30
- const targetOrigin = connection.type === "opaque" ? "*" : frameOrigin;
31
- let currentPresentation;
32
- let presentationIdentity;
33
- let disposed = false;
34
- let documentId;
35
- let sessionId;
36
- const pending = new Map;
37
- function hostState() {
38
- return {
39
- search: host.location.search,
40
- hash: host.location.hash,
41
- ...currentPresentation ? { presentation: currentPresentation } : {},
42
- logging: logger !== undefined
43
- };
44
- }
45
- function setLogger(value) {
46
- if (disposed || value === logger)
47
- return;
48
- const wasEnabled = logger !== undefined;
49
- logger = value;
50
- if (wasEnabled !== (logger !== undefined))
51
- publishState();
52
- }
53
- function setPresentation(value) {
54
- if (disposed)
55
- return;
56
- const identity = JSON.stringify(value);
57
- if (identity === presentationIdentity)
58
- return;
59
- presentationIdentity = identity;
60
- currentPresentation = identity === undefined ? undefined : JSON.parse(identity);
61
- publishState();
62
- }
63
- function cancelAll() {
64
- for (const controller of pending.values())
65
- controller.abort();
66
- pending.clear();
67
- }
68
- const endpoint = createBridgeEndpoint({
69
- role: "host",
70
- origin: frameOrigin,
71
- source: () => iframe.contentWindow,
72
- opaque: connection.type === "opaque",
73
- context: () => ({ documentId, sessionId, token }),
74
- post: (message) => iframe.contentWindow?.postMessage(message, targetOrigin),
75
- diagnostic: (direction, type) => onDiagnostic?.({ direction, type }),
76
- invalidRequest: (id) => {
77
- if (pending.has(id))
78
- return;
79
- if (pending.size >= MAX_PENDING)
80
- error(id, "bridge_busy", "Too many pending data requests.");
81
- else
82
- error(id, "invalid_message", "Invalid message route.");
83
- },
84
- handlers: {
85
- ready(message) {
86
- if (message.documentId !== documentId) {
87
- cancelAll();
88
- documentId = message.documentId;
89
- sessionId = crypto.randomUUID();
90
- }
91
- onStatusChange?.("connected");
92
- if (disposed)
93
- return;
94
- send("initialize", { state: hostState() });
95
- if (disposed)
96
- return;
97
- if (javascript !== undefined)
98
- send("scriptLoad", { javascript });
99
- },
100
- runtimeLog({ payload }) {
101
- try {
102
- logger?.[payload.method](...payload.args);
103
- } catch {}
104
- },
105
- runtimeReady() {
106
- onStatusChange?.("ready");
107
- },
108
- runtimeError() {
109
- onStatusChange?.("failed");
110
- },
111
- request(message) {
112
- request(message);
113
- },
114
- cancel(message) {
115
- pending.get(message.id)?.abort();
116
- pending.delete(message.id);
117
- },
118
- disconnect() {
119
- cancelAll();
120
- documentId = undefined;
121
- sessionId = undefined;
122
- onStatusChange?.("disconnected");
123
- }
124
- }
125
- });
126
- const send = endpoint.send;
127
- const receive = endpoint.receive;
128
- function error(id, code, message, requestId) {
129
- send("error", { id, code, message, requestId });
130
- }
131
- async function request(message) {
132
- const id = message.id;
133
- if (pending.has(id))
134
- return;
135
- if (pending.size >= MAX_PENDING)
136
- return error(id, "bridge_busy", "Too many pending data requests.");
137
- try {
138
- const body = JSON.stringify(message.payload);
139
- const limit = message.route === "annotation:draft" ? 384000 : 16384;
140
- if (message.payload !== undefined && (typeof body !== "string" || body.length > limit))
141
- throw new Error("Invalid payload");
142
- } catch {
143
- return error(id, "invalid_payload", "The message payload is invalid or too large.");
144
- }
145
- const controller = new AbortController;
146
- pending.set(id, controller);
147
- const timer = setTimeout(() => {
148
- if (pending.get(id) !== controller)
149
- return;
150
- pending.delete(id);
151
- controller.abort();
152
- error(id, "timeout", "The data request timed out.");
153
- }, REQUEST_TIMEOUT_MS);
154
- controller.signal.addEventListener("abort", () => clearTimeout(timer), {
155
- once: true
156
- });
157
- try {
158
- const response = await onMessage({ route: message.route, payload: message.payload }, { signal: controller.signal });
159
- if (pending.get(id) === controller)
160
- send("result", { id, response });
161
- } catch (failure) {
162
- if (pending.get(id) === controller) {
163
- if (failure instanceof MessageRoutingError2)
164
- error(id, failure.code, failure.message, failure.requestId);
165
- else
166
- error(id, "request_failed", "The message request failed. Retry the request.");
167
- }
168
- } finally {
169
- clearTimeout(timer);
170
- if (pending.get(id) === controller)
171
- pending.delete(id);
172
- }
173
- }
174
- function publishState() {
175
- if (disposed || !sessionId)
176
- return;
177
- send("stateUpdate", { state: hostState() });
178
- }
179
- function load() {
180
- if (connection.type === "opaque")
181
- token = crypto.randomUUID();
182
- cancelAll();
183
- documentId = undefined;
184
- sessionId = undefined;
185
- onStatusChange?.("connecting");
186
- send("connect", {});
187
- }
188
- function dispose() {
189
- disposed = true;
190
- endpoint.dispose();
191
- cancelAll();
192
- iframe.removeEventListener("load", load);
193
- host.removeEventListener("message", receive);
194
- host.removeEventListener("popstate", publishState);
195
- host.removeEventListener("pagehide", cancelAll);
196
- }
197
- setPresentation(presentation);
198
- iframe.addEventListener("load", load);
199
- host.addEventListener("message", receive);
200
- host.addEventListener("popstate", publishState);
201
- host.addEventListener("pagehide", cancelAll);
202
- onStatusChange?.("connecting");
203
- send("connect", {});
204
- return { dispose, setPresentation, setLogger };
205
- }
206
-
207
- // src/embed/source.ts
208
- function attachDataAppSource({
209
- iframe,
210
- source,
211
- presentation,
212
- logger,
213
- onMessage,
214
- onStatusChange,
215
- onDiagnostic,
216
- startupTimeoutMs = 30000
217
- }) {
218
- const host = iframe.ownerDocument.defaultView;
219
- if (!host)
220
- throw new Error("The iframe requires a host window.");
221
- const url = new URL(source.type === "url" ? source.url : source.bootstrapUrl, host.location.href);
222
- if (!/^https?:$/.test(url.protocol))
223
- throw new Error("Data apps require an HTTP(S) URL.");
224
- const opaque = source.type === "bundle";
225
- if (!opaque && url.origin === host.location.origin)
226
- throw new Error("URL data apps require a separate origin from the host.");
227
- iframe.setAttribute("sandbox", opaque ? "allow-scripts" : "allow-scripts allow-same-origin allow-downloads allow-popups allow-popups-to-escape-sandbox");
228
- iframe.referrerPolicy = "no-referrer";
229
- if (!opaque)
230
- url.searchParams.set(PARENT_PARAM, host.location.origin);
231
- let timer;
232
- let failed = false;
233
- function status(value) {
234
- if (value === "connecting")
235
- failed = false;
236
- if (failed && value !== "connecting")
237
- return;
238
- clearTimeout(timer);
239
- if (value === "connecting" || value === "connected")
240
- timer = setTimeout(() => {
241
- failed = true;
242
- bridge.dispose();
243
- onStatusChange?.("failed");
244
- }, startupTimeoutMs);
245
- if (value === "failed") {
246
- failed = true;
247
- bridge.dispose();
248
- }
249
- onStatusChange?.(value);
250
- }
251
- const bridge = attachDataAppConnection({
252
- iframe,
253
- connection: opaque ? { type: "opaque", token: crypto.randomUUID() } : { type: "origin", origin: url.origin },
254
- javascript: opaque ? source.javascript : undefined,
255
- presentation,
256
- logger,
257
- onMessage,
258
- onStatusChange: status,
259
- onDiagnostic,
260
- window: host
261
- });
262
- function error() {
263
- return status("failed");
264
- }
265
- iframe.addEventListener("error", error);
266
- iframe.src = url.href;
267
- function dispose() {
268
- clearTimeout(timer);
269
- iframe.removeEventListener("error", error);
270
- bridge.dispose();
271
- }
272
- return {
273
- dispose,
274
- setPresentation: bridge.setPresentation,
275
- setLogger: bridge.setLogger
276
- };
277
- }
278
-
279
- // src/embed/bridge.ts
280
- function attachDataAppBridge2(options) {
281
- return options.source ? attachDataAppSource(options) : attachDataAppConnection(options);
282
- }
283
-
284
- export { attachDataAppBridge2 };
285
-
286
- //# debugId=E598DB4534AD980C64756E2164756E21
@@ -1,12 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/embed/host.ts", "../src/embed/source.ts", "../src/embed/bridge.ts"],
4
- "sourcesContent": [
5
- "import { createBridgeEndpoint } from '@/src/core/bridge-endpoint';\nimport type { DataAppPresentation } from '@/src/core/presentation';\nimport type { DataAppLogger } from '@/src/core/logger';\nimport {\n MAX_PENDING,\n REQUEST_TIMEOUT_MS,\n validId,\n type BridgeEventMessage,\n type BridgeMessage,\n} from '@/src/core/bridge';\n\nimport {\n MessageRoutingError,\n type MessageDispatcher,\n} from '@/src/core/messages';\n\nexport type DataAppConnection =\n | { type: 'origin'; origin: string }\n | { type: 'opaque'; token: string };\nexport type DataAppStatus =\n | 'connecting'\n | 'connected'\n | 'ready'\n | 'failed'\n | 'disconnected';\nexport type DataAppDiagnostic = {\n direction: 'send' | 'receive';\n type: BridgeMessage['type'];\n};\n\nexport type DataAppHost = {\n dispose: () => void;\n setPresentation: (presentation?: DataAppPresentation) => void;\n setLogger: (logger?: DataAppLogger) => void;\n};\n\nexport type DataAppHostOptions = {\n iframe: HTMLIFrameElement;\n presentation?: DataAppPresentation;\n logger?: DataAppLogger;\n onStatusChange?: (status: DataAppStatus) => void;\n onDiagnostic?: (event: DataAppDiagnostic) => void;\n onMessage: MessageDispatcher;\n};\n\nexport type DataAppConnectionOptions = DataAppHostOptions & {\n connection: DataAppConnection;\n javascript?: string;\n window?: Window;\n};\n\n/** The bridge owns delivery and cancellation; the routed handler owns validation, authorization and execution. */\nexport function attachDataAppConnection({\n iframe,\n connection,\n javascript,\n presentation,\n logger,\n onStatusChange,\n onDiagnostic,\n onMessage,\n window: host = window,\n}: DataAppConnectionOptions): DataAppHost {\n const frameOrigin = connection.type === 'origin' ? connection.origin : 'null';\n if (\n connection.type === 'origin' &&\n new URL(frameOrigin).origin !== frameOrigin\n )\n throw new Error('Expected an exact frame origin.');\n if (connection.type === 'opaque' && !validId(connection.token))\n throw new Error('Invalid sandbox token.');\n let token = connection.type === 'opaque' ? connection.token : undefined;\n const targetOrigin = connection.type === 'opaque' ? '*' : frameOrigin;\n let currentPresentation: DataAppPresentation | undefined;\n let presentationIdentity: string | undefined;\n let disposed = false;\n let documentId: string | undefined;\n let sessionId: string | undefined;\n const pending = new Map<string, AbortController>();\n\n function hostState() {\n return {\n search: host.location.search,\n hash: host.location.hash,\n ...(currentPresentation ? { presentation: currentPresentation } : {}),\n logging: logger !== undefined,\n };\n }\n\n function setLogger(value: DataAppLogger | undefined) {\n if (disposed || value === logger) return;\n const wasEnabled = logger !== undefined;\n logger = value;\n if (wasEnabled !== (logger !== undefined)) publishState();\n }\n\n function setPresentation(value: DataAppPresentation | undefined) {\n if (disposed) return;\n const identity = JSON.stringify(value);\n if (identity === presentationIdentity) return;\n presentationIdentity = identity;\n currentPresentation =\n identity === undefined\n ? undefined\n : (JSON.parse(identity) as DataAppPresentation);\n publishState();\n }\n\n function cancelAll() {\n for (const controller of pending.values()) controller.abort();\n pending.clear();\n }\n\n const endpoint = createBridgeEndpoint({\n role: 'host',\n origin: frameOrigin,\n source: () => iframe.contentWindow,\n opaque: connection.type === 'opaque',\n context: () => ({ documentId, sessionId, token }),\n post: message => iframe.contentWindow?.postMessage(message, targetOrigin),\n diagnostic: (direction, type) => onDiagnostic?.({ direction, type }),\n invalidRequest: id => {\n if (pending.has(id)) return;\n if (pending.size >= MAX_PENDING)\n error(id, 'bridge_busy', 'Too many pending data requests.');\n else error(id, 'invalid_message', 'Invalid message route.');\n },\n handlers: {\n ready(message) {\n if (message.documentId !== documentId) {\n cancelAll();\n documentId = message.documentId;\n sessionId = crypto.randomUUID();\n }\n onStatusChange?.('connected');\n if (disposed) return;\n send('initialize', { state: hostState() });\n if (disposed) return;\n if (javascript !== undefined) send('scriptLoad', { javascript });\n },\n runtimeLog({ payload }) {\n try {\n logger?.[payload.method](...payload.args);\n } catch {\n // A host logger failure must not break bridge delivery.\n }\n },\n runtimeReady() {\n onStatusChange?.('ready');\n },\n runtimeError() {\n onStatusChange?.('failed');\n },\n request(message) {\n void request(message);\n },\n cancel(message) {\n pending.get(message.id)?.abort();\n pending.delete(message.id);\n },\n disconnect() {\n cancelAll();\n documentId = undefined;\n sessionId = undefined;\n onStatusChange?.('disconnected');\n },\n },\n });\n const send = endpoint.send;\n const receive = endpoint.receive;\n\n function error(\n id: string,\n code: string,\n message: string,\n requestId?: string\n ) {\n send('error', { id, code, message, requestId });\n }\n\n async function request(message: BridgeEventMessage<'request'>) {\n const id = message.id;\n if (pending.has(id)) return;\n if (pending.size >= MAX_PENDING)\n return error(id, 'bridge_busy', 'Too many pending data requests.');\n try {\n const body = JSON.stringify(message.payload);\n // PNG annotation captures have a separate validated 256 KiB image budget.\n const limit = message.route === 'annotation:draft' ? 384_000 : 16_384;\n if (\n message.payload !== undefined &&\n (typeof body !== 'string' || body.length > limit)\n )\n throw new Error('Invalid payload');\n } catch {\n return error(\n id,\n 'invalid_payload',\n 'The message payload is invalid or too large.'\n );\n }\n const controller = new AbortController();\n pending.set(id, controller);\n const timer = setTimeout(() => {\n if (pending.get(id) !== controller) return;\n pending.delete(id);\n controller.abort();\n error(id, 'timeout', 'The data request timed out.');\n }, REQUEST_TIMEOUT_MS);\n controller.signal.addEventListener('abort', () => clearTimeout(timer), {\n once: true,\n });\n try {\n const response = await onMessage(\n { route: message.route, payload: message.payload },\n { signal: controller.signal }\n );\n if (pending.get(id) === controller) send('result', { id, response });\n } catch (failure) {\n if (pending.get(id) === controller) {\n if (failure instanceof MessageRoutingError)\n error(id, failure.code, failure.message, failure.requestId);\n else\n error(\n id,\n 'request_failed',\n 'The message request failed. Retry the request.'\n );\n }\n } finally {\n clearTimeout(timer);\n if (pending.get(id) === controller) pending.delete(id);\n }\n }\n\n function publishState() {\n if (disposed || !sessionId) return;\n send('stateUpdate', { state: hostState() });\n }\n\n function load() {\n if (connection.type === 'opaque') token = crypto.randomUUID();\n cancelAll();\n documentId = undefined;\n sessionId = undefined;\n onStatusChange?.('connecting');\n send('connect', {});\n }\n\n function dispose() {\n disposed = true;\n endpoint.dispose();\n cancelAll();\n iframe.removeEventListener('load', load);\n host.removeEventListener('message', receive);\n host.removeEventListener('popstate', publishState);\n host.removeEventListener('pagehide', cancelAll);\n }\n\n setPresentation(presentation);\n iframe.addEventListener('load', load);\n host.addEventListener('message', receive);\n host.addEventListener('popstate', publishState);\n host.addEventListener('pagehide', cancelAll);\n // Reconnect an already-loaded iframe when its host bridge mounts again.\n onStatusChange?.('connecting');\n send('connect', {});\n\n return { dispose, setPresentation, setLogger };\n}\n",
6
- "import { PARENT_PARAM } from '@/src/core/bridge';\nimport {\n attachDataAppConnection,\n type DataAppStatus,\n type DataAppHost,\n type DataAppHostOptions,\n} from '@/src/embed/host';\n\nexport type DataAppSource =\n | { type: 'url'; url: string }\n | {\n type: 'bundle';\n bootstrapUrl: string;\n javascript: string;\n };\nexport type DataAppSourceOptions = DataAppHostOptions & {\n source: DataAppSource;\n startupTimeoutMs?: number;\n};\n\n/** Owns loading and sandbox policy. Dispose before replacing the source or retrying. */\nexport function attachDataAppSource({\n iframe,\n source,\n presentation,\n logger,\n onMessage,\n onStatusChange,\n onDiagnostic,\n startupTimeoutMs = 30_000,\n}: DataAppSourceOptions): DataAppHost {\n const host = iframe.ownerDocument.defaultView;\n if (!host) throw new Error('The iframe requires a host window.');\n const url = new URL(\n source.type === 'url' ? source.url : source.bootstrapUrl,\n host.location.href\n );\n if (!/^https?:$/.test(url.protocol))\n throw new Error('Data apps require an HTTP(S) URL.');\n const opaque = source.type === 'bundle';\n if (!opaque && url.origin === host.location.origin)\n throw new Error('URL data apps require a separate origin from the host.');\n iframe.setAttribute(\n 'sandbox',\n opaque\n ? 'allow-scripts'\n : 'allow-scripts allow-same-origin allow-downloads allow-popups allow-popups-to-escape-sandbox'\n );\n iframe.referrerPolicy = 'no-referrer';\n if (!opaque) url.searchParams.set(PARENT_PARAM, host.location.origin);\n let timer: ReturnType<typeof setTimeout> | undefined;\n let failed = false;\n\n function status(value: DataAppStatus) {\n if (value === 'connecting') failed = false;\n if (failed && value !== 'connecting') return;\n clearTimeout(timer);\n if (value === 'connecting' || value === 'connected')\n timer = setTimeout(() => {\n failed = true;\n bridge.dispose();\n onStatusChange?.('failed');\n }, startupTimeoutMs);\n if (value === 'failed') {\n failed = true;\n bridge.dispose();\n }\n onStatusChange?.(value);\n }\n\n const bridge = attachDataAppConnection({\n iframe,\n connection: opaque\n ? { type: 'opaque', token: crypto.randomUUID() }\n : { type: 'origin', origin: url.origin },\n javascript: opaque ? source.javascript : undefined,\n presentation,\n logger,\n onMessage,\n onStatusChange: status,\n onDiagnostic,\n window: host,\n });\n\n function error() {\n return status('failed');\n }\n\n iframe.addEventListener('error', error);\n iframe.src = url.href;\n\n function dispose() {\n clearTimeout(timer);\n iframe.removeEventListener('error', error);\n bridge.dispose();\n }\n\n return {\n dispose,\n setPresentation: bridge.setPresentation,\n setLogger: bridge.setLogger,\n };\n}\n",
7
- "import {\n attachDataAppConnection,\n type DataAppConnectionOptions,\n} from '@/src/embed/host';\nimport {\n attachDataAppSource,\n type DataAppSourceOptions,\n} from '@/src/embed/source';\n\nexport type DataAppBridgeOptions =\n | (DataAppSourceOptions & {\n connection?: never;\n window?: never;\n javascript?: never;\n })\n | (DataAppConnectionOptions & { source?: never; startupTimeoutMs?: never });\n\n/** Source mode configures and loads the iframe; connection mode attaches to a host-owned document. */\nexport function attachDataAppBridge(options: DataAppBridgeOptions) {\n return options.source\n ? attachDataAppSource(options)\n : attachDataAppConnection(options);\n}\n"
8
- ],
9
- "mappings": ";;;;;;;;;;;;AAoDO,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ,OAAO;AAAA,GACyB;AAAA,EACxC,MAAM,cAAc,WAAW,SAAS,WAAW,WAAW,SAAS;AAAA,EACvE,IACE,WAAW,SAAS,YACpB,IAAI,IAAI,WAAW,EAAE,WAAW;AAAA,IAEhC,MAAM,IAAI,MAAM,iCAAiC;AAAA,EACnD,IAAI,WAAW,SAAS,YAAY,CAAC,QAAQ,WAAW,KAAK;AAAA,IAC3D,MAAM,IAAI,MAAM,wBAAwB;AAAA,EAC1C,IAAI,QAAQ,WAAW,SAAS,WAAW,WAAW,QAAQ;AAAA,EAC9D,MAAM,eAAe,WAAW,SAAS,WAAW,MAAM;AAAA,EAC1D,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI,WAAW;AAAA,EACf,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,MAAM,UAAU,IAAI;AAAA,EAEpB,SAAS,SAAS,GAAG;AAAA,IACnB,OAAO;AAAA,MACL,QAAQ,KAAK,SAAS;AAAA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