uidl-runtime 0.1.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 (83) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +175 -0
  3. package/bin/validate.mjs +44 -0
  4. package/dist/actions/eventBus.d.ts +7 -0
  5. package/dist/actions/index.d.ts +5 -0
  6. package/dist/actions/interpreter.d.ts +54 -0
  7. package/dist/compiler/dashboard.d.ts +10 -0
  8. package/dist/compiler/form.d.ts +22 -0
  9. package/dist/compiler/index.d.ts +16 -0
  10. package/dist/compiler/list.d.ts +20 -0
  11. package/dist/compiler/report.d.ts +10 -0
  12. package/dist/compiler/settings.d.ts +10 -0
  13. package/dist/compiler/tree.d.ts +10 -0
  14. package/dist/compiler/types.d.ts +315 -0
  15. package/dist/compiler/wizard.d.ts +10 -0
  16. package/dist/components/BarcodeAndQRCode.d.ts +29 -0
  17. package/dist/components/charts.d.ts +66 -0
  18. package/dist/components/iconPaths.d.ts +5 -0
  19. package/dist/components/icons.d.ts +31 -0
  20. package/dist/components/primitives.d.ts +411 -0
  21. package/dist/data/adapters/http.d.ts +37 -0
  22. package/dist/data/adapters/inMemory.d.ts +62 -0
  23. package/dist/data/errors.d.ts +15 -0
  24. package/dist/data/index.d.ts +7 -0
  25. package/dist/data/testing/mockHttpServer.d.ts +16 -0
  26. package/dist/data/types.d.ts +74 -0
  27. package/dist/editor/Canvas.d.ts +22 -0
  28. package/dist/editor/Editor.d.ts +18 -0
  29. package/dist/editor/LayerTree.d.ts +12 -0
  30. package/dist/editor/PropertyPanel.d.ts +7 -0
  31. package/dist/editor/StylePanel.d.ts +7 -0
  32. package/dist/editor/ValidationStatus.d.ts +9 -0
  33. package/dist/editor/WidgetPalette.d.ts +6 -0
  34. package/dist/editor/document.d.ts +10 -0
  35. package/dist/editor/index.d.ts +2 -0
  36. package/dist/editor/store.d.ts +46 -0
  37. package/dist/expr/evaluate.d.ts +51 -0
  38. package/dist/hooks/useElementWidth.d.ts +14 -0
  39. package/dist/index.d.ts +61 -0
  40. package/dist/registry/defaults.d.ts +2 -0
  41. package/dist/registry/registry.d.ts +4 -0
  42. package/dist/renderer/RenderNode.d.ts +16 -0
  43. package/dist/renderer/UIDocumentRenderer.d.ts +13 -0
  44. package/dist/renderer/instantiateComponent.d.ts +18 -0
  45. package/dist/renderer/renderDocument.d.ts +63 -0
  46. package/dist/schema/action.schema.json +515 -0
  47. package/dist/schema/design-tokens.schema.json +51 -0
  48. package/dist/schema/jsonSchema.d.ts +11 -0
  49. package/dist/schema/theme-presets.schema.json +952 -0
  50. package/dist/schema/uidl-document.schema.json +187 -0
  51. package/dist/schemas/actions.d.ts +5 -0
  52. package/dist/schemas/document.d.ts +35 -0
  53. package/dist/schemas/theme.d.ts +260 -0
  54. package/dist/services/aiPromptGenerator.d.ts +11 -0
  55. package/dist/state/createDocumentState.d.ts +18 -0
  56. package/dist/state/dataSources.d.ts +58 -0
  57. package/dist/state/index.d.ts +4 -0
  58. package/dist/style.css +2 -0
  59. package/dist/theme/engine.d.ts +9 -0
  60. package/dist/theme/index.d.ts +7 -0
  61. package/dist/theme/meridianPreset.d.ts +5 -0
  62. package/dist/theme/presets.d.ts +5 -0
  63. package/dist/theme/registry.d.ts +15 -0
  64. package/dist/theme/serialize.d.ts +5 -0
  65. package/dist/theme/tailwind.d.ts +11 -0
  66. package/dist/types/actions.d.ts +116 -0
  67. package/dist/types/editor.d.ts +45 -0
  68. package/dist/types/index.d.ts +82 -0
  69. package/dist/types/theme.d.ts +95 -0
  70. package/dist/uidl-runtime.js +98 -0
  71. package/dist/uidl-runtime.js.map +1 -0
  72. package/dist/uidl-runtime.mjs +17779 -0
  73. package/dist/uidl-runtime.mjs.map +1 -0
  74. package/dist/utils/chart.d.ts +12 -0
  75. package/dist/utils/cn.d.ts +1 -0
  76. package/dist/utils/formLayout.d.ts +93 -0
  77. package/dist/utils/i18n.d.ts +132 -0
  78. package/dist/utils/listCell.d.ts +21 -0
  79. package/dist/utils/responsive.d.ts +3 -0
  80. package/dist/utils/tailwind.d.ts +23 -0
  81. package/dist/validate/validateResponsive.d.ts +7 -0
  82. package/dist/version.d.ts +10 -0
  83. package/package.json +109 -0
@@ -0,0 +1,12 @@
1
+ import { default as React } from 'react';
2
+ import { UIDLNode } from '../types';
3
+ export interface LayerTreeProps {
4
+ root: UIDLNode;
5
+ selectedNodeId: string | null;
6
+ hoveredNodeId: string | null;
7
+ onSelectNode: (nodeId: string | null) => void;
8
+ onHoverNode: (nodeId: string | null) => void;
9
+ onMoveNode?: (nodeId: string, targetParentId: string, index?: number) => void;
10
+ className?: string;
11
+ }
12
+ export declare function LayerTree({ root, selectedNodeId, hoveredNodeId, onSelectNode, onHoverNode, onMoveNode, className, }: LayerTreeProps): React.JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { UIDLNode } from '../types';
2
+ export interface PropertyPanelProps {
3
+ node: UIDLNode | null;
4
+ onUpdateNode: (nodeId: string, changes: Partial<UIDLNode>) => void;
5
+ className?: string;
6
+ }
7
+ export declare function PropertyPanel({ node, onUpdateNode, className }: PropertyPanelProps): import("react").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { UIDLNode } from '../types';
2
+ export interface StylePanelProps {
3
+ node: UIDLNode | null;
4
+ onUpdateNode: (nodeId: string, changes: Partial<UIDLNode>) => void;
5
+ className?: string;
6
+ }
7
+ export declare function StylePanel({ node, onUpdateNode, className }: StylePanelProps): import("react").JSX.Element;
@@ -0,0 +1,9 @@
1
+ export interface ValidationStatusProps {
2
+ errors: Array<{
3
+ path: string;
4
+ message: string;
5
+ severity: "error" | "warning";
6
+ }>;
7
+ className?: string;
8
+ }
9
+ export declare function ValidationStatus({ errors, className }: ValidationStatusProps): import("react").JSX.Element;
@@ -0,0 +1,6 @@
1
+ export interface WidgetPaletteProps {
2
+ onSelectWidget: (widgetType: string) => void;
3
+ selectedNodeId: string | null;
4
+ className?: string;
5
+ }
6
+ export declare function WidgetPalette({ onSelectWidget, selectedNodeId, className, }: WidgetPaletteProps): import("react").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { UIDLNode } from '../types';
2
+ import { RenderScope } from '../expr/evaluate';
3
+ export declare function buildFlatNodeMap(root: UIDLNode): Map<string, UIDLNode>;
4
+ export declare function buildNestedTree(flatMap: Map<string, UIDLNode>, rootId: string): UIDLNode;
5
+ export declare function findNodeById(flatMap: Map<string, UIDLNode>, nodeId: string): UIDLNode | undefined;
6
+ export declare function findParentId(flatMap: Map<string, UIDLNode>, nodeId: string): string | undefined;
7
+ export declare function removeChildFromNode(parent: UIDLNode, nodeId: string): UIDLNode;
8
+ export declare function findNodePath(flatMap: Map<string, UIDLNode>, nodeId: string): string[];
9
+ export declare function getNodeDepth(flatMap: Map<string, UIDLNode>, nodeId: string): number;
10
+ export declare function isNodeVisible(node: UIDLNode, scope?: RenderScope): boolean;
@@ -0,0 +1,2 @@
1
+ export { Editor } from './Editor';
2
+ export type { EditorProps } from './Editor';
@@ -0,0 +1,46 @@
1
+ import { UIDLDocument, UIDLNode } from '../types';
2
+ export interface EditorStore {
3
+ document: UIDLDocument;
4
+ flatNodeMap: Map<string, UIDLNode>;
5
+ history: {
6
+ past: UIDLDocument[];
7
+ future: UIDLDocument[];
8
+ };
9
+ selectedNodeId: string | null;
10
+ hoveredNodeId: string | null;
11
+ activeBreakpoint: string;
12
+ themeMode: "light" | "dark";
13
+ panelVisibility: {
14
+ palette: boolean;
15
+ layers: boolean;
16
+ properties: boolean;
17
+ style: boolean;
18
+ };
19
+ validationErrors: Array<{
20
+ path: string;
21
+ message: string;
22
+ severity: "error" | "warning";
23
+ }>;
24
+ isDirty: boolean;
25
+ canUndo: boolean;
26
+ canRedo: boolean;
27
+ selectNode: (nodeId: string | null) => void;
28
+ hoverNode: (nodeId: string | null) => void;
29
+ updateNode: (nodeId: string, changes: Partial<UIDLNode>) => void;
30
+ addChild: (parentId: string, childType: string, index?: number) => void;
31
+ deleteNode: (nodeId: string) => void;
32
+ moveNode: (nodeId: string, targetParentId: string, index?: number) => void;
33
+ setBreakpoint: (breakpoint: string) => void;
34
+ setThemeMode: (mode: "light" | "dark") => void;
35
+ togglePanel: (panel: keyof EditorStore["panelVisibility"]) => void;
36
+ setDocument: (document: UIDLDocument) => void;
37
+ setValidationErrors: (errors: Array<{
38
+ path: string;
39
+ message: string;
40
+ severity: "error" | "warning";
41
+ }>) => void;
42
+ markClean: () => void;
43
+ undo: () => void;
44
+ redo: () => void;
45
+ }
46
+ export declare function createEditorStore(initialDocument?: UIDLDocument): import('zustand').UseBoundStore<import('zustand').StoreApi<EditorStore>>;
@@ -0,0 +1,51 @@
1
+ export interface RenderScope {
2
+ theme?: unknown;
3
+ local?: Record<string, unknown>;
4
+ state?: Record<string, unknown>;
5
+ session?: Record<string, unknown>;
6
+ route?: Record<string, unknown>;
7
+ data?: Record<string, unknown>;
8
+ index?: number;
9
+ }
10
+ export interface LiteralExpr {
11
+ literal: unknown;
12
+ }
13
+ export interface PathExpr {
14
+ path: string;
15
+ }
16
+ export interface EqExpr {
17
+ "==": [Expr, Expr];
18
+ }
19
+ export interface NeqExpr {
20
+ "!=": [Expr, Expr];
21
+ }
22
+ export interface AndExpr {
23
+ and: [Expr, Expr];
24
+ }
25
+ export interface OrExpr {
26
+ or: [Expr, Expr];
27
+ }
28
+ export interface NotExpr {
29
+ not: Expr;
30
+ }
31
+ export interface IfExpr {
32
+ if: [Expr, Expr, Expr];
33
+ }
34
+ export interface CoalesceExpr {
35
+ "??": [Expr, Expr];
36
+ }
37
+ /**
38
+ * Aggregate a numeric field across a collection already in scope.
39
+ *
40
+ * List pages need a real total in their KPI row. Rather than open the evaluator up to
41
+ * arbitrary arithmetic, this stays declarative: name a collection path, a field, and one of
42
+ * three fixed reducers. Non-numeric and missing values are skipped rather than coerced, so a
43
+ * blank cell cannot silently turn a total into NaN.
44
+ */
45
+ export interface AggExpr {
46
+ agg: "sum" | "count" | "avg";
47
+ over: string;
48
+ field?: string;
49
+ }
50
+ export type Expr = LiteralExpr | PathExpr | EqExpr | NeqExpr | AndExpr | OrExpr | NotExpr | IfExpr | CoalesceExpr | AggExpr;
51
+ export declare function evaluate(expr: unknown, scope: RenderScope): unknown;
@@ -0,0 +1,14 @@
1
+ import { RefObject } from 'react';
2
+ /**
3
+ * Tracks an element's rendered width.
4
+ *
5
+ * Charts need it because Meridian sizes its SVGs by *aspect ratio*, and picks a different
6
+ * ratio at every call site so that the drawn height still lands around 235px — 4.15 for the
7
+ * full-width Cashflow line, 2.05 for the half-width Profit and Loss bars. A reusable widget
8
+ * has no such fixed call site, so it measures instead and derives the ratio from the width it
9
+ * actually got, which keeps the chart the same height in a narrow column and a wide page.
10
+ *
11
+ * Returns 0 until the first measurement (and in environments without ResizeObserver, such as
12
+ * jsdom), which callers must treat as "not measured yet" rather than "zero wide".
13
+ */
14
+ export declare function useElementWidth<T extends HTMLElement>(): [RefObject<T | null>, number];
@@ -0,0 +1,61 @@
1
+ export { renderUIDocument, createRenderContext } from './renderer/renderDocument';
2
+ export type { RenderOptions, RenderContext } from './renderer/renderDocument';
3
+ export { UIDocumentRenderer } from './renderer/UIDocumentRenderer';
4
+ export type { UIDocumentRendererProps } from './renderer/UIDocumentRenderer';
5
+ export { createRegistry, defaultRegistry, registerComponent } from './registry/registry';
6
+ export { UIDL_RUNTIME_VERSION, REGISTRY_VERSION, getRegistryVersion, getRegistryFingerprint, type RegistryVersion } from './version';
7
+ export type { UIDLDocument, UIDLNode, DesignTokens, WidgetManifest, ComponentRegistry, ComponentPropDescriptor, ComponentPropType, ComponentEventDescriptor, Theme, ThemePreset, PrimitiveTokens, SemanticTokens, TypographyToken, ComponentVariant, StyleIntent, ResponsiveValue } from './types';
8
+ export type { Action, SetStateAction, NavigateAction, ApiAction, CommandAction, CommandActionConfig, CommandHandler, CommandRequest, CommandResponse, MutationAction, MutationActionConfig, MutationHandler, MutationOperation, MutationRequest, MutationResponse, ResolvableActionValue, ShowSnackbarAction, ShowDialogAction, ValidateAction, SequenceAction, IfAction, } from './types/actions';
9
+ export { DocumentSchema, DesignTokensSchema, ThemePresetsSchema } from './schemas/document';
10
+ export { ActionSchema, ActionsSchema } from './schemas/actions';
11
+ export { generateJsonSchemas } from './schema/jsonSchema';
12
+ export type { JsonSchemaExport } from './schema/jsonSchema';
13
+ export { createThemeEngine } from './theme/engine';
14
+ export type { ThemeEngine } from './theme/engine';
15
+ export { registerTheme, registerThemePreset, getTheme, getThemePreset, listThemes, listPresets, createThemeRegistry } from './theme/registry';
16
+ export { defaultLightTheme, defaultDarkTheme, defaultLightPreset, defaultDarkPreset } from './theme/presets';
17
+ export { meridianLightTheme, meridianDarkTheme, meridianLightPreset, meridianDarkPreset } from './theme/meridianPreset';
18
+ export { themeToCssVariables, themeToCssVariablesMap, themeToTailwindV4, themeToTailwindV3 } from './theme/tailwind';
19
+ export { serializeTheme, serializeThemePreset, deserializeTheme, deserializeThemePreset } from './theme/serialize';
20
+ export { useElementWidth } from './hooks/useElementWidth';
21
+ export { normalizeNodeResponsive } from './utils/responsive';
22
+ export { validateResponsiveValue, validateResponsiveStyle } from './validate/validateResponsive';
23
+ export { createDocumentState, getByPath, setByPath } from './state/createDocumentState';
24
+ export type { DocumentStateStore } from './state/createDocumentState';
25
+ export { createInlineArrayResolver, isQueryDataSource, resolveQueryDescriptor, runDataSources, serializeResolvedQueries, } from './state/dataSources';
26
+ export type { DataSourceResolver, DataSourceContext, QueryDataSource, BindScope, DataSourceStatus, RunDataSourcesOptions, } from './state/dataSources';
27
+ export { DataError, isDataError, InMemoryAdapter, createInMemoryAdapter, HttpAdapter, createHttpAdapter, } from './data';
28
+ export type { DataAdapter, DataErrorCode, Mutation, Query, QueryFilter, QueryOp, QueryPage, QueryResult, QuerySort, RecordMeta, InMemoryAdapterOptions, HttpAdapterOptions, } from './data';
29
+ export { createEventBus, ActionInterpreter } from './actions';
30
+ export { Editor } from './editor';
31
+ export type { EditorProps } from './editor';
32
+ export { QRCodeSVG, BarcodeSVG, DataMatrixSVG } from './components/BarcodeAndQRCode';
33
+ export { Icon, IconWidget, ICON_PATHS, ICON_NAMES, hasIcon } from './components/icons';
34
+ export type { IconProps, IconName } from './components/icons';
35
+ export { MeridianBarChart, MeridianLineChart, MeridianDonutChart } from './components/charts';
36
+ export { prefixFormat, MERIDIAN_SERIES_COLORS, MERIDIAN_DONUT_COLORS } from './utils/chart';
37
+ export type { BarChartProps, LineChartProps, DonutChartProps, DonutSector } from './components/charts';
38
+ export type { QRCodeSVGProps, BarcodeSVGProps, DataMatrixSVGProps } from './components/BarcodeAndQRCode';
39
+ export { formatCellValue, isNumericFormat, statusColor } from './utils/listCell';
40
+ export type { CellFormat, CellFormatOptions } from './utils/listCell';
41
+ export { t, formatRupiah, formatIndonesianDate, formatTerbilang } from './utils/i18n';
42
+ export type { Language } from './utils/i18n';
43
+ export { generateUidlFromPrompt } from './services/aiPromptGenerator';
44
+ export { Drawer, Snackbar, Dialog, Button, Badge } from './components/primitives';
45
+ export type { DrawerProps, SnackbarProps, DialogProps, ButtonProps, BadgeProps } from './components/primitives';
46
+ export { PAGE_RECIPES, isPageRecipe, validateHostCapabilities, semanticNodeId, semanticListNodeIds, } from './compiler/types.js';
47
+ export type { PageRecipe, LocalizedText, FieldWidget, FieldOption, FieldMeta, ListColumn, ListFilter, ListSummary, ListPageMeta, StateTransition, DocumentStates, ChildTableRef, FormPageMeta, ReportColumn, ReportFilter, ReportPageMeta, DashboardKpi, DashboardChart, DashboardShortcut, DashboardPageMeta, SettingsField, SettingsSection, SettingsPageMeta, TreeNode, TreePageMeta, WizardStep, WizardPageMeta, RecipeMetaMap, HostCapabilities, UiPolicy, RoutePolicy, ResponsivePolicy, CompilePageInput, CompilePageInputFor, CompilePageResult, PageCompiler, CapabilityIssue, } from './compiler/types.js';
48
+ export { compileListPage, parseListQueryParams, serializeListQueryParams, } from './compiler/list.js';
49
+ export type { CompileListOptions } from './compiler/list.js';
50
+ export { compileFormPage } from './compiler/form.js';
51
+ export type { CompileFormOptions } from './compiler/form.js';
52
+ export { compileReportPage } from './compiler/report.js';
53
+ export type { CompileReportOptions } from './compiler/report.js';
54
+ export { compileDashboardPage } from './compiler/dashboard.js';
55
+ export type { CompileDashboardOptions } from './compiler/dashboard.js';
56
+ export { compileSettingsPage } from './compiler/settings.js';
57
+ export type { CompileSettingsOptions } from './compiler/settings.js';
58
+ export { compileTreePage } from './compiler/tree.js';
59
+ export type { CompileTreeOptions } from './compiler/tree.js';
60
+ export { compileWizardPage } from './compiler/wizard.js';
61
+ export type { CompileWizardOptions } from './compiler/wizard.js';
@@ -0,0 +1,2 @@
1
+ import { WidgetManifest } from '../types';
2
+ export declare const defaultWidgets: WidgetManifest[];
@@ -0,0 +1,4 @@
1
+ import { ComponentRegistry, WidgetManifest } from '../types';
2
+ export declare function createRegistry(): ComponentRegistry;
3
+ export declare const defaultRegistry: ComponentRegistry;
4
+ export declare function registerComponent(manifest: WidgetManifest): void;
@@ -0,0 +1,16 @@
1
+ import { default as React } from 'react';
2
+ import { ComponentRegistry, UIDLNode, Theme } from '../types';
3
+ import { RenderScope as ExprRenderScope } from '../expr/evaluate';
4
+ import { ActionInterpreter } from '../actions/interpreter';
5
+ interface RenderScope extends ExprRenderScope {
6
+ theme?: Theme;
7
+ local?: Record<string, unknown>;
8
+ index?: number;
9
+ actionInterpreter?: ActionInterpreter;
10
+ registry?: ComponentRegistry;
11
+ definitions?: Record<string, UIDLNode>;
12
+ /** componentIds currently being expanded, ancestor-first — used to detect circular references. */
13
+ componentStack?: string[];
14
+ }
15
+ export declare function renderNode(node: UIDLNode, scope?: RenderScope): React.ReactNode;
16
+ export {};
@@ -0,0 +1,13 @@
1
+ import { UIDLDocument } from '../types';
2
+ import { RenderOptions } from './renderDocument';
3
+ export interface UIDocumentRendererProps extends RenderOptions {
4
+ document: UIDLDocument;
5
+ }
6
+ /**
7
+ * The stateful counterpart to `renderUIDocument`: a real component that stays subscribed to the
8
+ * document's event bus for its whole lifetime, so `showDialog`/`showSnackbar` actions actually
9
+ * render something instead of firing an event nobody listens to. Use this (not the plain
10
+ * `renderUIDocument` function) whenever a document's actions may include `showDialog` or
11
+ * `showSnackbar`.
12
+ */
13
+ export declare function UIDocumentRenderer({ document, theme, stateStore, session, dataSources, dataAdapter, mutationHandler, commandHandler, onRouteChange, registry, apiAllowlist, apiMaxResponseBytes, apiMaxConcurrentCalls, }: UIDocumentRendererProps): import("react").JSX.Element;
@@ -0,0 +1,18 @@
1
+ import { UIDLNode } from '../types';
2
+ /**
3
+ * Merges an instance node (a node with `componentId` set, plus whatever `props`/`style`/etc it
4
+ * carries) onto its definition (the named sub-tree from `document.definitions`), producing the
5
+ * node to actually render. The instance always wins on conflicts — same "instance overrides
6
+ * template" convention as `variant.style`/`node.style` for `themeRef` in RenderNode.tsx.
7
+ *
8
+ * - `props`/`style`/`events`/`bindings`: shallow-merged, instance keys win.
9
+ * - `slots`: shallow-merged by slot name, instance's slot content replaces the definition's
10
+ * default content for that name; slot names the instance doesn't mention keep the
11
+ * definition's own content. (Slots always render after children, in whatever position
12
+ * RenderNode.tsx already renders them — this does not add interleaved/positioned slots.)
13
+ * - `children`: the instance's children *replace* the definition's entirely when the instance
14
+ * provides any; otherwise the definition's own (default/example) children are used.
15
+ * - Everything else the instance doesn't specify (type, responsive, repeat, themeRef, testId,
16
+ * visibility) falls back to the definition's value.
17
+ */
18
+ export declare function instantiateComponent(instanceNode: UIDLNode, definition: UIDLNode): UIDLNode;
@@ -0,0 +1,63 @@
1
+ import { default as React } from 'react';
2
+ import { ComponentRegistry, UIDLDocument, Theme } from '../types';
3
+ import { DocumentStateStore } from '../state/createDocumentState';
4
+ import { EventBus } from '../actions/eventBus';
5
+ import { ActionInterpreter, ApiAllowlist } from '../actions/interpreter';
6
+ import { DataAdapter } from '../data/types';
7
+ import { CommandHandler, MutationHandler } from '../types/actions';
8
+ export interface RenderOptions {
9
+ theme?: Theme;
10
+ stateStore?: DocumentStateStore;
11
+ session?: Record<string, unknown>;
12
+ dataSources?: Record<string, unknown>;
13
+ /**
14
+ * A `DataAdapter` to resolve `{"$query": {...}}` entries in `dataSources` against. Only
15
+ * `<UIDocumentRenderer />` actually issues the fetches (it owns the effect loop that reruns a
16
+ * query when its `$bind`-resolved params change); passing this to `renderUIDocument` still
17
+ * lets its single pass render the `state.$data.<name>.status === "loading"` placeholder
18
+ * correctly, but nothing will ever resolve it — see the `$query`-without-Renderer warning
19
+ * below.
20
+ */
21
+ dataAdapter?: DataAdapter;
22
+ /**
23
+ * Host-owned handler for UIDL `mutate` actions. Wire this to an adapter-backed domain service
24
+ * in demos, and later to the same HTTP contract, so business writes stay outside components.
25
+ */
26
+ mutationHandler?: MutationHandler;
27
+ /** Host-owned handler for UIDL `command` actions. Unset means commands are disabled. */
28
+ commandHandler?: CommandHandler;
29
+ onRouteChange?: (route: string | Record<string, unknown>) => void;
30
+ registry?: ComponentRegistry;
31
+ /**
32
+ * Hosts a document's `api` actions are allowed to call. `api` actions refuse to run unless
33
+ * this is set — see `ActionInterpreter`'s constructor for why the default is fail-closed.
34
+ */
35
+ apiAllowlist?: ApiAllowlist;
36
+ /** Max `api` response body size in bytes before the request is aborted. Default 5MB. */
37
+ apiMaxResponseBytes?: number;
38
+ /** Max number of `api` actions to run concurrently; further calls fail fast. Default 6. */
39
+ apiMaxConcurrentCalls?: number;
40
+ }
41
+ export interface RenderContext {
42
+ theme: Theme | undefined;
43
+ data: Record<string, unknown>;
44
+ stateSnapshot: Record<string, unknown> | undefined;
45
+ session: Record<string, unknown> | undefined;
46
+ eventBus: EventBus;
47
+ interpreter: ActionInterpreter;
48
+ }
49
+ /**
50
+ * Builds everything renderNode needs (theme, resolved data sources, an ActionInterpreter wired
51
+ * to a fresh EventBus) without rendering anything. Shared by `renderUIDocument` (a plain,
52
+ * single-pass function — has no way to react to further events after it returns) and
53
+ * `UIDocumentRenderer` (a real component that stays subscribed to the event bus, so `showDialog`/
54
+ * `showSnackbar` actions can actually show something — see UIDocumentRenderer.tsx).
55
+ */
56
+ export declare function createRenderContext(document: UIDLDocument, options?: RenderOptions): RenderContext;
57
+ export declare function renderUIDocument(document: UIDLDocument, options?: RenderOptions): React.ReactNode;
58
+ /**
59
+ * CSS custom properties for the theme's tokens are set once on the root element so
60
+ * `var(--color-primary)`-style references (from ThemeEngine.resolveInlineStyle) resolve for
61
+ * every descendant, without needing a global stylesheet or build-time Tailwind support.
62
+ */
63
+ export declare function withThemeCssVariables(rendered: React.ReactNode, theme: Theme | undefined): React.ReactNode;