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 +0,0 @@
1
- {"version":3,"sources":["../src/emulator/validators.ts","../src/emulator/api/command-api.ts","../src/emulator/api/custom-section-api.ts","../src/emulator/api/grist-api.ts","../src/emulator/api/grist-doc-api.ts","../src/emulator/api/grist-view.ts","../src/emulator/api/widget-api.ts","../src/emulator/api/index.ts","../src/emulator/core/event-bus.ts","../src/emulator/create-grist-emulator.ts","../src/emulator/templates.ts"],"sourcesContent":["import { z } from \"zod\"\n\nimport type { GristReplicaDocument } from \"../sdk/replica-document\"\n\nconst emulatorRowSchema = z\n .object({ id: z.number() })\n .catchall(z.unknown())\n\nconst formulaKindSchema = z.enum([\"computed\", \"trigger\", \"none\", \"empty_slot\"])\n\nconst replicaColumnSchema = z\n .object({\n colRef: z.number().optional(),\n type: z.string().optional(),\n label: z.string().optional(),\n parentPos: z.number().optional(),\n isFormula: z.boolean().optional(),\n formulaKind: formulaKindSchema.optional(),\n formula: z.string().optional(),\n description: z.string().optional(),\n widgetOptions: z.record(z.string(), z.unknown()).optional(),\n displayColRef: z.number().optional(),\n visibleColRef: z.number().optional(),\n })\n .strict()\n\nconst replicaTableSchema = z\n .object({\n label: z.string().optional(),\n columns: z.record(z.string(), replicaColumnSchema).optional(),\n rows: z.array(emulatorRowSchema).optional(),\n rowCount: z.number().optional(),\n dataOmitted: z.boolean().optional(),\n dataOmittedReason: z.string().optional(),\n error: z.string().optional(),\n })\n .strict()\n\nconst replicaSelectionSchema = z\n .object({\n tableId: z.string().optional(),\n rowId: z.union([z.number(), z.literal(\"new\"), z.null()]).optional(),\n mappings: z.unknown().nullable().optional(),\n cursor: z.unknown().optional(),\n })\n .strict()\n\nconst replicaWidgetConfigurationSchema = z\n .object({\n requiredAccess: z.string().optional(),\n columns: z.unknown().optional(),\n allowSelectBy: z.boolean().optional(),\n hasCustomOptions: z.boolean().optional(),\n })\n .strict()\n\nconst replicaAccessTokenSchema = z\n .object({\n token: z.string(),\n baseUrl: z.string(),\n ttlMsecs: z.number(),\n })\n .strict()\n\nconst replicaDocumentSchema = z\n .object({\n generatedAt: z.string(),\n source: z.string().optional(),\n docName: z.string().optional(),\n mode: z.enum([\"schema-only\", \"schema+samples\", \"schema+data\"]).optional(),\n tables: z.record(z.string(), replicaTableSchema),\n selection: replicaSelectionSchema.optional(),\n widgetOptions: z.record(z.string(), z.unknown()).optional(),\n widgetInteraction: z.unknown().optional(),\n configuration: replicaWidgetConfigurationSchema.optional(),\n accessToken: replicaAccessTokenSchema.nullable().optional(),\n })\n .strict()\n .refine((value) => Object.keys(value.tables).length > 0, {\n message: \"at least one table is required\",\n path: [\"tables\"],\n })\n\nfunction formatZodError(prefix: string, error: z.ZodError): Error {\n const details = error.issues\n .map((issue) => {\n const where = issue.path.length > 0 ? issue.path.join(\".\") : \"<root>\"\n return `${where}: ${issue.message}`\n })\n .join(\"; \")\n return new Error(`${prefix}: ${details}`)\n}\n\nexport function safeParseDocument(input: unknown) {\n return replicaDocumentSchema.safeParse(input)\n}\n\nexport function parseDocument(input: unknown): GristReplicaDocument {\n const result = safeParseDocument(input)\n if (!result.success) {\n throw formatZodError(\"parseDocument\", result.error)\n }\n return result.data as GristReplicaDocument\n}\n","import type { EventBus } from \"../core/event-bus\"\nimport type { CommandApiImpl } from \"./types\"\n\n/**\n * `CommandAPI` host implementation. The widget's \"Edit Options\" gear and a\n * few keyboard shortcuts call into this. We forward the call name on the bus\n * so the inspector and tests can observe it; useful to assert\n * `onEditOptions` flows.\n */\nexport function createCommandApiImpl(bus: EventBus): CommandApiImpl {\n return {\n async run(name) {\n bus.emit({ type: \"user-action\", action: [\"RunCommand\", name] })\n },\n }\n}\n","import { resolveMappings } from \"../core/mappings\"\nimport type { EventBus } from \"../core/event-bus\"\nimport type { GristWidgetConfiguration } from \"../../sdk/types\"\nimport type { EmulatorDocumentState } from \"../core/types\"\nimport type { CustomSectionApiImpl } from \"./types\"\n\n/**\n * `CustomSectionAPI` host implementation, called by `grist-plugin-api.js`\n * after `grist.ready()` to hand the host the widget's preferences:\n * required access, declared columns, allowSelectBy, hasCustomOptions, etc.\n *\n * Implementation:\n * - persists the configuration onto `state.configuration`,\n * - emits a `ready` event so the iframe transport knows it's safe to push\n * initial cursor / data / options messages,\n * - re-emits a `mappings-change` so the inspector and tests can react.\n */\nexport function createCustomSectionApiImpl(\n state: EmulatorDocumentState,\n bus: EventBus\n): CustomSectionApiImpl {\n return {\n async configure(settings) {\n const config: GristWidgetConfiguration = {\n requiredAccess: settings.requiredAccess as GristWidgetConfiguration[\"requiredAccess\"],\n columns: settings.columns as GristWidgetConfiguration[\"columns\"],\n allowSelectBy: settings.allowSelectBy as boolean | undefined,\n hasCustomOptions: settings.hasCustomOptions as boolean | undefined,\n }\n state.configuration = config\n bus.emit({ type: \"ready\", configuration: config })\n bus.emit({ type: \"mappings-change\", mappings: resolveMappings(state) })\n },\n\n async mappings() {\n return resolveMappings(state)\n },\n }\n}\n","import type { GristApiImpl } from \"./types\"\n\n/** `_grist_api` host implementation. Minimal v1 — extend as needed. */\nexport function createGristApiImpl(): GristApiImpl {\n return {\n async ping() {\n return \"pong\"\n },\n }\n}\n","import { applyUserActions } from \"../core/action-engine\"\nimport { rowsToColumnar } from \"../core/columnar\"\nimport { getTable, synthesizeTablesColumnMeta, synthesizeTablesMeta } from \"../core/document\"\nimport type { EventBus } from \"../core/event-bus\"\nimport type { EmulatorDocumentState } from \"../core/types\"\nimport type { GristDocApiImpl } from \"./types\"\n\n/**\n * `GristDocAPI` host implementation. Backs `grist.docApi.*` methods such as\n * `getDocName`, `listTables`, `fetchTable`, `applyUserActions` and\n * `getAccessToken`.\n *\n * `applyUserActions` is the only mutation entry point — every widget write\n * lands here, so tests can listen on the bus for `user-action` events to\n * assert exactly which actions a UI flow generated.\n */\nexport function createGristDocApiImpl(state: EmulatorDocumentState, bus: EventBus): GristDocApiImpl {\n return {\n async getDocName() {\n return state.docName\n },\n\n async listTables() {\n return [...state.tables.keys()]\n },\n\n async fetchTable(tableId) {\n if (tableId === \"_grist_Tables\") {\n return synthesizeTablesMeta(state)\n }\n if (tableId === \"_grist_Tables_column\") {\n return synthesizeTablesColumnMeta(state)\n }\n const table = getTable(state, tableId)\n return rowsToColumnar(table, table.rows)\n },\n\n async applyUserActions(actions) {\n const result = applyUserActions(state, bus, actions)\n return { retValues: result.retValues }\n },\n\n async getAccessToken() {\n if (!state.accessToken) {\n const err = new Error(\"getAccessToken not available (no token configured on emulator)\")\n // Mirror Grist's protocol: rejected stub call.\n throw err\n }\n return { ...state.accessToken }\n },\n }\n}\n","import { rowToRecord, rowsToColumnar } from \"../core/columnar\"\nimport { findRow, getSelectedTable } from \"../core/document\"\nimport type { EventBus } from \"../core/event-bus\"\nimport type { EmulatorDocumentState } from \"../core/types\"\nimport type { GristViewImpl } from \"./types\"\n\n/**\n * `GristView` host implementation.\n *\n * Exposes the section-scoped data API the widget uses through\n * `grist.docApi.fetchSelectedTable()`, `fetchSelectedRecord()` and\n * `setCursorPos()`. Reads from the emulator state, writes to the same state\n * via the action engine where applicable, and emits events on the bus so\n * subscribers (transports, inspector, tests) stay in sync.\n *\n * IMPORTANT: `fetchSelectedTable` always returns Grist's **columnar** wire\n * shape. The production `grist-plugin-api.js` wrapper (which the iframe\n * transport talks to) expects the raw RPC stub to return columnar and does\n * the `format: \"rows\"` transposition + `keepEncoded: false` decoding itself.\n * Returning rows here used to crash the wrapper's `mapValues(data, col =>\n * col.map(decodeObject))` pass — `data` was an array, `col` was a row object\n * with no `.map` method — so widgets observed `records === null` forever.\n * The inline transport mirrors the same wrapper semantics in\n * `transports/inline.ts` so widget code sees identical results in both modes.\n */\nexport function createGristViewImpl(state: EmulatorDocumentState, bus: EventBus): GristViewImpl {\n return {\n async fetchSelectedTable(options) {\n const table = getSelectedTable(state)\n return rowsToColumnar(table, table.rows, { keepEncoded: options?.keepEncoded })\n },\n\n async fetchSelectedRecord(rowId, options) {\n const table = getSelectedTable(state)\n const row = findRow(table, rowId)\n if (!row) throw new Error(`No row ${rowId} in ${table.tableId}`)\n return rowToRecord(table, row, { keepEncoded: options?.keepEncoded })\n },\n\n async allowSelectBy() {\n return state.configuration?.allowSelectBy ?? false\n },\n\n async setSelectedRows(rowIds) {\n if (!rowIds || rowIds.length === 0) {\n state.selection.rowId = null\n } else {\n state.selection.rowId = rowIds[0]\n }\n bus.emit({\n type: \"cursor-change\",\n tableId: state.selection.tableId,\n rowId: state.selection.rowId,\n })\n },\n\n async setCursorPos(cursor) {\n const tableId = state.selection.tableId\n if (typeof cursor.rowId === \"number\") state.selection.rowId = cursor.rowId\n state.selection.cursor = { ...state.selection.cursor, ...cursor }\n bus.emit({\n type: \"cursor-change\",\n tableId,\n rowId: state.selection.rowId,\n cursor: state.selection.cursor,\n })\n },\n }\n}\n","import type { EventBus } from \"../core/event-bus\"\nimport type { EmulatorDocumentState } from \"../core/types\"\nimport type { WidgetApiImpl } from \"./types\"\n\n/**\n * `WidgetAPI` host implementation, backing `grist.widgetApi.*`. Reads and\n * writes the per-widget options bag persisted on the emulator state. Each\n * mutation triggers an `options-change` event so subscribers (the transport\n * pushes an `onOptions` message; tests/inspector update accordingly) stay in\n * lock-step with the document.\n */\nexport function createWidgetApiImpl(state: EmulatorDocumentState, bus: EventBus): WidgetApiImpl {\n function emit() {\n bus.emit({\n type: \"options-change\",\n options: { ...state.widgetOptions },\n interaction: { ...state.widgetInteraction },\n })\n }\n\n return {\n async getOption(key) {\n return state.widgetOptions[key]\n },\n\n async setOption(key, value) {\n state.widgetOptions[key] = value\n emit()\n },\n\n async getOptions() {\n return Object.keys(state.widgetOptions).length > 0 ? { ...state.widgetOptions } : null\n },\n\n async setOptions(options) {\n state.widgetOptions = { ...state.widgetOptions, ...options }\n emit()\n },\n\n async clearOptions() {\n state.widgetOptions = {}\n emit()\n },\n }\n}\n","/**\n * Bundles the six host-side Grist API implementations into one record so\n * transports (iframe, inline) can wire them up uniformly.\n */\n\nimport type { EventBus } from \"../core/event-bus\"\nimport type { EmulatorDocumentState } from \"../core/types\"\nimport { createCommandApiImpl } from \"./command-api\"\nimport { createCustomSectionApiImpl } from \"./custom-section-api\"\nimport { createGristApiImpl } from \"./grist-api\"\nimport { createGristDocApiImpl } from \"./grist-doc-api\"\nimport { createGristViewImpl } from \"./grist-view\"\nimport type {\n CommandApiImpl,\n CustomSectionApiImpl,\n GristApiImpl,\n GristDocApiImpl,\n GristViewImpl,\n WidgetApiImpl,\n} from \"./types\"\nimport { createWidgetApiImpl } from \"./widget-api\"\n\nexport type EmulatorApiBundle = {\n GristView: GristViewImpl\n GristDocAPI: GristDocApiImpl\n WidgetAPI: WidgetApiImpl\n CustomSectionAPI: CustomSectionApiImpl\n GristAPI: GristApiImpl\n CommandAPI: CommandApiImpl\n}\n\n/**\n * Build the implementations bound to a given document state and event bus.\n * Cheap to call — every method delegates to the (mutable) `state`.\n */\nexport function createApiBundle(state: EmulatorDocumentState, bus: EventBus): EmulatorApiBundle {\n return {\n GristView: createGristViewImpl(state, bus),\n GristDocAPI: createGristDocApiImpl(state, bus),\n WidgetAPI: createWidgetApiImpl(state, bus),\n CustomSectionAPI: createCustomSectionApiImpl(state, bus),\n GristAPI: createGristApiImpl(),\n CommandAPI: createCommandApiImpl(bus),\n }\n}\n\nexport type {\n CommandApiImpl,\n CustomSectionApiImpl,\n GristApiImpl,\n GristDocApiImpl,\n GristViewImpl,\n WidgetApiImpl,\n} from \"./types\"\n","/**\n * Tiny pub-sub used to broadcast every emulator state change to:\n * - the transports (which translate events into protocol messages),\n * - the React DevTools inspector (timeline view),\n * - the testing harness (assertions on emitted events).\n */\n\nimport type { GristCursorPos, GristWidgetColumnMap, GristWidgetInteraction } from \"../../sdk/types\"\n\nexport type EmulatorEvent =\n | { type: \"data-change\"; tableId: string }\n | { type: \"cursor-change\"; tableId: string; rowId: number | \"new\" | null; cursor?: GristCursorPos }\n | { type: \"options-change\"; options: Record<string, unknown>; interaction: GristWidgetInteraction }\n | { type: \"theme-change\"; message: Record<string, unknown> }\n | { type: \"ready\"; configuration: unknown }\n | { type: \"user-action\"; action: unknown[] }\n | { type: \"mappings-change\"; mappings: GristWidgetColumnMap | null }\n\nexport type EmulatorEventListener = (event: EmulatorEvent) => void\n\nexport type EventBus = {\n emit: (event: EmulatorEvent) => void\n on: (listener: EmulatorEventListener) => () => void\n history: () => readonly EmulatorEvent[]\n clear: () => void\n}\n\nexport type EventBusOptions = {\n /** Cap on history length (DevTools / tests). Defaults to 200. */\n historyLimit?: number\n}\n\nexport function createEventBus(options: EventBusOptions = {}): EventBus {\n const limit = options.historyLimit ?? 200\n const listeners = new Set<EmulatorEventListener>()\n const history: EmulatorEvent[] = []\n\n return {\n emit(event) {\n history.push(event)\n if (history.length > limit) history.shift()\n for (const fn of [...listeners]) {\n try {\n fn(event)\n } catch (err) {\n console.error(\"[grist-emulator] event listener threw:\", err)\n }\n }\n },\n on(listener) {\n listeners.add(listener)\n return () => {\n listeners.delete(listener)\n }\n },\n history() {\n return history\n },\n clear() {\n history.length = 0\n },\n }\n}\n","/**\n * Top-level emulator factory. Produces a fully-wired emulator instance:\n *\n * - typed in-memory document state,\n * - shared event bus,\n * - the six host API impls,\n * - one transport (inline by default, iframe when an iframe is provided),\n * - imperative helpers (`mutate`, `apply`, `selectRow`, `selectTable`)\n * that drive the document via the action engine and emit corresponding\n * events.\n *\n * The instance is multi-instance friendly: nothing is stored on `window`.\n */\n\nimport { createApiBundle } from \"./api\"\nimport type { EmulatorApiBundle } from \"./api\"\nimport { applyUserActions } from \"./core/action-engine\"\nimport { createDocument } from \"./core/document\"\nimport { createEventBus } from \"./core/event-bus\"\nimport type { EventBus } from \"./core/event-bus\"\nimport { resolveMappings } from \"./core/mappings\"\nimport type { EmulatorDocumentState } from \"./core/types\"\nimport type { GristReplicaDocument } from \"../sdk/replica-document\"\nimport type { GristWidgetColumnMap } from \"../sdk/types\"\nimport { buildGristThemeHostMessage } from \"./theme-message\"\nimport { createIframeTransport, createInlineTransport } from \"./transports\"\nimport type { EmulatorTransport, InlineGristGlobal } from \"./transports\"\nimport { parseDocument } from \"./validators\"\n\nexport type CreateGristEmulatorOptions = {\n /** The starting document (must satisfy {@link parseDocument}). */\n document: GristReplicaDocument\n /**\n * Pick a transport:\n * - omit / \"inline\" → synthesises `window.grist` directly (or onto `target`),\n * - \"iframe\" → wires a real iframe loading `grist-plugin-api.js`.\n */\n transport?:\n | { kind: \"inline\"; target?: Window & typeof globalThis }\n | { kind: \"iframe\"; iframe: HTMLIFrameElement; targetOrigin?: string }\n /** Initial widget options exposed via `WidgetAPI`. */\n widgetOptions?: Record<string, unknown>\n /**\n * Initial widget interaction info (`access_level` and friends) sent\n * alongside `onOptions`. Defaults to `{ access_level: \"read table\" }`.\n */\n widgetInteraction?: Record<string, unknown>\n /** Initial document theme replayed on widget ready (host `message` channel). */\n initialTheme?: \"light\" | \"dark\"\n}\n\nexport type GristEmulator = {\n /** Underlying mutable document. Treat as read-only outside of `mutate(...)`. */\n state: EmulatorDocumentState\n bus: EventBus\n api: EmulatorApiBundle\n transport: EmulatorTransport\n /** Synthesised `grist` global (only for the inline transport). */\n grist?: InlineGristGlobal\n\n /** Apply a list of Grist user actions; emits the matching events. */\n apply: (actions: unknown[][]) => { retValues: unknown[] }\n /** Convenience helpers for tests and demos. */\n mutate: {\n addRow: (tableId: string, fields: Record<string, unknown>) => number\n updateRow: (tableId: string, rowId: number, fields: Record<string, unknown>) => void\n removeRow: (tableId: string, rowId: number) => void\n }\n selectRow: (rowId: number | \"new\" | null) => void\n selectTable: (tableId: string) => void\n /**\n * Set logical→real column mappings for the playground inspector (and tests).\n * Pass `undefined` to clear — `mappings()` becomes `null` until set again.\n */\n setColumnMappings: (mappings: GristWidgetColumnMap | undefined) => void\n setOptions: (options: Record<string, unknown>) => Promise<void>\n setInteraction: (interaction: Record<string, unknown>) => void\n /** Host theme controls (`grist.on(\"message\")` / `msg.theme`). */\n theme: {\n set: (theme: \"light\" | \"dark\") => void\n }\n /** Tear down the emulator. Idempotent. */\n dispose: () => void\n}\n\nexport function createGristEmulator(options: CreateGristEmulatorOptions): GristEmulator {\n const validatedDocument = parseDocument(options.document)\n const state = createDocument({\n ...validatedDocument,\n widgetOptions: options.widgetOptions ?? validatedDocument.widgetOptions,\n widgetInteraction:\n options.widgetInteraction ?? validatedDocument.widgetInteraction ?? { access_level: \"read table\" },\n })\n const bus = createEventBus()\n const api = createApiBundle(state, bus)\n\n const transportKind = options.transport?.kind ?? \"inline\"\n let transport: EmulatorTransport\n let grist: InlineGristGlobal | undefined\n\n if (transportKind === \"iframe\") {\n if (options.transport?.kind !== \"iframe\") throw new Error(\"transport mismatch\")\n transport = createIframeTransport({\n iframe: options.transport.iframe,\n targetOrigin: options.transport.targetOrigin,\n state,\n bus,\n api,\n initialTheme: options.initialTheme,\n })\n } else {\n const inline = createInlineTransport({\n state,\n bus,\n api,\n initialTheme: options.initialTheme,\n target: options.transport?.kind === \"inline\" ? options.transport.target : undefined,\n })\n transport = inline\n grist = inline.grist\n }\n\n function apply(actions: unknown[][]) {\n return applyUserActions(state, bus, actions)\n }\n\n return {\n state,\n bus,\n api,\n transport,\n grist,\n apply,\n mutate: {\n addRow: (tableId, fields) => apply([[\"AddRecord\", tableId, null, fields]]).retValues[0] as number,\n updateRow: (tableId, rowId, fields) => {\n apply([[\"UpdateRecord\", tableId, rowId, fields]])\n },\n removeRow: (tableId, rowId) => {\n apply([[\"RemoveRecord\", tableId, rowId]])\n },\n },\n selectRow(rowId) {\n state.selection.rowId = rowId\n bus.emit({ type: \"cursor-change\", tableId: state.selection.tableId, rowId })\n },\n selectTable(tableId) {\n if (!state.tables.has(tableId)) throw new Error(`Unknown table: ${tableId}`)\n state.selection.tableId = tableId\n const first = state.tables.get(tableId)!.rows[0]?.id ?? null\n state.selection.rowId = first\n bus.emit({ type: \"data-change\", tableId })\n bus.emit({ type: \"cursor-change\", tableId, rowId: first })\n },\n setColumnMappings(mappings) {\n if (mappings === undefined) {\n delete state.selection.mappings\n } else {\n state.selection.mappings = mappings\n }\n bus.emit({ type: \"mappings-change\", mappings: resolveMappings(state) })\n },\n async setOptions(opts) {\n await api.WidgetAPI.setOptions(opts)\n },\n setInteraction(interaction) {\n state.widgetInteraction = { ...interaction }\n bus.emit({ type: \"options-change\", options: { ...state.widgetOptions }, interaction: { ...interaction } })\n },\n theme: {\n set(next) {\n bus.emit({ type: \"theme-change\", message: buildGristThemeHostMessage(next) })\n },\n },\n dispose() {\n transport.dispose()\n bus.clear()\n },\n }\n}\n","/**\n * Document templates exposed at the top of the emulator API.\n *\n * Templates return plain data — they don't allocate state, the caller passes\n * the returned value into `createGristEmulator(...)` which performs the allocation.\n */\n\nimport type { GristReplicaDocument } from \"../sdk/replica-document\"\n\nconst PRESET_GENERATED_AT = \"1970-01-01T00:00:00.000Z\"\n\nfunction replicaBase(overrides: Omit<GristReplicaDocument, \"generatedAt\">): GristReplicaDocument {\n return {\n generatedAt: PRESET_GENERATED_AT,\n ...overrides,\n }\n}\n\n/**\n * Useful templates for quick demos and tests.\n */\nexport const presets = {\n /**\n * Default starter fixture for demos / sandboxes that need a neutral document\n * without choosing a domain-specific preset.\n */\n defaultTemplate(): GristReplicaDocument {\n return replicaBase({\n docName: \"Default\",\n tables: {\n Table1: {\n label: \"Table1\",\n rows: [\n { id: 1, Name: \"Alice\" },\n { id: 2, Name: \"Bob\" },\n ],\n },\n },\n })\n },\n blank(): GristReplicaDocument {\n return replicaBase({\n docName: \"Blank\",\n tables: {\n Table1: { rows: [{ id: 1 }] },\n },\n })\n },\n todoList(): GristReplicaDocument {\n return replicaBase({\n docName: \"Todo list\",\n mode: \"schema+data\",\n tables: {\n Tasks: {\n label: \"Tasks\",\n columns: {\n title: { type: \"Text\", label: \"Title\" },\n done: { type: \"Bool\", label: \"Done\" },\n priority: { type: \"Choice\", label: \"Priority\" },\n },\n rows: [\n { id: 1, title: \"Buy milk\", done: false, priority: \"high\" },\n { id: 2, title: \"Write the SOTA emulator\", done: true, priority: \"high\" },\n { id: 3, title: \"Ship it\", done: false, priority: \"medium\" },\n ],\n },\n },\n })\n },\n contacts(): GristReplicaDocument {\n return replicaBase({\n docName: \"Contacts\",\n mode: \"schema+data\",\n tables: {\n Contacts: {\n label: \"Contacts\",\n columns: {\n firstName: { type: \"Text\" },\n lastName: { type: \"Text\" },\n email: { type: \"Text\" },\n company: { type: \"Text\" },\n },\n rows: [\n { id: 1, firstName: \"Ada\", lastName: \"Lovelace\", email: \"ada@analytical.engine\", company: \"British Crown\" },\n { id: 2, firstName: \"Linus\", lastName: \"Torvalds\", email: \"linus@kernel.org\", company: \"Linux Foundation\" },\n { id: 3, firstName: \"Margaret\", lastName: \"Hamilton\", email: \"margaret@apollo.nasa\", company: \"NASA\" },\n ],\n },\n },\n })\n },\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,SAAS;AAIlB,IAAM,oBAAoB,EACvB,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EACzB,SAAS,EAAE,QAAQ,CAAC;AAEvB,IAAM,oBAAoB,EAAE,KAAK,CAAC,YAAY,WAAW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