inkbridge 0.1.0-beta.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 +201 -0
- package/bin/inkhouse.mjs +171 -0
- package/code.js +11802 -0
- package/manifest.json +30 -0
- package/package.json +45 -0
- package/scanner/blob-placement-regression.ts +132 -0
- package/scanner/class-collector.ts +69 -0
- package/scanner/cli.ts +336 -0
- package/scanner/component-scanner.ts +2876 -0
- package/scanner/css-patch-regression.ts +112 -0
- package/scanner/css-token-reader-regression.ts +92 -0
- package/scanner/css-token-reader.ts +477 -0
- package/scanner/font-style-resolver-regression.ts +32 -0
- package/scanner/index.ts +9 -0
- package/scanner/radial-gradient-regression.ts +53 -0
- package/scanner/style-map.ts +149 -0
- package/scanner/tailwind-parser.ts +644 -0
- package/scanner/transform-math-regression.ts +42 -0
- package/scanner/types.ts +298 -0
- package/src/blob-placement.ts +111 -0
- package/src/change-detection.ts +204 -0
- package/src/class-utils.ts +105 -0
- package/src/clip-path-decorative.ts +194 -0
- package/src/color-resolver.ts +98 -0
- package/src/colors.ts +196 -0
- package/src/component-defs.ts +54 -0
- package/src/component-gen.ts +561 -0
- package/src/component-lookup.ts +82 -0
- package/src/config.ts +115 -0
- package/src/design-system.ts +59 -0
- package/src/dev-server.ts +173 -0
- package/src/figma-globals.d.ts +3 -0
- package/src/font-style-resolver.ts +171 -0
- package/src/github.ts +1465 -0
- package/src/icon-builder.ts +607 -0
- package/src/image-cache.ts +22 -0
- package/src/inline-text.ts +271 -0
- package/src/layout-parser.ts +667 -0
- package/src/layout-utils.ts +155 -0
- package/src/main.ts +687 -0
- package/src/node-ir.ts +595 -0
- package/src/pack-provider.ts +148 -0
- package/src/packs.ts +126 -0
- package/src/radial-gradient.ts +84 -0
- package/src/render-context.ts +138 -0
- package/src/responsive-analyzer.ts +139 -0
- package/src/state-analyzer.ts +143 -0
- package/src/story-builder.ts +1706 -0
- package/src/story-layout.ts +38 -0
- package/src/tailwind.ts +2379 -0
- package/src/text-builder.ts +116 -0
- package/src/text-line.ts +42 -0
- package/src/token-source.ts +43 -0
- package/src/tokens.ts +717 -0
- package/src/transform-math.ts +44 -0
- package/src/ui-builder.ts +1996 -0
- package/src/utility-resolver.ts +125 -0
- package/src/variables.ts +1042 -0
- package/src/width-solver.ts +466 -0
- package/templates/patch-tokens-route.ts +165 -0
- package/templates/scan-components-route.ts +57 -0
- package/ui.html +1222 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { pxFromSizeToken } from './variables';
|
|
2
|
+
|
|
3
|
+
export type UtilityAtom = {
|
|
4
|
+
raw: string;
|
|
5
|
+
variants: string[];
|
|
6
|
+
important: boolean;
|
|
7
|
+
utility: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type SpacingScale = Record<string, number>;
|
|
11
|
+
|
|
12
|
+
const MAX_WIDTH_MAP: Record<string, number> = {
|
|
13
|
+
'max-w-xs': 320,
|
|
14
|
+
'max-w-sm': 384,
|
|
15
|
+
'max-w-md': 448,
|
|
16
|
+
'max-w-lg': 512,
|
|
17
|
+
'max-w-xl': 576,
|
|
18
|
+
'max-w-2xl': 672,
|
|
19
|
+
'max-w-3xl': 768,
|
|
20
|
+
'max-w-4xl': 896,
|
|
21
|
+
'max-w-5xl': 1024,
|
|
22
|
+
'max-w-6xl': 1152,
|
|
23
|
+
'max-w-7xl': 1280,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export function parseUtilityClass(input: string): UtilityAtom {
|
|
27
|
+
let cls = input.trim();
|
|
28
|
+
let important = false;
|
|
29
|
+
if (cls.startsWith('!')) {
|
|
30
|
+
important = true;
|
|
31
|
+
cls = cls.slice(1);
|
|
32
|
+
}
|
|
33
|
+
if (cls.endsWith('!')) {
|
|
34
|
+
important = true;
|
|
35
|
+
cls = cls.slice(0, -1);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const parts: string[] = [];
|
|
39
|
+
let buf = '';
|
|
40
|
+
let depth = 0;
|
|
41
|
+
for (let i = 0; i < cls.length; i++) {
|
|
42
|
+
const ch = cls[i];
|
|
43
|
+
if (ch === '[') depth++;
|
|
44
|
+
if (ch === ']') depth = Math.max(0, depth - 1);
|
|
45
|
+
if (ch === ':' && depth === 0) {
|
|
46
|
+
parts.push(buf);
|
|
47
|
+
buf = '';
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
buf += ch;
|
|
51
|
+
}
|
|
52
|
+
if (buf) parts.push(buf);
|
|
53
|
+
|
|
54
|
+
if (parts.length <= 1) {
|
|
55
|
+
return { raw: input, variants: [], important, utility: parts[0] || '' };
|
|
56
|
+
}
|
|
57
|
+
return { raw: input, variants: parts.slice(0, -1), important, utility: parts[parts.length - 1] };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function hasResponsiveVariant(variants: string[]): boolean {
|
|
61
|
+
return variants.some(v => ['sm', 'md', 'lg', 'xl', '2xl'].includes(v));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function variantState(variants: string[]): string | null {
|
|
65
|
+
if (variants.includes('hover')) return 'hover';
|
|
66
|
+
if (variants.includes('focus-visible')) return 'focus-visible';
|
|
67
|
+
if (variants.includes('focus')) return 'focus';
|
|
68
|
+
if (variants.includes('disabled')) return 'disabled';
|
|
69
|
+
if (variants.includes('active')) return 'active';
|
|
70
|
+
if (variants.some(v => v.startsWith('data-[state=') || v.startsWith('data-[state='))) return 'open';
|
|
71
|
+
if (variants.includes('aria-invalid')) return 'error';
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function parseLength(value: string): number | null {
|
|
76
|
+
const trimmed = value.trim();
|
|
77
|
+
if (trimmed === '0') return 0;
|
|
78
|
+
const pxMatch = trimmed.match(/^(-?\d+(?:\.\d+)?)px$/);
|
|
79
|
+
if (pxMatch) return parseFloat(pxMatch[1]);
|
|
80
|
+
const remMatch = trimmed.match(/^(-?\d+(?:\.\d+)?)rem$/);
|
|
81
|
+
if (remMatch) return parseFloat(remMatch[1]) * 16;
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function spacingValue(token: string, spacingScale: SpacingScale): number | null {
|
|
86
|
+
if (!token) return null;
|
|
87
|
+
if (token.indexOf('/') !== -1) return null;
|
|
88
|
+
if (spacingScale && spacingScale[token] != null) return spacingScale[token];
|
|
89
|
+
const numeric = parseFloat(token);
|
|
90
|
+
if (!Number.isNaN(numeric)) return numeric * 4;
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function extractArbitraryValue(utility: string): string | null {
|
|
95
|
+
const match = utility.match(/\[(.+)\]$/);
|
|
96
|
+
return match ? match[1] : null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function resolveMaxWidth(utility: string): number | null {
|
|
100
|
+
if (MAX_WIDTH_MAP[utility]) return MAX_WIDTH_MAP[utility];
|
|
101
|
+
const arbitrary = extractArbitraryValue(utility);
|
|
102
|
+
if (arbitrary) return parseLength(arbitrary);
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function resolveRadius(utility: string, radiusGroup: Record<string, string> | null): number | null {
|
|
107
|
+
if (utility === 'rounded') {
|
|
108
|
+
return radiusGroup && radiusGroup.base ? pxFromSizeToken(radiusGroup.base) : 6;
|
|
109
|
+
}
|
|
110
|
+
if (utility.startsWith('rounded-[')) {
|
|
111
|
+
const arbitrary = extractArbitraryValue(utility);
|
|
112
|
+
if (arbitrary) {
|
|
113
|
+
const len = parseLength(arbitrary);
|
|
114
|
+
if (len != null) return len;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const match = utility.match(/^rounded-(.+)$/);
|
|
118
|
+
if (!match) return null;
|
|
119
|
+
const key = match[1];
|
|
120
|
+
if (radiusGroup && radiusGroup[key]) {
|
|
121
|
+
return pxFromSizeToken(radiusGroup[key]);
|
|
122
|
+
}
|
|
123
|
+
const fallback: Record<string, number> = { none: 0, sm: 2, md: 6, lg: 8, xl: 12, '2xl': 16, '3xl': 24, full: 9999 };
|
|
124
|
+
return fallback[key] ?? null;
|
|
125
|
+
}
|