@batiq/core
Advanced tools
Comparing version 0.1.0-alpha.0 to 0.1.0-alpha2
{ | ||
"name": "@batiq/core", | ||
"version": "0.1.0-alpha.0", | ||
"version": "0.1.0-alpha2", | ||
"type": "module", | ||
@@ -14,3 +14,7 @@ "scripts": { | ||
"main": "./index.cjs", | ||
"types": "./src/index.d.ts" | ||
"types": "./src/index.d.ts", | ||
"peerDependencies": { | ||
"react": "18.2.0", | ||
"@sinclair/typebox": "0.25.21" | ||
} | ||
} |
@@ -1,5 +0,5 @@ | ||
import * as React from "react"; | ||
import { JSONSchemaType } from "ajv"; | ||
import { Path } from "./lens"; | ||
export type ComponentDefinition<P extends Record<string, any>> = (React.ComponentType<React.PropsWithChildren<P>> | ((props: React.PropsWithChildren<P>) => JSX.Element)) & { | ||
import { TTuple, TArray } from "@sinclair/typebox"; | ||
export type ComponentDefinition<P extends Record<string, any>> = { | ||
inputs: ComponentInput<P>; | ||
@@ -9,7 +9,43 @@ }; | ||
export type ComponentSchema = { | ||
type: "component"; | ||
from: string; | ||
name?: string; | ||
properties: Record<string, any>; | ||
children: ComponentSchema[]; | ||
properties: Record<string, Property>; | ||
children: Primitive[]; | ||
}; | ||
export type ActionDefinition<S extends TTuple | TArray = TTuple<[]>> = { | ||
inputs: S; | ||
returns?: string | string[]; | ||
isHook?: true; | ||
pure?: boolean; | ||
root?: boolean; | ||
} | { | ||
inputs: S; | ||
returns?: string | string[]; | ||
isHook?: false; | ||
}; | ||
export type ActionSchema = { | ||
type: "action"; | ||
from: string; | ||
name: string; | ||
id?: string; | ||
arguments: Container<Primitive | ExpressionSchema>[]; | ||
next?: string | number; | ||
onError?: string | number; | ||
}; | ||
export type ExpressionSchema = { | ||
type: "expression"; | ||
expression: string; | ||
}; | ||
export type BreakpointSchema<T> = { | ||
type: "breakpoint"; | ||
breakpoints: Record<string, T>; | ||
}; | ||
export type Primitive = ComponentSchema | ExpressionSchema | string | number | boolean; | ||
export type Container<T> = T | Container<T>[] | { | ||
[key in string extends "type" ? never : string]: Container<T>; | ||
}; | ||
export type Value = Container<Primitive>; | ||
export type Children = Container<Primitive | ExpressionSchema>; | ||
export type Property = Container<Primitive | ExpressionSchema | ActionSchema> | BreakpointSchema<Container<Primitive | ExpressionSchema | ActionSchema>>; | ||
export type PageSchema = { | ||
@@ -27,2 +63,6 @@ name: string; | ||
export type Platform = "web" | "native" | "webcomponent"; | ||
export type FontStyle = { | ||
fontFamily: string; | ||
fontWeight: "normal" | "bold" | "100" | "200" | "300" | "400" | "500" | "600" | "700" | "800" | "900"; | ||
}; | ||
export type AppSchema = { | ||
@@ -53,2 +93,13 @@ batiq: string; | ||
}>; | ||
fonts: { | ||
[platform: string]: { | ||
regular: FontStyle; | ||
medium: FontStyle; | ||
bold: FontStyle; | ||
heavy: FontStyle; | ||
}; | ||
}; | ||
breakpoints: { | ||
[key: string]: number; | ||
}; | ||
[key: string]: any; | ||
@@ -55,0 +106,0 @@ }>; |
28646
3
692
3