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.
- package/LICENSE +21 -0
- package/README.md +175 -0
- package/bin/validate.mjs +44 -0
- package/dist/actions/eventBus.d.ts +7 -0
- package/dist/actions/index.d.ts +5 -0
- package/dist/actions/interpreter.d.ts +54 -0
- package/dist/compiler/dashboard.d.ts +10 -0
- package/dist/compiler/form.d.ts +22 -0
- package/dist/compiler/index.d.ts +16 -0
- package/dist/compiler/list.d.ts +20 -0
- package/dist/compiler/report.d.ts +10 -0
- package/dist/compiler/settings.d.ts +10 -0
- package/dist/compiler/tree.d.ts +10 -0
- package/dist/compiler/types.d.ts +315 -0
- package/dist/compiler/wizard.d.ts +10 -0
- package/dist/components/BarcodeAndQRCode.d.ts +29 -0
- package/dist/components/charts.d.ts +66 -0
- package/dist/components/iconPaths.d.ts +5 -0
- package/dist/components/icons.d.ts +31 -0
- package/dist/components/primitives.d.ts +411 -0
- package/dist/data/adapters/http.d.ts +37 -0
- package/dist/data/adapters/inMemory.d.ts +62 -0
- package/dist/data/errors.d.ts +15 -0
- package/dist/data/index.d.ts +7 -0
- package/dist/data/testing/mockHttpServer.d.ts +16 -0
- package/dist/data/types.d.ts +74 -0
- package/dist/editor/Canvas.d.ts +22 -0
- package/dist/editor/Editor.d.ts +18 -0
- package/dist/editor/LayerTree.d.ts +12 -0
- package/dist/editor/PropertyPanel.d.ts +7 -0
- package/dist/editor/StylePanel.d.ts +7 -0
- package/dist/editor/ValidationStatus.d.ts +9 -0
- package/dist/editor/WidgetPalette.d.ts +6 -0
- package/dist/editor/document.d.ts +10 -0
- package/dist/editor/index.d.ts +2 -0
- package/dist/editor/store.d.ts +46 -0
- package/dist/expr/evaluate.d.ts +51 -0
- package/dist/hooks/useElementWidth.d.ts +14 -0
- package/dist/index.d.ts +61 -0
- package/dist/registry/defaults.d.ts +2 -0
- package/dist/registry/registry.d.ts +4 -0
- package/dist/renderer/RenderNode.d.ts +16 -0
- package/dist/renderer/UIDocumentRenderer.d.ts +13 -0
- package/dist/renderer/instantiateComponent.d.ts +18 -0
- package/dist/renderer/renderDocument.d.ts +63 -0
- package/dist/schema/action.schema.json +515 -0
- package/dist/schema/design-tokens.schema.json +51 -0
- package/dist/schema/jsonSchema.d.ts +11 -0
- package/dist/schema/theme-presets.schema.json +952 -0
- package/dist/schema/uidl-document.schema.json +187 -0
- package/dist/schemas/actions.d.ts +5 -0
- package/dist/schemas/document.d.ts +35 -0
- package/dist/schemas/theme.d.ts +260 -0
- package/dist/services/aiPromptGenerator.d.ts +11 -0
- package/dist/state/createDocumentState.d.ts +18 -0
- package/dist/state/dataSources.d.ts +58 -0
- package/dist/state/index.d.ts +4 -0
- package/dist/style.css +2 -0
- package/dist/theme/engine.d.ts +9 -0
- package/dist/theme/index.d.ts +7 -0
- package/dist/theme/meridianPreset.d.ts +5 -0
- package/dist/theme/presets.d.ts +5 -0
- package/dist/theme/registry.d.ts +15 -0
- package/dist/theme/serialize.d.ts +5 -0
- package/dist/theme/tailwind.d.ts +11 -0
- package/dist/types/actions.d.ts +116 -0
- package/dist/types/editor.d.ts +45 -0
- package/dist/types/index.d.ts +82 -0
- package/dist/types/theme.d.ts +95 -0
- package/dist/uidl-runtime.js +98 -0
- package/dist/uidl-runtime.js.map +1 -0
- package/dist/uidl-runtime.mjs +17779 -0
- package/dist/uidl-runtime.mjs.map +1 -0
- package/dist/utils/chart.d.ts +12 -0
- package/dist/utils/cn.d.ts +1 -0
- package/dist/utils/formLayout.d.ts +93 -0
- package/dist/utils/i18n.d.ts +132 -0
- package/dist/utils/listCell.d.ts +21 -0
- package/dist/utils/responsive.d.ts +3 -0
- package/dist/utils/tailwind.d.ts +23 -0
- package/dist/validate/validateResponsive.d.ts +7 -0
- package/dist/version.d.ts +10 -0
- package/package.json +109 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
export interface SetStateAction {
|
|
2
|
+
setState: {
|
|
3
|
+
path: string;
|
|
4
|
+
value: unknown;
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
export interface NavigateAction {
|
|
8
|
+
navigate: {
|
|
9
|
+
route: string | Record<string, unknown>;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export interface ApiAction {
|
|
13
|
+
api: {
|
|
14
|
+
url: string;
|
|
15
|
+
method: "GET" | "POST" | "PUT" | "DELETE";
|
|
16
|
+
body?: Record<string, unknown>;
|
|
17
|
+
dataSource?: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export type MutationOperation = "create" | "update" | "delete" | "transition";
|
|
21
|
+
export type ResolvableActionValue<T = unknown> = T | {
|
|
22
|
+
$bind: string;
|
|
23
|
+
} | {
|
|
24
|
+
$expr: unknown;
|
|
25
|
+
};
|
|
26
|
+
export interface MutationActionConfig {
|
|
27
|
+
operation: MutationOperation;
|
|
28
|
+
/** Collection/doctype key understood by the host adapter or domain service. */
|
|
29
|
+
collection: ResolvableActionValue<string>;
|
|
30
|
+
id?: ResolvableActionValue<string | number>;
|
|
31
|
+
payload?: ResolvableActionValue<Record<string, unknown>>;
|
|
32
|
+
transition?: ResolvableActionValue<string>;
|
|
33
|
+
version?: ResolvableActionValue<number>;
|
|
34
|
+
resultPath?: string;
|
|
35
|
+
errorPath?: string;
|
|
36
|
+
fieldErrorsPath?: string;
|
|
37
|
+
statusPath?: string;
|
|
38
|
+
/** Runs only after the host mutationHandler resolves successfully. */
|
|
39
|
+
onSuccess?: Action;
|
|
40
|
+
/** Runs only after the host mutationHandler rejects or request validation fails. */
|
|
41
|
+
onError?: Action;
|
|
42
|
+
}
|
|
43
|
+
export interface MutationAction {
|
|
44
|
+
mutate: MutationActionConfig;
|
|
45
|
+
}
|
|
46
|
+
export interface CommandActionConfig {
|
|
47
|
+
/** Host-owned command name, e.g. "workspace.schema.save". */
|
|
48
|
+
name: ResolvableActionValue<string>;
|
|
49
|
+
payload?: ResolvableActionValue<Record<string, unknown>>;
|
|
50
|
+
resultPath?: string;
|
|
51
|
+
errorPath?: string;
|
|
52
|
+
statusPath?: string;
|
|
53
|
+
onSuccess?: Action;
|
|
54
|
+
onError?: Action;
|
|
55
|
+
}
|
|
56
|
+
export interface CommandAction {
|
|
57
|
+
command: CommandActionConfig;
|
|
58
|
+
}
|
|
59
|
+
export interface MutationRequest {
|
|
60
|
+
operation: MutationOperation;
|
|
61
|
+
collection: string;
|
|
62
|
+
id?: string | number;
|
|
63
|
+
payload?: Record<string, unknown>;
|
|
64
|
+
transition?: string;
|
|
65
|
+
version?: number;
|
|
66
|
+
}
|
|
67
|
+
export interface MutationResponse {
|
|
68
|
+
success: boolean;
|
|
69
|
+
request?: MutationRequest;
|
|
70
|
+
data?: unknown;
|
|
71
|
+
error?: string;
|
|
72
|
+
code?: string;
|
|
73
|
+
fields?: Record<string, string>;
|
|
74
|
+
}
|
|
75
|
+
export type MutationHandler = (request: MutationRequest) => Promise<unknown> | unknown;
|
|
76
|
+
export interface CommandRequest {
|
|
77
|
+
name: string;
|
|
78
|
+
payload?: Record<string, unknown>;
|
|
79
|
+
}
|
|
80
|
+
export interface CommandResponse {
|
|
81
|
+
success: boolean;
|
|
82
|
+
request?: CommandRequest;
|
|
83
|
+
data?: unknown;
|
|
84
|
+
error?: string;
|
|
85
|
+
code?: string;
|
|
86
|
+
fields?: Record<string, string>;
|
|
87
|
+
}
|
|
88
|
+
export type CommandHandler = (request: CommandRequest) => Promise<unknown> | unknown;
|
|
89
|
+
export interface ShowSnackbarAction {
|
|
90
|
+
showSnackbar: {
|
|
91
|
+
message: string;
|
|
92
|
+
duration?: number;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
export interface ShowDialogAction {
|
|
96
|
+
showDialog: {
|
|
97
|
+
title: string;
|
|
98
|
+
content: string;
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export interface ValidateAction {
|
|
102
|
+
validate: {
|
|
103
|
+
fields: string[];
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
export interface SequenceAction {
|
|
107
|
+
sequence: Action[];
|
|
108
|
+
}
|
|
109
|
+
export interface IfAction {
|
|
110
|
+
if: {
|
|
111
|
+
condition: Record<string, unknown>;
|
|
112
|
+
then: Action;
|
|
113
|
+
else?: Action;
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
export type Action = SetStateAction | NavigateAction | ApiAction | MutationAction | CommandAction | ShowSnackbarAction | ShowDialogAction | ValidateAction | SequenceAction | IfAction;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { UIDLDocument, UIDLNode } from './index';
|
|
2
|
+
export interface EditorDocument {
|
|
3
|
+
document: UIDLDocument;
|
|
4
|
+
flatNodeMap: Map<string, UIDLNode>;
|
|
5
|
+
}
|
|
6
|
+
export interface EditorState {
|
|
7
|
+
document: EditorDocument;
|
|
8
|
+
selectedNodeId: string | null;
|
|
9
|
+
hoveredNodeId: string | null;
|
|
10
|
+
activeBreakpoint: BreakpointId;
|
|
11
|
+
themeMode: "light" | "dark";
|
|
12
|
+
panelVisibility: PanelVisibility;
|
|
13
|
+
validationErrors: ValidationError[];
|
|
14
|
+
isDirty: boolean;
|
|
15
|
+
}
|
|
16
|
+
export type BreakpointId = "base" | "sm" | "md" | "lg" | "xl" | "2xl";
|
|
17
|
+
export interface PanelVisibility {
|
|
18
|
+
palette: boolean;
|
|
19
|
+
layers: boolean;
|
|
20
|
+
properties: boolean;
|
|
21
|
+
style: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface ValidationError {
|
|
24
|
+
path: string;
|
|
25
|
+
message: string;
|
|
26
|
+
severity: "error" | "warning";
|
|
27
|
+
}
|
|
28
|
+
export interface EditorAction {
|
|
29
|
+
type: "selectNode" | "hoverNode" | "updateNode" | "addChild" | "deleteNode" | "moveNode" | "setBreakpoint" | "setThemeMode" | "togglePanel" | "setDocument" | "setValidationErrors" | "markClean";
|
|
30
|
+
payload?: unknown;
|
|
31
|
+
}
|
|
32
|
+
export interface UpdateNodePayload {
|
|
33
|
+
nodeId: string;
|
|
34
|
+
changes: Partial<UIDLNode>;
|
|
35
|
+
}
|
|
36
|
+
export interface AddChildPayload {
|
|
37
|
+
parentId: string;
|
|
38
|
+
childType: string;
|
|
39
|
+
index?: number;
|
|
40
|
+
}
|
|
41
|
+
export interface MoveNodePayload {
|
|
42
|
+
nodeId: string;
|
|
43
|
+
targetParentId: string;
|
|
44
|
+
index?: number;
|
|
45
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
export interface UIDLDocument {
|
|
2
|
+
$schema?: string;
|
|
3
|
+
version: string;
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
route?: string;
|
|
7
|
+
theme?: string;
|
|
8
|
+
state?: Record<string, unknown>;
|
|
9
|
+
dataSources?: Record<string, unknown>;
|
|
10
|
+
/**
|
|
11
|
+
* Named, reusable node sub-trees ("component templates"). A node with `componentId: "X"`
|
|
12
|
+
* instantiates `definitions.X` at render time — see `renderer/instantiateComponent.ts`.
|
|
13
|
+
*/
|
|
14
|
+
definitions?: Record<string, UIDLNode>;
|
|
15
|
+
root: UIDLNode;
|
|
16
|
+
}
|
|
17
|
+
export interface UIDLNode {
|
|
18
|
+
id: string;
|
|
19
|
+
type: string;
|
|
20
|
+
name?: string;
|
|
21
|
+
props?: Record<string, unknown>;
|
|
22
|
+
style?: Record<string, unknown>;
|
|
23
|
+
children?: UIDLNode[];
|
|
24
|
+
slots?: Record<string, UIDLNode[]>;
|
|
25
|
+
responsive?: Record<string, unknown>;
|
|
26
|
+
visibility?: Record<string, unknown>;
|
|
27
|
+
bindings?: Record<string, unknown>;
|
|
28
|
+
events?: Record<string, unknown>;
|
|
29
|
+
repeat?: Record<string, unknown>;
|
|
30
|
+
ref?: string;
|
|
31
|
+
componentId?: string;
|
|
32
|
+
themeRef?: string;
|
|
33
|
+
testId?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface DesignTokens {
|
|
36
|
+
color?: Record<string, string>;
|
|
37
|
+
font?: Record<string, string>;
|
|
38
|
+
spacing?: Record<string, string>;
|
|
39
|
+
radius?: Record<string, string>;
|
|
40
|
+
shadow?: Record<string, unknown>;
|
|
41
|
+
}
|
|
42
|
+
export interface WidgetManifest<TProps = Record<string, unknown>> {
|
|
43
|
+
type: string;
|
|
44
|
+
component: React.ComponentType<TProps>;
|
|
45
|
+
category: "layout" | "base" | "form" | "data" | "navigation" | "advanced";
|
|
46
|
+
acceptsChildren: boolean;
|
|
47
|
+
defaultProps?: Partial<TProps>;
|
|
48
|
+
propDescriptors?: ComponentPropDescriptor[];
|
|
49
|
+
propSchema?: Record<string, unknown>;
|
|
50
|
+
slots?: string[];
|
|
51
|
+
events?: string[];
|
|
52
|
+
eventDescriptors?: ComponentEventDescriptor[];
|
|
53
|
+
/**
|
|
54
|
+
* Hide from the Editor's WidgetPalette (Round 15). Chrome widgets like Sidebar/Navbar/
|
|
55
|
+
* Toolbar/Drawer/Panel are part of the document vocabulary and still fully renderable
|
|
56
|
+
* from JSON — they just aren't meant to be drag-dropped into a canvas by authors.
|
|
57
|
+
* Absent = visible, same as before this flag existed.
|
|
58
|
+
*/
|
|
59
|
+
hideFromPalette?: boolean;
|
|
60
|
+
toTailwind?: (props: TProps, style?: Record<string, unknown>) => string;
|
|
61
|
+
}
|
|
62
|
+
export type ComponentPropType = "string" | "number" | "boolean" | "enum" | "array" | "object" | "node";
|
|
63
|
+
export interface ComponentPropDescriptor {
|
|
64
|
+
name: string;
|
|
65
|
+
type: ComponentPropType;
|
|
66
|
+
description?: string;
|
|
67
|
+
values?: readonly string[];
|
|
68
|
+
required?: boolean;
|
|
69
|
+
bindable?: boolean;
|
|
70
|
+
}
|
|
71
|
+
export interface ComponentEventDescriptor {
|
|
72
|
+
name: string;
|
|
73
|
+
description?: string;
|
|
74
|
+
payload?: "value" | "rowAction" | "card" | "node" | "submit" | "close" | "event";
|
|
75
|
+
}
|
|
76
|
+
export interface ComponentRegistry {
|
|
77
|
+
get(type: string): WidgetManifest | undefined;
|
|
78
|
+
register(manifest: WidgetManifest): void;
|
|
79
|
+
has(type: string): boolean;
|
|
80
|
+
list(): WidgetManifest[];
|
|
81
|
+
}
|
|
82
|
+
export type { Theme, ThemePreset, PrimitiveTokens, SemanticTokens, TypographyToken, ComponentVariant, StyleIntent, ResponsiveValue, } from './theme';
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
export interface ResponsiveValue<T> {
|
|
2
|
+
base?: T;
|
|
3
|
+
[breakpoint: string]: T | undefined;
|
|
4
|
+
}
|
|
5
|
+
export interface PrimitiveTokens {
|
|
6
|
+
color: Record<string, string>;
|
|
7
|
+
spacing: Record<string, string>;
|
|
8
|
+
radius: Record<string, string>;
|
|
9
|
+
shadow: Record<string, string>;
|
|
10
|
+
font: Record<string, string>;
|
|
11
|
+
border: Record<string, string>;
|
|
12
|
+
}
|
|
13
|
+
export interface SemanticTokens {
|
|
14
|
+
color: Record<string, string>;
|
|
15
|
+
spacing: Record<string, string>;
|
|
16
|
+
radius: Record<string, string>;
|
|
17
|
+
shadow: Record<string, string>;
|
|
18
|
+
typography: Record<string, TypographyToken>;
|
|
19
|
+
}
|
|
20
|
+
export interface TypographyToken {
|
|
21
|
+
fontFamily?: string;
|
|
22
|
+
fontSize?: string;
|
|
23
|
+
fontWeight?: number | string;
|
|
24
|
+
lineHeight?: string;
|
|
25
|
+
letterSpacing?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface ComponentVariant {
|
|
28
|
+
name: string;
|
|
29
|
+
props?: Record<string, unknown>;
|
|
30
|
+
style?: StyleIntent;
|
|
31
|
+
className?: string;
|
|
32
|
+
}
|
|
33
|
+
export type StyleIntent = {
|
|
34
|
+
gap?: string | ResponsiveValue<string>;
|
|
35
|
+
padding?: string | ResponsiveValue<string>;
|
|
36
|
+
paddingTop?: string | ResponsiveValue<string>;
|
|
37
|
+
paddingRight?: string | ResponsiveValue<string>;
|
|
38
|
+
paddingBottom?: string | ResponsiveValue<string>;
|
|
39
|
+
paddingLeft?: string | ResponsiveValue<string>;
|
|
40
|
+
margin?: string | ResponsiveValue<string>;
|
|
41
|
+
marginTop?: string | ResponsiveValue<string>;
|
|
42
|
+
marginRight?: string | ResponsiveValue<string>;
|
|
43
|
+
marginBottom?: string | ResponsiveValue<string>;
|
|
44
|
+
marginLeft?: string | ResponsiveValue<string>;
|
|
45
|
+
width?: string | ResponsiveValue<string>;
|
|
46
|
+
height?: string | ResponsiveValue<string>;
|
|
47
|
+
minWidth?: string | ResponsiveValue<string>;
|
|
48
|
+
maxWidth?: string | ResponsiveValue<string>;
|
|
49
|
+
minHeight?: string | ResponsiveValue<string>;
|
|
50
|
+
maxHeight?: string | ResponsiveValue<string>;
|
|
51
|
+
flexDirection?: "row" | "column" | "row-reverse" | "column-reverse" | ResponsiveValue<"row" | "column" | "row-reverse" | "column-reverse">;
|
|
52
|
+
justifyContent?: "start" | "center" | "end" | "space-between" | "space-around" | "space-evenly" | ResponsiveValue<"start" | "center" | "end" | "space-between" | "space-around" | "space-evenly">;
|
|
53
|
+
alignItems?: "start" | "center" | "end" | "stretch" | "baseline" | ResponsiveValue<"start" | "center" | "end" | "stretch" | "baseline">;
|
|
54
|
+
display?: string | ResponsiveValue<string>;
|
|
55
|
+
position?: "static" | "relative" | "absolute" | "fixed" | "sticky" | ResponsiveValue<"static" | "relative" | "absolute" | "fixed" | "sticky">;
|
|
56
|
+
/** Shorthand for top/right/bottom/left together (Tailwind's `inset-*` utilities). */
|
|
57
|
+
inset?: string | ResponsiveValue<string>;
|
|
58
|
+
top?: string | ResponsiveValue<string>;
|
|
59
|
+
right?: string | ResponsiveValue<string>;
|
|
60
|
+
bottom?: string | ResponsiveValue<string>;
|
|
61
|
+
left?: string | ResponsiveValue<string>;
|
|
62
|
+
zIndex?: number | ResponsiveValue<number>;
|
|
63
|
+
background?: string | ResponsiveValue<string>;
|
|
64
|
+
color?: string | ResponsiveValue<string>;
|
|
65
|
+
fontSize?: string | ResponsiveValue<string>;
|
|
66
|
+
fontWeight?: number | string | ResponsiveValue<number | string>;
|
|
67
|
+
lineHeight?: string | ResponsiveValue<string>;
|
|
68
|
+
letterSpacing?: string | ResponsiveValue<string>;
|
|
69
|
+
borderRadius?: string | ResponsiveValue<string>;
|
|
70
|
+
borderWidth?: string | ResponsiveValue<string>;
|
|
71
|
+
borderColor?: string | ResponsiveValue<string>;
|
|
72
|
+
shadow?: string | ResponsiveValue<string>;
|
|
73
|
+
opacity?: number | ResponsiveValue<number>;
|
|
74
|
+
/**
|
|
75
|
+
* A semantic typography token reference (e.g. `"{semantics.typography.headline-medium}"`),
|
|
76
|
+
* applying that token's fontFamily/fontSize/fontWeight/lineHeight/letterSpacing together.
|
|
77
|
+
* Not responsive — a single typography token per node.
|
|
78
|
+
*/
|
|
79
|
+
typography?: string;
|
|
80
|
+
};
|
|
81
|
+
export interface Theme {
|
|
82
|
+
id: string;
|
|
83
|
+
name: string;
|
|
84
|
+
mode: "light" | "dark";
|
|
85
|
+
breakpoints: Record<string, string>;
|
|
86
|
+
primitives: PrimitiveTokens;
|
|
87
|
+
semantics: SemanticTokens;
|
|
88
|
+
variants: Record<string, ComponentVariant[]>;
|
|
89
|
+
}
|
|
90
|
+
export interface ThemePreset {
|
|
91
|
+
id: string;
|
|
92
|
+
label: string;
|
|
93
|
+
mode: "light" | "dark";
|
|
94
|
+
theme: Theme;
|
|
95
|
+
}
|