@mildastudio/milda 0.1.0 → 0.1.1

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 CHANGED
@@ -1,26 +1,44 @@
1
- # milda
1
+ # @mildastudio/milda
2
2
 
3
- The **Milda language** — a platform-neutral design language for describing design
3
+ The **Milda language** - a platform-neutral design language for describing design
4
4
  systems and their components, and the canonical AST that tools exchange.
5
5
 
6
6
  Milda separates *what a component is* (its contract, anatomy, behavior, and
7
7
  styling intent) from *how any one platform realizes it*. A description written
8
- once can be generated into React, CSS, Figma variables, and — by design — other
8
+ once can be generated into React, CSS, Figma variables, and - by design - other
9
9
  targets, without the description itself leaking platform assumptions.
10
10
 
11
+ > This repository is the public, open-source mirror of the `packages/milda`
12
+ > package from the Milda monorepo, which stays the single source of truth. See
13
+ > [milda.dev](https://milda.dev) for the product and the full DSL documentation.
14
+
15
+ ## Install
16
+
17
+ ```bash
18
+ npm install @mildastudio/milda
19
+ ```
20
+
21
+ ```ts
22
+ import { preludeV0, validate, resolveToken } from "@mildastudio/milda";
23
+ ```
24
+
11
25
  ## What's in here
12
26
 
13
- - **AST** (`types/ast.ts`) — the canonical interchange artifact. The spec in
14
- `docs/dsl/PRELUDE.md` is the normative source of truth; this package is one
15
- implementation of it.
16
- - **Tokens** (`types/tokens.ts`) — layered, context-aware token values
17
- (color, dimension, shadow, typography, …) with alias chains and an explicit
27
+ - **Spec** (`spec/`) - the normative language: [`PRELUDE.md`](spec/PRELUDE.md)
28
+ (source of truth), [`GRAMMAR.ebnf`](spec/GRAMMAR.ebnf), [`ast.schema.json`](spec/ast.schema.json),
29
+ [`ROADMAP.md`](spec/ROADMAP.md), the language design [`proposals/`](spec/proposals/),
30
+ and `examples/` (validate them with `node spec/validate.js`).
31
+ - **AST** (`types/ast.ts`) - the canonical interchange artifact. The spec in
32
+ [`spec/PRELUDE.md`](spec/PRELUDE.md) is the normative source of truth; this package
33
+ is one implementation of it.
34
+ - **Tokens** (`types/tokens.ts`) - layered, context-aware token values
35
+ (color, dimension, shadow, typography, ...) with alias chains and an explicit
18
36
  `escape` leaf for values a target can't express natively.
19
- - **Facets, layout, states, capabilities** (`types/facets.ts`) — the
37
+ - **Facets, layout, states, capabilities** (`types/facets.ts`) - the
20
38
  platform-neutral styling and layout vocabulary.
21
- - **Prelude** (`prelude/preludeV0.ts`) — the standard library expressed as
39
+ - **Prelude** (`prelude/preludeV0.ts`) - the standard library expressed as
22
40
  data: behavior *atoms*, *archetypes*, facets, states, and capabilities.
23
- - **Engine** (`engine/*`) — pure, side-effect-free semantics over the AST:
41
+ - **Engine** (`engine/*`) - pure, side-effect-free semantics over the AST:
24
42
  `resolveToken`, `resolveFacets`/`resolveLayout`, `validate`, and `conformance`
25
43
  (which reports where a description has holes for a given target).
26
44
 
@@ -32,12 +50,19 @@ targets, without the description itself leaking platform assumptions.
32
50
  in the language.
33
51
  - **Honest escape hatches.** Where a value or capability can't be expressed
34
52
  cleanly, the model carries an explicit `escape` leaf rather than silently
35
- approximating — so `conformance` can tell you exactly what won't survive a
53
+ approximating - so `conformance` can tell you exactly what won't survive a
36
54
  given target.
37
55
 
56
+ ## Where it fits
57
+
58
+ `@mildastudio/milda` is the language layer. The generators and pipeline that
59
+ consume it live in the [milda-engine](https://github.com/mildastudio/milda-engine)
60
+ repo (`@mildastudio/core`, `@mildastudio/contract`, `@mildastudio/generate`,
61
+ `@mildastudio/release`), which depends on this package.
62
+
38
63
  ## Status
39
64
 
40
- `0.x` — the language and AST are still evolving; treat the shape as unstable
65
+ `0.x` - the language and AST are still evolving; treat the shape as unstable
41
66
  until `1.0`.
42
67
 
43
68
  ## License
package/dist/index.d.mts CHANGED
@@ -37,6 +37,7 @@ interface ObjectField {
37
37
  type PropValue = string | number | boolean | PropValue[] | {
38
38
  [key: string]: PropValue;
39
39
  };
40
+ type Metadata = Record<string, PropValue>;
40
41
  interface SharedType {
41
42
  id: Id;
42
43
  name: string;
@@ -67,7 +68,7 @@ interface MildaDocumentBase {
67
68
  interface TokenRef {
68
69
  ref: Id;
69
70
  }
70
- type PrimitiveTokenType = 'color' | 'spacing' | 'radius' | 'size' | 'shadow' | 'typography' | 'fontFamily' | 'duration' | 'opacity' | 'blur' | 'tonal' | 'border';
71
+ type PrimitiveTokenType = 'color' | 'spacing' | 'radius' | 'size' | 'shadow' | 'typography' | 'fontFamily' | 'fontWeight' | 'duration' | 'opacity' | 'blur' | 'tonal' | 'border';
71
72
  type FacetTokenType = 'elevation' | 'ring' | 'backdrop' | 'none';
72
73
  type TokenType$1 = PrimitiveTokenType | FacetTokenType;
73
74
  type ColorSpace = 'srgb' | 'display-p3' | 'oklch' | 'hsl';
@@ -101,6 +102,9 @@ interface FontFamilyValue {
101
102
  category: FontCategory;
102
103
  assetId?: Id | null;
103
104
  }
105
+ interface FontWeightValue {
106
+ weight: number;
107
+ }
104
108
  interface TypographyValue {
105
109
  family: TokenRef | FontFamilyValue;
106
110
  size: DimensionValue;
@@ -142,6 +146,7 @@ interface TokenValueSchemaByType {
142
146
  shadow: ShadowValue;
143
147
  typography: TypographyValue;
144
148
  fontFamily: FontFamilyValue;
149
+ fontWeight: FontWeightValue;
145
150
  duration: DurationValue;
146
151
  opacity: OpacityValue;
147
152
  blur: BlurValue;
@@ -190,9 +195,9 @@ interface ContextGroup {
190
195
  name: string;
191
196
  contexts: Context[];
192
197
  }
193
- declare const TOKEN_VALUE_KIND: Record<TokenType$1, 'color' | 'dimension' | 'shadow' | 'typography' | 'fontFamily' | 'duration' | 'opacity' | 'blur' | 'tonal' | 'border' | 'facet'>;
198
+ declare const TOKEN_VALUE_KIND: Record<TokenType$1, 'color' | 'dimension' | 'shadow' | 'typography' | 'fontFamily' | 'fontWeight' | 'duration' | 'opacity' | 'blur' | 'tonal' | 'border' | 'facet'>;
194
199
 
195
- type FacetName = 'fill' | 'ink' | 'border' | 'corner' | 'inset' | 'gap' | 'text' | 'textClamp' | 'textWrap' | 'elevation' | 'overlay' | 'opacity' | 'ring' | 'backdrop';
200
+ type FacetName = 'fill' | 'ink' | 'border' | 'border.top' | 'border.right' | 'border.bottom' | 'border.left' | 'border.inline-start' | 'border.inline-end' | 'border.block-start' | 'border.block-end' | 'corner' | 'inset' | 'gap' | 'text' | 'textClamp' | 'textWrap' | 'weight' | 'font' | 'slant' | 'elevation' | 'overlay' | 'opacity' | 'ring' | 'backdrop';
196
201
  type InsetValue = {
197
202
  block?: Id;
198
203
  inline?: Id;
@@ -204,12 +209,20 @@ type InsetValue = {
204
209
  } | {
205
210
  all: Id;
206
211
  };
212
+ type BorderFacetStyle = 'solid' | 'dashed' | 'dotted';
213
+ interface BorderFacetValue {
214
+ width?: Id;
215
+ color?: Id;
216
+ style?: BorderFacetStyle;
217
+ }
207
218
  type FacetValue = {
208
219
  token: Id;
209
220
  } | {
210
221
  literal: string | number | boolean;
211
222
  } | {
212
223
  inset: InsetValue;
224
+ } | {
225
+ border: BorderFacetValue;
213
226
  } | {
214
227
  raw: string;
215
228
  };
@@ -375,6 +388,9 @@ interface CompositeBehavior {
375
388
  builtFrom: string[];
376
389
  uses?: UsesClause[];
377
390
  composition?: CoordEntry[];
391
+ emits?: {
392
+ name: string;
393
+ }[];
378
394
  note?: string;
379
395
  }
380
396
  type ArchetypeGroup = 'Actions' | 'Inputs' | 'Disclosure' | 'Navigation' | 'Collections' | 'Feedback' | 'Media';
@@ -459,6 +475,7 @@ interface PropDef {
459
475
  required?: boolean;
460
476
  description?: string;
461
477
  binding?: string;
478
+ meta?: Metadata;
462
479
  }
463
480
  interface EventDef {
464
481
  id?: Id;
@@ -476,15 +493,62 @@ interface PartState {
476
493
  layout?: LayoutSpec;
477
494
  facets?: FacetMap;
478
495
  }
496
+ type PredicateRef = {
497
+ kind: 'prop';
498
+ path: string;
499
+ } | {
500
+ kind: 'state';
501
+ state: string;
502
+ } | {
503
+ kind: 'context';
504
+ group: string;
505
+ } | {
506
+ kind: 'ancestor';
507
+ nodeId: string;
508
+ state: string;
509
+ };
510
+ type CompareOp = 'eq' | 'ne' | 'lt' | 'lte' | 'gt' | 'gte' | 'contains' | 'set' | 'unset';
511
+ type Predicate = {
512
+ kind: 'all';
513
+ items: Predicate[];
514
+ } | {
515
+ kind: 'any';
516
+ items: Predicate[];
517
+ } | {
518
+ kind: 'not';
519
+ item: Predicate;
520
+ } | {
521
+ kind: 'cmp';
522
+ ref: PredicateRef;
523
+ op: CompareOp;
524
+ value?: PropValue;
525
+ };
479
526
  interface PartVariant {
480
527
  when?: RealizeCond;
528
+ whenPredicate?: Predicate;
481
529
  states?: StateName[];
482
530
  facets?: FacetMap;
483
531
  layout?: LayoutSpec;
484
532
  }
533
+ type PartSlotArity = 'single' | 'optional' | 'many';
534
+ type PartSlotAccepts = {
535
+ kind: 'content';
536
+ } | {
537
+ kind: 'type';
538
+ ref: string;
539
+ } | {
540
+ kind: 'component';
541
+ ref: string;
542
+ };
543
+ interface PartSlot {
544
+ arity: PartSlotArity;
545
+ accepts: PartSlotAccepts;
546
+ }
485
547
  interface Part {
486
548
  layout?: LayoutSpec;
487
549
  facets?: FacetMap;
550
+ slot?: PartSlot;
551
+ presence?: Predicate;
488
552
  states?: Partial<Record<StateName, PartState>>;
489
553
  variants?: PartVariant[];
490
554
  }
@@ -513,6 +577,8 @@ interface BrowseRealize {
513
577
  interface CommitRealize {
514
578
  mode: 'explicit' | 'continuous';
515
579
  on?: string[];
580
+ live?: string;
581
+ settled?: string;
516
582
  }
517
583
  interface Realization {
518
584
  target: string;
@@ -524,6 +590,8 @@ interface Realization {
524
590
  drop?: string[];
525
591
  wire?: Wire[];
526
592
  note?: string;
593
+ dismiss?: string[];
594
+ backdrop?: string;
527
595
  }
528
596
  interface Composition {
529
597
  uses: UsesClause[];
@@ -538,6 +606,7 @@ interface Component {
538
606
  anatomy: Anatomy;
539
607
  realize: Realization[];
540
608
  composition?: Composition;
609
+ meta?: Metadata;
541
610
  }
542
611
 
543
612
  type AssetKind = 'font' | 'image' | 'svg' | 'video' | 'animation';
@@ -613,6 +682,7 @@ interface Project extends MildaDocumentBase {
613
682
 
614
683
  declare const preludeV0: PreludeDocument;
615
684
  declare const atomsByName: Record<string, Atom>;
685
+ declare const compositesByName: Record<string, CompositeBehavior>;
616
686
  declare const archetypesByName: Record<string, ArchetypeDef>;
617
687
 
618
688
  type ResolvedToken = {
@@ -649,6 +719,7 @@ interface ValidationIssue {
649
719
  code: string;
650
720
  message: string;
651
721
  where?: string;
722
+ id?: string;
652
723
  }
653
724
  declare function validate(doc: Project, prelude: PreludeDocument): ValidationIssue[];
654
725
 
@@ -695,9 +766,27 @@ interface ParseIssue {
695
766
  line: number;
696
767
  col: number;
697
768
  }
769
+ interface SourcePosition {
770
+ line: number;
771
+ col: number;
772
+ }
773
+ interface SourceRange {
774
+ start: SourcePosition;
775
+ end: SourcePosition;
776
+ }
777
+ type SpanKind = 'component' | 'token' | 'contextGroup' | 'context' | 'sharedType' | 'part' | 'prop' | 'event';
778
+ interface NodeSpan {
779
+ id: string;
780
+ kind: SpanKind;
781
+ name: string;
782
+ nameRange: SourceRange;
783
+ fullRange: SourceRange;
784
+ parentId?: string;
785
+ }
698
786
  interface ParseResult {
699
787
  document: DesignSystemDocument;
700
788
  issues: ParseIssue[];
789
+ spans: NodeSpan[];
701
790
  }
702
791
  interface ParseOptions {
703
792
  name?: string;
@@ -706,7 +795,7 @@ interface ParseOptions {
706
795
  }
707
796
  declare function parseMildaDocument(src: string, opts?: ParseOptions): ParseResult;
708
797
 
709
- type TokenType = 'word' | 'string' | 'lbrace' | 'rbrace' | 'lparen' | 'rparen' | 'lt' | 'gt' | 'colon' | 'equals' | 'comma' | 'semi' | 'question' | 'arrow' | 'newline' | 'eof';
798
+ type TokenType = 'word' | 'string' | 'lbrace' | 'rbrace' | 'lparen' | 'rparen' | 'lbracket' | 'rbracket' | 'lt' | 'gt' | 'lte' | 'gte' | 'ne' | 'colon' | 'equals' | 'comma' | 'semi' | 'question' | 'arrow' | 'at' | 'newline' | 'eof';
710
799
  interface Token {
711
800
  type: TokenType;
712
801
  value: string;
@@ -721,4 +810,4 @@ declare class LexError extends Error {
721
810
  }
722
811
  declare function lex(src: string): Token[];
723
812
 
724
- export { type AliasTokenValue, type Align, type Anatomy, type AnatomyPart, type AnimationAsset, type AnimationFormat, type AnyTokenValue, type ArchetypeDef, type ArchetypeGroup, type ArchetypeRealize, type Asset, type AssetByKind, type AssetFolder, type AssetKind, type AssetRegistry, type Assignment, type Atom, type AtomContextVar, type AtomEvent, type AtomParam, type AtomStateNode, type AxisIntent, type AxisSize, type AxisSizeValue, type BlurValue, type BorderStyle, type BorderValue, type BorderWidth, type BrowseRealize, type Capability, type CapabilityDef, type ColorOrRef, type ColorSpace, type ColorValue, type CommitRealize, type Component, type CompositeBehavior, type Composition, type ConformanceOptions, type ConformanceReport, type ContentCategory, type Context, type ContextGroup, type Contract, type CoordEntry, type DesignSystemDocument, type DimensionOrRef, type DimensionUnit, type DimensionValue, type Distribute, type DocumentKind, type DocumentMeta, type Token as DslToken, type DurationValue, type Emit, type EscapeTokenValue, type EventDef, type Expose, type FacetDef, type FacetMap, type FacetName, type FacetTokenType, type FacetValue, type FontAsset, type FontCategory, type FontFamilyValue, type Foundations, type Hole, type Id, type ImageAsset, type InsetValue, type Layer, type LayoutSpec, LexError, type MildaDocumentBase, type NoneValue, type ObjectField, type OpacityValue, type ParamBinding, type ParseIssue, type ParseOptions, type ParseResult, type Part, type PartRole, type PartState, type PartVariant, type Position, type PreludeDocument, type PresentationRealize, type PrimitiveTokenType, type Project, type DocumentMeta as ProjectMeta, type ProjectMetadataEntry, type PropDef, type PropValue, type RawTokenValue, type Realization, type RealizeCond, type RequiresClause, type ResolveFacetsInput, type ResolvedToken, type ShadowLayer, type ShadowValue, type SharedType, type StackAxis, type StateDef, type StateName, type Substitution, type SvgAsset, TOKEN_VALUE_KIND, type TaxonomyNote, type Token$1 as Token, type TokenRef, type TokenType$1 as TokenType, type TokenValue, type TokenValueSchemaByType, type TonalValue, type Transition, type TransitionTarget, type TypeExpr, type TypeRef, type TypographyValue, type UsesClause, type ValidationIssue, type VideoAsset, type Wire, allTokensOfType, archetypesByName, atomsByName, collectActiveStates, conformance, findToken, lex, parseMildaDocument, preludeV0, resolveFacets, resolveLayout, resolveToken, validate };
813
+ export { type AliasTokenValue, type Align, type Anatomy, type AnatomyPart, type AnimationAsset, type AnimationFormat, type AnyTokenValue, type ArchetypeDef, type ArchetypeGroup, type ArchetypeRealize, type Asset, type AssetByKind, type AssetFolder, type AssetKind, type AssetRegistry, type Assignment, type Atom, type AtomContextVar, type AtomEvent, type AtomParam, type AtomStateNode, type AxisIntent, type AxisSize, type AxisSizeValue, type BlurValue, type BorderFacetStyle, type BorderFacetValue, type BorderStyle, type BorderValue, type BorderWidth, type BrowseRealize, type Capability, type CapabilityDef, type ColorOrRef, type ColorSpace, type ColorValue, type CommitRealize, type CompareOp, type Component, type CompositeBehavior, type Composition, type ConformanceOptions, type ConformanceReport, type ContentCategory, type Context, type ContextGroup, type Contract, type CoordEntry, type DesignSystemDocument, type DimensionOrRef, type DimensionUnit, type DimensionValue, type Distribute, type DocumentKind, type DocumentMeta, type Token as DslToken, type DurationValue, type Emit, type EscapeTokenValue, type EventDef, type Expose, type FacetDef, type FacetMap, type FacetName, type FacetTokenType, type FacetValue, type FontAsset, type FontCategory, type FontFamilyValue, type FontWeightValue, type Foundations, type Hole, type Id, type ImageAsset, type InsetValue, type Layer, type LayoutSpec, LexError, type Metadata, type MildaDocumentBase, type NodeSpan, type NoneValue, type ObjectField, type OpacityValue, type ParamBinding, type ParseIssue, type ParseOptions, type ParseResult, type Part, type PartRole, type PartSlot, type PartSlotAccepts, type PartSlotArity, type PartState, type PartVariant, type Position, type Predicate, type PredicateRef, type PreludeDocument, type PresentationRealize, type PrimitiveTokenType, type Project, type DocumentMeta as ProjectMeta, type ProjectMetadataEntry, type PropDef, type PropValue, type RawTokenValue, type Realization, type RealizeCond, type RequiresClause, type ResolveFacetsInput, type ResolvedToken, type ShadowLayer, type ShadowValue, type SharedType, type SourcePosition, type SourceRange, type SpanKind, type StackAxis, type StateDef, type StateName, type Substitution, type SvgAsset, TOKEN_VALUE_KIND, type TaxonomyNote, type Token$1 as Token, type TokenRef, type TokenType$1 as TokenType, type TokenValue, type TokenValueSchemaByType, type TonalValue, type Transition, type TransitionTarget, type TypeExpr, type TypeRef, type TypographyValue, type UsesClause, type ValidationIssue, type VideoAsset, type Wire, allTokensOfType, archetypesByName, atomsByName, collectActiveStates, compositesByName, conformance, findToken, lex, parseMildaDocument, preludeV0, resolveFacets, resolveLayout, resolveToken, validate };
package/dist/index.d.ts CHANGED
@@ -37,6 +37,7 @@ interface ObjectField {
37
37
  type PropValue = string | number | boolean | PropValue[] | {
38
38
  [key: string]: PropValue;
39
39
  };
40
+ type Metadata = Record<string, PropValue>;
40
41
  interface SharedType {
41
42
  id: Id;
42
43
  name: string;
@@ -67,7 +68,7 @@ interface MildaDocumentBase {
67
68
  interface TokenRef {
68
69
  ref: Id;
69
70
  }
70
- type PrimitiveTokenType = 'color' | 'spacing' | 'radius' | 'size' | 'shadow' | 'typography' | 'fontFamily' | 'duration' | 'opacity' | 'blur' | 'tonal' | 'border';
71
+ type PrimitiveTokenType = 'color' | 'spacing' | 'radius' | 'size' | 'shadow' | 'typography' | 'fontFamily' | 'fontWeight' | 'duration' | 'opacity' | 'blur' | 'tonal' | 'border';
71
72
  type FacetTokenType = 'elevation' | 'ring' | 'backdrop' | 'none';
72
73
  type TokenType$1 = PrimitiveTokenType | FacetTokenType;
73
74
  type ColorSpace = 'srgb' | 'display-p3' | 'oklch' | 'hsl';
@@ -101,6 +102,9 @@ interface FontFamilyValue {
101
102
  category: FontCategory;
102
103
  assetId?: Id | null;
103
104
  }
105
+ interface FontWeightValue {
106
+ weight: number;
107
+ }
104
108
  interface TypographyValue {
105
109
  family: TokenRef | FontFamilyValue;
106
110
  size: DimensionValue;
@@ -142,6 +146,7 @@ interface TokenValueSchemaByType {
142
146
  shadow: ShadowValue;
143
147
  typography: TypographyValue;
144
148
  fontFamily: FontFamilyValue;
149
+ fontWeight: FontWeightValue;
145
150
  duration: DurationValue;
146
151
  opacity: OpacityValue;
147
152
  blur: BlurValue;
@@ -190,9 +195,9 @@ interface ContextGroup {
190
195
  name: string;
191
196
  contexts: Context[];
192
197
  }
193
- declare const TOKEN_VALUE_KIND: Record<TokenType$1, 'color' | 'dimension' | 'shadow' | 'typography' | 'fontFamily' | 'duration' | 'opacity' | 'blur' | 'tonal' | 'border' | 'facet'>;
198
+ declare const TOKEN_VALUE_KIND: Record<TokenType$1, 'color' | 'dimension' | 'shadow' | 'typography' | 'fontFamily' | 'fontWeight' | 'duration' | 'opacity' | 'blur' | 'tonal' | 'border' | 'facet'>;
194
199
 
195
- type FacetName = 'fill' | 'ink' | 'border' | 'corner' | 'inset' | 'gap' | 'text' | 'textClamp' | 'textWrap' | 'elevation' | 'overlay' | 'opacity' | 'ring' | 'backdrop';
200
+ type FacetName = 'fill' | 'ink' | 'border' | 'border.top' | 'border.right' | 'border.bottom' | 'border.left' | 'border.inline-start' | 'border.inline-end' | 'border.block-start' | 'border.block-end' | 'corner' | 'inset' | 'gap' | 'text' | 'textClamp' | 'textWrap' | 'weight' | 'font' | 'slant' | 'elevation' | 'overlay' | 'opacity' | 'ring' | 'backdrop';
196
201
  type InsetValue = {
197
202
  block?: Id;
198
203
  inline?: Id;
@@ -204,12 +209,20 @@ type InsetValue = {
204
209
  } | {
205
210
  all: Id;
206
211
  };
212
+ type BorderFacetStyle = 'solid' | 'dashed' | 'dotted';
213
+ interface BorderFacetValue {
214
+ width?: Id;
215
+ color?: Id;
216
+ style?: BorderFacetStyle;
217
+ }
207
218
  type FacetValue = {
208
219
  token: Id;
209
220
  } | {
210
221
  literal: string | number | boolean;
211
222
  } | {
212
223
  inset: InsetValue;
224
+ } | {
225
+ border: BorderFacetValue;
213
226
  } | {
214
227
  raw: string;
215
228
  };
@@ -375,6 +388,9 @@ interface CompositeBehavior {
375
388
  builtFrom: string[];
376
389
  uses?: UsesClause[];
377
390
  composition?: CoordEntry[];
391
+ emits?: {
392
+ name: string;
393
+ }[];
378
394
  note?: string;
379
395
  }
380
396
  type ArchetypeGroup = 'Actions' | 'Inputs' | 'Disclosure' | 'Navigation' | 'Collections' | 'Feedback' | 'Media';
@@ -459,6 +475,7 @@ interface PropDef {
459
475
  required?: boolean;
460
476
  description?: string;
461
477
  binding?: string;
478
+ meta?: Metadata;
462
479
  }
463
480
  interface EventDef {
464
481
  id?: Id;
@@ -476,15 +493,62 @@ interface PartState {
476
493
  layout?: LayoutSpec;
477
494
  facets?: FacetMap;
478
495
  }
496
+ type PredicateRef = {
497
+ kind: 'prop';
498
+ path: string;
499
+ } | {
500
+ kind: 'state';
501
+ state: string;
502
+ } | {
503
+ kind: 'context';
504
+ group: string;
505
+ } | {
506
+ kind: 'ancestor';
507
+ nodeId: string;
508
+ state: string;
509
+ };
510
+ type CompareOp = 'eq' | 'ne' | 'lt' | 'lte' | 'gt' | 'gte' | 'contains' | 'set' | 'unset';
511
+ type Predicate = {
512
+ kind: 'all';
513
+ items: Predicate[];
514
+ } | {
515
+ kind: 'any';
516
+ items: Predicate[];
517
+ } | {
518
+ kind: 'not';
519
+ item: Predicate;
520
+ } | {
521
+ kind: 'cmp';
522
+ ref: PredicateRef;
523
+ op: CompareOp;
524
+ value?: PropValue;
525
+ };
479
526
  interface PartVariant {
480
527
  when?: RealizeCond;
528
+ whenPredicate?: Predicate;
481
529
  states?: StateName[];
482
530
  facets?: FacetMap;
483
531
  layout?: LayoutSpec;
484
532
  }
533
+ type PartSlotArity = 'single' | 'optional' | 'many';
534
+ type PartSlotAccepts = {
535
+ kind: 'content';
536
+ } | {
537
+ kind: 'type';
538
+ ref: string;
539
+ } | {
540
+ kind: 'component';
541
+ ref: string;
542
+ };
543
+ interface PartSlot {
544
+ arity: PartSlotArity;
545
+ accepts: PartSlotAccepts;
546
+ }
485
547
  interface Part {
486
548
  layout?: LayoutSpec;
487
549
  facets?: FacetMap;
550
+ slot?: PartSlot;
551
+ presence?: Predicate;
488
552
  states?: Partial<Record<StateName, PartState>>;
489
553
  variants?: PartVariant[];
490
554
  }
@@ -513,6 +577,8 @@ interface BrowseRealize {
513
577
  interface CommitRealize {
514
578
  mode: 'explicit' | 'continuous';
515
579
  on?: string[];
580
+ live?: string;
581
+ settled?: string;
516
582
  }
517
583
  interface Realization {
518
584
  target: string;
@@ -524,6 +590,8 @@ interface Realization {
524
590
  drop?: string[];
525
591
  wire?: Wire[];
526
592
  note?: string;
593
+ dismiss?: string[];
594
+ backdrop?: string;
527
595
  }
528
596
  interface Composition {
529
597
  uses: UsesClause[];
@@ -538,6 +606,7 @@ interface Component {
538
606
  anatomy: Anatomy;
539
607
  realize: Realization[];
540
608
  composition?: Composition;
609
+ meta?: Metadata;
541
610
  }
542
611
 
543
612
  type AssetKind = 'font' | 'image' | 'svg' | 'video' | 'animation';
@@ -613,6 +682,7 @@ interface Project extends MildaDocumentBase {
613
682
 
614
683
  declare const preludeV0: PreludeDocument;
615
684
  declare const atomsByName: Record<string, Atom>;
685
+ declare const compositesByName: Record<string, CompositeBehavior>;
616
686
  declare const archetypesByName: Record<string, ArchetypeDef>;
617
687
 
618
688
  type ResolvedToken = {
@@ -649,6 +719,7 @@ interface ValidationIssue {
649
719
  code: string;
650
720
  message: string;
651
721
  where?: string;
722
+ id?: string;
652
723
  }
653
724
  declare function validate(doc: Project, prelude: PreludeDocument): ValidationIssue[];
654
725
 
@@ -695,9 +766,27 @@ interface ParseIssue {
695
766
  line: number;
696
767
  col: number;
697
768
  }
769
+ interface SourcePosition {
770
+ line: number;
771
+ col: number;
772
+ }
773
+ interface SourceRange {
774
+ start: SourcePosition;
775
+ end: SourcePosition;
776
+ }
777
+ type SpanKind = 'component' | 'token' | 'contextGroup' | 'context' | 'sharedType' | 'part' | 'prop' | 'event';
778
+ interface NodeSpan {
779
+ id: string;
780
+ kind: SpanKind;
781
+ name: string;
782
+ nameRange: SourceRange;
783
+ fullRange: SourceRange;
784
+ parentId?: string;
785
+ }
698
786
  interface ParseResult {
699
787
  document: DesignSystemDocument;
700
788
  issues: ParseIssue[];
789
+ spans: NodeSpan[];
701
790
  }
702
791
  interface ParseOptions {
703
792
  name?: string;
@@ -706,7 +795,7 @@ interface ParseOptions {
706
795
  }
707
796
  declare function parseMildaDocument(src: string, opts?: ParseOptions): ParseResult;
708
797
 
709
- type TokenType = 'word' | 'string' | 'lbrace' | 'rbrace' | 'lparen' | 'rparen' | 'lt' | 'gt' | 'colon' | 'equals' | 'comma' | 'semi' | 'question' | 'arrow' | 'newline' | 'eof';
798
+ type TokenType = 'word' | 'string' | 'lbrace' | 'rbrace' | 'lparen' | 'rparen' | 'lbracket' | 'rbracket' | 'lt' | 'gt' | 'lte' | 'gte' | 'ne' | 'colon' | 'equals' | 'comma' | 'semi' | 'question' | 'arrow' | 'at' | 'newline' | 'eof';
710
799
  interface Token {
711
800
  type: TokenType;
712
801
  value: string;
@@ -721,4 +810,4 @@ declare class LexError extends Error {
721
810
  }
722
811
  declare function lex(src: string): Token[];
723
812
 
724
- export { type AliasTokenValue, type Align, type Anatomy, type AnatomyPart, type AnimationAsset, type AnimationFormat, type AnyTokenValue, type ArchetypeDef, type ArchetypeGroup, type ArchetypeRealize, type Asset, type AssetByKind, type AssetFolder, type AssetKind, type AssetRegistry, type Assignment, type Atom, type AtomContextVar, type AtomEvent, type AtomParam, type AtomStateNode, type AxisIntent, type AxisSize, type AxisSizeValue, type BlurValue, type BorderStyle, type BorderValue, type BorderWidth, type BrowseRealize, type Capability, type CapabilityDef, type ColorOrRef, type ColorSpace, type ColorValue, type CommitRealize, type Component, type CompositeBehavior, type Composition, type ConformanceOptions, type ConformanceReport, type ContentCategory, type Context, type ContextGroup, type Contract, type CoordEntry, type DesignSystemDocument, type DimensionOrRef, type DimensionUnit, type DimensionValue, type Distribute, type DocumentKind, type DocumentMeta, type Token as DslToken, type DurationValue, type Emit, type EscapeTokenValue, type EventDef, type Expose, type FacetDef, type FacetMap, type FacetName, type FacetTokenType, type FacetValue, type FontAsset, type FontCategory, type FontFamilyValue, type Foundations, type Hole, type Id, type ImageAsset, type InsetValue, type Layer, type LayoutSpec, LexError, type MildaDocumentBase, type NoneValue, type ObjectField, type OpacityValue, type ParamBinding, type ParseIssue, type ParseOptions, type ParseResult, type Part, type PartRole, type PartState, type PartVariant, type Position, type PreludeDocument, type PresentationRealize, type PrimitiveTokenType, type Project, type DocumentMeta as ProjectMeta, type ProjectMetadataEntry, type PropDef, type PropValue, type RawTokenValue, type Realization, type RealizeCond, type RequiresClause, type ResolveFacetsInput, type ResolvedToken, type ShadowLayer, type ShadowValue, type SharedType, type StackAxis, type StateDef, type StateName, type Substitution, type SvgAsset, TOKEN_VALUE_KIND, type TaxonomyNote, type Token$1 as Token, type TokenRef, type TokenType$1 as TokenType, type TokenValue, type TokenValueSchemaByType, type TonalValue, type Transition, type TransitionTarget, type TypeExpr, type TypeRef, type TypographyValue, type UsesClause, type ValidationIssue, type VideoAsset, type Wire, allTokensOfType, archetypesByName, atomsByName, collectActiveStates, conformance, findToken, lex, parseMildaDocument, preludeV0, resolveFacets, resolveLayout, resolveToken, validate };
813
+ export { type AliasTokenValue, type Align, type Anatomy, type AnatomyPart, type AnimationAsset, type AnimationFormat, type AnyTokenValue, type ArchetypeDef, type ArchetypeGroup, type ArchetypeRealize, type Asset, type AssetByKind, type AssetFolder, type AssetKind, type AssetRegistry, type Assignment, type Atom, type AtomContextVar, type AtomEvent, type AtomParam, type AtomStateNode, type AxisIntent, type AxisSize, type AxisSizeValue, type BlurValue, type BorderFacetStyle, type BorderFacetValue, type BorderStyle, type BorderValue, type BorderWidth, type BrowseRealize, type Capability, type CapabilityDef, type ColorOrRef, type ColorSpace, type ColorValue, type CommitRealize, type CompareOp, type Component, type CompositeBehavior, type Composition, type ConformanceOptions, type ConformanceReport, type ContentCategory, type Context, type ContextGroup, type Contract, type CoordEntry, type DesignSystemDocument, type DimensionOrRef, type DimensionUnit, type DimensionValue, type Distribute, type DocumentKind, type DocumentMeta, type Token as DslToken, type DurationValue, type Emit, type EscapeTokenValue, type EventDef, type Expose, type FacetDef, type FacetMap, type FacetName, type FacetTokenType, type FacetValue, type FontAsset, type FontCategory, type FontFamilyValue, type FontWeightValue, type Foundations, type Hole, type Id, type ImageAsset, type InsetValue, type Layer, type LayoutSpec, LexError, type Metadata, type MildaDocumentBase, type NodeSpan, type NoneValue, type ObjectField, type OpacityValue, type ParamBinding, type ParseIssue, type ParseOptions, type ParseResult, type Part, type PartRole, type PartSlot, type PartSlotAccepts, type PartSlotArity, type PartState, type PartVariant, type Position, type Predicate, type PredicateRef, type PreludeDocument, type PresentationRealize, type PrimitiveTokenType, type Project, type DocumentMeta as ProjectMeta, type ProjectMetadataEntry, type PropDef, type PropValue, type RawTokenValue, type Realization, type RealizeCond, type RequiresClause, type ResolveFacetsInput, type ResolvedToken, type ShadowLayer, type ShadowValue, type SharedType, type SourcePosition, type SourceRange, type SpanKind, type StackAxis, type StateDef, type StateName, type Substitution, type SvgAsset, TOKEN_VALUE_KIND, type TaxonomyNote, type Token$1 as Token, type TokenRef, type TokenType$1 as TokenType, type TokenValue, type TokenValueSchemaByType, type TonalValue, type Transition, type TransitionTarget, type TypeExpr, type TypeRef, type TypographyValue, type UsesClause, type ValidationIssue, type VideoAsset, type Wire, allTokensOfType, archetypesByName, atomsByName, collectActiveStates, compositesByName, conformance, findToken, lex, parseMildaDocument, preludeV0, resolveFacets, resolveLayout, resolveToken, validate };