grist-widget-sdk 0.3.26 → 0.4.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 (90) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/README.md +1 -1
  3. package/dist/app.cjs +1139 -4336
  4. package/dist/app.cjs.map +1 -1
  5. package/dist/app.d.cts +1 -3
  6. package/dist/app.d.ts +1 -3
  7. package/dist/app.js +9 -517
  8. package/dist/app.js.map +1 -1
  9. package/dist/chunk-4ZGVKGDF.js +204 -0
  10. package/dist/chunk-4ZGVKGDF.js.map +1 -0
  11. package/dist/{chunk-YQNMIL33.js → chunk-B5ZZNLVS.js} +528 -181
  12. package/dist/chunk-B5ZZNLVS.js.map +1 -0
  13. package/dist/chunk-O7NY46QY.js +1830 -0
  14. package/dist/chunk-O7NY46QY.js.map +1 -0
  15. package/dist/chunk-P6VTEKWO.js +618 -0
  16. package/dist/chunk-P6VTEKWO.js.map +1 -0
  17. package/dist/emulator/testing.cjs +2084 -391
  18. package/dist/emulator/testing.cjs.map +1 -1
  19. package/dist/emulator/testing.d.cts +55 -7
  20. package/dist/emulator/testing.d.ts +55 -7
  21. package/dist/emulator/testing.js +144 -19
  22. package/dist/emulator/testing.js.map +1 -1
  23. package/dist/emulator.cjs +59 -249
  24. package/dist/emulator.cjs.map +1 -1
  25. package/dist/emulator.d.cts +3 -5
  26. package/dist/emulator.d.ts +3 -5
  27. package/dist/emulator.js +5 -11
  28. package/dist/index.cjs +1373 -4859
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.d.cts +81 -260
  31. package/dist/index.d.ts +81 -260
  32. package/dist/index.js +8 -161
  33. package/dist/{inline-C7DkvuET.d.cts → templates-CGmRIQBV.d.cts} +89 -35
  34. package/dist/{inline-DpcT8tV9.d.ts → templates-Cq94qOcf.d.ts} +89 -35
  35. package/dist/{types-D3JxUCfL.d.cts → types-DBStn0Dk.d.cts} +2 -26
  36. package/dist/{types-D3JxUCfL.d.ts → types-DBStn0Dk.d.ts} +2 -26
  37. package/dist/use-grist-BK0eke9K.d.cts +358 -0
  38. package/dist/use-grist-C5DMZ3wU.d.ts +358 -0
  39. package/package.json +8 -37
  40. package/dist/advanced.cjs +0 -2799
  41. package/dist/advanced.cjs.map +0 -1
  42. package/dist/advanced.d.cts +0 -822
  43. package/dist/advanced.d.ts +0 -822
  44. package/dist/advanced.js +0 -875
  45. package/dist/advanced.js.map +0 -1
  46. package/dist/chunk-22U7WAY3.js +0 -463
  47. package/dist/chunk-22U7WAY3.js.map +0 -1
  48. package/dist/chunk-64SVRWW7.js +0 -758
  49. package/dist/chunk-64SVRWW7.js.map +0 -1
  50. package/dist/chunk-ELGVOHFD.js +0 -32
  51. package/dist/chunk-ELGVOHFD.js.map +0 -1
  52. package/dist/chunk-EPEBKXVN.js +0 -470
  53. package/dist/chunk-EPEBKXVN.js.map +0 -1
  54. package/dist/chunk-GTTD5HPO.js +0 -36
  55. package/dist/chunk-GTTD5HPO.js.map +0 -1
  56. package/dist/chunk-JASMM2YC.js +0 -243
  57. package/dist/chunk-JASMM2YC.js.map +0 -1
  58. package/dist/chunk-N3X46JW2.js +0 -37
  59. package/dist/chunk-N3X46JW2.js.map +0 -1
  60. package/dist/chunk-PDGEZ24B.js +0 -2366
  61. package/dist/chunk-PDGEZ24B.js.map +0 -1
  62. package/dist/chunk-PM3B4WYV.js +0 -12
  63. package/dist/chunk-PM3B4WYV.js.map +0 -1
  64. package/dist/chunk-REV5AUXD.js +0 -25
  65. package/dist/chunk-REV5AUXD.js.map +0 -1
  66. package/dist/chunk-TZB3OZA6.js +0 -1630
  67. package/dist/chunk-TZB3OZA6.js.map +0 -1
  68. package/dist/chunk-YQNMIL33.js.map +0 -1
  69. package/dist/create-grist-emulator-BCqp1BF9.d.ts +0 -81
  70. package/dist/create-grist-emulator-DBM8OSIR.d.cts +0 -81
  71. package/dist/emulator/devtools.cjs +0 -1404
  72. package/dist/emulator/devtools.cjs.map +0 -1
  73. package/dist/emulator/devtools.d.cts +0 -48
  74. package/dist/emulator/devtools.d.ts +0 -48
  75. package/dist/emulator/devtools.js +0 -508
  76. package/dist/emulator/devtools.js.map +0 -1
  77. package/dist/emulator/transports.cjs +0 -1132
  78. package/dist/emulator/transports.cjs.map +0 -1
  79. package/dist/emulator/transports.d.cts +0 -38
  80. package/dist/emulator/transports.d.ts +0 -38
  81. package/dist/emulator/transports.js +0 -12
  82. package/dist/emulator/transports.js.map +0 -1
  83. package/dist/templates-8k2LKoO-.d.cts +0 -24
  84. package/dist/templates-DIwi_mvI.d.ts +0 -24
  85. package/dist/use-grist-reads-DUMvJgV7.d.ts +0 -480
  86. package/dist/use-grist-reads-DpjVuI0H.d.cts +0 -480
  87. package/dist/use-grist-types-DdOLEJXN.d.cts +0 -499
  88. package/dist/use-grist-types-kwxoFeub.d.ts +0 -499
  89. package/dist/use-grist-widget-options-from-context-CGOlQ5Vc.d.cts +0 -43
  90. package/dist/use-grist-widget-options-from-context-CGOlQ5Vc.d.ts +0 -43
@@ -1,10 +1,10 @@
1
- import { ReactElement } from 'react';
1
+ import { ReactElement, ComponentType } from 'react';
2
2
  import { RenderOptions, RenderResult } from '@testing-library/react';
3
3
  export { RenderOptions, RenderResult, act, cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react';
4
- import { CreateGristEmulatorOptions, GristEmulator } from '../emulator.cjs';
5
- import { EmulatorEvent } from '../emulator.cjs';
6
- export { p as presets } from '../templates-8k2LKoO-.cjs';
7
- import '../types-D3JxUCfL.cjs';
4
+ import { CreateGristEmulatorOptions, GristEmulator, EmulatorEvent } from '../emulator.cjs';
5
+ export { p as presets } from '../templates-CGmRIQBV.cjs';
6
+ import { UseGristOptions } from '../index.cjs';
7
+ import { GristReplicaDocument } from '../emulator.cjs';
8
8
 
9
9
  /**
10
10
  * `renderWithGrist(ui, options)` — drop-in replacement for
@@ -27,6 +27,54 @@ type RenderWithGristResult = RenderResult & {
27
27
  };
28
28
  declare function renderWithGrist(ui: ReactElement, options?: RenderWithGristOptions): RenderWithGristResult;
29
29
 
30
+ type SmokeTestWidgetOptions = {
31
+ /** The widget, as `src/main.tsx` passes it to `mountGristWidget()`. */
32
+ App: ComponentType;
33
+ /** The widget's `GRIST_OPTIONS`. */
34
+ options: UseGristOptions;
35
+ /**
36
+ * The Grist document to run against. Defaults to one table with a column
37
+ * per column the widget declares, typed after the first type it accepts,
38
+ * and one row of sample values.
39
+ */
40
+ document?: GristReplicaDocument;
41
+ /** How long to wait for the widget to render, in ms. Defaults to 10 000. */
42
+ timeout?: number;
43
+ };
44
+ /**
45
+ * Mounts the widget the way `mountGristWidget()` does inside Grist, against
46
+ * an emulated Grist document with every column it declares mapped and the
47
+ * access it requests granted, and waits until it renders past
48
+ * `GristBoundary`. Resolves once it has,
49
+ * rejects with the widget's own error if it throws, or with what the page
50
+ * showed instead if it never gets there. Then unmounts.
51
+ *
52
+ * A widget's whole smoke test:
53
+ *
54
+ * ```tsx
55
+ * import { it } from "vitest"
56
+ * import { smokeTestWidget } from "grist-widget-sdk/emulator/testing"
57
+ * import App, { GRIST_OPTIONS } from "./App"
58
+ *
59
+ * it("renders inside Grist", () => smokeTestWidget({ App, options: GRIST_OPTIONS }))
60
+ * ```
61
+ *
62
+ * It only reads `GRIST_OPTIONS`, so it stays valid as the widget changes,
63
+ * and it improves with each SDK release.
64
+ */
65
+ declare function smokeTestWidget({ App, options, document, timeout, }: SmokeTestWidgetOptions): Promise<void>;
66
+
67
+ /**
68
+ * Browser APIs jsdom lacks but widget UI commonly uses, as inert stand-ins:
69
+ * `ResizeObserver` (charts, virtualized lists, popovers) and
70
+ * `window.matchMedia` (the theme, responsive hooks; it reports a light,
71
+ * wide screen). Only installs what's missing, so a test's own mock wins.
72
+ *
73
+ * {@link smokeTestWidget} calls it. For a widget's other tests, call it at
74
+ * the top of the test file or in a Vitest setup file.
75
+ */
76
+ declare function installJsdomStubs(): void;
77
+
30
78
  /**
31
79
  * Vitest helpers to assert what the widget did to the document.
32
80
  *
@@ -47,5 +95,5 @@ type WaitForEventOptions = {
47
95
  declare function waitForEvent(emulator: GristEmulator, kind: WaitForEventKind, options?: WaitForEventOptions): Promise<EmulatorEvent>;
48
96
  declare function waitForEvent(emulator: GristEmulator, predicate: (event: EmulatorEvent) => boolean, timeoutMs?: number): Promise<EmulatorEvent>;
49
97
 
50
- export { actionsOf, eventsOf, renderWithGrist, waitForEvent };
51
- export type { RenderWithGristOptions, RenderWithGristResult, WaitForEventKind, WaitForEventOptions };
98
+ export { actionsOf, eventsOf, installJsdomStubs, renderWithGrist, smokeTestWidget, waitForEvent };
99
+ export type { RenderWithGristOptions, RenderWithGristResult, SmokeTestWidgetOptions, WaitForEventKind, WaitForEventOptions };
@@ -1,10 +1,10 @@
1
- import { ReactElement } from 'react';
1
+ import { ReactElement, ComponentType } from 'react';
2
2
  import { RenderOptions, RenderResult } from '@testing-library/react';
3
3
  export { RenderOptions, RenderResult, act, cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react';
4
- import { CreateGristEmulatorOptions, GristEmulator } from '../emulator.js';
5
- import { EmulatorEvent } from '../emulator.js';
6
- export { p as presets } from '../templates-DIwi_mvI.js';
7
- import '../types-D3JxUCfL.js';
4
+ import { CreateGristEmulatorOptions, GristEmulator, EmulatorEvent } from '../emulator.js';
5
+ export { p as presets } from '../templates-Cq94qOcf.js';
6
+ import { UseGristOptions } from '../index.js';
7
+ import { GristReplicaDocument } from '../emulator.js';
8
8
 
9
9
  /**
10
10
  * `renderWithGrist(ui, options)` — drop-in replacement for
@@ -27,6 +27,54 @@ type RenderWithGristResult = RenderResult & {
27
27
  };
28
28
  declare function renderWithGrist(ui: ReactElement, options?: RenderWithGristOptions): RenderWithGristResult;
29
29
 
30
+ type SmokeTestWidgetOptions = {
31
+ /** The widget, as `src/main.tsx` passes it to `mountGristWidget()`. */
32
+ App: ComponentType;
33
+ /** The widget's `GRIST_OPTIONS`. */
34
+ options: UseGristOptions;
35
+ /**
36
+ * The Grist document to run against. Defaults to one table with a column
37
+ * per column the widget declares, typed after the first type it accepts,
38
+ * and one row of sample values.
39
+ */
40
+ document?: GristReplicaDocument;
41
+ /** How long to wait for the widget to render, in ms. Defaults to 10 000. */
42
+ timeout?: number;
43
+ };
44
+ /**
45
+ * Mounts the widget the way `mountGristWidget()` does inside Grist, against
46
+ * an emulated Grist document with every column it declares mapped and the
47
+ * access it requests granted, and waits until it renders past
48
+ * `GristBoundary`. Resolves once it has,
49
+ * rejects with the widget's own error if it throws, or with what the page
50
+ * showed instead if it never gets there. Then unmounts.
51
+ *
52
+ * A widget's whole smoke test:
53
+ *
54
+ * ```tsx
55
+ * import { it } from "vitest"
56
+ * import { smokeTestWidget } from "grist-widget-sdk/emulator/testing"
57
+ * import App, { GRIST_OPTIONS } from "./App"
58
+ *
59
+ * it("renders inside Grist", () => smokeTestWidget({ App, options: GRIST_OPTIONS }))
60
+ * ```
61
+ *
62
+ * It only reads `GRIST_OPTIONS`, so it stays valid as the widget changes,
63
+ * and it improves with each SDK release.
64
+ */
65
+ declare function smokeTestWidget({ App, options, document, timeout, }: SmokeTestWidgetOptions): Promise<void>;
66
+
67
+ /**
68
+ * Browser APIs jsdom lacks but widget UI commonly uses, as inert stand-ins:
69
+ * `ResizeObserver` (charts, virtualized lists, popovers) and
70
+ * `window.matchMedia` (the theme, responsive hooks; it reports a light,
71
+ * wide screen). Only installs what's missing, so a test's own mock wins.
72
+ *
73
+ * {@link smokeTestWidget} calls it. For a widget's other tests, call it at
74
+ * the top of the test file or in a Vitest setup file.
75
+ */
76
+ declare function installJsdomStubs(): void;
77
+
30
78
  /**
31
79
  * Vitest helpers to assert what the widget did to the document.
32
80
  *
@@ -47,5 +95,5 @@ type WaitForEventOptions = {
47
95
  declare function waitForEvent(emulator: GristEmulator, kind: WaitForEventKind, options?: WaitForEventOptions): Promise<EmulatorEvent>;
48
96
  declare function waitForEvent(emulator: GristEmulator, predicate: (event: EmulatorEvent) => boolean, timeoutMs?: number): Promise<EmulatorEvent>;
49
97
 
50
- export { actionsOf, eventsOf, renderWithGrist, waitForEvent };
51
- export type { RenderWithGristOptions, RenderWithGristResult, WaitForEventKind, WaitForEventOptions };
98
+ export { actionsOf, eventsOf, installJsdomStubs, renderWithGrist, smokeTestWidget, waitForEvent };
99
+ export type { RenderWithGristOptions, RenderWithGristResult, SmokeTestWidgetOptions, WaitForEventKind, WaitForEventOptions };
@@ -1,35 +1,27 @@
1
1
  import {
2
- resetEmbeddedHandshakeManagerForTests,
3
- resetGristEventsForTests,
4
- resetGristReadyCacheForTests
5
- } from "../chunk-TZB3OZA6.js";
2
+ GristWidgetApp
3
+ } from "../chunk-P6VTEKWO.js";
4
+ import {
5
+ resetGristForTests
6
+ } from "../chunk-O7NY46QY.js";
6
7
  import {
7
8
  createGristEmulator,
8
9
  presets
9
- } from "../chunk-22U7WAY3.js";
10
- import "../chunk-YQNMIL33.js";
11
- import "../chunk-GTTD5HPO.js";
12
- import "../chunk-N3X46JW2.js";
13
- import "../chunk-ELGVOHFD.js";
14
- import "../chunk-PM3B4WYV.js";
15
- import "../chunk-64SVRWW7.js";
10
+ } from "../chunk-B5ZZNLVS.js";
11
+ import "../chunk-4ZGVKGDF.js";
16
12
 
17
13
  // src/emulator/testing/render-with-grist.tsx
18
14
  import { render } from "@testing-library/react";
19
15
  function renderWithGrist(ui, options = {}) {
20
16
  fakeIframeContext();
21
- resetGristEventsForTests();
22
- resetGristReadyCacheForTests();
23
- resetEmbeddedHandshakeManagerForTests();
17
+ resetGristForTests();
24
18
  const emulator = options.existing ?? createGristEmulator(options.emulator ?? { document: presets.blank() });
25
19
  const result = render(ui, options);
26
20
  const originalUnmount = result.unmount;
27
21
  result.unmount = () => {
28
22
  originalUnmount();
29
23
  if (!options.existing) emulator.dispose();
30
- resetGristReadyCacheForTests();
31
- resetGristEventsForTests();
32
- resetEmbeddedHandshakeManagerForTests();
24
+ resetGristForTests();
33
25
  };
34
26
  return Object.assign(result, { emulator });
35
27
  }
@@ -45,6 +37,137 @@ function fakeIframeContext() {
45
37
  }
46
38
  }
47
39
 
40
+ // src/emulator/testing/smoke-test-widget.tsx
41
+ import { Component } from "react";
42
+ import { waitFor } from "@testing-library/react";
43
+
44
+ // src/emulator/testing/jsdom-stubs.ts
45
+ function installJsdomStubs() {
46
+ if (typeof window === "undefined") return;
47
+ globalThis.ResizeObserver ?? (globalThis.ResizeObserver = class ResizeObserver {
48
+ observe() {
49
+ }
50
+ unobserve() {
51
+ }
52
+ disconnect() {
53
+ }
54
+ });
55
+ window.matchMedia ?? (window.matchMedia = (query) => ({
56
+ matches: false,
57
+ media: query,
58
+ onchange: null,
59
+ addEventListener() {
60
+ },
61
+ removeEventListener() {
62
+ },
63
+ addListener() {
64
+ },
65
+ removeListener() {
66
+ },
67
+ dispatchEvent: () => false
68
+ }));
69
+ }
70
+
71
+ // src/emulator/testing/smoke-test-widget.tsx
72
+ import { jsx } from "react/jsx-runtime";
73
+ async function smokeTestWidget({
74
+ App,
75
+ options,
76
+ document,
77
+ timeout = 1e4
78
+ }) {
79
+ installJsdomStubs();
80
+ const crash = { error: void 0 };
81
+ function Probe() {
82
+ return /* @__PURE__ */ jsx(CatchRenderError, { crash, children: /* @__PURE__ */ jsx("div", { "data-grist-smoke-test": "", children: /* @__PURE__ */ jsx(App, {}) }) });
83
+ }
84
+ const columns = declaredColumns(options);
85
+ const gristDocument = document ?? smokeTestDocument(columns);
86
+ const result = renderWithGrist(/* @__PURE__ */ jsx(GristWidgetApp, { App: Probe, options }), {
87
+ emulator: {
88
+ document: gristDocument,
89
+ // Granted as the user would in Grist's widget panel: the access the
90
+ // widget asks for, unless the given document says otherwise.
91
+ widgetInteraction: gristDocument.widgetInteraction ?? { access_level: options.requiredAccess ?? "read table" }
92
+ }
93
+ });
94
+ try {
95
+ if (columns.length > 0) result.emulator.setColumnMappings(mapEveryColumn(columns));
96
+ try {
97
+ await waitFor(
98
+ () => {
99
+ if (crash.error !== void 0) return;
100
+ const probe = result.container.querySelector("[data-grist-smoke-test]");
101
+ if (!probe || !probe.hasChildNodes()) throw new Error("not rendered yet");
102
+ },
103
+ { timeout }
104
+ );
105
+ } catch {
106
+ const shown = result.container.textContent?.trim().replace(/\s+/g, " ") || "nothing";
107
+ throw new Error(
108
+ `smokeTestWidget: the widget didn't render past GristBoundary within ${timeout} ms. The page showed: "${shown.slice(0, 300)}".`
109
+ );
110
+ }
111
+ if (crash.error !== void 0) throw crash.error;
112
+ } finally {
113
+ result.unmount();
114
+ }
115
+ }
116
+ var CatchRenderError = class extends Component {
117
+ constructor() {
118
+ super(...arguments);
119
+ this.state = { failed: false };
120
+ }
121
+ static getDerivedStateFromError() {
122
+ return { failed: true };
123
+ }
124
+ componentDidCatch(error) {
125
+ this.props.crash.error = error;
126
+ }
127
+ render() {
128
+ return this.state.failed ? null : this.props.children;
129
+ }
130
+ };
131
+ function declaredColumns(options) {
132
+ return (options.columns ?? []).map(
133
+ (column) => typeof column === "string" ? { name: column, type: "Any", allowMultiple: false } : { name: column.name, type: firstType(column.type), allowMultiple: column.allowMultiple === true }
134
+ );
135
+ }
136
+ function firstType(type) {
137
+ return (type ?? "Any").split(",")[0].trim() || "Any";
138
+ }
139
+ function mapEveryColumn(columns) {
140
+ return Object.fromEntries(columns.map((c) => [c.name, c.allowMultiple ? [c.name] : c.name]));
141
+ }
142
+ function smokeTestDocument(columns) {
143
+ return {
144
+ generatedAt: "1970-01-01T00:00:00.000Z",
145
+ docName: "Smoke test",
146
+ mode: "schema+data",
147
+ tables: {
148
+ Table1: {
149
+ columns: Object.fromEntries(columns.map((c) => [c.name, { type: c.type }])),
150
+ rows: [{ id: 1, ...Object.fromEntries(columns.map((c) => [c.name, sampleValue(c.type)])) }]
151
+ }
152
+ }
153
+ };
154
+ }
155
+ function sampleValue(type) {
156
+ switch (type) {
157
+ case "Numeric":
158
+ case "Int":
159
+ return 42;
160
+ case "Bool":
161
+ return true;
162
+ case "Date":
163
+ case "DateTime":
164
+ return 1767225600;
165
+ // 2026-01-01, as Grist stores it: epoch seconds
166
+ default:
167
+ return "Sample";
168
+ }
169
+ }
170
+
48
171
  // src/emulator/testing/matchers.ts
49
172
  function actionsOf(emulator) {
50
173
  return emulator.bus.history().filter((e) => e.type === "user-action").map((e) => e.action);
@@ -105,7 +228,7 @@ import {
105
228
  fireEvent,
106
229
  render as render2,
107
230
  screen,
108
- waitFor,
231
+ waitFor as waitFor2,
109
232
  within
110
233
  } from "@testing-library/react";
111
234
  export {
@@ -114,11 +237,13 @@ export {
114
237
  cleanup,
115
238
  eventsOf,
116
239
  fireEvent,
240
+ installJsdomStubs,
117
241
  presets,
118
242
  render2 as render,
119
243
  renderWithGrist,
120
244
  screen,
121
- waitFor,
245
+ smokeTestWidget,
246
+ waitFor2 as waitFor,
122
247
  waitForEvent,
123
248
  within
124
249
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/emulator/testing/render-with-grist.tsx","../../src/emulator/testing/matchers.ts","../../src/emulator/testing/index.ts"],"sourcesContent":["/**\n * `renderWithGrist(ui, options)` — drop-in replacement for\n * `@testing-library/react`'s `render(ui)` that boots a Grist emulator\n * (inline transport) and exposes it to the test.\n *\n * The emulator is mounted as `window.grist`. The SDK hooks (`useGrist`,\n * `useGristReady`, etc.) detect it via the same path they use in production.\n *\n * Cleanup is automatic when the test's container unmounts.\n */\n\nimport type { ReactElement } from \"react\"\n\nimport { render, type RenderOptions, type RenderResult } from \"@testing-library/react\"\n\nimport { resetEmbeddedHandshakeManagerForTests } from \"../../sdk/internal/embedded-handshake-manager\"\nimport { resetGristReadyCacheForTests } from \"../../sdk/internal/ready-singleton\"\nimport { resetGristEventsForTests } from \"../../sdk/internal/subscriptions\"\nimport { createGristEmulator } from \"../create-grist-emulator\"\nimport type { CreateGristEmulatorOptions, GristEmulator } from \"../create-grist-emulator\"\nimport { presets } from \"../templates\"\n\nexport type RenderWithGristOptions = RenderOptions & {\n emulator?: CreateGristEmulatorOptions\n /** Skip mounting the emulator; you bring your own. Useful for shared fixtures. */\n existing?: GristEmulator\n}\n\nexport type RenderWithGristResult = RenderResult & {\n emulator: GristEmulator\n}\n\nexport function renderWithGrist(\n ui: ReactElement,\n options: RenderWithGristOptions = {}\n): RenderWithGristResult {\n // Make `window.self !== window.top` evaluate to `true` so\n // `useGristAvailability` reports the widget as embedded. We only do this in\n // jsdom; real browsers already enforce this distinction for iframes.\n fakeIframeContext()\n\n resetGristEventsForTests()\n resetGristReadyCacheForTests()\n resetEmbeddedHandshakeManagerForTests()\n\n const emulator =\n options.existing ??\n createGristEmulator(options.emulator ?? { document: presets.blank() })\n\n const result = render(ui, options)\n const originalUnmount = result.unmount\n result.unmount = () => {\n originalUnmount()\n if (!options.existing) emulator.dispose()\n resetGristReadyCacheForTests()\n resetGristEventsForTests()\n resetEmbeddedHandshakeManagerForTests()\n }\n return Object.assign(result, { emulator })\n}\n\nfunction fakeIframeContext() {\n if (typeof window === \"undefined\") return\n if (window.self !== window.top) return // already iframe-like\n try {\n Object.defineProperty(window, \"top\", {\n configurable: true,\n get: () => ({}),\n })\n } catch {\n // Some jsdom versions block redefinition; fail silently — tests using\n // `useGristAvailability` will need to bypass it explicitly in that case.\n }\n}\n","/**\n * Vitest helpers to assert what the widget did to the document.\n *\n * Usage:\n *\n * const { emulator } = renderWithGrist(<MyWidget />)\n * await userEvent.click(screen.getByText(\"Add\"))\n * expect(actionsOf(emulator)).toContainEqual([\"AddRecord\", \"Tasks\", null, { title: \"X\" }])\n */\n\nimport type { GristEmulator } from \"../create-grist-emulator\"\nimport type { EmulatorEvent } from \"../core/event-bus\"\n\nexport function actionsOf(emulator: GristEmulator): unknown[][] {\n return emulator.bus\n .history()\n .filter((e: EmulatorEvent): e is Extract<EmulatorEvent, { type: \"user-action\" }> => e.type === \"user-action\")\n .map((e) => e.action as unknown[])\n}\n\nexport function eventsOf(emulator: GristEmulator): readonly EmulatorEvent[] {\n return emulator.bus.history()\n}\n\n/** Bus event kinds aligned with grist host callbacks (see inline transport). */\nexport type WaitForEventKind = \"ready\" | \"record\" | \"records\" | \"options\" | \"theme\" | \"cursor\"\n\nexport type WaitForEventOptions = {\n timeoutMs?: number\n}\n\nfunction predicateForKind(kind: WaitForEventKind): (event: EmulatorEvent) => boolean {\n switch (kind) {\n case \"ready\":\n return (e) => e.type === \"ready\"\n case \"record\":\n case \"cursor\":\n return (e) => e.type === \"cursor-change\"\n case \"records\":\n return (e) => e.type === \"data-change\"\n case \"options\":\n return (e) => e.type === \"options-change\"\n case \"theme\":\n return (e) => e.type === \"theme-change\"\n }\n}\n\nfunction waitForNextEvent(\n emulator: GristEmulator,\n predicate: (event: EmulatorEvent) => boolean,\n timeoutMs: number,\n label?: string\n): Promise<EmulatorEvent> {\n return new Promise((resolve, reject) => {\n const timer = setTimeout(() => {\n off()\n const hint = label ? ` (kind: ${label})` : \"\"\n const recent = emulator.bus\n .history()\n .slice(-5)\n .map((e) => e.type)\n .join(\", \")\n reject(\n new Error(\n `waitForEvent timed out after ${timeoutMs}ms${hint}.` +\n (recent ? ` Recent bus events: ${recent}.` : \" No bus events yet.\")\n )\n )\n }, timeoutMs)\n const off = emulator.bus.on((event) => {\n if (predicate(event)) {\n clearTimeout(timer)\n off()\n resolve(event)\n }\n })\n })\n}\n\nexport function waitForEvent(\n emulator: GristEmulator,\n kind: WaitForEventKind,\n options?: WaitForEventOptions\n): Promise<EmulatorEvent>\nexport function waitForEvent(\n emulator: GristEmulator,\n predicate: (event: EmulatorEvent) => boolean,\n timeoutMs?: number\n): Promise<EmulatorEvent>\nexport function waitForEvent(\n emulator: GristEmulator,\n kindOrPredicate: WaitForEventKind | ((event: EmulatorEvent) => boolean),\n timeoutOrOptions: number | WaitForEventOptions = 1000\n): Promise<EmulatorEvent> {\n if (typeof kindOrPredicate === \"string\") {\n const opts = typeof timeoutOrOptions === \"object\" ? timeoutOrOptions : {}\n const timeoutMs = opts.timeoutMs ?? 1000\n return waitForNextEvent(emulator, predicateForKind(kindOrPredicate), timeoutMs, kindOrPredicate)\n }\n const timeoutMs = typeof timeoutOrOptions === \"number\" ? timeoutOrOptions : 1000\n return waitForNextEvent(emulator, kindOrPredicate, timeoutMs)\n}\n","/**\n * Test entry point — `grist-widget-sdk/emulator/testing`.\n *\n * Bundles `renderWithGrist`, matchers, document presets, and the most-used\n * @testing-library/react primitives so a typical test file only needs one\n * import line:\n *\n * import {\n * renderWithGrist, presets, screen, fireEvent, waitFor, actionsOf,\n * } from \"grist-widget-sdk/emulator/testing\"\n */\n\nexport { renderWithGrist } from \"./render-with-grist\"\nexport type {\n RenderWithGristOptions,\n RenderWithGristResult,\n} from \"./render-with-grist\"\n\nexport {\n actionsOf,\n eventsOf,\n waitForEvent,\n type WaitForEventKind,\n type WaitForEventOptions,\n} from \"./matchers\"\n\n// Document fixtures (re-export from the emulator entry for convenience).\nexport { presets } from \"../templates\"\n\n// @testing-library/react convenience re-exports — see AGENTS.md\nexport {\n act,\n cleanup,\n fireEvent,\n render,\n screen,\n waitFor,\n within,\n} from \"@testing-library/react\"\nexport type { RenderOptions, RenderResult } from \"@testing-library/react\"\n"],"mappings":";;;;;;;;;;;;;;;;;AAaA,SAAS,cAAqD;AAmBvD,SAAS,gBACd,IACA,UAAkC,CAAC,GACZ;AAIvB,oBAAkB;AAElB,2BAAyB;AACzB,+BAA6B;AAC7B,wCAAsC;AAEtC,QAAM,WACJ,QAAQ,YACR,oBAAoB,QAAQ,YAAY,EAAE,UAAU,QAAQ,MAAM,EAAE,CAAC;AAEvE,QAAM,SAAS,OAAO,IAAI,OAAO;AACjC,QAAM,kBAAkB,OAAO;AAC/B,SAAO,UAAU,MAAM;AACrB,oBAAgB;AAChB,QAAI,CAAC,QAAQ,SAAU,UAAS,QAAQ;AACxC,iCAA6B;AAC7B,6BAAyB;AACzB,0CAAsC;AAAA,EACxC;AACA,SAAO,OAAO,OAAO,QAAQ,EAAE,SAAS,CAAC;AAC3C;AAEA,SAAS,oBAAoB;AAC3B,MAAI,OAAO,WAAW,YAAa;AACnC,MAAI,OAAO,SAAS,OAAO,IAAK;AAChC,MAAI;AACF,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;AAAA,MACf;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACH;AAYO,SAAS,aACd,UACA,iBACA,mBAAiD,KACzB;AACxB,MAAI,OAAO,oBAAoB,UAAU;AACvC,UAAM,OAAO,OAAO,qBAAqB,WAAW,mBAAmB,CAAC;AACxE,UAAMA,aAAY,KAAK,aAAa;AACpC,WAAO,iBAAiB,UAAU,iBAAiB,eAAe,GAAGA,YAAW,eAAe;AAAA,EACjG;AACA,QAAM,YAAY,OAAO,qBAAqB,WAAW,mBAAmB;AAC5E,SAAO,iBAAiB,UAAU,iBAAiB,SAAS;AAC9D;;;ACvEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAAC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":["timeoutMs","render"]}
1
+ {"version":3,"sources":["../../src/emulator/testing/render-with-grist.tsx","../../src/emulator/testing/smoke-test-widget.tsx","../../src/emulator/testing/jsdom-stubs.ts","../../src/emulator/testing/matchers.ts","../../src/emulator/testing/index.ts"],"sourcesContent":["/**\n * `renderWithGrist(ui, options)` — drop-in replacement for\n * `@testing-library/react`'s `render(ui)` that boots a Grist emulator\n * (inline transport) and exposes it to the test.\n *\n * The emulator is mounted as `window.grist`. The SDK hooks (`useGrist`,\n * `useGristReady`, etc.) detect it via the same path they use in production.\n *\n * Cleanup is automatic when the test's container unmounts.\n */\n\nimport type { ReactElement } from \"react\"\n\nimport { render, type RenderOptions, type RenderResult } from \"@testing-library/react\"\n\nimport { resetGristForTests } from \"../../sdk/use-grist\"\nimport { createGristEmulator } from \"../create-grist-emulator\"\nimport type { CreateGristEmulatorOptions, GristEmulator } from \"../create-grist-emulator\"\nimport { presets } from \"../templates\"\n\nexport type RenderWithGristOptions = RenderOptions & {\n emulator?: CreateGristEmulatorOptions\n /** Skip mounting the emulator; you bring your own. Useful for shared fixtures. */\n existing?: GristEmulator\n}\n\nexport type RenderWithGristResult = RenderResult & {\n emulator: GristEmulator\n}\n\nexport function renderWithGrist(\n ui: ReactElement,\n options: RenderWithGristOptions = {}\n): RenderWithGristResult {\n // Make `window.self !== window.top` evaluate to `true` so\n // `useGristAvailability` reports the widget as embedded. We only do this in\n // jsdom; real browsers already enforce this distinction for iframes.\n fakeIframeContext()\n\n resetGristForTests()\n\n const emulator =\n options.existing ??\n createGristEmulator(options.emulator ?? { document: presets.blank() })\n\n const result = render(ui, options)\n const originalUnmount = result.unmount\n result.unmount = () => {\n originalUnmount()\n if (!options.existing) emulator.dispose()\n resetGristForTests()\n }\n return Object.assign(result, { emulator })\n}\n\nfunction fakeIframeContext() {\n if (typeof window === \"undefined\") return\n if (window.self !== window.top) return // already iframe-like\n try {\n Object.defineProperty(window, \"top\", {\n configurable: true,\n get: () => ({}),\n })\n } catch {\n // Some jsdom versions block redefinition; fail silently — tests using\n // `useGristAvailability` will need to bypass it explicitly in that case.\n }\n}\n","import { Component, type ComponentType, type ReactNode } from \"react\"\nimport { waitFor } from \"@testing-library/react\"\n\nimport { GristWidgetApp } from \"../../app/mount-grist-widget\"\nimport type { GristColumnToMap, GristReplicaDocument, GristWidgetColumnMap, UseGristOptions } from \"../../sdk\"\nimport { installJsdomStubs } from \"./jsdom-stubs\"\nimport { renderWithGrist } from \"./render-with-grist\"\n\nexport type SmokeTestWidgetOptions = {\n /** The widget, as `src/main.tsx` passes it to `mountGristWidget()`. */\n App: ComponentType\n /** The widget's `GRIST_OPTIONS`. */\n options: UseGristOptions\n /**\n * The Grist document to run against. Defaults to one table with a column\n * per column the widget declares, typed after the first type it accepts,\n * and one row of sample values.\n */\n document?: GristReplicaDocument\n /** How long to wait for the widget to render, in ms. Defaults to 10 000. */\n timeout?: number\n}\n\n/**\n * Mounts the widget the way `mountGristWidget()` does inside Grist, against\n * an emulated Grist document with every column it declares mapped and the\n * access it requests granted, and waits until it renders past\n * `GristBoundary`. Resolves once it has,\n * rejects with the widget's own error if it throws, or with what the page\n * showed instead if it never gets there. Then unmounts.\n *\n * A widget's whole smoke test:\n *\n * ```tsx\n * import { it } from \"vitest\"\n * import { smokeTestWidget } from \"grist-widget-sdk/emulator/testing\"\n * import App, { GRIST_OPTIONS } from \"./App\"\n *\n * it(\"renders inside Grist\", () => smokeTestWidget({ App, options: GRIST_OPTIONS }))\n * ```\n *\n * It only reads `GRIST_OPTIONS`, so it stays valid as the widget changes,\n * and it improves with each SDK release.\n */\nexport async function smokeTestWidget({\n App,\n options,\n document,\n timeout = 10_000,\n}: SmokeTestWidgetOptions): Promise<void> {\n installJsdomStubs()\n\n const crash: { error: unknown } = { error: undefined }\n function Probe() {\n return (\n <CatchRenderError crash={crash}>\n <div data-grist-smoke-test=\"\">\n <App />\n </div>\n </CatchRenderError>\n )\n }\n\n const columns = declaredColumns(options)\n const gristDocument = document ?? smokeTestDocument(columns)\n const result = renderWithGrist(<GristWidgetApp App={Probe} options={options} />, {\n emulator: {\n document: gristDocument,\n // Granted as the user would in Grist's widget panel: the access the\n // widget asks for, unless the given document says otherwise.\n widgetInteraction: gristDocument.widgetInteraction ?? { access_level: options.requiredAccess ?? \"read table\" },\n },\n })\n try {\n if (columns.length > 0) result.emulator.setColumnMappings(mapEveryColumn(columns))\n\n try {\n await waitFor(\n () => {\n if (crash.error !== undefined) return\n const probe = result.container.querySelector(\"[data-grist-smoke-test]\")\n if (!probe || !probe.hasChildNodes()) throw new Error(\"not rendered yet\")\n },\n { timeout }\n )\n } catch {\n const shown = result.container.textContent?.trim().replace(/\\s+/g, \" \") || \"nothing\"\n throw new Error(\n `smokeTestWidget: the widget didn't render past GristBoundary within ${timeout} ms. ` +\n `The page showed: \"${shown.slice(0, 300)}\".`\n )\n }\n if (crash.error !== undefined) throw crash.error\n } finally {\n result.unmount()\n }\n}\n\n/** Records the widget's render error, so the test fails with it rather than a timeout. */\nclass CatchRenderError extends Component<{ crash: { error: unknown }; children: ReactNode }, { failed: boolean }> {\n state = { failed: false }\n\n static getDerivedStateFromError() {\n return { failed: true }\n }\n\n componentDidCatch(error: unknown) {\n this.props.crash.error = error\n }\n\n render() {\n return this.state.failed ? null : this.props.children\n }\n}\n\ntype Column = { name: string; type: string; allowMultiple: boolean }\n\nfunction declaredColumns(options: UseGristOptions): Column[] {\n return (options.columns ?? []).map((column: string | GristColumnToMap) =>\n typeof column === \"string\"\n ? { name: column, type: \"Any\", allowMultiple: false }\n : { name: column.name, type: firstType(column.type), allowMultiple: column.allowMultiple === true }\n )\n}\n\n/** The first Grist type a column accepts: `\"Text,Ref,Choice\"` gives `\"Text\"`. */\nfunction firstType(type: string | undefined): string {\n return (type ?? \"Any\").split(\",\")[0].trim() || \"Any\"\n}\n\nfunction mapEveryColumn(columns: Column[]): GristWidgetColumnMap {\n return Object.fromEntries(columns.map((c) => [c.name, c.allowMultiple ? [c.name] : c.name]))\n}\n\n/** One table with a column per declared column, and one row of sample values. */\nfunction smokeTestDocument(columns: Column[]): GristReplicaDocument {\n return {\n generatedAt: \"1970-01-01T00:00:00.000Z\",\n docName: \"Smoke test\",\n mode: \"schema+data\",\n tables: {\n Table1: {\n columns: Object.fromEntries(columns.map((c) => [c.name, { type: c.type }])),\n rows: [{ id: 1, ...Object.fromEntries(columns.map((c) => [c.name, sampleValue(c.type)])) }],\n },\n },\n }\n}\n\nfunction sampleValue(type: string): unknown {\n switch (type) {\n case \"Numeric\":\n case \"Int\":\n return 42\n case \"Bool\":\n return true\n case \"Date\":\n case \"DateTime\":\n return 1767225600 // 2026-01-01, as Grist stores it: epoch seconds\n default:\n return \"Sample\"\n }\n}\n","/**\n * Browser APIs jsdom lacks but widget UI commonly uses, as inert stand-ins:\n * `ResizeObserver` (charts, virtualized lists, popovers) and\n * `window.matchMedia` (the theme, responsive hooks; it reports a light,\n * wide screen). Only installs what's missing, so a test's own mock wins.\n *\n * {@link smokeTestWidget} calls it. For a widget's other tests, call it at\n * the top of the test file or in a Vitest setup file.\n */\nexport function installJsdomStubs(): void {\n if (typeof window === \"undefined\") return\n\n globalThis.ResizeObserver ??= class ResizeObserver {\n observe() {}\n unobserve() {}\n disconnect() {}\n }\n\n window.matchMedia ??= (query: string) =>\n ({\n matches: false,\n media: query,\n onchange: null,\n addEventListener() {},\n removeEventListener() {},\n addListener() {},\n removeListener() {},\n dispatchEvent: () => false,\n }) as MediaQueryList\n}\n","/**\n * Vitest helpers to assert what the widget did to the document.\n *\n * Usage:\n *\n * const { emulator } = renderWithGrist(<MyWidget />)\n * await userEvent.click(screen.getByText(\"Add\"))\n * expect(actionsOf(emulator)).toContainEqual([\"AddRecord\", \"Tasks\", null, { title: \"X\" }])\n */\n\nimport type { GristEmulator } from \"../create-grist-emulator\"\nimport type { EmulatorEvent } from \"../core/event-bus\"\n\nexport function actionsOf(emulator: GristEmulator): unknown[][] {\n return emulator.bus\n .history()\n .filter((e: EmulatorEvent): e is Extract<EmulatorEvent, { type: \"user-action\" }> => e.type === \"user-action\")\n .map((e) => e.action as unknown[])\n}\n\nexport function eventsOf(emulator: GristEmulator): readonly EmulatorEvent[] {\n return emulator.bus.history()\n}\n\n/** Bus event kinds aligned with grist host callbacks (see inline transport). */\nexport type WaitForEventKind = \"ready\" | \"record\" | \"records\" | \"options\" | \"theme\" | \"cursor\"\n\nexport type WaitForEventOptions = {\n timeoutMs?: number\n}\n\nfunction predicateForKind(kind: WaitForEventKind): (event: EmulatorEvent) => boolean {\n switch (kind) {\n case \"ready\":\n return (e) => e.type === \"ready\"\n case \"record\":\n case \"cursor\":\n return (e) => e.type === \"cursor-change\"\n case \"records\":\n return (e) => e.type === \"data-change\"\n case \"options\":\n return (e) => e.type === \"options-change\"\n case \"theme\":\n return (e) => e.type === \"theme-change\"\n }\n}\n\nfunction waitForNextEvent(\n emulator: GristEmulator,\n predicate: (event: EmulatorEvent) => boolean,\n timeoutMs: number,\n label?: string\n): Promise<EmulatorEvent> {\n return new Promise((resolve, reject) => {\n const timer = setTimeout(() => {\n off()\n const hint = label ? ` (kind: ${label})` : \"\"\n const recent = emulator.bus\n .history()\n .slice(-5)\n .map((e) => e.type)\n .join(\", \")\n reject(\n new Error(\n `waitForEvent timed out after ${timeoutMs}ms${hint}.` +\n (recent ? ` Recent bus events: ${recent}.` : \" No bus events yet.\")\n )\n )\n }, timeoutMs)\n const off = emulator.bus.on((event) => {\n if (predicate(event)) {\n clearTimeout(timer)\n off()\n resolve(event)\n }\n })\n })\n}\n\nexport function waitForEvent(\n emulator: GristEmulator,\n kind: WaitForEventKind,\n options?: WaitForEventOptions\n): Promise<EmulatorEvent>\nexport function waitForEvent(\n emulator: GristEmulator,\n predicate: (event: EmulatorEvent) => boolean,\n timeoutMs?: number\n): Promise<EmulatorEvent>\nexport function waitForEvent(\n emulator: GristEmulator,\n kindOrPredicate: WaitForEventKind | ((event: EmulatorEvent) => boolean),\n timeoutOrOptions: number | WaitForEventOptions = 1000\n): Promise<EmulatorEvent> {\n if (typeof kindOrPredicate === \"string\") {\n const opts = typeof timeoutOrOptions === \"object\" ? timeoutOrOptions : {}\n const timeoutMs = opts.timeoutMs ?? 1000\n return waitForNextEvent(emulator, predicateForKind(kindOrPredicate), timeoutMs, kindOrPredicate)\n }\n const timeoutMs = typeof timeoutOrOptions === \"number\" ? timeoutOrOptions : 1000\n return waitForNextEvent(emulator, kindOrPredicate, timeoutMs)\n}\n","/**\n * Test entry point — `grist-widget-sdk/emulator/testing`.\n *\n * Bundles `renderWithGrist`, matchers, document presets, and the most-used\n * @testing-library/react primitives so a typical test file only needs one\n * import line:\n *\n * import {\n * renderWithGrist, presets, screen, fireEvent, waitFor, actionsOf,\n * } from \"grist-widget-sdk/emulator/testing\"\n */\n\nexport { renderWithGrist } from \"./render-with-grist\"\nexport type {\n RenderWithGristOptions,\n RenderWithGristResult,\n} from \"./render-with-grist\"\n\nexport { smokeTestWidget, type SmokeTestWidgetOptions } from \"./smoke-test-widget\"\nexport { installJsdomStubs } from \"./jsdom-stubs\"\n\nexport {\n actionsOf,\n eventsOf,\n waitForEvent,\n type WaitForEventKind,\n type WaitForEventOptions,\n} from \"./matchers\"\n\n// Document fixtures (re-export from the emulator entry for convenience).\nexport { presets } from \"../templates\"\n\n// @testing-library/react convenience re-exports — see AGENTS.md\nexport {\n act,\n cleanup,\n fireEvent,\n render,\n screen,\n waitFor,\n within,\n} from \"@testing-library/react\"\nexport type { RenderOptions, RenderResult } from \"@testing-library/react\"\n"],"mappings":";;;;;;;;;;;;;AAaA,SAAS,cAAqD;AAiBvD,SAAS,gBACd,IACA,UAAkC,CAAC,GACZ;AAIvB,oBAAkB;AAElB,qBAAmB;AAEnB,QAAM,WACJ,QAAQ,YACR,oBAAoB,QAAQ,YAAY,EAAE,UAAU,QAAQ,MAAM,EAAE,CAAC;AAEvE,QAAM,SAAS,OAAO,IAAI,OAAO;AACjC,QAAM,kBAAkB,OAAO;AAC/B,SAAO,UAAU,MAAM;AACrB,oBAAgB;AAChB,QAAI,CAAC,QAAQ,SAAU,UAAS,QAAQ;AACxC,uBAAmB;AAAA,EACrB;AACA,SAAO,OAAO,OAAO,QAAQ,EAAE,SAAS,CAAC;AAC3C;AAEA,SAAS,oBAAoB;AAC3B,MAAI,OAAO,WAAW,YAAa;AACnC,MAAI,OAAO,SAAS,OAAO,IAAK;AAChC,MAAI;AACF,WAAO,eAAe,QAAQ,OAAO;AAAA,MACnC,cAAc;AAAA,MACd,KAAK,OAAO,CAAC;AAAA,IACf,CAAC;AAAA,EACH,QAAQ;AAAA,EAGR;AACF;;;ACnEA,SAAS,iBAAqD;AAC9D,SAAS,eAAe;;;ACQjB,SAAS,oBAA0B;AACxC,MAAI,OAAO,WAAW,YAAa;AAEnC,aAAW,mBAAX,WAAW,iBAAmB,MAAM,eAAe;AAAA,IACjD,UAAU;AAAA,IAAC;AAAA,IACX,YAAY;AAAA,IAAC;AAAA,IACb,aAAa;AAAA,IAAC;AAAA,EAChB;AAEA,SAAO,eAAP,OAAO,aAAe,CAAC,WACpB;AAAA,IACC,SAAS;AAAA,IACT,OAAO;AAAA,IACP,UAAU;AAAA,IACV,mBAAmB;AAAA,IAAC;AAAA,IACpB,sBAAsB;AAAA,IAAC;AAAA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