@vellum-ui/core 0.0.0-stage → 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/dist/ast/base-node.d.ts +11 -0
- package/dist/ast/base-node.d.ts.map +1 -0
- package/dist/ast/base-node.js +1 -0
- package/dist/ast/base-node.js.map +1 -0
- package/dist/ast/conditional-node.d.ts +9 -0
- package/dist/ast/conditional-node.js +1 -0
- package/dist/ast/container-node.d.ts +11 -0
- package/dist/ast/container-node.d.ts.map +1 -0
- package/dist/ast/container-node.js +1 -0
- package/dist/ast/container-node.js.map +1 -0
- package/dist/ast/index.d.ts +9 -0
- package/dist/ast/index.d.ts.map +1 -0
- package/dist/ast/index.js +1 -0
- package/dist/ast/index.js.map +1 -0
- package/dist/ast/leaf-node.d.ts +33 -0
- package/dist/ast/leaf-node.d.ts.map +1 -0
- package/dist/ast/leaf-node.js +1 -0
- package/dist/ast/leaf-node.js.map +1 -0
- package/dist/ast/style.d.ts +5 -0
- package/dist/ast/style.js +1 -0
- package/dist/ast/text-segment.d.ts +10 -0
- package/dist/ast/text-segment.js +1 -0
- package/dist/ast/value.d.ts +12 -0
- package/dist/ast/value.js +1 -0
- package/dist/ast/vellum-document.d.ts +22 -0
- package/dist/ast/vellum-document.d.ts.map +1 -0
- package/dist/ast/vellum-document.js +1 -0
- package/dist/ast/vellum-document.js.map +1 -0
- package/dist/ast/vellum-node.d.ts +4 -0
- package/dist/ast/vellum-node.d.ts.map +1 -0
- package/dist/ast/vellum-node.js +1 -0
- package/dist/ast/vellum-node.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/layout/alignment.d.ts +6 -0
- package/dist/layout/alignment.js +9 -0
- package/dist/layout/anchor.d.ts +10 -0
- package/dist/layout/anchor.js +14 -0
- package/dist/layout/conditional.d.ts +13 -0
- package/dist/layout/conditional.js +34 -0
- package/dist/layout/index.d.ts +10 -0
- package/dist/layout/index.js +5 -0
- package/dist/layout/layout-properties.d.ts +25 -0
- package/dist/layout/layout-properties.js +14 -0
- package/dist/layout/spacing.d.ts +3 -0
- package/dist/layout/spacing.js +15 -0
- package/dist/lexer/character.d.ts +4 -0
- package/dist/lexer/character.js +12 -0
- package/dist/lexer/index.d.ts +6 -0
- package/dist/lexer/index.js +3 -0
- package/dist/lexer/lexer-error.d.ts +7 -0
- package/dist/lexer/lexer-error.js +10 -0
- package/dist/lexer/lexer.d.ts +21 -0
- package/dist/lexer/lexer.js +190 -0
- package/dist/lexer/token-kind.d.ts +1 -0
- package/dist/lexer/token-kind.js +1 -0
- package/dist/lexer/token.d.ts +12 -0
- package/dist/lexer/token.js +1 -0
- package/dist/lexer/tokenize.d.ts +2 -0
- package/dist/lexer/tokenize.js +4 -0
- package/dist/parser/ast-builder.d.ts +13 -0
- package/dist/parser/ast-builder.js +298 -0
- package/dist/parser/binding-collector.d.ts +8 -0
- package/dist/parser/binding-collector.js +22 -0
- package/dist/parser/binding-extractor.d.ts +8 -0
- package/dist/parser/binding-extractor.js +52 -0
- package/dist/parser/compiler.d.ts +2 -0
- package/dist/parser/compiler.js +19 -0
- package/dist/parser/descriptor.d.ts +30 -0
- package/dist/parser/descriptor.js +1 -0
- package/dist/parser/id-generator.d.ts +5 -0
- package/dist/parser/id-generator.js +8 -0
- package/dist/parser/index.d.ts +14 -0
- package/dist/parser/index.js +9 -0
- package/dist/parser/parser-error.d.ts +7 -0
- package/dist/parser/parser-error.js +10 -0
- package/dist/parser/parser.d.ts +25 -0
- package/dist/parser/parser.js +251 -0
- package/dist/parser/string-value.d.ts +2 -0
- package/dist/parser/string-value.js +16 -0
- package/dist/parser/style-resolver.d.ts +4 -0
- package/dist/parser/style-resolver.js +12 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/alignment.d.ts +1 -0
- package/dist/types/alignment.d.ts.map +1 -0
- package/dist/types/alignment.js +1 -0
- package/dist/types/alignment.js.map +1 -0
- package/dist/types/anchor.d.ts +1 -0
- package/dist/types/anchor.d.ts.map +1 -0
- package/dist/types/anchor.js +1 -0
- package/dist/types/anchor.js.map +1 -0
- package/dist/types/binding-expression.d.ts +1 -0
- package/dist/types/binding-expression.d.ts.map +1 -0
- package/dist/types/binding-expression.js +1 -0
- package/dist/types/binding-expression.js.map +1 -0
- package/dist/types/box-spacing.d.ts +1 -0
- package/dist/types/box-spacing.d.ts.map +1 -0
- package/dist/types/box-spacing.js +1 -0
- package/dist/types/box-spacing.js.map +1 -0
- package/dist/types/color-hex.d.ts +1 -0
- package/dist/types/color-hex.d.ts.map +1 -0
- package/dist/types/color-hex.js +1 -0
- package/dist/types/color-hex.js.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/vector2.d.ts +1 -0
- package/dist/types/vector2.d.ts.map +1 -0
- package/dist/types/vector2.js +1 -0
- package/dist/types/vector2.js.map +1 -0
- package/package.json +16 -3
- package/README.md +0 -3
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Anchor } from '../types/anchor.js';
|
|
2
|
+
import type { BoxSpacing } from '../types/box-spacing.js';
|
|
3
|
+
export type NodeId = string;
|
|
4
|
+
export interface BaseNode {
|
|
5
|
+
readonly id: NodeId;
|
|
6
|
+
readonly anchor: Anchor;
|
|
7
|
+
readonly margin: BoxSpacing;
|
|
8
|
+
readonly padding: BoxSpacing;
|
|
9
|
+
readonly visible: boolean;
|
|
10
|
+
readonly styleNames: readonly string[];
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-node.d.ts","sourceRoot":"","sources":["../../src/ast/base-node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAE5B,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-node.js","sourceRoot":"","sources":["../../src/ast/base-node.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BindingExpression } from '../types/binding-expression.js';
|
|
2
|
+
import type { BaseNode } from './base-node.js';
|
|
3
|
+
import type { VellumNode } from './vellum-node.js';
|
|
4
|
+
export interface ConditionalNode extends BaseNode {
|
|
5
|
+
readonly kind: 'Conditional';
|
|
6
|
+
readonly condition: BindingExpression;
|
|
7
|
+
readonly consequent: readonly VellumNode[];
|
|
8
|
+
readonly alternate: readonly VellumNode[];
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Alignment } from '../types/alignment.js';
|
|
2
|
+
import type { BaseNode } from './base-node.js';
|
|
3
|
+
import type { VellumNode } from './vellum-node.js';
|
|
4
|
+
export type ContainerKind = 'Panel' | 'Row' | 'Column';
|
|
5
|
+
export interface ContainerNode extends BaseNode {
|
|
6
|
+
readonly kind: ContainerKind;
|
|
7
|
+
readonly gap: number;
|
|
8
|
+
readonly align: Alignment;
|
|
9
|
+
readonly justify: Alignment;
|
|
10
|
+
readonly children: readonly VellumNode[];
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"container-node.d.ts","sourceRoot":"","sources":["../../src/ast/container-node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,CAAC;AAEvD,MAAM,WAAW,aAAc,SAAQ,QAAQ;IAC7C,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC,aAAa,GAAG,QAAQ,CAAC,EAAE,CAAC;CAC1D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"container-node.js","sourceRoot":"","sources":["../../src/ast/container-node.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type { NodeId, BaseNode } from './base-node.js';
|
|
2
|
+
export type { ContainerKind, ContainerNode } from './container-node.js';
|
|
3
|
+
export type { LeafKind, ClickActionKind, ClickAction, TextNode, ImageNode, ButtonNode, LeafNode, } from './leaf-node.js';
|
|
4
|
+
export type { LiteralTextSegment, BindingTextSegment, TextSegment } from './text-segment.js';
|
|
5
|
+
export type { IdentifierValue, InterpolatedStringValue, PropertyValue } from './value.js';
|
|
6
|
+
export type { StyleDeclaration } from './style.js';
|
|
7
|
+
export type { ConditionalNode } from './conditional-node.js';
|
|
8
|
+
export type { VellumNode } from './vellum-node.js';
|
|
9
|
+
export type { DocumentMetadata, DetectedStateBinding, VellumDocument, } from './vellum-document.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ast/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACpD,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACrE,YAAY,EACV,QAAQ,EACR,eAAe,EACf,WAAW,EACX,QAAQ,EACR,SAAS,EACT,UAAU,EACV,QAAQ,GACT,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,YAAY,EACV,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,GACf,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ast/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ColorHex } from '../types/color-hex.js';
|
|
2
|
+
import type { Vector2 } from '../types/vector2.js';
|
|
3
|
+
import type { BaseNode } from './base-node.js';
|
|
4
|
+
import type { TextSegment } from './text-segment.js';
|
|
5
|
+
export type LeafKind = 'Text' | 'Image' | 'Button';
|
|
6
|
+
export type ClickActionKind = 'UpdateState' | 'Navigate' | 'EmitEvent';
|
|
7
|
+
export interface ClickAction {
|
|
8
|
+
readonly kind: ClickActionKind;
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly payload?: Readonly<Record<string, string>>;
|
|
11
|
+
}
|
|
12
|
+
export interface TextNode extends BaseNode {
|
|
13
|
+
readonly kind: 'Text';
|
|
14
|
+
readonly content: readonly TextSegment[];
|
|
15
|
+
readonly fontSize: number;
|
|
16
|
+
readonly color: ColorHex;
|
|
17
|
+
readonly fontWeight: number;
|
|
18
|
+
readonly maxLines?: number;
|
|
19
|
+
}
|
|
20
|
+
export interface ImageNode extends BaseNode {
|
|
21
|
+
readonly kind: 'Image';
|
|
22
|
+
readonly source: readonly TextSegment[];
|
|
23
|
+
readonly size: Vector2;
|
|
24
|
+
readonly alt: string;
|
|
25
|
+
}
|
|
26
|
+
export interface ButtonNode extends BaseNode {
|
|
27
|
+
readonly kind: 'Button';
|
|
28
|
+
readonly label: readonly TextSegment[];
|
|
29
|
+
readonly onClick: ClickAction;
|
|
30
|
+
readonly backgroundColor: ColorHex;
|
|
31
|
+
readonly textColor: ColorHex;
|
|
32
|
+
}
|
|
33
|
+
export type LeafNode = TextNode | ImageNode | ButtonNode;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"leaf-node.d.ts","sourceRoot":"","sources":["../../src/ast/leaf-node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEnD,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG,UAAU,GAAG,WAAW,CAAC;AAEvE,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC;CAChE;AAED,MAAM,WAAW,QAAS,SAAQ,QAAQ;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,CAAC,EAAE,iBAAiB,CAAC;IACzC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,SAAU,SAAQ,QAAQ;IACzC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,aAAa,CAAC,EAAE,iBAAiB,CAAC;IAC3C,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,UAAW,SAAQ,QAAQ;IAC1C,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,YAAY,CAAC,EAAE,iBAAiB,CAAC;IAC1C,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,eAAe,EAAE,QAAQ,CAAC;IACnC,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC;CAC9B;AAED,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"leaf-node.js","sourceRoot":"","sources":["../../src/ast/leaf-node.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { BindingExpression } from '../types/binding-expression.js';
|
|
2
|
+
export interface LiteralTextSegment {
|
|
3
|
+
readonly kind: 'Literal';
|
|
4
|
+
readonly value: string;
|
|
5
|
+
}
|
|
6
|
+
export interface BindingTextSegment {
|
|
7
|
+
readonly kind: 'Binding';
|
|
8
|
+
readonly expression: BindingExpression;
|
|
9
|
+
}
|
|
10
|
+
export type TextSegment = LiteralTextSegment | BindingTextSegment;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { BindingExpression } from '../types/binding-expression.js';
|
|
2
|
+
import type { TextSegment } from './text-segment.js';
|
|
3
|
+
export interface IdentifierValue {
|
|
4
|
+
readonly kind: 'Identifier';
|
|
5
|
+
readonly name: string;
|
|
6
|
+
}
|
|
7
|
+
export interface InterpolatedStringValue {
|
|
8
|
+
readonly kind: 'InterpolatedString';
|
|
9
|
+
readonly segments: readonly TextSegment[];
|
|
10
|
+
readonly expressions: readonly BindingExpression[];
|
|
11
|
+
}
|
|
12
|
+
export type PropertyValue = string | number | boolean | readonly PropertyValue[] | IdentifierValue | InterpolatedStringValue;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { BindingExpression } from '../types/binding-expression.js';
|
|
2
|
+
import type { NodeId } from './base-node.js';
|
|
3
|
+
import type { StyleDeclaration } from './style.js';
|
|
4
|
+
import type { VellumNode } from './vellum-node.js';
|
|
5
|
+
export interface DocumentMetadata {
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly version: string;
|
|
8
|
+
readonly description?: string;
|
|
9
|
+
readonly author?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface DetectedStateBinding {
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly expression: BindingExpression;
|
|
14
|
+
readonly nodeIds: readonly NodeId[];
|
|
15
|
+
}
|
|
16
|
+
export interface VellumDocument {
|
|
17
|
+
readonly schemaVersion: 1;
|
|
18
|
+
readonly root: VellumNode;
|
|
19
|
+
readonly metadata: DocumentMetadata;
|
|
20
|
+
readonly stateBindings: readonly DetectedStateBinding[];
|
|
21
|
+
readonly styles: readonly StyleDeclaration[];
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vellum-document.d.ts","sourceRoot":"","sources":["../../src/ast/vellum-document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,iBAAiB,CAAC;IACvC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,QAAQ,CAAC,aAAa,EAAE,SAAS,oBAAoB,EAAE,CAAC;CACzD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vellum-document.js","sourceRoot":"","sources":["../../src/ast/vellum-document.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vellum-node.d.ts","sourceRoot":"","sources":["../../src/ast/vellum-node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,MAAM,UAAU,GAAG,aAAa,GAAG,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vellum-node.js","sourceRoot":"","sources":["../../src/ast/vellum-node.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type * from './types/index.js';
|
|
2
|
+
export type * from './ast/index.js';
|
|
3
|
+
export type * from './layout/index.js';
|
|
4
|
+
export { normalizeBoxSpacing, resolveAnchor, resolveAlignment, normalizeLayoutProperties, resolveConditionalHierarchy, negateCondition, } from './layout/index.js';
|
|
5
|
+
export type { TokenKind } from './lexer/index.js';
|
|
6
|
+
export type { Token, SourcePosition } from './lexer/index.js';
|
|
7
|
+
export type { LexerErrorCode } from './lexer/index.js';
|
|
8
|
+
export { Lexer, LexerError, tokenize } from './lexer/index.js';
|
|
9
|
+
export type { ParserErrorCode } from './parser/index.js';
|
|
10
|
+
export type { ParsedArgument, ParsedComponent, ParsedConditional, ParsedNode, ParsedProgram, } from './parser/index.js';
|
|
11
|
+
export type { ExtractedStringValue } from './parser/index.js';
|
|
12
|
+
export type { ResolvedProperties } from './parser/index.js';
|
|
13
|
+
export type { BuildContext } from './parser/index.js';
|
|
14
|
+
export { Parser, ParserError, compileVlmToAst, extractStringValue, parseStringValue, resolveStyleProperties, BindingCollector, NodeIdGenerator, buildDocument, buildNode, } from './parser/index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,MAAM,EACN,SAAS,EACT,OAAO,EACP,UAAU,EACV,QAAQ,EACR,iBAAiB,GAClB,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,MAAM,EACN,QAAQ,EACR,aAAa,EACb,aAAa,EACb,QAAQ,EACR,eAAe,EACf,WAAW,EACX,QAAQ,EACR,SAAS,EACT,UAAU,EACV,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,GACf,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { normalizeBoxSpacing, resolveAnchor, resolveAlignment, normalizeLayoutProperties, resolveConditionalHierarchy, negateCondition, } from './layout/index.js';
|
|
2
|
+
export { Lexer, LexerError, tokenize } from './lexer/index.js';
|
|
3
|
+
export { Parser, ParserError, compileVlmToAst, extractStringValue, parseStringValue, resolveStyleProperties, BindingCollector, NodeIdGenerator, buildDocument, buildNode, } from './parser/index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const ALIGNMENT_TABLE = {
|
|
2
|
+
Start: { offset: 0, stretch: false },
|
|
3
|
+
Center: { offset: 0.5, stretch: false },
|
|
4
|
+
End: { offset: 1, stretch: false },
|
|
5
|
+
Stretch: { offset: 0, stretch: true },
|
|
6
|
+
};
|
|
7
|
+
export function resolveAlignment(alignment) {
|
|
8
|
+
return ALIGNMENT_TABLE[alignment];
|
|
9
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Anchor } from '../types/anchor.js';
|
|
2
|
+
export type HorizontalAnchor = 'left' | 'center' | 'right';
|
|
3
|
+
export type VerticalAnchor = 'top' | 'center' | 'bottom';
|
|
4
|
+
export interface NormalizedAnchor {
|
|
5
|
+
readonly x: number;
|
|
6
|
+
readonly y: number;
|
|
7
|
+
readonly horizontal: HorizontalAnchor;
|
|
8
|
+
readonly vertical: VerticalAnchor;
|
|
9
|
+
}
|
|
10
|
+
export declare function resolveAnchor(anchor: Anchor): NormalizedAnchor;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const ANCHOR_TABLE = {
|
|
2
|
+
TopLeft: { x: 0, y: 0, horizontal: 'left', vertical: 'top' },
|
|
3
|
+
TopCenter: { x: 0.5, y: 0, horizontal: 'center', vertical: 'top' },
|
|
4
|
+
TopRight: { x: 1, y: 0, horizontal: 'right', vertical: 'top' },
|
|
5
|
+
CenterLeft: { x: 0, y: 0.5, horizontal: 'left', vertical: 'center' },
|
|
6
|
+
Center: { x: 0.5, y: 0.5, horizontal: 'center', vertical: 'center' },
|
|
7
|
+
CenterRight: { x: 1, y: 0.5, horizontal: 'right', vertical: 'center' },
|
|
8
|
+
BottomLeft: { x: 0, y: 1, horizontal: 'left', vertical: 'bottom' },
|
|
9
|
+
BottomCenter: { x: 0.5, y: 1, horizontal: 'center', vertical: 'bottom' },
|
|
10
|
+
BottomRight: { x: 1, y: 1, horizontal: 'right', vertical: 'bottom' },
|
|
11
|
+
};
|
|
12
|
+
export function resolveAnchor(anchor) {
|
|
13
|
+
return ANCHOR_TABLE[anchor];
|
|
14
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { BindingExpression } from '../types/binding-expression.js';
|
|
2
|
+
import type { ConditionalNode } from '../ast/conditional-node.js';
|
|
3
|
+
import type { VellumNode } from '../ast/vellum-node.js';
|
|
4
|
+
import type { NormalizedLayoutProperties } from './layout-properties.js';
|
|
5
|
+
export type ResolvedNode = Exclude<VellumNode, ConditionalNode>;
|
|
6
|
+
export interface ResolvedLayoutNode {
|
|
7
|
+
readonly node: ResolvedNode;
|
|
8
|
+
readonly layout: NormalizedLayoutProperties;
|
|
9
|
+
readonly conditions: readonly BindingExpression[];
|
|
10
|
+
readonly children: readonly ResolvedLayoutNode[];
|
|
11
|
+
}
|
|
12
|
+
export declare function negateCondition(condition: BindingExpression): BindingExpression;
|
|
13
|
+
export declare function resolveConditionalHierarchy(root: VellumNode): readonly ResolvedLayoutNode[];
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { normalizeLayoutProperties } from './layout-properties.js';
|
|
2
|
+
export function negateCondition(condition) {
|
|
3
|
+
return `!(${condition})`;
|
|
4
|
+
}
|
|
5
|
+
export function resolveConditionalHierarchy(root) {
|
|
6
|
+
if (isConditional(root)) {
|
|
7
|
+
const consequent = root.consequent.flatMap((child) => resolveConditionalHierarchy(child).map((node) => extendConditions(node, root.condition)));
|
|
8
|
+
const alternate = root.alternate.flatMap((child) => resolveConditionalHierarchy(child).map((node) => extendConditions(node, negateCondition(root.condition))));
|
|
9
|
+
return [...consequent, ...alternate];
|
|
10
|
+
}
|
|
11
|
+
return [buildResolvedNode(root, [])];
|
|
12
|
+
}
|
|
13
|
+
function isConditional(node) {
|
|
14
|
+
return node.kind === 'Conditional';
|
|
15
|
+
}
|
|
16
|
+
function buildResolvedNode(node, conditions) {
|
|
17
|
+
const children = isContainer(node)
|
|
18
|
+
? node.children.flatMap((child) => resolveConditionalHierarchy(child))
|
|
19
|
+
: [];
|
|
20
|
+
const layout = normalizeLayoutProperties({
|
|
21
|
+
anchor: node.anchor,
|
|
22
|
+
margin: node.margin,
|
|
23
|
+
padding: node.padding,
|
|
24
|
+
visible: node.visible,
|
|
25
|
+
...(isContainer(node) ? { gap: node.gap, align: node.align, justify: node.justify } : {}),
|
|
26
|
+
});
|
|
27
|
+
return { node, layout, conditions, children };
|
|
28
|
+
}
|
|
29
|
+
function extendConditions(node, condition) {
|
|
30
|
+
return { ...node, conditions: [condition, ...node.conditions] };
|
|
31
|
+
}
|
|
32
|
+
function isContainer(node) {
|
|
33
|
+
return node.kind === 'Panel' || node.kind === 'Row' || node.kind === 'Column';
|
|
34
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { normalizeBoxSpacing } from './spacing.js';
|
|
2
|
+
export type { NormalizedBoxSpacing } from './spacing.js';
|
|
3
|
+
export { resolveAnchor } from './anchor.js';
|
|
4
|
+
export type { NormalizedAnchor, HorizontalAnchor, VerticalAnchor } from './anchor.js';
|
|
5
|
+
export { resolveAlignment } from './alignment.js';
|
|
6
|
+
export type { NormalizedAlignment } from './alignment.js';
|
|
7
|
+
export { normalizeLayoutProperties } from './layout-properties.js';
|
|
8
|
+
export type { LayoutPropertiesInput, NormalizedLayoutProperties } from './layout-properties.js';
|
|
9
|
+
export { resolveConditionalHierarchy, negateCondition } from './conditional.js';
|
|
10
|
+
export type { ResolvedLayoutNode, ResolvedNode } from './conditional.js';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { normalizeBoxSpacing } from './spacing.js';
|
|
2
|
+
export { resolveAnchor } from './anchor.js';
|
|
3
|
+
export { resolveAlignment } from './alignment.js';
|
|
4
|
+
export { normalizeLayoutProperties } from './layout-properties.js';
|
|
5
|
+
export { resolveConditionalHierarchy, negateCondition } from './conditional.js';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Alignment } from '../types/alignment.js';
|
|
2
|
+
import type { Anchor } from '../types/anchor.js';
|
|
3
|
+
import type { BoxSpacing } from '../types/box-spacing.js';
|
|
4
|
+
import type { NormalizedAlignment } from './alignment.js';
|
|
5
|
+
import type { NormalizedAnchor } from './anchor.js';
|
|
6
|
+
import type { NormalizedBoxSpacing } from './spacing.js';
|
|
7
|
+
export interface LayoutPropertiesInput {
|
|
8
|
+
readonly anchor: Anchor;
|
|
9
|
+
readonly margin: BoxSpacing;
|
|
10
|
+
readonly padding: BoxSpacing;
|
|
11
|
+
readonly visible: boolean;
|
|
12
|
+
readonly gap?: number;
|
|
13
|
+
readonly align?: Alignment;
|
|
14
|
+
readonly justify?: Alignment;
|
|
15
|
+
}
|
|
16
|
+
export interface NormalizedLayoutProperties {
|
|
17
|
+
readonly anchor: NormalizedAnchor;
|
|
18
|
+
readonly margin: NormalizedBoxSpacing;
|
|
19
|
+
readonly padding: NormalizedBoxSpacing;
|
|
20
|
+
readonly visible: boolean;
|
|
21
|
+
readonly gap: number;
|
|
22
|
+
readonly align: NormalizedAlignment;
|
|
23
|
+
readonly justify: NormalizedAlignment;
|
|
24
|
+
}
|
|
25
|
+
export declare function normalizeLayoutProperties(input: LayoutPropertiesInput): NormalizedLayoutProperties;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { resolveAlignment } from './alignment.js';
|
|
2
|
+
import { resolveAnchor } from './anchor.js';
|
|
3
|
+
import { normalizeBoxSpacing } from './spacing.js';
|
|
4
|
+
export function normalizeLayoutProperties(input) {
|
|
5
|
+
return {
|
|
6
|
+
anchor: resolveAnchor(input.anchor),
|
|
7
|
+
margin: normalizeBoxSpacing(input.margin),
|
|
8
|
+
padding: normalizeBoxSpacing(input.padding),
|
|
9
|
+
visible: input.visible,
|
|
10
|
+
gap: input.gap ?? 0,
|
|
11
|
+
align: resolveAlignment(input.align ?? 'Start'),
|
|
12
|
+
justify: resolveAlignment(input.justify ?? 'Start'),
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function normalizeBoxSpacing(spacing) {
|
|
2
|
+
if (typeof spacing === 'number') {
|
|
3
|
+
return [spacing, spacing, spacing, spacing];
|
|
4
|
+
}
|
|
5
|
+
if (spacing.length === 4) {
|
|
6
|
+
return [spacing[0], spacing[1], spacing[2], spacing[3]];
|
|
7
|
+
}
|
|
8
|
+
if (spacing.length === 2) {
|
|
9
|
+
const vertical = spacing[0];
|
|
10
|
+
const horizontal = spacing[1];
|
|
11
|
+
return [vertical, horizontal, vertical, horizontal];
|
|
12
|
+
}
|
|
13
|
+
const value = spacing[0];
|
|
14
|
+
return [value, value, value, value];
|
|
15
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function isWhitespace(char) {
|
|
2
|
+
return char === ' ' || char === '\t' || char === '\r' || char === '\n';
|
|
3
|
+
}
|
|
4
|
+
export function isDigit(char) {
|
|
5
|
+
return char >= '0' && char <= '9';
|
|
6
|
+
}
|
|
7
|
+
export function isIdentifierStart(char) {
|
|
8
|
+
return (char >= 'A' && char <= 'Z') || (char >= 'a' && char <= 'z') || char === '_';
|
|
9
|
+
}
|
|
10
|
+
export function isIdentifierPart(char) {
|
|
11
|
+
return isIdentifierStart(char) || isDigit(char);
|
|
12
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { TokenKind } from './token-kind.js';
|
|
2
|
+
export type { Token, SourcePosition } from './token.js';
|
|
3
|
+
export type { LexerErrorCode } from './lexer-error.js';
|
|
4
|
+
export { LexerError } from './lexer-error.js';
|
|
5
|
+
export { Lexer } from './lexer.js';
|
|
6
|
+
export { tokenize } from './tokenize.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SourcePosition } from './token.js';
|
|
2
|
+
export type LexerErrorCode = 'UnexpectedCharacter' | 'UnterminatedString' | 'InvalidEscapeSequence';
|
|
3
|
+
export declare class LexerError extends Error {
|
|
4
|
+
readonly code: LexerErrorCode;
|
|
5
|
+
readonly position: SourcePosition;
|
|
6
|
+
constructor(code: LexerErrorCode, message: string, position: SourcePosition);
|
|
7
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Token } from './token.js';
|
|
2
|
+
export declare class Lexer {
|
|
3
|
+
private readonly source;
|
|
4
|
+
private offset;
|
|
5
|
+
private line;
|
|
6
|
+
private column;
|
|
7
|
+
constructor(source: string);
|
|
8
|
+
tokenize(): readonly Token[];
|
|
9
|
+
private scanToken;
|
|
10
|
+
private scanSingle;
|
|
11
|
+
private scanNumber;
|
|
12
|
+
private scanIdentifier;
|
|
13
|
+
private scanOperator;
|
|
14
|
+
private scanString;
|
|
15
|
+
private applyEscape;
|
|
16
|
+
private currentChar;
|
|
17
|
+
private peekChar;
|
|
18
|
+
private advance;
|
|
19
|
+
private currentPosition;
|
|
20
|
+
private createToken;
|
|
21
|
+
}
|