inkbridge 0.1.0-beta.2 → 0.1.0-beta.21
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 +108 -25
- package/bin/inkbridge.mjs +354 -83
- package/code.js +40 -11802
- package/manifest.json +1 -0
- package/package.json +74 -23
- package/scanner/adapter-utils-regression.ts +159 -0
- package/scanner/aspect-percent-position-regression.ts +237 -0
- package/scanner/aspect-ratio-regression.ts +90 -0
- package/scanner/blob-placement-regression.ts +2 -2
- package/scanner/block-cache-regression.ts +195 -0
- package/scanner/bundle-size-regression.ts +50 -0
- package/scanner/child-sizing-matrix-regression.ts +303 -0
- package/scanner/cli.ts +342 -13
- package/scanner/component-scanner.ts +2108 -174
- package/scanner/component-sections-regression.ts +198 -0
- package/scanner/compound-classes-lookup-regression.ts +163 -0
- package/scanner/css-token-reader-regression.ts +7 -6
- package/scanner/css-token-reader.ts +152 -31
- package/scanner/cva-jsx-child-fallback-regression.ts +98 -0
- package/scanner/cva-master-icon-regression.ts +315 -0
- package/scanner/data-attr-prop-alias-regression.ts +129 -0
- package/scanner/explicit-size-root-regression.ts +102 -0
- package/scanner/font-family-extract-regression.ts +113 -0
- package/scanner/font-style-resolver-regression.ts +1 -1
- package/scanner/framework-adapter-shadcn-regression.ts +480 -0
- package/scanner/full-width-matrix-regression.ts +338 -0
- package/scanner/grid-cols-extraction-regression.ts +110 -0
- package/scanner/image-src-collector-regression.ts +204 -0
- package/scanner/inline-flex-regression.ts +235 -0
- package/scanner/input-range-regression.ts +217 -0
- package/scanner/instance-rendering-regression.ts +224 -0
- package/scanner/jsx-prop-unresolved-regression.ts +178 -0
- package/scanner/jsx-text-regression.ts +178 -0
- package/scanner/layout-alignment-regression.ts +108 -0
- package/scanner/layout-flex-regression.ts +90 -0
- package/scanner/layout-mode-regression.ts +71 -0
- package/scanner/layout-sizing-regression.ts +227 -0
- package/scanner/layout-spacing-regression.ts +135 -0
- package/scanner/local-const-className-regression.ts +331 -0
- package/scanner/percent-position-regression.ts +105 -0
- package/scanner/provider-cascade-regression.ts +224 -0
- package/scanner/provider-flatten-regression.ts +235 -0
- package/scanner/radial-gradient-regression.ts +1 -1
- package/scanner/render-prop-parser-regression.ts +161 -0
- package/scanner/ring-utility-regression.ts +153 -0
- package/scanner/sandbox-spread-regression.ts +125 -0
- package/scanner/selection-pressed-regression.ts +241 -0
- package/scanner/size-full-normalization-regression.ts +127 -0
- package/scanner/state-classification-regression.ts +175 -0
- package/scanner/story-diagnostics-regression.ts +216 -0
- package/scanner/story-dimensioning-regression.ts +298 -0
- package/scanner/story-render-strategy-regression.ts +205 -0
- package/scanner/stretch-to-parent-width-regression.ts +147 -0
- package/scanner/svg-fill-parent-regression.ts +98 -0
- package/scanner/svg-group-inheritance-regression.ts +166 -0
- package/scanner/svg-marker-inline-regression.ts +211 -0
- package/scanner/svg-marker-regression.ts +116 -0
- package/scanner/tailwind-parser.ts +46 -4
- package/scanner/text-resize-matrix-regression.ts +173 -0
- package/scanner/transform-math-regression.ts +1 -1
- package/scanner/types.ts +26 -2
- package/src/cache/frame-cache.ts +150 -0
- package/src/cache/index.ts +2 -0
- package/src/{component-defs.ts → components/component-defs.ts} +25 -10
- package/src/{component-gen.ts → components/component-gen.ts} +43 -116
- package/src/components/component-instance.ts +386 -0
- package/src/components/component-library.ts +44 -0
- package/src/components/component-lookup.ts +161 -0
- package/src/components/index.ts +7 -0
- package/src/components/scanner-types.ts +39 -0
- package/src/components/symbol-instance-policy.ts +312 -0
- package/src/design-system/block-cache.ts +130 -0
- package/src/design-system/component-sections.ts +107 -0
- package/src/design-system/cva-inference.ts +187 -0
- package/src/design-system/cva-master.ts +427 -0
- package/src/design-system/cva-utils.ts +29 -0
- package/src/design-system/design-system.ts +334 -0
- package/src/design-system/frame-stabilizers.ts +191 -0
- package/src/design-system/frame-utils.ts +46 -0
- package/src/design-system/generated-node.ts +84 -0
- package/src/design-system/icon-rendering.ts +229 -0
- package/src/design-system/index.ts +13 -0
- package/src/design-system/instance-rendering.ts +307 -0
- package/src/design-system/master-shared.ts +133 -0
- package/src/design-system/node-helpers.ts +237 -0
- package/src/design-system/node-variants.ts +196 -0
- package/src/design-system/non-cva-master.ts +104 -0
- package/src/design-system/portal-handling.ts +138 -0
- package/src/design-system/preview-builder.ts +738 -0
- package/src/{render-context.ts → design-system/render-context.ts} +32 -6
- package/src/design-system/render-prop-parser.ts +50 -0
- package/src/design-system/responsive-resolver.ts +180 -0
- package/src/design-system/selectable-state.ts +157 -0
- package/src/design-system/state-master.ts +267 -0
- package/src/design-system/state-utils.ts +15 -0
- package/src/design-system/story-builder-context.ts +40 -0
- package/src/design-system/story-builder.ts +1322 -0
- package/src/design-system/story-diagnostics.ts +80 -0
- package/src/design-system/story-dimensioning.ts +272 -0
- package/src/design-system/story-frames.ts +400 -0
- package/src/design-system/story-instance.ts +333 -0
- package/src/{story-layout.ts → design-system/story-layout.ts} +2 -2
- package/src/design-system/story-render-strategy.ts +150 -0
- package/src/design-system/story-tree-search.ts +110 -0
- package/src/design-system/symbol-fallback.ts +89 -0
- package/src/design-system/symbol-source.ts +172 -0
- package/src/design-system/table-helpers.ts +56 -0
- package/src/design-system/tag-predicates.ts +99 -0
- package/src/design-system/theme-context.ts +52 -0
- package/src/design-system/typography.ts +100 -0
- package/src/design-system/ui-builder.ts +2676 -0
- package/src/{clip-path-decorative.ts → effects/clip-path-decorative.ts} +11 -11
- package/src/effects/icon-builder.ts +1074 -0
- package/src/effects/index.ts +5 -0
- package/src/effects/portal-panel.ts +369 -0
- package/src/{radial-gradient.ts → effects/radial-gradient.ts} +1 -1
- package/src/framework-adapters/index.ts +47 -0
- package/src/framework-adapters/shadcn.ts +541 -0
- package/src/{github.ts → github/github.ts} +46 -21
- package/src/github/index.ts +1 -0
- package/src/layout/deferred-layout.ts +1556 -0
- package/src/layout/index.ts +24 -0
- package/src/layout/layout-parser.ts +375 -0
- package/src/{layout-utils.ts → layout/layout-utils.ts} +23 -17
- package/src/layout/parser/alignment.ts +54 -0
- package/src/layout/parser/flex.ts +59 -0
- package/src/layout/parser/index.ts +65 -0
- package/src/layout/parser/ir.ts +80 -0
- package/src/layout/parser/layout-mode.ts +57 -0
- package/src/layout/parser/sizing.ts +241 -0
- package/src/layout/parser/spacing-scale.ts +78 -0
- package/src/layout/parser/spacing.ts +134 -0
- package/src/layout/ring-utils.ts +120 -0
- package/src/layout/size-utils.ts +143 -0
- package/src/layout/text-resize-decision.ts +51 -0
- package/src/{width-solver.ts → layout/width-solver.ts} +168 -37
- package/src/main.ts +444 -162
- package/src/{config.ts → plugin/config.ts} +12 -12
- package/src/{dev-server.ts → plugin/dev-server.ts} +3 -3
- package/src/plugin/image-src-collector.ts +52 -0
- package/src/plugin/index.ts +3 -0
- package/src/plugin/packs/index.ts +2 -0
- package/src/{pack-provider.ts → plugin/packs/pack-provider.ts} +12 -12
- package/src/{packs.ts → plugin/packs/packs.ts} +22 -17
- package/src/render-engine-version.ts +2 -0
- package/src/tailwind/adapter-utils.ts +137 -0
- package/src/{class-utils.ts → tailwind/class-utils.ts} +33 -6
- package/src/tailwind/index.ts +8 -0
- package/src/tailwind/jsx-utils.ts +319 -0
- package/src/{node-ir.ts → tailwind/node-ir.ts} +208 -19
- package/src/{responsive-analyzer.ts → tailwind/responsive-analyzer.ts} +32 -2
- package/src/{state-analyzer.ts → tailwind/state-analyzer.ts} +71 -5
- package/src/{tailwind.ts → tailwind/tailwind.ts} +423 -674
- package/src/{utility-resolver.ts → tailwind/utility-resolver.ts} +27 -6
- package/src/{font-style-resolver.ts → text/font-style-resolver.ts} +0 -2
- package/src/text/index.ts +4 -0
- package/src/{inline-text.ts → text/inline-text.ts} +13 -13
- package/src/{text-builder.ts → text/text-builder.ts} +24 -7
- package/src/{text-line.ts → text/text-line.ts} +2 -2
- package/src/{change-detection.ts → tokens/change-detection.ts} +12 -12
- package/src/{color-resolver.ts → tokens/color-resolver.ts} +1 -6
- package/src/{colors.ts → tokens/colors.ts} +13 -6
- package/src/tokens/index.ts +6 -0
- package/src/{token-source.ts → tokens/token-source.ts} +4 -1
- package/src/{tokens.ts → tokens/tokens.ts} +116 -20
- package/src/{variables.ts → tokens/variables.ts} +447 -102
- package/templates/patch-tokens-route.ts +25 -6
- package/templates/scan-components-route.ts +26 -5
- package/ui.html +485 -37
- package/src/component-lookup.ts +0 -82
- package/src/design-system.ts +0 -59
- package/src/icon-builder.ts +0 -607
- package/src/layout-parser.ts +0 -667
- package/src/story-builder.ts +0 -1706
- package/src/ui-builder.ts +0 -1996
- /package/src/{image-cache.ts → cache/image-cache.ts} +0 -0
- /package/src/{blob-placement.ts → effects/blob-placement.ts} +0 -0
- /package/src/{transform-math.ts → tailwind/transform-math.ts} +0 -0
|
@@ -2,9 +2,14 @@
|
|
|
2
2
|
* Figma Token Patch API Route
|
|
3
3
|
*
|
|
4
4
|
* Generated by `inkbridge setup`. Do not move this file.
|
|
5
|
-
* The Figma plugin calls POST /api/
|
|
5
|
+
* The Figma plugin calls POST /api/inkbridge/patch-tokens during Push to Code
|
|
6
6
|
* to apply token updates via a PostCSS AST patcher.
|
|
7
7
|
*
|
|
8
|
+
* Types are deliberately explicit (no implicit `any` from `request.json()`
|
|
9
|
+
* or property access on unknown payloads) so this file passes consumer
|
|
10
|
+
* projects that enable strict `@typescript-eslint/no-explicit-any` /
|
|
11
|
+
* `no-unsafe-*` rules without needing per-file eslint-disable comments.
|
|
12
|
+
*
|
|
8
13
|
* To re-generate: pnpm exec inkbridge setup
|
|
9
14
|
*/
|
|
10
15
|
|
|
@@ -18,6 +23,18 @@ const CORS = {
|
|
|
18
23
|
};
|
|
19
24
|
|
|
20
25
|
type ThemeUpdateMap = Record<string, Record<string, string>>;
|
|
26
|
+
type PatchPayload = { cssText?: unknown; updatesByTheme?: unknown };
|
|
27
|
+
|
|
28
|
+
function isThemeUpdateMap(value: unknown): value is ThemeUpdateMap {
|
|
29
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) return false;
|
|
30
|
+
for (const inner of Object.values(value as Record<string, unknown>)) {
|
|
31
|
+
if (!inner || typeof inner !== 'object' || Array.isArray(inner)) return false;
|
|
32
|
+
for (const v of Object.values(inner as Record<string, unknown>)) {
|
|
33
|
+
if (typeof v !== 'string') return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
21
38
|
|
|
22
39
|
function parseThemeSelectors(selector: string): string[] {
|
|
23
40
|
const themes = new Set<string>();
|
|
@@ -137,11 +154,13 @@ function patchCssVariables(cssText: string, updatesByTheme: ThemeUpdateMap): str
|
|
|
137
154
|
return root.toString();
|
|
138
155
|
}
|
|
139
156
|
|
|
140
|
-
export async function POST(request: Request) {
|
|
157
|
+
export async function POST(request: Request): Promise<NextResponse> {
|
|
141
158
|
try {
|
|
142
|
-
const payload = await request.json();
|
|
143
|
-
const cssText = typeof payload
|
|
144
|
-
const updatesByTheme = (payload
|
|
159
|
+
const payload = (await request.json()) as PatchPayload;
|
|
160
|
+
const cssText = typeof payload.cssText === 'string' ? payload.cssText : '';
|
|
161
|
+
const updatesByTheme: ThemeUpdateMap = isThemeUpdateMap(payload.updatesByTheme)
|
|
162
|
+
? payload.updatesByTheme
|
|
163
|
+
: {};
|
|
145
164
|
|
|
146
165
|
if (!cssText) {
|
|
147
166
|
return NextResponse.json(
|
|
@@ -160,6 +179,6 @@ export async function POST(request: Request) {
|
|
|
160
179
|
}
|
|
161
180
|
}
|
|
162
181
|
|
|
163
|
-
export async function OPTIONS() {
|
|
182
|
+
export async function OPTIONS(): Promise<NextResponse> {
|
|
164
183
|
return new NextResponse(null, { headers: CORS });
|
|
165
184
|
}
|
|
@@ -2,9 +2,14 @@
|
|
|
2
2
|
* Figma Component Scanner API Route
|
|
3
3
|
*
|
|
4
4
|
* Generated by `inkbridge setup`. Do not move this file.
|
|
5
|
-
* The Figma plugin calls GET /api/
|
|
5
|
+
* The Figma plugin calls GET /api/inkbridge/scan-components when the user
|
|
6
6
|
* clicks "Generate Design System Page".
|
|
7
7
|
*
|
|
8
|
+
* Types are deliberately explicit (no implicit `any` from `JSON.parse` or
|
|
9
|
+
* `request.json()`) so this file passes consumer projects that enable
|
|
10
|
+
* strict `@typescript-eslint/no-explicit-any` /
|
|
11
|
+
* `no-unsafe-*` rules without needing per-file eslint-disable comments.
|
|
12
|
+
*
|
|
8
13
|
* To re-generate: pnpm exec inkbridge setup
|
|
9
14
|
*/
|
|
10
15
|
|
|
@@ -15,7 +20,17 @@ import { spawnSync } from 'child_process';
|
|
|
15
20
|
|
|
16
21
|
const CWD = process.cwd();
|
|
17
22
|
const TSX = path.resolve(CWD, 'node_modules/.bin/tsx');
|
|
18
|
-
|
|
23
|
+
// `INKBRIDGE_LOCAL=1` (set by `pnpm inkbridge:dev:local` in projects that
|
|
24
|
+
// sit next to a sibling inkbridge checkout) points the scanner at the
|
|
25
|
+
// source tree directly instead of going through `node_modules/inkbridge`.
|
|
26
|
+
// pnpm hard-links package files at install time, but most editors break
|
|
27
|
+
// those links on save (save-as-rename semantics), so without this flag
|
|
28
|
+
// every scanner edit requires a `pnpm add -D inkbridge@file:... --force`.
|
|
29
|
+
// The flag turns scanner-side iteration into a true hot loop.
|
|
30
|
+
const LOCAL_CLI = path.resolve(CWD, '..', 'inkbridge', 'tools', 'figma-plugin', 'scanner', 'cli.ts');
|
|
31
|
+
const CLI = process.env.INKBRIDGE_LOCAL === '1' && fs.existsSync(LOCAL_CLI)
|
|
32
|
+
? LOCAL_CLI
|
|
33
|
+
: path.resolve(CWD, 'node_modules/inkbridge/scanner/cli.ts');
|
|
19
34
|
const OUTPUT = path.resolve(CWD, '.inkbridge/component-definitions.json');
|
|
20
35
|
|
|
21
36
|
const CORS = {
|
|
@@ -24,7 +39,13 @@ const CORS = {
|
|
|
24
39
|
'Access-Control-Allow-Headers': 'Content-Type',
|
|
25
40
|
};
|
|
26
41
|
|
|
27
|
-
|
|
42
|
+
// Shape of the scanner output is opaque to the route — we forward it
|
|
43
|
+
// to the plugin verbatim. Typing as `unknown` (the type-safe stand-in
|
|
44
|
+
// for `any`) keeps strict lints happy without pulling the scanner's
|
|
45
|
+
// internal types into a route file the consumer owns.
|
|
46
|
+
type ScannerOutput = Record<string, unknown>;
|
|
47
|
+
|
|
48
|
+
export async function GET(request: Request): Promise<NextResponse> {
|
|
28
49
|
try {
|
|
29
50
|
const url = new URL(request.url);
|
|
30
51
|
const tokenSourceMode = url.searchParams.get('tokenSourceMode') || 'auto';
|
|
@@ -42,7 +63,7 @@ export async function GET(request: Request) {
|
|
|
42
63
|
throw new Error(result.stderr || 'Scanner exited with non-zero status');
|
|
43
64
|
}
|
|
44
65
|
|
|
45
|
-
const output = JSON.parse(fs.readFileSync(OUTPUT, 'utf-8'));
|
|
66
|
+
const output = JSON.parse(fs.readFileSync(OUTPUT, 'utf-8')) as ScannerOutput;
|
|
46
67
|
return NextResponse.json(output, { headers: CORS });
|
|
47
68
|
} catch (error) {
|
|
48
69
|
return NextResponse.json(
|
|
@@ -52,6 +73,6 @@ export async function GET(request: Request) {
|
|
|
52
73
|
}
|
|
53
74
|
}
|
|
54
75
|
|
|
55
|
-
export async function OPTIONS() {
|
|
76
|
+
export async function OPTIONS(): Promise<NextResponse> {
|
|
56
77
|
return new NextResponse(null, { headers: CORS });
|
|
57
78
|
}
|