@wire-dsl/engine 0.3.0 → 0.4.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/dist/index.cjs +555 -151
- package/dist/index.d.cts +54 -3
- package/dist/index.d.ts +54 -3
- package/dist/index.js +555 -151
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -267,7 +267,7 @@ interface IRScreen {
|
|
|
267
267
|
ref: string;
|
|
268
268
|
};
|
|
269
269
|
}
|
|
270
|
-
type IRNode = IRContainerNode | IRComponentNode;
|
|
270
|
+
type IRNode = IRContainerNode | IRComponentNode | IRInstanceNode;
|
|
271
271
|
interface IRContainerNode {
|
|
272
272
|
id: string;
|
|
273
273
|
kind: 'container';
|
|
@@ -298,6 +298,28 @@ interface IRMeta {
|
|
|
298
298
|
source?: string;
|
|
299
299
|
nodeId?: string;
|
|
300
300
|
}
|
|
301
|
+
/**
|
|
302
|
+
* Wraps an expanded user-defined component or layout instance.
|
|
303
|
+
* Preserves the call-site identity (nodeId) in the SVG so the canvas
|
|
304
|
+
* can select and edit the instance independently from its definition.
|
|
305
|
+
*/
|
|
306
|
+
interface IRInstanceNode {
|
|
307
|
+
id: string;
|
|
308
|
+
kind: 'instance';
|
|
309
|
+
/** Name of the user-defined component or layout (e.g. "MyComp") */
|
|
310
|
+
definitionName: string;
|
|
311
|
+
/** Whether it originated from a `define Component` or `define Layout` */
|
|
312
|
+
definitionKind: 'component' | 'layout';
|
|
313
|
+
/** Props/params passed at the call site (e.g. { text: "Hello" }) */
|
|
314
|
+
invocationProps: Record<string, string | number>;
|
|
315
|
+
/** Reference to the root IR node produced by expanding the definition */
|
|
316
|
+
expandedRoot: {
|
|
317
|
+
ref: string;
|
|
318
|
+
};
|
|
319
|
+
style: IRNodeStyle;
|
|
320
|
+
/** meta.nodeId = SourceMap nodeId of the call-site AST node */
|
|
321
|
+
meta: IRMeta;
|
|
322
|
+
}
|
|
301
323
|
declare class IRGenerator {
|
|
302
324
|
private idGen;
|
|
303
325
|
private nodes;
|
|
@@ -441,6 +463,13 @@ declare class LayoutEngine {
|
|
|
441
463
|
private calculateSplit;
|
|
442
464
|
private calculatePanel;
|
|
443
465
|
private calculateCard;
|
|
466
|
+
/**
|
|
467
|
+
* Calculate layout for an instance node.
|
|
468
|
+
* The instance is a transparent wrapper — its bounding box equals the
|
|
469
|
+
* expanded root's bounding box. We calculate the expanded root first and
|
|
470
|
+
* then copy its position to the instance nodeId so the renderer can use it.
|
|
471
|
+
*/
|
|
472
|
+
private calculateInstance;
|
|
444
473
|
private calculateComponent;
|
|
445
474
|
private resolveSpacing;
|
|
446
475
|
private getSeparateSize;
|
|
@@ -568,6 +597,12 @@ interface SVGRenderOptions {
|
|
|
568
597
|
theme?: 'light' | 'dark';
|
|
569
598
|
includeLabels?: boolean;
|
|
570
599
|
screenName?: string;
|
|
600
|
+
/**
|
|
601
|
+
* When true, renders visual diagnostic overlays for invalid DSL states
|
|
602
|
+
* (e.g. empty containers). Enable in editor/canvas mode; leave false for
|
|
603
|
+
* clean exports (CLI, PDF, PNG).
|
|
604
|
+
*/
|
|
605
|
+
showDiagnostics?: boolean;
|
|
571
606
|
}
|
|
572
607
|
interface SVGComponent {
|
|
573
608
|
tag: string;
|
|
@@ -641,6 +676,16 @@ declare class SVGRenderer {
|
|
|
641
676
|
protected renderTopbar(node: IRComponentNode, pos: any): string;
|
|
642
677
|
protected renderPanelBorder(node: IRNode, pos: any, output: string[]): void;
|
|
643
678
|
protected renderCardBorder(node: IRNode, pos: any, output: string[]): void;
|
|
679
|
+
/**
|
|
680
|
+
* Renders a yellow warning placeholder for containers with no children.
|
|
681
|
+
* Only shown when `showDiagnostics` is enabled (editor/canvas mode).
|
|
682
|
+
*/
|
|
683
|
+
protected renderEmptyContainerDiagnostic(pos: {
|
|
684
|
+
x: number;
|
|
685
|
+
y: number;
|
|
686
|
+
width: number;
|
|
687
|
+
height: number;
|
|
688
|
+
}, containerType?: string): string;
|
|
644
689
|
protected renderSplitDecoration(node: IRNode, pos: any, output: string[]): void;
|
|
645
690
|
protected renderTable(node: IRComponentNode, pos: any): string;
|
|
646
691
|
protected renderChartPlaceholder(node: IRComponentNode, pos: any): string;
|
|
@@ -750,7 +795,7 @@ declare class SVGRenderer {
|
|
|
750
795
|
* Get data-node-id attribute string for SVG elements
|
|
751
796
|
* Enables bidirectional selection between code and canvas
|
|
752
797
|
*/
|
|
753
|
-
protected getDataNodeId(node: IRComponentNode | IRContainerNode): string;
|
|
798
|
+
protected getDataNodeId(node: IRComponentNode | IRContainerNode | IRInstanceNode): string;
|
|
754
799
|
}
|
|
755
800
|
declare function renderToSVG(ir: IRContract, layout: LayoutResult, options?: SVGRenderOptions): string;
|
|
756
801
|
declare function createSVGElement(tag: string, attrs: Record<string, string | number>, children?: string[]): string;
|
|
@@ -796,6 +841,12 @@ declare class SkeletonSVGRenderer extends SVGRenderer {
|
|
|
796
841
|
* Render label as gray block
|
|
797
842
|
*/
|
|
798
843
|
protected renderLabel(node: IRComponentNode, pos: any): string;
|
|
844
|
+
/**
|
|
845
|
+
* Render image as a plain skeleton rectangle — no icon, no placeholder label,
|
|
846
|
+
* just a filled block with the correct dimensions (aspect-ratio is preserved
|
|
847
|
+
* by the layout engine, so pos already has the right size).
|
|
848
|
+
*/
|
|
849
|
+
protected renderImage(node: IRComponentNode, pos: any): string;
|
|
799
850
|
/**
|
|
800
851
|
* Render badge as shape only (no text)
|
|
801
852
|
*/
|
|
@@ -1342,4 +1393,4 @@ declare class SourceMapResolver {
|
|
|
1342
1393
|
|
|
1343
1394
|
declare const version = "0.0.1";
|
|
1344
1395
|
|
|
1345
|
-
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 };
|
|
1396
|
+
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 IRInstanceNode, 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
|
@@ -267,7 +267,7 @@ interface IRScreen {
|
|
|
267
267
|
ref: string;
|
|
268
268
|
};
|
|
269
269
|
}
|
|
270
|
-
type IRNode = IRContainerNode | IRComponentNode;
|
|
270
|
+
type IRNode = IRContainerNode | IRComponentNode | IRInstanceNode;
|
|
271
271
|
interface IRContainerNode {
|
|
272
272
|
id: string;
|
|
273
273
|
kind: 'container';
|
|
@@ -298,6 +298,28 @@ interface IRMeta {
|
|
|
298
298
|
source?: string;
|
|
299
299
|
nodeId?: string;
|
|
300
300
|
}
|
|
301
|
+
/**
|
|
302
|
+
* Wraps an expanded user-defined component or layout instance.
|
|
303
|
+
* Preserves the call-site identity (nodeId) in the SVG so the canvas
|
|
304
|
+
* can select and edit the instance independently from its definition.
|
|
305
|
+
*/
|
|
306
|
+
interface IRInstanceNode {
|
|
307
|
+
id: string;
|
|
308
|
+
kind: 'instance';
|
|
309
|
+
/** Name of the user-defined component or layout (e.g. "MyComp") */
|
|
310
|
+
definitionName: string;
|
|
311
|
+
/** Whether it originated from a `define Component` or `define Layout` */
|
|
312
|
+
definitionKind: 'component' | 'layout';
|
|
313
|
+
/** Props/params passed at the call site (e.g. { text: "Hello" }) */
|
|
314
|
+
invocationProps: Record<string, string | number>;
|
|
315
|
+
/** Reference to the root IR node produced by expanding the definition */
|
|
316
|
+
expandedRoot: {
|
|
317
|
+
ref: string;
|
|
318
|
+
};
|
|
319
|
+
style: IRNodeStyle;
|
|
320
|
+
/** meta.nodeId = SourceMap nodeId of the call-site AST node */
|
|
321
|
+
meta: IRMeta;
|
|
322
|
+
}
|
|
301
323
|
declare class IRGenerator {
|
|
302
324
|
private idGen;
|
|
303
325
|
private nodes;
|
|
@@ -441,6 +463,13 @@ declare class LayoutEngine {
|
|
|
441
463
|
private calculateSplit;
|
|
442
464
|
private calculatePanel;
|
|
443
465
|
private calculateCard;
|
|
466
|
+
/**
|
|
467
|
+
* Calculate layout for an instance node.
|
|
468
|
+
* The instance is a transparent wrapper — its bounding box equals the
|
|
469
|
+
* expanded root's bounding box. We calculate the expanded root first and
|
|
470
|
+
* then copy its position to the instance nodeId so the renderer can use it.
|
|
471
|
+
*/
|
|
472
|
+
private calculateInstance;
|
|
444
473
|
private calculateComponent;
|
|
445
474
|
private resolveSpacing;
|
|
446
475
|
private getSeparateSize;
|
|
@@ -568,6 +597,12 @@ interface SVGRenderOptions {
|
|
|
568
597
|
theme?: 'light' | 'dark';
|
|
569
598
|
includeLabels?: boolean;
|
|
570
599
|
screenName?: string;
|
|
600
|
+
/**
|
|
601
|
+
* When true, renders visual diagnostic overlays for invalid DSL states
|
|
602
|
+
* (e.g. empty containers). Enable in editor/canvas mode; leave false for
|
|
603
|
+
* clean exports (CLI, PDF, PNG).
|
|
604
|
+
*/
|
|
605
|
+
showDiagnostics?: boolean;
|
|
571
606
|
}
|
|
572
607
|
interface SVGComponent {
|
|
573
608
|
tag: string;
|
|
@@ -641,6 +676,16 @@ declare class SVGRenderer {
|
|
|
641
676
|
protected renderTopbar(node: IRComponentNode, pos: any): string;
|
|
642
677
|
protected renderPanelBorder(node: IRNode, pos: any, output: string[]): void;
|
|
643
678
|
protected renderCardBorder(node: IRNode, pos: any, output: string[]): void;
|
|
679
|
+
/**
|
|
680
|
+
* Renders a yellow warning placeholder for containers with no children.
|
|
681
|
+
* Only shown when `showDiagnostics` is enabled (editor/canvas mode).
|
|
682
|
+
*/
|
|
683
|
+
protected renderEmptyContainerDiagnostic(pos: {
|
|
684
|
+
x: number;
|
|
685
|
+
y: number;
|
|
686
|
+
width: number;
|
|
687
|
+
height: number;
|
|
688
|
+
}, containerType?: string): string;
|
|
644
689
|
protected renderSplitDecoration(node: IRNode, pos: any, output: string[]): void;
|
|
645
690
|
protected renderTable(node: IRComponentNode, pos: any): string;
|
|
646
691
|
protected renderChartPlaceholder(node: IRComponentNode, pos: any): string;
|
|
@@ -750,7 +795,7 @@ declare class SVGRenderer {
|
|
|
750
795
|
* Get data-node-id attribute string for SVG elements
|
|
751
796
|
* Enables bidirectional selection between code and canvas
|
|
752
797
|
*/
|
|
753
|
-
protected getDataNodeId(node: IRComponentNode | IRContainerNode): string;
|
|
798
|
+
protected getDataNodeId(node: IRComponentNode | IRContainerNode | IRInstanceNode): string;
|
|
754
799
|
}
|
|
755
800
|
declare function renderToSVG(ir: IRContract, layout: LayoutResult, options?: SVGRenderOptions): string;
|
|
756
801
|
declare function createSVGElement(tag: string, attrs: Record<string, string | number>, children?: string[]): string;
|
|
@@ -796,6 +841,12 @@ declare class SkeletonSVGRenderer extends SVGRenderer {
|
|
|
796
841
|
* Render label as gray block
|
|
797
842
|
*/
|
|
798
843
|
protected renderLabel(node: IRComponentNode, pos: any): string;
|
|
844
|
+
/**
|
|
845
|
+
* Render image as a plain skeleton rectangle — no icon, no placeholder label,
|
|
846
|
+
* just a filled block with the correct dimensions (aspect-ratio is preserved
|
|
847
|
+
* by the layout engine, so pos already has the right size).
|
|
848
|
+
*/
|
|
849
|
+
protected renderImage(node: IRComponentNode, pos: any): string;
|
|
799
850
|
/**
|
|
800
851
|
* Render badge as shape only (no text)
|
|
801
852
|
*/
|
|
@@ -1342,4 +1393,4 @@ declare class SourceMapResolver {
|
|
|
1342
1393
|
|
|
1343
1394
|
declare const version = "0.0.1";
|
|
1344
1395
|
|
|
1345
|
-
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 };
|
|
1396
|
+
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 IRInstanceNode, 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 };
|