@meissa_a/meissa 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/README.md +350 -0
- package/dist/apps/app-generator.d.ts +30 -0
- package/dist/apps/index.d.ts +25 -0
- package/dist/apps/postmessage.d.ts +24 -0
- package/dist/apps/template.d.ts +10 -0
- package/dist/apps/types.d.ts +107 -0
- package/dist/apps.cjs +687 -0
- package/dist/apps.js +645 -0
- package/dist/client/component.d.ts +17 -0
- package/dist/client/content.d.ts +12 -0
- package/dist/client/index.d.ts +7 -0
- package/dist/client/patch.d.ts +6 -0
- package/dist/client/renderer.d.ts +43 -0
- package/dist/client/types.d.ts +52 -0
- package/dist/client.cjs +3558 -0
- package/dist/client.js +3524 -0
- package/dist/renderer/ComponentRenderer.d.ts +11 -0
- package/dist/renderer/MeissaRenderer.d.ts +8 -0
- package/dist/renderer/components/Alert.d.ts +2 -0
- package/dist/renderer/components/Badge.d.ts +2 -0
- package/dist/renderer/components/Btn.d.ts +2 -0
- package/dist/renderer/components/Card.d.ts +2 -0
- package/dist/renderer/components/Chart.d.ts +2 -0
- package/dist/renderer/components/Code.d.ts +2 -0
- package/dist/renderer/components/Col.d.ts +2 -0
- package/dist/renderer/components/Divider.d.ts +2 -0
- package/dist/renderer/components/Form.d.ts +2 -0
- package/dist/renderer/components/Grid.d.ts +2 -0
- package/dist/renderer/components/Heading.d.ts +2 -0
- package/dist/renderer/components/Img.d.ts +2 -0
- package/dist/renderer/components/Input.d.ts +2 -0
- package/dist/renderer/components/List.d.ts +2 -0
- package/dist/renderer/components/Progress.d.ts +2 -0
- package/dist/renderer/components/Row.d.ts +2 -0
- package/dist/renderer/components/Select.d.ts +2 -0
- package/dist/renderer/components/Split.d.ts +2 -0
- package/dist/renderer/components/Stat.d.ts +2 -0
- package/dist/renderer/components/Table.d.ts +2 -0
- package/dist/renderer/components/Tabs.d.ts +2 -0
- package/dist/renderer/components/Text.d.ts +2 -0
- package/dist/renderer/components/index.d.ts +2 -0
- package/dist/renderer/context/ActionContext.d.ts +3 -0
- package/dist/renderer/context/DataContext.d.ts +3 -0
- package/dist/renderer/context/FormContext.d.ts +10 -0
- package/dist/renderer/core/binder.d.ts +17 -0
- package/dist/renderer/core/evaluator.d.ts +13 -0
- package/dist/renderer/core/iterator.d.ts +10 -0
- package/dist/renderer/core/normalizer.d.ts +5 -0
- package/dist/renderer/core/parser.d.ts +8 -0
- package/dist/renderer/core/resolver.d.ts +6 -0
- package/dist/renderer/core/types.d.ts +68 -0
- package/dist/renderer/index.d.ts +7 -0
- package/dist/renderer/utils/cn.d.ts +2 -0
- package/dist/renderer/utils/filters.d.ts +8 -0
- package/dist/renderer/utils/sanitize.d.ts +9 -0
- package/dist/renderer.cjs +3273 -0
- package/dist/renderer.js +3239 -0
- package/dist/server/index.d.ts +4 -0
- package/dist/server/markdown.d.ts +9 -0
- package/dist/server/server.d.ts +39 -0
- package/dist/server/types.d.ts +56 -0
- package/dist/server/validator.d.ts +5 -0
- package/dist/server.cjs +345 -0
- package/dist/server.js +303 -0
- package/package.json +84 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { NormalizedNode } from "./core/types";
|
|
2
|
+
interface ComponentRendererProps {
|
|
3
|
+
node: NormalizedNode;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Recursively renders a normalized Meissa node.
|
|
7
|
+
*
|
|
8
|
+
* Pipeline per node: evaluate conditionals → expand each → bind props → render component
|
|
9
|
+
*/
|
|
10
|
+
export declare function ComponentRenderer({ node }: ComponentRendererProps): import("react").JSX.Element | null;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MeissaRendererProps } from "./core/types";
|
|
2
|
+
/**
|
|
3
|
+
* Top-level Meissa renderer.
|
|
4
|
+
*
|
|
5
|
+
* Accepts a Meissa schema (JSON), data context, and callbacks.
|
|
6
|
+
* Renders the complete UI tree.
|
|
7
|
+
*/
|
|
8
|
+
export declare function MeissaRenderer({ schema, data: externalData, theme, onAction, onNavigate, className, }: MeissaRendererProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type { FormContextValue } from "../core/types";
|
|
3
|
+
export declare function useForm(): FormContextValue | null;
|
|
4
|
+
interface FormProviderProps {
|
|
5
|
+
submitAction: string;
|
|
6
|
+
onSubmit: (action: string, values: Record<string, unknown>) => void;
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
export declare function FormProvider({ submitAction, onSubmit, children }: FormProviderProps): import("react").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve a string containing {{binding}} expressions against a data context.
|
|
3
|
+
*
|
|
4
|
+
* If the string is *exactly* one binding (no surrounding text), the raw typed
|
|
5
|
+
* value is returned (preserving arrays, objects, numbers, booleans).
|
|
6
|
+
* Otherwise, interpolation produces a string.
|
|
7
|
+
*/
|
|
8
|
+
export declare function resolveBindings(template: unknown, data: Record<string, unknown>): unknown;
|
|
9
|
+
/**
|
|
10
|
+
* Resolve a dot-notation path against data.
|
|
11
|
+
* Supports: "user.name", "items[0].name", "$", "$i", "$first", "$last"
|
|
12
|
+
*/
|
|
13
|
+
export declare function resolvePath(path: string, data: Record<string, unknown>): unknown;
|
|
14
|
+
/**
|
|
15
|
+
* Meissa truthiness rules.
|
|
16
|
+
*/
|
|
17
|
+
export declare function isTruthy(value: unknown): boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { NormalizedNode } from "./types";
|
|
2
|
+
export interface EvalResult {
|
|
3
|
+
node: NormalizedNode | null;
|
|
4
|
+
hidden: boolean;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Evaluate conditionals (if/show/switch) on a node.
|
|
8
|
+
*
|
|
9
|
+
* - `if`: returns null node if falsy (removed from DOM)
|
|
10
|
+
* - `show`: sets hidden=true if falsy (display:none)
|
|
11
|
+
* - `switch`: selects the matching case branch
|
|
12
|
+
*/
|
|
13
|
+
export declare function evaluate(node: NormalizedNode, data: Record<string, unknown>): EvalResult;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { NormalizedNode } from "./types";
|
|
2
|
+
export interface IterationItem {
|
|
3
|
+
node: NormalizedNode;
|
|
4
|
+
data: Record<string, unknown>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Expand an `each` node into multiple copies of its template,
|
|
8
|
+
* each with an augmented data context containing $, $i, $first, $last.
|
|
9
|
+
*/
|
|
10
|
+
export declare function expandEach(node: NormalizedNode, data: Record<string, unknown>): IterationItem[];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MeissaDocument, MeissaInput, NormalizedNode } from "./types";
|
|
2
|
+
export interface ParseResult {
|
|
3
|
+
nodes: NormalizedNode[];
|
|
4
|
+
defs: Record<string, NormalizedNode>;
|
|
5
|
+
data: Record<string, unknown>;
|
|
6
|
+
theme?: MeissaDocument["theme"];
|
|
7
|
+
}
|
|
8
|
+
export declare function parse(input: MeissaInput): ParseResult;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { NormalizedNode } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Walk the tree and replace ["ref", "name"] nodes with cloned def templates.
|
|
4
|
+
* Refs are resolved once at parse time (not recursive — no self-referencing).
|
|
5
|
+
*/
|
|
6
|
+
export declare function resolveRefs(nodes: NormalizedNode[], defs: Record<string, NormalizedNode>): NormalizedNode[];
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export type MeissaPrimary = string | number | boolean | null;
|
|
3
|
+
export type MeissaTuple = [string] | [string, MeissaPrimary] | [string, Record<string, unknown>] | [string, unknown[]] | [string, Record<string, unknown>, unknown[]] | [string, MeissaPrimary, unknown[]];
|
|
4
|
+
export interface MeissaObject {
|
|
5
|
+
type: string;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}
|
|
8
|
+
export type MeissaNode = MeissaTuple | MeissaObject;
|
|
9
|
+
export interface MeissaDocument {
|
|
10
|
+
v?: number;
|
|
11
|
+
ui: unknown[];
|
|
12
|
+
defs?: Record<string, unknown>;
|
|
13
|
+
theme?: MeissaTheme;
|
|
14
|
+
data?: Record<string, unknown>;
|
|
15
|
+
}
|
|
16
|
+
export type MeissaInput = unknown[] | MeissaNode | MeissaDocument;
|
|
17
|
+
export interface NormalizedNode {
|
|
18
|
+
type: string;
|
|
19
|
+
id?: string;
|
|
20
|
+
if?: string;
|
|
21
|
+
show?: string;
|
|
22
|
+
class?: string;
|
|
23
|
+
children?: NormalizedNode[];
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
}
|
|
26
|
+
export interface MeissaTheme {
|
|
27
|
+
radius?: "none" | "sm" | "md" | "lg" | "full";
|
|
28
|
+
density?: "compact" | "default" | "relaxed";
|
|
29
|
+
font?: string;
|
|
30
|
+
colors?: {
|
|
31
|
+
primary?: string;
|
|
32
|
+
destructive?: string;
|
|
33
|
+
success?: string;
|
|
34
|
+
warning?: string;
|
|
35
|
+
bg?: string;
|
|
36
|
+
fg?: string;
|
|
37
|
+
muted?: string;
|
|
38
|
+
border?: string;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export type ActionHandler = (name: string, args?: Record<string, unknown>) => void;
|
|
42
|
+
export type NavigateHandler = (uri: string) => void;
|
|
43
|
+
export interface MeissaRendererProps {
|
|
44
|
+
schema: MeissaInput;
|
|
45
|
+
data?: Record<string, unknown>;
|
|
46
|
+
theme?: MeissaTheme;
|
|
47
|
+
onAction?: ActionHandler;
|
|
48
|
+
onNavigate?: NavigateHandler;
|
|
49
|
+
className?: string;
|
|
50
|
+
}
|
|
51
|
+
export interface ComponentProps {
|
|
52
|
+
node: NormalizedNode;
|
|
53
|
+
children?: ReactNode;
|
|
54
|
+
}
|
|
55
|
+
export type MeissaComponent = React.FC<ComponentProps>;
|
|
56
|
+
export interface DataContextValue {
|
|
57
|
+
data: Record<string, unknown>;
|
|
58
|
+
root: Record<string, unknown>;
|
|
59
|
+
}
|
|
60
|
+
export interface ActionContextValue {
|
|
61
|
+
onAction: ActionHandler;
|
|
62
|
+
onNavigate: NavigateHandler;
|
|
63
|
+
}
|
|
64
|
+
export interface FormContextValue {
|
|
65
|
+
values: Record<string, string>;
|
|
66
|
+
setValue: (name: string, value: string) => void;
|
|
67
|
+
submit: (action?: string, extraArgs?: Record<string, unknown>) => void;
|
|
68
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { MeissaRenderer } from "./MeissaRenderer";
|
|
2
|
+
export { ComponentRenderer } from "./ComponentRenderer";
|
|
3
|
+
export { COMPONENT_REGISTRY } from "./components";
|
|
4
|
+
export { parse } from "./core/parser";
|
|
5
|
+
export { normalize } from "./core/normalizer";
|
|
6
|
+
export { resolveBindings } from "./core/binder";
|
|
7
|
+
export type { MeissaInput, MeissaDocument, MeissaNode, MeissaTuple, MeissaObject, NormalizedNode, MeissaTheme, MeissaRendererProps, ComponentProps, MeissaComponent, ActionHandler, NavigateHandler, DataContextValue, ActionContextValue, FormContextValue, } from "./core/types";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in Meissa filters for data binding.
|
|
3
|
+
* Syntax: {{value | filterName}} or {{value | filterName:arg}}
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Apply a filter expression like "truncate:50" or "currency" to a value.
|
|
7
|
+
*/
|
|
8
|
+
export declare function applyFilter(filterExpr: string, value: unknown): unknown;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Basic XSS sanitization for user-provided content rendered as text.
|
|
3
|
+
* Strips potentially dangerous HTML/JS patterns.
|
|
4
|
+
*/
|
|
5
|
+
export declare function sanitize(input: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Validate a URL is safe (no javascript: protocol, etc.)
|
|
8
|
+
*/
|
|
9
|
+
export declare function sanitizeUrl(url: string): string;
|