grist-widget-sdk 0.3.26 → 0.3.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/advanced.js +10 -13
- package/dist/advanced.js.map +1 -1
- package/dist/app.js +10 -514
- package/dist/app.js.map +1 -1
- package/dist/chunk-6Y2IONGJ.js +519 -0
- package/dist/chunk-6Y2IONGJ.js.map +1 -0
- package/dist/{chunk-PDGEZ24B.js → chunk-B4AKVSWV.js} +16 -20
- package/dist/{chunk-PDGEZ24B.js.map → chunk-B4AKVSWV.js.map} +1 -1
- package/dist/{chunk-TZB3OZA6.js → chunk-NO6FYX33.js} +782 -328
- package/dist/chunk-NO6FYX33.js.map +1 -0
- package/dist/{chunk-JASMM2YC.js → chunk-OPTOYD2Y.js} +36 -2
- package/dist/chunk-OPTOYD2Y.js.map +1 -0
- package/dist/emulator/devtools.js +2 -4
- package/dist/emulator/devtools.js.map +1 -1
- package/dist/emulator/testing.cjs +5098 -87
- package/dist/emulator/testing.cjs.map +1 -1
- package/dist/emulator/testing.d.cts +55 -4
- package/dist/emulator/testing.d.ts +55 -4
- package/dist/emulator/testing.js +142 -4
- package/dist/emulator/testing.js.map +1 -1
- package/dist/index.js +4 -7
- package/package.json +1 -1
- package/dist/chunk-EPEBKXVN.js +0 -470
- package/dist/chunk-EPEBKXVN.js.map +0 -1
- package/dist/chunk-JASMM2YC.js.map +0 -1
- package/dist/chunk-N3X46JW2.js +0 -37
- package/dist/chunk-N3X46JW2.js.map +0 -1
- package/dist/chunk-TZB3OZA6.js.map +0 -1
|
@@ -1,10 +1,13 @@
|
|
|
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
4
|
import { CreateGristEmulatorOptions, GristEmulator } from '../emulator.cjs';
|
|
5
|
+
import { GristReplicaDocument } from '../emulator.cjs';
|
|
6
|
+
import { UseGristOptions } from '../index.cjs';
|
|
5
7
|
import { EmulatorEvent } from '../emulator.cjs';
|
|
6
8
|
export { p as presets } from '../templates-8k2LKoO-.cjs';
|
|
7
|
-
import '../
|
|
9
|
+
import '../use-grist-reads-DpjVuI0H.cjs';
|
|
10
|
+
import 'zod';
|
|
8
11
|
|
|
9
12
|
/**
|
|
10
13
|
* `renderWithGrist(ui, options)` — drop-in replacement for
|
|
@@ -27,6 +30,54 @@ type RenderWithGristResult = RenderResult & {
|
|
|
27
30
|
};
|
|
28
31
|
declare function renderWithGrist(ui: ReactElement, options?: RenderWithGristOptions): RenderWithGristResult;
|
|
29
32
|
|
|
33
|
+
type SmokeTestWidgetOptions = {
|
|
34
|
+
/** The widget, as `src/main.tsx` passes it to `mountGristWidget()`. */
|
|
35
|
+
App: ComponentType;
|
|
36
|
+
/** The widget's `GRIST_OPTIONS`. */
|
|
37
|
+
options: UseGristOptions;
|
|
38
|
+
/**
|
|
39
|
+
* The Grist document to run against. Defaults to one table with a column
|
|
40
|
+
* per column the widget declares, typed after the first type it accepts,
|
|
41
|
+
* and one row of sample values.
|
|
42
|
+
*/
|
|
43
|
+
document?: GristReplicaDocument;
|
|
44
|
+
/** How long to wait for the widget to render, in ms. Defaults to 10 000. */
|
|
45
|
+
timeout?: number;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Mounts the widget the way `mountGristWidget()` does inside Grist, against
|
|
49
|
+
* an emulated Grist document with every column it declares mapped and the
|
|
50
|
+
* access it requests granted, and waits until it renders past
|
|
51
|
+
* `GristBoundary`. Resolves once it has,
|
|
52
|
+
* rejects with the widget's own error if it throws, or with what the page
|
|
53
|
+
* showed instead if it never gets there. Then unmounts.
|
|
54
|
+
*
|
|
55
|
+
* A widget's whole smoke test:
|
|
56
|
+
*
|
|
57
|
+
* ```tsx
|
|
58
|
+
* import { it } from "vitest"
|
|
59
|
+
* import { smokeTestWidget } from "grist-widget-sdk/emulator/testing"
|
|
60
|
+
* import App, { GRIST_OPTIONS } from "./App"
|
|
61
|
+
*
|
|
62
|
+
* it("renders inside Grist", () => smokeTestWidget({ App, options: GRIST_OPTIONS }))
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* It only reads `GRIST_OPTIONS`, so it stays valid as the widget changes,
|
|
66
|
+
* and it improves with each SDK release.
|
|
67
|
+
*/
|
|
68
|
+
declare function smokeTestWidget({ App, options, document, timeout, }: SmokeTestWidgetOptions): Promise<void>;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Browser APIs jsdom lacks but widget UI commonly uses, as inert stand-ins:
|
|
72
|
+
* `ResizeObserver` (charts, virtualized lists, popovers) and
|
|
73
|
+
* `window.matchMedia` (the theme, responsive hooks; it reports a light,
|
|
74
|
+
* wide screen). Only installs what's missing, so a test's own mock wins.
|
|
75
|
+
*
|
|
76
|
+
* {@link smokeTestWidget} calls it. For a widget's other tests, call it at
|
|
77
|
+
* the top of the test file or in a Vitest setup file.
|
|
78
|
+
*/
|
|
79
|
+
declare function installJsdomStubs(): void;
|
|
80
|
+
|
|
30
81
|
/**
|
|
31
82
|
* Vitest helpers to assert what the widget did to the document.
|
|
32
83
|
*
|
|
@@ -47,5 +98,5 @@ type WaitForEventOptions = {
|
|
|
47
98
|
declare function waitForEvent(emulator: GristEmulator, kind: WaitForEventKind, options?: WaitForEventOptions): Promise<EmulatorEvent>;
|
|
48
99
|
declare function waitForEvent(emulator: GristEmulator, predicate: (event: EmulatorEvent) => boolean, timeoutMs?: number): Promise<EmulatorEvent>;
|
|
49
100
|
|
|
50
|
-
export { actionsOf, eventsOf, renderWithGrist, waitForEvent };
|
|
51
|
-
export type { RenderWithGristOptions, RenderWithGristResult, WaitForEventKind, WaitForEventOptions };
|
|
101
|
+
export { actionsOf, eventsOf, installJsdomStubs, renderWithGrist, smokeTestWidget, waitForEvent };
|
|
102
|
+
export type { RenderWithGristOptions, RenderWithGristResult, SmokeTestWidgetOptions, WaitForEventKind, WaitForEventOptions };
|
|
@@ -1,10 +1,13 @@
|
|
|
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
4
|
import { CreateGristEmulatorOptions, GristEmulator } from '../emulator.js';
|
|
5
|
+
import { GristReplicaDocument } from '../emulator.js';
|
|
6
|
+
import { UseGristOptions } from '../index.js';
|
|
5
7
|
import { EmulatorEvent } from '../emulator.js';
|
|
6
8
|
export { p as presets } from '../templates-DIwi_mvI.js';
|
|
7
|
-
import '../
|
|
9
|
+
import '../use-grist-reads-DUMvJgV7.js';
|
|
10
|
+
import 'zod';
|
|
8
11
|
|
|
9
12
|
/**
|
|
10
13
|
* `renderWithGrist(ui, options)` — drop-in replacement for
|
|
@@ -27,6 +30,54 @@ type RenderWithGristResult = RenderResult & {
|
|
|
27
30
|
};
|
|
28
31
|
declare function renderWithGrist(ui: ReactElement, options?: RenderWithGristOptions): RenderWithGristResult;
|
|
29
32
|
|
|
33
|
+
type SmokeTestWidgetOptions = {
|
|
34
|
+
/** The widget, as `src/main.tsx` passes it to `mountGristWidget()`. */
|
|
35
|
+
App: ComponentType;
|
|
36
|
+
/** The widget's `GRIST_OPTIONS`. */
|
|
37
|
+
options: UseGristOptions;
|
|
38
|
+
/**
|
|
39
|
+
* The Grist document to run against. Defaults to one table with a column
|
|
40
|
+
* per column the widget declares, typed after the first type it accepts,
|
|
41
|
+
* and one row of sample values.
|
|
42
|
+
*/
|
|
43
|
+
document?: GristReplicaDocument;
|
|
44
|
+
/** How long to wait for the widget to render, in ms. Defaults to 10 000. */
|
|
45
|
+
timeout?: number;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Mounts the widget the way `mountGristWidget()` does inside Grist, against
|
|
49
|
+
* an emulated Grist document with every column it declares mapped and the
|
|
50
|
+
* access it requests granted, and waits until it renders past
|
|
51
|
+
* `GristBoundary`. Resolves once it has,
|
|
52
|
+
* rejects with the widget's own error if it throws, or with what the page
|
|
53
|
+
* showed instead if it never gets there. Then unmounts.
|
|
54
|
+
*
|
|
55
|
+
* A widget's whole smoke test:
|
|
56
|
+
*
|
|
57
|
+
* ```tsx
|
|
58
|
+
* import { it } from "vitest"
|
|
59
|
+
* import { smokeTestWidget } from "grist-widget-sdk/emulator/testing"
|
|
60
|
+
* import App, { GRIST_OPTIONS } from "./App"
|
|
61
|
+
*
|
|
62
|
+
* it("renders inside Grist", () => smokeTestWidget({ App, options: GRIST_OPTIONS }))
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* It only reads `GRIST_OPTIONS`, so it stays valid as the widget changes,
|
|
66
|
+
* and it improves with each SDK release.
|
|
67
|
+
*/
|
|
68
|
+
declare function smokeTestWidget({ App, options, document, timeout, }: SmokeTestWidgetOptions): Promise<void>;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Browser APIs jsdom lacks but widget UI commonly uses, as inert stand-ins:
|
|
72
|
+
* `ResizeObserver` (charts, virtualized lists, popovers) and
|
|
73
|
+
* `window.matchMedia` (the theme, responsive hooks; it reports a light,
|
|
74
|
+
* wide screen). Only installs what's missing, so a test's own mock wins.
|
|
75
|
+
*
|
|
76
|
+
* {@link smokeTestWidget} calls it. For a widget's other tests, call it at
|
|
77
|
+
* the top of the test file or in a Vitest setup file.
|
|
78
|
+
*/
|
|
79
|
+
declare function installJsdomStubs(): void;
|
|
80
|
+
|
|
30
81
|
/**
|
|
31
82
|
* Vitest helpers to assert what the widget did to the document.
|
|
32
83
|
*
|
|
@@ -47,5 +98,5 @@ type WaitForEventOptions = {
|
|
|
47
98
|
declare function waitForEvent(emulator: GristEmulator, kind: WaitForEventKind, options?: WaitForEventOptions): Promise<EmulatorEvent>;
|
|
48
99
|
declare function waitForEvent(emulator: GristEmulator, predicate: (event: EmulatorEvent) => boolean, timeoutMs?: number): Promise<EmulatorEvent>;
|
|
49
100
|
|
|
50
|
-
export { actionsOf, eventsOf, renderWithGrist, waitForEvent };
|
|
51
|
-
export type { RenderWithGristOptions, RenderWithGristResult, WaitForEventKind, WaitForEventOptions };
|
|
101
|
+
export { actionsOf, eventsOf, installJsdomStubs, renderWithGrist, smokeTestWidget, waitForEvent };
|
|
102
|
+
export type { RenderWithGristOptions, RenderWithGristResult, SmokeTestWidgetOptions, WaitForEventKind, WaitForEventOptions };
|
package/dist/emulator/testing.js
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GristWidgetApp
|
|
3
|
+
} from "../chunk-6Y2IONGJ.js";
|
|
4
|
+
import "../chunk-B4AKVSWV.js";
|
|
1
5
|
import {
|
|
2
6
|
resetEmbeddedHandshakeManagerForTests,
|
|
3
7
|
resetGristEventsForTests,
|
|
4
8
|
resetGristReadyCacheForTests
|
|
5
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-NO6FYX33.js";
|
|
6
10
|
import {
|
|
7
11
|
createGristEmulator,
|
|
8
12
|
presets
|
|
9
13
|
} from "../chunk-22U7WAY3.js";
|
|
10
14
|
import "../chunk-YQNMIL33.js";
|
|
11
15
|
import "../chunk-GTTD5HPO.js";
|
|
12
|
-
import "../chunk-
|
|
16
|
+
import "../chunk-REV5AUXD.js";
|
|
17
|
+
import "../chunk-OPTOYD2Y.js";
|
|
13
18
|
import "../chunk-ELGVOHFD.js";
|
|
14
19
|
import "../chunk-PM3B4WYV.js";
|
|
15
20
|
import "../chunk-64SVRWW7.js";
|
|
@@ -45,6 +50,137 @@ function fakeIframeContext() {
|
|
|
45
50
|
}
|
|
46
51
|
}
|
|
47
52
|
|
|
53
|
+
// src/emulator/testing/smoke-test-widget.tsx
|
|
54
|
+
import { Component } from "react";
|
|
55
|
+
import { waitFor } from "@testing-library/react";
|
|
56
|
+
|
|
57
|
+
// src/emulator/testing/jsdom-stubs.ts
|
|
58
|
+
function installJsdomStubs() {
|
|
59
|
+
if (typeof window === "undefined") return;
|
|
60
|
+
globalThis.ResizeObserver ?? (globalThis.ResizeObserver = class ResizeObserver {
|
|
61
|
+
observe() {
|
|
62
|
+
}
|
|
63
|
+
unobserve() {
|
|
64
|
+
}
|
|
65
|
+
disconnect() {
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
window.matchMedia ?? (window.matchMedia = (query) => ({
|
|
69
|
+
matches: false,
|
|
70
|
+
media: query,
|
|
71
|
+
onchange: null,
|
|
72
|
+
addEventListener() {
|
|
73
|
+
},
|
|
74
|
+
removeEventListener() {
|
|
75
|
+
},
|
|
76
|
+
addListener() {
|
|
77
|
+
},
|
|
78
|
+
removeListener() {
|
|
79
|
+
},
|
|
80
|
+
dispatchEvent: () => false
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// src/emulator/testing/smoke-test-widget.tsx
|
|
85
|
+
import { jsx } from "react/jsx-runtime";
|
|
86
|
+
async function smokeTestWidget({
|
|
87
|
+
App,
|
|
88
|
+
options,
|
|
89
|
+
document,
|
|
90
|
+
timeout = 1e4
|
|
91
|
+
}) {
|
|
92
|
+
installJsdomStubs();
|
|
93
|
+
const crash = { error: void 0 };
|
|
94
|
+
function Probe() {
|
|
95
|
+
return /* @__PURE__ */ jsx(CatchRenderError, { crash, children: /* @__PURE__ */ jsx("div", { "data-grist-smoke-test": "", children: /* @__PURE__ */ jsx(App, {}) }) });
|
|
96
|
+
}
|
|
97
|
+
const columns = declaredColumns(options);
|
|
98
|
+
const gristDocument = document ?? smokeTestDocument(columns);
|
|
99
|
+
const result = renderWithGrist(/* @__PURE__ */ jsx(GristWidgetApp, { App: Probe, options }), {
|
|
100
|
+
emulator: {
|
|
101
|
+
document: gristDocument,
|
|
102
|
+
// Granted as the user would in Grist's widget panel: the access the
|
|
103
|
+
// widget asks for, unless the given document says otherwise.
|
|
104
|
+
widgetInteraction: gristDocument.widgetInteraction ?? { access_level: options.requiredAccess ?? "read table" }
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
try {
|
|
108
|
+
if (columns.length > 0) result.emulator.setColumnMappings(mapEveryColumn(columns));
|
|
109
|
+
try {
|
|
110
|
+
await waitFor(
|
|
111
|
+
() => {
|
|
112
|
+
if (crash.error !== void 0) return;
|
|
113
|
+
const probe = result.container.querySelector("[data-grist-smoke-test]");
|
|
114
|
+
if (!probe || !probe.hasChildNodes()) throw new Error("not rendered yet");
|
|
115
|
+
},
|
|
116
|
+
{ timeout }
|
|
117
|
+
);
|
|
118
|
+
} catch {
|
|
119
|
+
const shown = result.container.textContent?.trim().replace(/\s+/g, " ") || "nothing";
|
|
120
|
+
throw new Error(
|
|
121
|
+
`smokeTestWidget: the widget didn't render past GristBoundary within ${timeout} ms. The page showed: "${shown.slice(0, 300)}".`
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
if (crash.error !== void 0) throw crash.error;
|
|
125
|
+
} finally {
|
|
126
|
+
result.unmount();
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
var CatchRenderError = class extends Component {
|
|
130
|
+
constructor() {
|
|
131
|
+
super(...arguments);
|
|
132
|
+
this.state = { failed: false };
|
|
133
|
+
}
|
|
134
|
+
static getDerivedStateFromError() {
|
|
135
|
+
return { failed: true };
|
|
136
|
+
}
|
|
137
|
+
componentDidCatch(error) {
|
|
138
|
+
this.props.crash.error = error;
|
|
139
|
+
}
|
|
140
|
+
render() {
|
|
141
|
+
return this.state.failed ? null : this.props.children;
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
function declaredColumns(options) {
|
|
145
|
+
return (options.columns ?? []).map(
|
|
146
|
+
(column) => typeof column === "string" ? { name: column, type: "Any", allowMultiple: false } : { name: column.name, type: firstType(column.type), allowMultiple: column.allowMultiple === true }
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
function firstType(type) {
|
|
150
|
+
return (type ?? "Any").split(",")[0].trim() || "Any";
|
|
151
|
+
}
|
|
152
|
+
function mapEveryColumn(columns) {
|
|
153
|
+
return Object.fromEntries(columns.map((c) => [c.name, c.allowMultiple ? [c.name] : c.name]));
|
|
154
|
+
}
|
|
155
|
+
function smokeTestDocument(columns) {
|
|
156
|
+
return {
|
|
157
|
+
generatedAt: "1970-01-01T00:00:00.000Z",
|
|
158
|
+
docName: "Smoke test",
|
|
159
|
+
mode: "schema+data",
|
|
160
|
+
tables: {
|
|
161
|
+
Table1: {
|
|
162
|
+
columns: Object.fromEntries(columns.map((c) => [c.name, { type: c.type }])),
|
|
163
|
+
rows: [{ id: 1, ...Object.fromEntries(columns.map((c) => [c.name, sampleValue(c.type)])) }]
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
function sampleValue(type) {
|
|
169
|
+
switch (type) {
|
|
170
|
+
case "Numeric":
|
|
171
|
+
case "Int":
|
|
172
|
+
return 42;
|
|
173
|
+
case "Bool":
|
|
174
|
+
return true;
|
|
175
|
+
case "Date":
|
|
176
|
+
case "DateTime":
|
|
177
|
+
return 1767225600;
|
|
178
|
+
// 2026-01-01, as Grist stores it: epoch seconds
|
|
179
|
+
default:
|
|
180
|
+
return "Sample";
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
48
184
|
// src/emulator/testing/matchers.ts
|
|
49
185
|
function actionsOf(emulator) {
|
|
50
186
|
return emulator.bus.history().filter((e) => e.type === "user-action").map((e) => e.action);
|
|
@@ -105,7 +241,7 @@ import {
|
|
|
105
241
|
fireEvent,
|
|
106
242
|
render as render2,
|
|
107
243
|
screen,
|
|
108
|
-
waitFor,
|
|
244
|
+
waitFor as waitFor2,
|
|
109
245
|
within
|
|
110
246
|
} from "@testing-library/react";
|
|
111
247
|
export {
|
|
@@ -114,11 +250,13 @@ export {
|
|
|
114
250
|
cleanup,
|
|
115
251
|
eventsOf,
|
|
116
252
|
fireEvent,
|
|
253
|
+
installJsdomStubs,
|
|
117
254
|
presets,
|
|
118
255
|
render2 as render,
|
|
119
256
|
renderWithGrist,
|
|
120
257
|
screen,
|
|
121
|
-
|
|
258
|
+
smokeTestWidget,
|
|
259
|
+
waitFor2 as waitFor,
|
|
122
260
|
waitForEvent,
|
|
123
261
|
within
|
|
124
262
|
};
|
|
@@ -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,WAAO,eAAe,QAAQ,OAAO;AAAA,MACnC,cAAc;AAAA,MACd,KAAK,OAAO,CAAC;AAAA,IACf,CAAC;AAAA,EACH,QAAQ;AAAA,EAGR;AACF;;;AC5DO,SAAS,UAAU,UAAsC;AAC9D,SAAO,SAAS,IACb,QAAQ,EACR,OAAO,CAAC,MAA2E,EAAE,SAAS,aAAa,EAC3G,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U,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 { 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","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;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,WAAO,eAAe,QAAQ,OAAO;AAAA,MACnC,cAAc;AAAA,MACd,KAAK,OAAO,CAAC;AAAA,IACf,CAAC;AAAA,EACH,QAAQ;AAAA,EAGR;AACF;;;ACzEA,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,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OAC/C,SAAS,uBAAuB,MAAM,MAAM;AAAA,QACjD;AAAA,MACF;AAAA,IACF,GAAG,SAAS;AACZ,UAAM,MAAM,SAAS,IAAI,GAAG,CAAC,UAAU;AACrC,UAAI,UAAU,KAAK,GAAG;AACpB,qBAAa,KAAK;AAClB,YAAI;AACJ,gBAAQ,KAAK;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;;;ACpEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAAC;AAAA,EACA;AAAA,EACA,WAAAC;AAAA,EACA;AAAA,OACK;","names":["timeoutMs","render","waitFor"]}
|
package/dist/index.js
CHANGED
|
@@ -51,15 +51,13 @@ import {
|
|
|
51
51
|
useGristTheme,
|
|
52
52
|
useGristWrites,
|
|
53
53
|
useWidgetMetadata
|
|
54
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-B4AKVSWV.js";
|
|
55
55
|
import {
|
|
56
56
|
fetchWithGristAuth,
|
|
57
57
|
getGristAccessToken,
|
|
58
|
-
useGristWidgetOptionsFromContext
|
|
59
|
-
} from "./chunk-EPEBKXVN.js";
|
|
60
|
-
import {
|
|
58
|
+
useGristWidgetOptionsFromContext,
|
|
61
59
|
validateColumnMappings
|
|
62
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-NO6FYX33.js";
|
|
63
61
|
import {
|
|
64
62
|
buildReplicaJsonPayload,
|
|
65
63
|
normalizeReplicaDocumentInput,
|
|
@@ -79,8 +77,7 @@ import {
|
|
|
79
77
|
safeParseRowsToDisplayRows,
|
|
80
78
|
sortRowsByGristOrder,
|
|
81
79
|
tableDataToRows
|
|
82
|
-
} from "./chunk-
|
|
83
|
-
import "./chunk-N3X46JW2.js";
|
|
80
|
+
} from "./chunk-OPTOYD2Y.js";
|
|
84
81
|
import {
|
|
85
82
|
coerceGristDocApiRefRowId,
|
|
86
83
|
decodeGristValue,
|