@wire-dsl/engine 0.2.4 → 0.4.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/index.d.cts CHANGED
@@ -34,7 +34,7 @@ interface PropertySourceMap {
34
34
  /**
35
35
  * Types of nodes in Wire DSL
36
36
  */
37
- type SourceMapNodeType = 'project' | 'screen' | 'layout' | 'component' | 'component-definition' | 'cell' | 'style' | 'mocks' | 'colors';
37
+ type SourceMapNodeType = 'project' | 'screen' | 'layout' | 'component' | 'component-definition' | 'layout-definition' | 'cell' | 'style' | 'mocks' | 'colors';
38
38
  /**
39
39
  * Main SourceMap entry - represents one node in the AST
40
40
  */
@@ -121,6 +121,7 @@ interface AST {
121
121
  mocks: Record<string, string>;
122
122
  colors: Record<string, string>;
123
123
  definedComponents: ASTDefinedComponent[];
124
+ definedLayouts: ASTDefinedLayout[];
124
125
  screens: ASTScreen[];
125
126
  _meta?: {
126
127
  nodeId: string;
@@ -172,6 +173,14 @@ interface ParseWireDSLWithSourceMapOptions {
172
173
  throwOnError?: boolean;
173
174
  includeSemanticWarnings?: boolean;
174
175
  }
176
+ interface ASTDefinedLayout {
177
+ type: 'definedLayout';
178
+ name: string;
179
+ body: ASTLayout;
180
+ _meta?: {
181
+ nodeId: string;
182
+ };
183
+ }
175
184
  declare function parseWireDSL(input: string): AST;
176
185
  /**
177
186
  * Parse Wire DSL with SourceMap generation
@@ -293,9 +302,11 @@ declare class IRGenerator {
293
302
  private idGen;
294
303
  private nodes;
295
304
  private definedComponents;
305
+ private definedLayouts;
296
306
  private definedComponentIndices;
297
307
  private undefinedComponentsUsed;
298
308
  private warnings;
309
+ private errors;
299
310
  private style;
300
311
  generate(ast: AST): IRContract;
301
312
  private applyStyle;
@@ -320,6 +331,15 @@ declare class IRGenerator {
320
331
  private convertCell;
321
332
  private convertComponent;
322
333
  private expandDefinedComponent;
334
+ private expandDefinedLayout;
335
+ private resolveChildrenSlot;
336
+ private convertASTNode;
337
+ private resolveLayoutParams;
338
+ private normalizeSplitParams;
339
+ private resolveComponentProps;
340
+ private resolveBindingValue;
341
+ private isBindingTargetRequired;
342
+ private reportUnusedArguments;
323
343
  private cleanParams;
324
344
  private sanitizeId;
325
345
  }
@@ -578,7 +598,7 @@ declare const THEMES: {
578
598
  };
579
599
  };
580
600
  declare class SVGRenderer {
581
- private ir;
601
+ protected ir: IRContract;
582
602
  private layout;
583
603
  protected options: Required<Omit<SVGRenderOptions, 'screenName'>> & {
584
604
  screenName?: string;
@@ -621,6 +641,7 @@ declare class SVGRenderer {
621
641
  protected renderTopbar(node: IRComponentNode, pos: any): string;
622
642
  protected renderPanelBorder(node: IRNode, pos: any, output: string[]): void;
623
643
  protected renderCardBorder(node: IRNode, pos: any, output: string[]): void;
644
+ protected renderSplitDecoration(node: IRNode, pos: any, output: string[]): void;
624
645
  protected renderTable(node: IRComponentNode, pos: any): string;
625
646
  protected renderChartPlaceholder(node: IRComponentNode, pos: any): string;
626
647
  protected renderText(node: IRComponentNode, pos: any): string;
@@ -655,6 +676,8 @@ declare class SVGRenderer {
655
676
  protected resolveAccentColor(): string;
656
677
  protected resolveControlColor(): string;
657
678
  protected resolveChartColor(): string;
679
+ protected resolveTextColor(): string;
680
+ protected resolveMutedColor(): string;
658
681
  protected getSemanticVariantColor(variant: string): string | undefined;
659
682
  protected hexToRgba(hex: string, alpha: number): string;
660
683
  protected getIconSize(size?: string): number;
@@ -757,6 +780,10 @@ declare class SkeletonSVGRenderer extends SVGRenderer {
757
780
  * Render link as placeholder block + underline (no text)
758
781
  */
759
782
  protected renderLink(node: IRComponentNode, pos: any): string;
783
+ /**
784
+ * Render breadcrumbs as skeleton blocks: <rect> / <rect> / <rect accent>
785
+ */
786
+ protected renderBreadcrumbs(node: IRComponentNode, pos: any): string;
760
787
  /**
761
788
  * Render heading as gray block
762
789
  */
@@ -769,6 +796,12 @@ declare class SkeletonSVGRenderer extends SVGRenderer {
769
796
  * Render label as gray block
770
797
  */
771
798
  protected renderLabel(node: IRComponentNode, pos: any): string;
799
+ /**
800
+ * Render image as a plain skeleton rectangle — no icon, no placeholder label,
801
+ * just a filled block with the correct dimensions (aspect-ratio is preserved
802
+ * by the layout engine, so pos already has the right size).
803
+ */
804
+ protected renderImage(node: IRComponentNode, pos: any): string;
772
805
  /**
773
806
  * Render badge as shape only (no text)
774
807
  */
@@ -1108,8 +1141,9 @@ declare class SourceMapBuilder {
1108
1141
  * - screen → "screen-0", "screen-1"
1109
1142
  * - component Button → "component-button-0", "component-button-1"
1110
1143
  * - layout stack → "layout-stack-0", "layout-stack-1"
1111
- * - cell → "cell-0", "cell-1"
1112
- * - component-definition → "define-MyButton"
1144
+ * - cell → "cell-0", "cell-1"
1145
+ * - component-definition → "define-MyButton"
1146
+ * - layout-definition → "define-layout-MyShell"
1113
1147
  */
1114
1148
  private generateNodeId;
1115
1149
  /**
@@ -1146,7 +1180,7 @@ declare class SourceMapBuilder {
1146
1180
  build(): SourceMapEntry[];
1147
1181
  /**
1148
1182
  * Calculate insertionPoints for all container nodes
1149
- * Container nodes: project, screen, layout, cell, component-definition
1183
+ * Container nodes: project, screen, layout, cell, component-definition, layout-definition
1150
1184
  */
1151
1185
  private calculateAllInsertionPoints;
1152
1186
  /**
@@ -1314,4 +1348,4 @@ declare class SourceMapResolver {
1314
1348
 
1315
1349
  declare const version = "0.0.1";
1316
1350
 
1317
- export { type AST, type ASTCell, type ASTComponent, type ASTDefinedComponent, type ASTLayout, type ASTScreen, type CapturedTokens, type CodeRange, DENSITY_TOKENS, DEVICE_PRESETS, type DesignTokens, type DevicePreset, type IRComponent, type IRComponentNode, type IRContainerNode, type IRContract, IRGenerator, type IRLayout, type IRMeta, type IRMetadata, type IRNode, type IRNodeStyle, type IRProject, type IRScreen, type IRStyle, type IRWireframe, type InsertionPoint, LayoutEngine, type LayoutPosition, type LayoutResult, type ParseDiagnosticsResult, type ParseError, type ParseResult, type ParseWireDSLWithSourceMapOptions, type ParsedComponent, type ParsedWireframe, type Position, type PositionQueryResult, type PropertySourceMap, type SVGComponent, type SVGRenderOptions, SVGRenderer, SkeletonSVGRenderer, SketchSVGRenderer, SourceMapBuilder, type SourceMapEntry, type SourceMapNodeType, SourceMapResolver, buildSVG, calculateLayout, createSVGElement, generateIR, generateStableNodeId, getTypeFromNodeId, isValidDevice, isValidNodeId, parseWireDSL, parseWireDSLWithSourceMap, renderToSVG, resolveDevicePreset, resolveGridPosition, resolveTokens, version };
1351
+ export { type AST, type ASTCell, type ASTComponent, type ASTDefinedComponent, type ASTDefinedLayout, type ASTLayout, type ASTScreen, type CapturedTokens, type CodeRange, DENSITY_TOKENS, DEVICE_PRESETS, type DesignTokens, type DevicePreset, type IRComponent, type IRComponentNode, type IRContainerNode, type IRContract, IRGenerator, type IRLayout, type IRMeta, type IRMetadata, type IRNode, type IRNodeStyle, type IRProject, type IRScreen, type IRStyle, type IRWireframe, type InsertionPoint, LayoutEngine, type LayoutPosition, type LayoutResult, type ParseDiagnosticsResult, type ParseError, type ParseResult, type ParseWireDSLWithSourceMapOptions, type ParsedComponent, type ParsedWireframe, type Position, type PositionQueryResult, type PropertySourceMap, type SVGComponent, type SVGRenderOptions, SVGRenderer, SkeletonSVGRenderer, SketchSVGRenderer, SourceMapBuilder, type SourceMapEntry, type SourceMapNodeType, SourceMapResolver, buildSVG, calculateLayout, createSVGElement, generateIR, generateStableNodeId, getTypeFromNodeId, isValidDevice, isValidNodeId, parseWireDSL, parseWireDSLWithSourceMap, renderToSVG, resolveDevicePreset, resolveGridPosition, resolveTokens, version };
package/dist/index.d.ts CHANGED
@@ -34,7 +34,7 @@ interface PropertySourceMap {
34
34
  /**
35
35
  * Types of nodes in Wire DSL
36
36
  */
37
- type SourceMapNodeType = 'project' | 'screen' | 'layout' | 'component' | 'component-definition' | 'cell' | 'style' | 'mocks' | 'colors';
37
+ type SourceMapNodeType = 'project' | 'screen' | 'layout' | 'component' | 'component-definition' | 'layout-definition' | 'cell' | 'style' | 'mocks' | 'colors';
38
38
  /**
39
39
  * Main SourceMap entry - represents one node in the AST
40
40
  */
@@ -121,6 +121,7 @@ interface AST {
121
121
  mocks: Record<string, string>;
122
122
  colors: Record<string, string>;
123
123
  definedComponents: ASTDefinedComponent[];
124
+ definedLayouts: ASTDefinedLayout[];
124
125
  screens: ASTScreen[];
125
126
  _meta?: {
126
127
  nodeId: string;
@@ -172,6 +173,14 @@ interface ParseWireDSLWithSourceMapOptions {
172
173
  throwOnError?: boolean;
173
174
  includeSemanticWarnings?: boolean;
174
175
  }
176
+ interface ASTDefinedLayout {
177
+ type: 'definedLayout';
178
+ name: string;
179
+ body: ASTLayout;
180
+ _meta?: {
181
+ nodeId: string;
182
+ };
183
+ }
175
184
  declare function parseWireDSL(input: string): AST;
176
185
  /**
177
186
  * Parse Wire DSL with SourceMap generation
@@ -293,9 +302,11 @@ declare class IRGenerator {
293
302
  private idGen;
294
303
  private nodes;
295
304
  private definedComponents;
305
+ private definedLayouts;
296
306
  private definedComponentIndices;
297
307
  private undefinedComponentsUsed;
298
308
  private warnings;
309
+ private errors;
299
310
  private style;
300
311
  generate(ast: AST): IRContract;
301
312
  private applyStyle;
@@ -320,6 +331,15 @@ declare class IRGenerator {
320
331
  private convertCell;
321
332
  private convertComponent;
322
333
  private expandDefinedComponent;
334
+ private expandDefinedLayout;
335
+ private resolveChildrenSlot;
336
+ private convertASTNode;
337
+ private resolveLayoutParams;
338
+ private normalizeSplitParams;
339
+ private resolveComponentProps;
340
+ private resolveBindingValue;
341
+ private isBindingTargetRequired;
342
+ private reportUnusedArguments;
323
343
  private cleanParams;
324
344
  private sanitizeId;
325
345
  }
@@ -578,7 +598,7 @@ declare const THEMES: {
578
598
  };
579
599
  };
580
600
  declare class SVGRenderer {
581
- private ir;
601
+ protected ir: IRContract;
582
602
  private layout;
583
603
  protected options: Required<Omit<SVGRenderOptions, 'screenName'>> & {
584
604
  screenName?: string;
@@ -621,6 +641,7 @@ declare class SVGRenderer {
621
641
  protected renderTopbar(node: IRComponentNode, pos: any): string;
622
642
  protected renderPanelBorder(node: IRNode, pos: any, output: string[]): void;
623
643
  protected renderCardBorder(node: IRNode, pos: any, output: string[]): void;
644
+ protected renderSplitDecoration(node: IRNode, pos: any, output: string[]): void;
624
645
  protected renderTable(node: IRComponentNode, pos: any): string;
625
646
  protected renderChartPlaceholder(node: IRComponentNode, pos: any): string;
626
647
  protected renderText(node: IRComponentNode, pos: any): string;
@@ -655,6 +676,8 @@ declare class SVGRenderer {
655
676
  protected resolveAccentColor(): string;
656
677
  protected resolveControlColor(): string;
657
678
  protected resolveChartColor(): string;
679
+ protected resolveTextColor(): string;
680
+ protected resolveMutedColor(): string;
658
681
  protected getSemanticVariantColor(variant: string): string | undefined;
659
682
  protected hexToRgba(hex: string, alpha: number): string;
660
683
  protected getIconSize(size?: string): number;
@@ -757,6 +780,10 @@ declare class SkeletonSVGRenderer extends SVGRenderer {
757
780
  * Render link as placeholder block + underline (no text)
758
781
  */
759
782
  protected renderLink(node: IRComponentNode, pos: any): string;
783
+ /**
784
+ * Render breadcrumbs as skeleton blocks: <rect> / <rect> / <rect accent>
785
+ */
786
+ protected renderBreadcrumbs(node: IRComponentNode, pos: any): string;
760
787
  /**
761
788
  * Render heading as gray block
762
789
  */
@@ -769,6 +796,12 @@ declare class SkeletonSVGRenderer extends SVGRenderer {
769
796
  * Render label as gray block
770
797
  */
771
798
  protected renderLabel(node: IRComponentNode, pos: any): string;
799
+ /**
800
+ * Render image as a plain skeleton rectangle — no icon, no placeholder label,
801
+ * just a filled block with the correct dimensions (aspect-ratio is preserved
802
+ * by the layout engine, so pos already has the right size).
803
+ */
804
+ protected renderImage(node: IRComponentNode, pos: any): string;
772
805
  /**
773
806
  * Render badge as shape only (no text)
774
807
  */
@@ -1108,8 +1141,9 @@ declare class SourceMapBuilder {
1108
1141
  * - screen → "screen-0", "screen-1"
1109
1142
  * - component Button → "component-button-0", "component-button-1"
1110
1143
  * - layout stack → "layout-stack-0", "layout-stack-1"
1111
- * - cell → "cell-0", "cell-1"
1112
- * - component-definition → "define-MyButton"
1144
+ * - cell → "cell-0", "cell-1"
1145
+ * - component-definition → "define-MyButton"
1146
+ * - layout-definition → "define-layout-MyShell"
1113
1147
  */
1114
1148
  private generateNodeId;
1115
1149
  /**
@@ -1146,7 +1180,7 @@ declare class SourceMapBuilder {
1146
1180
  build(): SourceMapEntry[];
1147
1181
  /**
1148
1182
  * Calculate insertionPoints for all container nodes
1149
- * Container nodes: project, screen, layout, cell, component-definition
1183
+ * Container nodes: project, screen, layout, cell, component-definition, layout-definition
1150
1184
  */
1151
1185
  private calculateAllInsertionPoints;
1152
1186
  /**
@@ -1314,4 +1348,4 @@ declare class SourceMapResolver {
1314
1348
 
1315
1349
  declare const version = "0.0.1";
1316
1350
 
1317
- export { type AST, type ASTCell, type ASTComponent, type ASTDefinedComponent, type ASTLayout, type ASTScreen, type CapturedTokens, type CodeRange, DENSITY_TOKENS, DEVICE_PRESETS, type DesignTokens, type DevicePreset, type IRComponent, type IRComponentNode, type IRContainerNode, type IRContract, IRGenerator, type IRLayout, type IRMeta, type IRMetadata, type IRNode, type IRNodeStyle, type IRProject, type IRScreen, type IRStyle, type IRWireframe, type InsertionPoint, LayoutEngine, type LayoutPosition, type LayoutResult, type ParseDiagnosticsResult, type ParseError, type ParseResult, type ParseWireDSLWithSourceMapOptions, type ParsedComponent, type ParsedWireframe, type Position, type PositionQueryResult, type PropertySourceMap, type SVGComponent, type SVGRenderOptions, SVGRenderer, SkeletonSVGRenderer, SketchSVGRenderer, SourceMapBuilder, type SourceMapEntry, type SourceMapNodeType, SourceMapResolver, buildSVG, calculateLayout, createSVGElement, generateIR, generateStableNodeId, getTypeFromNodeId, isValidDevice, isValidNodeId, parseWireDSL, parseWireDSLWithSourceMap, renderToSVG, resolveDevicePreset, resolveGridPosition, resolveTokens, version };
1351
+ export { type AST, type ASTCell, type ASTComponent, type ASTDefinedComponent, type ASTDefinedLayout, type ASTLayout, type ASTScreen, type CapturedTokens, type CodeRange, DENSITY_TOKENS, DEVICE_PRESETS, type DesignTokens, type DevicePreset, type IRComponent, type IRComponentNode, type IRContainerNode, type IRContract, IRGenerator, type IRLayout, type IRMeta, type IRMetadata, type IRNode, type IRNodeStyle, type IRProject, type IRScreen, type IRStyle, type IRWireframe, type InsertionPoint, LayoutEngine, type LayoutPosition, type LayoutResult, type ParseDiagnosticsResult, type ParseError, type ParseResult, type ParseWireDSLWithSourceMapOptions, type ParsedComponent, type ParsedWireframe, type Position, type PositionQueryResult, type PropertySourceMap, type SVGComponent, type SVGRenderOptions, SVGRenderer, SkeletonSVGRenderer, SketchSVGRenderer, SourceMapBuilder, type SourceMapEntry, type SourceMapNodeType, SourceMapResolver, buildSVG, calculateLayout, createSVGElement, generateIR, generateStableNodeId, getTypeFromNodeId, isValidDevice, isValidNodeId, parseWireDSL, parseWireDSLWithSourceMap, renderToSVG, resolveDevicePreset, resolveGridPosition, resolveTokens, version };