@wireweave/core 1.0.0-beta.20260107130839 → 1.0.0-beta.20260107132939

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.
@@ -1,173 +0,0 @@
1
- /**
2
- * Renderer type definitions for wireweave
3
- *
4
- * Provides types for rendering options, themes, and context
5
- */
6
-
7
- // ===========================================
8
- // Render Options
9
- // ===========================================
10
-
11
- export interface RenderOptions {
12
- /** Theme variant */
13
- theme?: 'light' | 'dark';
14
- /** Scale factor for sizing */
15
- scale?: number;
16
- /** Include CSS styles in output */
17
- includeStyles?: boolean;
18
- /** Minify output (no indentation/newlines) */
19
- minify?: boolean;
20
- /** CSS class prefix for scoping */
21
- classPrefix?: string;
22
- }
23
-
24
- export interface RenderResult {
25
- /** Rendered HTML content */
26
- html: string;
27
- /** Generated CSS styles */
28
- css: string;
29
- }
30
-
31
- export interface SvgRenderOptions {
32
- /** Width of the SVG viewport */
33
- width?: number;
34
- /** Height of the SVG viewport */
35
- height?: number;
36
- /** Padding around content */
37
- padding?: number;
38
- /** Scale factor */
39
- scale?: number;
40
- /** Background color */
41
- background?: string;
42
- /** Font family */
43
- fontFamily?: string;
44
- }
45
-
46
- export interface SvgRenderResult {
47
- /** Rendered SVG content */
48
- svg: string;
49
- /** Actual width */
50
- width: number;
51
- /** Actual height */
52
- height: number;
53
- }
54
-
55
- // ===========================================
56
- // Render Context
57
- // ===========================================
58
-
59
- export interface RenderContext {
60
- /** Resolved render options */
61
- options: Required<RenderOptions>;
62
- /** Theme configuration */
63
- theme: ThemeConfig;
64
- /** Current nesting depth for indentation */
65
- depth: number;
66
- }
67
-
68
- // ===========================================
69
- // Theme Configuration
70
- // ===========================================
71
-
72
- export interface ThemeColors {
73
- /** Primary action color */
74
- primary: string;
75
- /** Secondary/muted action color */
76
- secondary: string;
77
- /** Success state color */
78
- success: string;
79
- /** Warning state color */
80
- warning: string;
81
- /** Danger/error state color */
82
- danger: string;
83
- /** Muted/disabled color */
84
- muted: string;
85
- /** Background color */
86
- background: string;
87
- /** Foreground/text color */
88
- foreground: string;
89
- /** Border color */
90
- border: string;
91
- }
92
-
93
- export interface ThemeConfig {
94
- /** Color palette */
95
- colors: ThemeColors;
96
- /** Spacing scale (number -> px value) */
97
- spacing: Record<number, string>;
98
- /** Border radius */
99
- radius: string;
100
- /** Font family */
101
- fontFamily: string;
102
- /** Shadow styles */
103
- shadows: Record<string, string>;
104
- }
105
-
106
- // ===========================================
107
- // Default Theme (Wireframe Style - Black/White/Gray)
108
- // ===========================================
109
-
110
- /**
111
- * Default wireframe theme using black/white/gray palette
112
- * Follows wireweave design principles for sketch-like appearance
113
- */
114
- export const defaultTheme: ThemeConfig = {
115
- colors: {
116
- // Wireframe uses minimal colors - black/white/gray
117
- primary: '#000000',
118
- secondary: '#888888',
119
- success: '#888888',
120
- warning: '#888888',
121
- danger: '#888888',
122
- muted: '#888888',
123
- background: '#FFFFFF',
124
- foreground: '#000000',
125
- border: '#000000',
126
- },
127
- spacing: {
128
- 0: '0px',
129
- 1: '4px',
130
- 2: '8px',
131
- 3: '12px',
132
- 4: '16px',
133
- 5: '20px',
134
- 6: '24px',
135
- 8: '32px',
136
- 10: '40px',
137
- 12: '48px',
138
- 16: '64px',
139
- 20: '80px',
140
- },
141
- radius: '4px',
142
- fontFamily: 'system-ui, -apple-system, sans-serif',
143
- shadows: {
144
- none: 'none',
145
- sm: '0 1px 2px 0 rgba(0, 0, 0, 0.1)',
146
- md: '0 4px 6px -1px rgba(0, 0, 0, 0.15)',
147
- lg: '0 10px 15px -3px rgba(0, 0, 0, 0.2)',
148
- xl: '0 20px 25px -5px rgba(0, 0, 0, 0.25)',
149
- },
150
- };
151
-
152
- /**
153
- * Dark theme configuration
154
- * Inverts colors for dark mode display
155
- */
156
- export const darkTheme: ThemeConfig = {
157
- ...defaultTheme,
158
- colors: {
159
- ...defaultTheme.colors,
160
- background: '#1A1A1A',
161
- foreground: '#FFFFFF',
162
- border: '#FFFFFF',
163
- primary: '#FFFFFF',
164
- muted: '#888888',
165
- },
166
- };
167
-
168
- /**
169
- * Get theme configuration by name
170
- */
171
- export function getTheme(name: 'light' | 'dark'): ThemeConfig {
172
- return name === 'dark' ? darkTheme : defaultTheme;
173
- }
@@ -1,138 +0,0 @@
1
- /**
2
- * AST Type definitions for wireweave
3
- *
4
- * Re-exports all types from the AST module for external consumption.
5
- * This provides a stable public API for type imports.
6
- */
7
-
8
- // Re-export everything from ast/types
9
- export type {
10
- // Source Location
11
- Position,
12
- SourceLocation,
13
-
14
- // Base
15
- BaseNode,
16
-
17
- // Common Props
18
- SpacingValue,
19
- SpacingProps,
20
- WidthValue,
21
- HeightValue,
22
- SizeProps,
23
- JustifyValue,
24
- AlignValue,
25
- DirectionValue,
26
- FlexProps,
27
- GridProps,
28
- CommonProps,
29
-
30
- // Document
31
- WireframeDocument,
32
-
33
- // Layout
34
- PageNode,
35
- HeaderNode,
36
- MainNode,
37
- FooterNode,
38
- SidebarNode,
39
- SectionNode,
40
-
41
- // Grid
42
- RowNode,
43
- ColNode,
44
-
45
- // Container
46
- ShadowValue,
47
- CardNode,
48
- ModalNode,
49
- DrawerPosition,
50
- DrawerNode,
51
- AccordionNode,
52
-
53
- // Text
54
- TextSize,
55
- TextWeight,
56
- TextAlign,
57
- TextNode,
58
- TitleLevel,
59
- TitleNode,
60
- LinkNode,
61
-
62
- // Input
63
- InputType,
64
- InputNode,
65
- TextareaNode,
66
- SelectNode,
67
- SelectOption,
68
- CheckboxNode,
69
- RadioNode,
70
- SwitchNode,
71
- SliderNode,
72
-
73
- // Button
74
- ButtonVariant,
75
- ButtonSize,
76
- ButtonNode,
77
-
78
- // Display
79
- ImageNode,
80
- PlaceholderNode,
81
- AvatarSize,
82
- AvatarNode,
83
- BadgeVariant,
84
- BadgeNode,
85
- IconNode,
86
-
87
- // Data
88
- TableNode,
89
- ListItemNode,
90
- ListNode,
91
-
92
- // Feedback
93
- AlertVariant,
94
- AlertNode,
95
- ToastPosition,
96
- ToastNode,
97
- ProgressNode,
98
- SpinnerSize,
99
- SpinnerNode,
100
-
101
- // Overlay
102
- TooltipPosition,
103
- TooltipNode,
104
- PopoverNode,
105
- DropdownItemNode,
106
- DividerNode,
107
- DropdownNode,
108
-
109
- // Navigation
110
- NavItem,
111
- NavNode,
112
- TabNode,
113
- TabsNode,
114
- BreadcrumbItem,
115
- BreadcrumbNode,
116
-
117
- // Divider Component
118
- DividerComponentNode,
119
-
120
- // Node Type Unions
121
- LayoutNode,
122
- GridNode,
123
- ContainerComponentNode,
124
- TextContentNode,
125
- InputComponentNode,
126
- DisplayNode,
127
- DataNode,
128
- FeedbackNode,
129
- OverlayNode,
130
- NavigationNode,
131
- ContainerNode,
132
- LeafNode,
133
- AnyNode,
134
- NodeType,
135
- } from '../ast/types';
136
-
137
- // Re-export guards for convenience
138
- export { isContainerNode, isLeafNode } from '../ast/guards';
@@ -1,17 +0,0 @@
1
- /**
2
- * Viewport module for wireweave
3
- *
4
- * Handles viewport sizing, device presets, and scaling
5
- */
6
-
7
- export type { ViewportSize, PreviewWrapperOptions } from './presets';
8
- export {
9
- DEVICE_PRESETS,
10
- DEFAULT_VIEWPORT,
11
- parseViewportString,
12
- resolveViewport,
13
- getDevicePresets,
14
- isValidDevicePreset,
15
- calculateViewportScale,
16
- wrapInPreviewContainer,
17
- } from './presets';
@@ -1,181 +0,0 @@
1
- /**
2
- * Device viewport presets for wireweave
3
- *
4
- * Standard device dimensions for wireframe design
5
- */
6
-
7
- export interface ViewportSize {
8
- width: number;
9
- height: number;
10
- label: string;
11
- category: 'desktop' | 'tablet' | 'mobile';
12
- }
13
-
14
- /**
15
- * Device preset definitions
16
- */
17
- export const DEVICE_PRESETS: Record<string, ViewportSize> = {
18
- // Desktop
19
- 'desktop-sm': { width: 1280, height: 800, label: 'Small Laptop', category: 'desktop' },
20
- 'desktop': { width: 1440, height: 900, label: 'Desktop', category: 'desktop' },
21
- 'desktop-lg': { width: 1920, height: 1080, label: 'Full HD', category: 'desktop' },
22
- 'desktop-xl': { width: 2560, height: 1440, label: 'QHD', category: 'desktop' },
23
-
24
- // Tablet
25
- 'ipad': { width: 1024, height: 768, label: 'iPad (Landscape)', category: 'tablet' },
26
- 'ipad-portrait': { width: 768, height: 1024, label: 'iPad (Portrait)', category: 'tablet' },
27
- 'ipad-pro': { width: 1366, height: 1024, label: 'iPad Pro 12.9"', category: 'tablet' },
28
- 'ipad-pro-portrait': { width: 1024, height: 1366, label: 'iPad Pro 12.9" (Portrait)', category: 'tablet' },
29
-
30
- // Mobile
31
- 'iphone-se': { width: 375, height: 667, label: 'iPhone SE', category: 'mobile' },
32
- 'iphone14': { width: 390, height: 844, label: 'iPhone 14', category: 'mobile' },
33
- 'iphone14-pro': { width: 393, height: 852, label: 'iPhone 14 Pro', category: 'mobile' },
34
- 'iphone14-pro-max': { width: 430, height: 932, label: 'iPhone 14 Pro Max', category: 'mobile' },
35
- 'android': { width: 360, height: 800, label: 'Android', category: 'mobile' },
36
- 'android-lg': { width: 412, height: 915, label: 'Android Large', category: 'mobile' },
37
- };
38
-
39
- /**
40
- * Default viewport size (desktop)
41
- */
42
- export const DEFAULT_VIEWPORT: ViewportSize = DEVICE_PRESETS['desktop'];
43
-
44
- /**
45
- * Parse viewport value (e.g., "1440x900", "1440", or number)
46
- */
47
- export function parseViewportString(value: string | number): { width: number; height?: number } | null {
48
- // If it's already a number, treat as width only
49
- if (typeof value === 'number') {
50
- return { width: value };
51
- }
52
-
53
- // Format: "1440x900" or "1440"
54
- const match = value.match(/^(\d+)(?:x(\d+))?$/);
55
- if (!match) return null;
56
-
57
- const width = parseInt(match[1], 10);
58
- const height = match[2] ? parseInt(match[2], 10) : undefined;
59
-
60
- return { width, height };
61
- }
62
-
63
- /**
64
- * Get viewport size from device preset or explicit size
65
- */
66
- export function resolveViewport(
67
- viewport?: string | number,
68
- device?: string
69
- ): ViewportSize {
70
- // Device preset takes precedence
71
- if (device && DEVICE_PRESETS[device]) {
72
- return DEVICE_PRESETS[device];
73
- }
74
-
75
- // Parse explicit viewport
76
- if (viewport !== undefined) {
77
- const parsed = parseViewportString(viewport);
78
- if (parsed) {
79
- return {
80
- width: parsed.width,
81
- height: parsed.height || DEFAULT_VIEWPORT.height,
82
- label: `${parsed.width}x${parsed.height || DEFAULT_VIEWPORT.height}`,
83
- category: parsed.width <= 430 ? 'mobile' : parsed.width <= 1024 ? 'tablet' : 'desktop',
84
- };
85
- }
86
- }
87
-
88
- // Default
89
- return DEFAULT_VIEWPORT;
90
- }
91
-
92
- /**
93
- * Get all available device presets
94
- */
95
- export function getDevicePresets(): Record<string, ViewportSize> {
96
- return { ...DEVICE_PRESETS };
97
- }
98
-
99
- /**
100
- * Check if a device preset exists
101
- */
102
- export function isValidDevicePreset(device: string): boolean {
103
- return device in DEVICE_PRESETS;
104
- }
105
-
106
- /**
107
- * Calculate scale factor to fit viewport in container
108
- *
109
- * @param viewport - The viewport dimensions
110
- * @param containerWidth - Available container width
111
- * @param containerHeight - Available container height (optional)
112
- * @param maxScale - Maximum scale factor (default: 1)
113
- * @returns Scale factor (0-1 range, or up to maxScale)
114
- */
115
- export function calculateViewportScale(
116
- viewport: ViewportSize,
117
- containerWidth: number,
118
- containerHeight?: number,
119
- maxScale: number = 1
120
- ): number {
121
- const scaleX = containerWidth / viewport.width;
122
- const scaleY = containerHeight ? containerHeight / viewport.height : Infinity;
123
-
124
- // Use the smaller scale to fit both dimensions
125
- const scale = Math.min(scaleX, scaleY, maxScale);
126
-
127
- // Round to 3 decimal places
128
- return Math.round(scale * 1000) / 1000;
129
- }
130
-
131
- /**
132
- * Options for creating preview wrapper HTML
133
- */
134
- export interface PreviewWrapperOptions {
135
- /** CSS class prefix (default: 'wf') */
136
- prefix?: string;
137
- /** Dark mode background */
138
- darkMode?: boolean;
139
- /** Container width for auto-scaling */
140
- containerWidth?: number;
141
- /** Container height for auto-scaling */
142
- containerHeight?: number;
143
- /** Custom scale (overrides auto-calculated scale) */
144
- scale?: number;
145
- }
146
-
147
- /**
148
- * Wrap rendered HTML in a preview container with scaling
149
- *
150
- * @param html - The rendered wireframe HTML
151
- * @param viewport - The viewport size used for rendering
152
- * @param options - Preview wrapper options
153
- * @returns HTML string with preview wrapper
154
- */
155
- export function wrapInPreviewContainer(
156
- html: string,
157
- viewport: ViewportSize,
158
- options: PreviewWrapperOptions = {}
159
- ): string {
160
- const {
161
- prefix = 'wf',
162
- darkMode = false,
163
- containerWidth,
164
- containerHeight,
165
- scale: customScale,
166
- } = options;
167
-
168
- // Calculate scale if container dimensions provided
169
- const scale =
170
- customScale ??
171
- (containerWidth ? calculateViewportScale(viewport, containerWidth, containerHeight) : 1);
172
-
173
- const previewClass = `${prefix}-viewport-preview${darkMode ? ' dark' : ''}`;
174
- const wrapperStyle = `transform: scale(${scale}); width: ${viewport.width}px; height: ${viewport.height}px;`;
175
-
176
- return `<div class="${previewClass}" style="width: 100%; min-height: ${Math.round(viewport.height * scale)}px;">
177
- <div class="${prefix}-viewport-wrapper" style="${wrapperStyle}">
178
- ${html}
179
- </div>
180
- </div>`;
181
- }