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,81 +0,0 @@
1
- import { E as EmulatorDocumentState, g as EventBus, c as EmulatorApiBundle, f as EmulatorTransport, I as InlineGristGlobal } from './inline-DpcT8tV9.js';
2
- import { d as GristWidgetColumnMap, b as GristReplicaDocument } from './types-D3JxUCfL.js';
3
-
4
- /**
5
- * Top-level emulator factory. Produces a fully-wired emulator instance:
6
- *
7
- * - typed in-memory document state,
8
- * - shared event bus,
9
- * - the six host API impls,
10
- * - one transport (inline by default, iframe when an iframe is provided),
11
- * - imperative helpers (`mutate`, `apply`, `selectRow`, `selectTable`)
12
- * that drive the document via the action engine and emit corresponding
13
- * events.
14
- *
15
- * The instance is multi-instance friendly: nothing is stored on `window`.
16
- */
17
-
18
- type CreateGristEmulatorOptions = {
19
- /** The starting document (must satisfy {@link parseDocument}). */
20
- document: GristReplicaDocument;
21
- /**
22
- * Pick a transport:
23
- * - omit / "inline" → synthesises `window.grist` directly (or onto `target`),
24
- * - "iframe" → wires a real iframe loading `grist-plugin-api.js`.
25
- */
26
- transport?: {
27
- kind: "inline";
28
- target?: Window & typeof globalThis;
29
- } | {
30
- kind: "iframe";
31
- iframe: HTMLIFrameElement;
32
- targetOrigin?: string;
33
- };
34
- /** Initial widget options exposed via `WidgetAPI`. */
35
- widgetOptions?: Record<string, unknown>;
36
- /**
37
- * Initial widget interaction info (`access_level` and friends) sent
38
- * alongside `onOptions`. Defaults to `{ access_level: "read table" }`.
39
- */
40
- widgetInteraction?: Record<string, unknown>;
41
- /** Initial document theme replayed on widget ready (host `message` channel). */
42
- initialTheme?: "light" | "dark";
43
- };
44
- type GristEmulator = {
45
- /** Underlying mutable document. Treat as read-only outside of `mutate(...)`. */
46
- state: EmulatorDocumentState;
47
- bus: EventBus;
48
- api: EmulatorApiBundle;
49
- transport: EmulatorTransport;
50
- /** Synthesised `grist` global (only for the inline transport). */
51
- grist?: InlineGristGlobal;
52
- /** Apply a list of Grist user actions; emits the matching events. */
53
- apply: (actions: unknown[][]) => {
54
- retValues: unknown[];
55
- };
56
- /** Convenience helpers for tests and demos. */
57
- mutate: {
58
- addRow: (tableId: string, fields: Record<string, unknown>) => number;
59
- updateRow: (tableId: string, rowId: number, fields: Record<string, unknown>) => void;
60
- removeRow: (tableId: string, rowId: number) => void;
61
- };
62
- selectRow: (rowId: number | "new" | null) => void;
63
- selectTable: (tableId: string) => void;
64
- /**
65
- * Set logical→real column mappings for the playground inspector (and tests).
66
- * Pass `undefined` to clear — `mappings()` becomes `null` until set again.
67
- */
68
- setColumnMappings: (mappings: GristWidgetColumnMap | undefined) => void;
69
- setOptions: (options: Record<string, unknown>) => Promise<void>;
70
- setInteraction: (interaction: Record<string, unknown>) => void;
71
- /** Host theme controls (`grist.on("message")` / `msg.theme`). */
72
- theme: {
73
- set: (theme: "light" | "dark") => void;
74
- };
75
- /** Tear down the emulator. Idempotent. */
76
- dispose: () => void;
77
- };
78
- declare function createGristEmulator(options: CreateGristEmulatorOptions): GristEmulator;
79
-
80
- export { createGristEmulator as c };
81
- export type { CreateGristEmulatorOptions as C, GristEmulator as G };
@@ -1,81 +0,0 @@
1
- import { E as EmulatorDocumentState, g as EventBus, c as EmulatorApiBundle, f as EmulatorTransport, I as InlineGristGlobal } from './inline-C7DkvuET.cjs';
2
- import { d as GristWidgetColumnMap, b as GristReplicaDocument } from './types-D3JxUCfL.cjs';
3
-
4
- /**
5
- * Top-level emulator factory. Produces a fully-wired emulator instance:
6
- *
7
- * - typed in-memory document state,
8
- * - shared event bus,
9
- * - the six host API impls,
10
- * - one transport (inline by default, iframe when an iframe is provided),
11
- * - imperative helpers (`mutate`, `apply`, `selectRow`, `selectTable`)
12
- * that drive the document via the action engine and emit corresponding
13
- * events.
14
- *
15
- * The instance is multi-instance friendly: nothing is stored on `window`.
16
- */
17
-
18
- type CreateGristEmulatorOptions = {
19
- /** The starting document (must satisfy {@link parseDocument}). */
20
- document: GristReplicaDocument;
21
- /**
22
- * Pick a transport:
23
- * - omit / "inline" → synthesises `window.grist` directly (or onto `target`),
24
- * - "iframe" → wires a real iframe loading `grist-plugin-api.js`.
25
- */
26
- transport?: {
27
- kind: "inline";
28
- target?: Window & typeof globalThis;
29
- } | {
30
- kind: "iframe";
31
- iframe: HTMLIFrameElement;
32
- targetOrigin?: string;
33
- };
34
- /** Initial widget options exposed via `WidgetAPI`. */
35
- widgetOptions?: Record<string, unknown>;
36
- /**
37
- * Initial widget interaction info (`access_level` and friends) sent
38
- * alongside `onOptions`. Defaults to `{ access_level: "read table" }`.
39
- */
40
- widgetInteraction?: Record<string, unknown>;
41
- /** Initial document theme replayed on widget ready (host `message` channel). */
42
- initialTheme?: "light" | "dark";
43
- };
44
- type GristEmulator = {
45
- /** Underlying mutable document. Treat as read-only outside of `mutate(...)`. */
46
- state: EmulatorDocumentState;
47
- bus: EventBus;
48
- api: EmulatorApiBundle;
49
- transport: EmulatorTransport;
50
- /** Synthesised `grist` global (only for the inline transport). */
51
- grist?: InlineGristGlobal;
52
- /** Apply a list of Grist user actions; emits the matching events. */
53
- apply: (actions: unknown[][]) => {
54
- retValues: unknown[];
55
- };
56
- /** Convenience helpers for tests and demos. */
57
- mutate: {
58
- addRow: (tableId: string, fields: Record<string, unknown>) => number;
59
- updateRow: (tableId: string, rowId: number, fields: Record<string, unknown>) => void;
60
- removeRow: (tableId: string, rowId: number) => void;
61
- };
62
- selectRow: (rowId: number | "new" | null) => void;
63
- selectTable: (tableId: string) => void;
64
- /**
65
- * Set logical→real column mappings for the playground inspector (and tests).
66
- * Pass `undefined` to clear — `mappings()` becomes `null` until set again.
67
- */
68
- setColumnMappings: (mappings: GristWidgetColumnMap | undefined) => void;
69
- setOptions: (options: Record<string, unknown>) => Promise<void>;
70
- setInteraction: (interaction: Record<string, unknown>) => void;
71
- /** Host theme controls (`grist.on("message")` / `msg.theme`). */
72
- theme: {
73
- set: (theme: "light" | "dark") => void;
74
- };
75
- /** Tear down the emulator. Idempotent. */
76
- dispose: () => void;
77
- };
78
- declare function createGristEmulator(options: CreateGristEmulatorOptions): GristEmulator;
79
-
80
- export { createGristEmulator as c };
81
- export type { CreateGristEmulatorOptions as C, GristEmulator as G };