@luci-dev/format 0.0.0-stage → 0.5.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/LICENSE +21 -0
- package/dist/agents.d.ts +25 -0
- package/dist/agents.d.ts.map +1 -0
- package/dist/agents.js +36 -0
- package/dist/agents.js.map +1 -0
- package/dist/capture/baseline.d.ts +53 -0
- package/dist/capture/baseline.d.ts.map +1 -0
- package/dist/capture/baseline.js +400 -0
- package/dist/capture/baseline.js.map +1 -0
- package/dist/capture/check.d.ts +111 -0
- package/dist/capture/check.d.ts.map +1 -0
- package/dist/capture/check.js +327 -0
- package/dist/capture/check.js.map +1 -0
- package/dist/capture/collection.d.ts +2647 -0
- package/dist/capture/collection.d.ts.map +1 -0
- package/dist/capture/collection.js +103 -0
- package/dist/capture/collection.js.map +1 -0
- package/dist/capture/compare.d.ts +50 -0
- package/dist/capture/compare.d.ts.map +1 -0
- package/dist/capture/compare.js +167 -0
- package/dist/capture/compare.js.map +1 -0
- package/dist/capture/format.d.ts +59 -0
- package/dist/capture/format.d.ts.map +1 -0
- package/dist/capture/format.js +540 -0
- package/dist/capture/format.js.map +1 -0
- package/dist/capture/image.d.ts +42 -0
- package/dist/capture/image.d.ts.map +1 -0
- package/dist/capture/image.js +103 -0
- package/dist/capture/image.js.map +1 -0
- package/dist/capture/index.d.ts +18 -0
- package/dist/capture/index.d.ts.map +1 -0
- package/dist/capture/index.js +18 -0
- package/dist/capture/index.js.map +1 -0
- package/dist/capture/layout.d.ts +21 -0
- package/dist/capture/layout.d.ts.map +1 -0
- package/dist/capture/layout.js +131 -0
- package/dist/capture/layout.js.map +1 -0
- package/dist/capture/merge.d.ts +46 -0
- package/dist/capture/merge.d.ts.map +1 -0
- package/dist/capture/merge.js +251 -0
- package/dist/capture/merge.js.map +1 -0
- package/dist/capture/read.d.ts +91 -0
- package/dist/capture/read.d.ts.map +1 -0
- package/dist/capture/read.js +179 -0
- package/dist/capture/read.js.map +1 -0
- package/dist/capture/remap.d.ts +34 -0
- package/dist/capture/remap.d.ts.map +1 -0
- package/dist/capture/remap.js +227 -0
- package/dist/capture/remap.js.map +1 -0
- package/dist/capture/rule.d.ts +19 -0
- package/dist/capture/rule.d.ts.map +1 -0
- package/dist/capture/rule.js +39 -0
- package/dist/capture/rule.js.map +1 -0
- package/dist/capture/schema.d.ts +3020 -0
- package/dist/capture/schema.d.ts.map +1 -0
- package/dist/capture/schema.js +488 -0
- package/dist/capture/schema.js.map +1 -0
- package/dist/capture/spacingUnit.d.ts +32 -0
- package/dist/capture/spacingUnit.d.ts.map +1 -0
- package/dist/capture/spacingUnit.js +49 -0
- package/dist/capture/spacingUnit.js.map +1 -0
- package/dist/capture/stitch.d.ts +11 -0
- package/dist/capture/stitch.d.ts.map +1 -0
- package/dist/capture/stitch.js +382 -0
- package/dist/capture/stitch.js.map +1 -0
- package/dist/capture/tokensExport.d.ts +37 -0
- package/dist/capture/tokensExport.d.ts.map +1 -0
- package/dist/capture/tokensExport.js +355 -0
- package/dist/capture/tokensExport.js.map +1 -0
- package/dist/capture/values.d.ts +47 -0
- package/dist/capture/values.d.ts.map +1 -0
- package/dist/capture/values.js +155 -0
- package/dist/capture/values.js.map +1 -0
- package/dist/feedback/index.d.ts +7 -0
- package/dist/feedback/index.d.ts.map +1 -0
- package/dist/feedback/index.js +7 -0
- package/dist/feedback/index.js.map +1 -0
- package/dist/feedback/layoutPrompt.d.ts +26 -0
- package/dist/feedback/layoutPrompt.d.ts.map +1 -0
- package/dist/feedback/layoutPrompt.js +38 -0
- package/dist/feedback/layoutPrompt.js.map +1 -0
- package/dist/feedback/parts.d.ts +17 -0
- package/dist/feedback/parts.d.ts.map +1 -0
- package/dist/feedback/parts.js +50 -0
- package/dist/feedback/parts.js.map +1 -0
- package/dist/feedback/prompt.d.ts +13 -0
- package/dist/feedback/prompt.d.ts.map +1 -0
- package/dist/feedback/prompt.js +114 -0
- package/dist/feedback/prompt.js.map +1 -0
- package/dist/feedback/schema.d.ts +504 -0
- package/dist/feedback/schema.d.ts.map +1 -0
- package/dist/feedback/schema.js +236 -0
- package/dist/feedback/schema.js.map +1 -0
- package/dist/feedback/wireframePrompt.d.ts +9 -0
- package/dist/feedback/wireframePrompt.d.ts.map +1 -0
- package/dist/feedback/wireframePrompt.js +24 -0
- package/dist/feedback/wireframePrompt.js.map +1 -0
- package/dist/home.d.ts +13 -0
- package/dist/home.d.ts.map +1 -0
- package/dist/home.js +19 -0
- package/dist/home.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/markdown/sections.d.ts +24 -0
- package/dist/markdown/sections.d.ts.map +1 -0
- package/dist/markdown/sections.js +58 -0
- package/dist/markdown/sections.js.map +1 -0
- package/dist/memory/activeTask.d.ts +25 -0
- package/dist/memory/activeTask.d.ts.map +1 -0
- package/dist/memory/activeTask.js +33 -0
- package/dist/memory/activeTask.js.map +1 -0
- package/dist/memory/brainJson.d.ts +44 -0
- package/dist/memory/brainJson.d.ts.map +1 -0
- package/dist/memory/brainJson.js +44 -0
- package/dist/memory/brainJson.js.map +1 -0
- package/dist/memory/decision.d.ts +30 -0
- package/dist/memory/decision.d.ts.map +1 -0
- package/dist/memory/decision.js +86 -0
- package/dist/memory/decision.js.map +1 -0
- package/dist/memory/layout.d.ts +41 -0
- package/dist/memory/layout.d.ts.map +1 -0
- package/dist/memory/layout.js +76 -0
- package/dist/memory/layout.js.map +1 -0
- package/dist/memory/proposed.d.ts +29 -0
- package/dist/memory/proposed.d.ts.map +1 -0
- package/dist/memory/proposed.js +63 -0
- package/dist/memory/proposed.js.map +1 -0
- package/dist/product.d.ts +17 -0
- package/dist/product.d.ts.map +1 -0
- package/dist/product.js +17 -0
- package/dist/product.js.map +1 -0
- package/dist/result.d.ts +17 -0
- package/dist/result.d.ts.map +1 -0
- package/dist/result.js +20 -0
- package/dist/result.js.map +1 -0
- package/dist/skills/contract.d.ts +137 -0
- package/dist/skills/contract.d.ts.map +1 -0
- package/dist/skills/contract.js +131 -0
- package/dist/skills/contract.js.map +1 -0
- package/dist/skills/frontmatter.d.ts +31 -0
- package/dist/skills/frontmatter.d.ts.map +1 -0
- package/dist/skills/frontmatter.js +214 -0
- package/dist/skills/frontmatter.js.map +1 -0
- package/package.json +31 -3
- package/README.md +0 -3
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Screenshot mode (v0.4): a file estimated from an image, for apps and pictures that cannot be
|
|
3
|
+
* inspected. Only colors can be read from pixels, so the file is a color system with method
|
|
4
|
+
* "estimated": the image's palette, each color with its share of the picture, and a role guessed from
|
|
5
|
+
* how it sits against the rest (the largest area is the background; the color that stands out most
|
|
6
|
+
* against it, the text; the most saturated, the accent; a faint line color, the border).
|
|
7
|
+
* Text styles and spacing cannot be read from an image, and the file says so. Pure and browser-safe.
|
|
8
|
+
*/
|
|
9
|
+
import type { ColorRole, ColorSystem } from './schema.js';
|
|
10
|
+
export interface PaletteColor {
|
|
11
|
+
/** The color: red, green, blue (0-255). */
|
|
12
|
+
rgb: readonly [number, number, number];
|
|
13
|
+
/** Its share of the image's visible pixels, 0-1. */
|
|
14
|
+
share: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The image's palette from its RGBA pixels (a canvas's ImageData.data), largest share first: pixels
|
|
18
|
+
* are counted in 5-bit buckets, then buckets close in color merge into one color, weighted by count.
|
|
19
|
+
*/
|
|
20
|
+
export declare function estimatePalette(rgba: ArrayLike<number>, options?: {
|
|
21
|
+
maxColors?: number;
|
|
22
|
+
}): PaletteColor[];
|
|
23
|
+
/** WCAG contrast ratio of two colors. */
|
|
24
|
+
export declare const contrastOf: (a: readonly number[], b: readonly number[]) => number;
|
|
25
|
+
/** Each palette color's role, guessed from how it sits against the background. */
|
|
26
|
+
export declare function guessRoles(palette: readonly PaletteColor[]): {
|
|
27
|
+
color: PaletteColor;
|
|
28
|
+
role: ColorRole;
|
|
29
|
+
}[];
|
|
30
|
+
/** "My Screenshot.png" -> "my-screenshot". */
|
|
31
|
+
export declare const imageSlug: (fileName: string) => string;
|
|
32
|
+
/**
|
|
33
|
+
* The color system estimated from an image: name image-<file>, source file:///<file name> (no path),
|
|
34
|
+
* method estimated; each role row's Uses is the color's share of the image in percent.
|
|
35
|
+
*/
|
|
36
|
+
export declare function imageColorSystem(palette: readonly PaletteColor[], options: {
|
|
37
|
+
file: string;
|
|
38
|
+
captured: string;
|
|
39
|
+
}): ColorSystem | null;
|
|
40
|
+
/** The file name for an image's color system: image-<file>.system.color.design.md. */
|
|
41
|
+
export declare const imageFileName: (file: string) => string;
|
|
42
|
+
//# sourceMappingURL=image.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/capture/image.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1D,MAAM,WAAW,YAAY;IAC3B,2CAA2C;IAC3C,GAAG,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAC;CACf;AASD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,OAAO,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,YAAY,EAAE,CAwB7G;AAID,yCAAyC;AACzC,eAAO,MAAM,UAAU,MAAO,SAAS,MAAM,EAAE,KAAK,SAAS,MAAM,EAAE,WAGpE,CAAC;AAGF,kFAAkF;AAClF,wBAAgB,UAAU,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,GAAG;IAAE,KAAK,EAAE,YAAY,CAAC;IAAC,IAAI,EAAE,SAAS,CAAA;CAAE,EAAE,CAmBvG;AAGD,8CAA8C;AAC9C,eAAO,MAAM,SAAS,aAAc,MAAM,WACqF,CAAC;AAEhI;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,EAAE,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,WAAW,GAAG,IAAI,CAQlI;AAED,sFAAsF;AACtF,eAAO,MAAM,aAAa,SAAU,MAAM,WAAsD,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/** Colors closer than this (in RGB) are one color: anti-aliasing and compression make many near-copies. */
|
|
2
|
+
const MERGE_DISTANCE = 28;
|
|
3
|
+
/** A color must cover at least this share of the image to count. */
|
|
4
|
+
const MIN_SHARE = 0.004;
|
|
5
|
+
const dist = (a, b) => Math.hypot(a[0] - b[0], a[1] - b[1], a[2] - b[2]);
|
|
6
|
+
/**
|
|
7
|
+
* The image's palette from its RGBA pixels (a canvas's ImageData.data), largest share first: pixels
|
|
8
|
+
* are counted in 5-bit buckets, then buckets close in color merge into one color, weighted by count.
|
|
9
|
+
*/
|
|
10
|
+
export function estimatePalette(rgba, options = {}) {
|
|
11
|
+
const max = options.maxColors ?? 8;
|
|
12
|
+
const bins = new Map();
|
|
13
|
+
let total = 0;
|
|
14
|
+
for (let i = 0; i + 3 < rgba.length; i += 4) {
|
|
15
|
+
if (rgba[i + 3] < 128)
|
|
16
|
+
continue;
|
|
17
|
+
const r = rgba[i], g = rgba[i + 1], b = rgba[i + 2];
|
|
18
|
+
const key = ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3);
|
|
19
|
+
const bin = bins.get(key);
|
|
20
|
+
if (bin) {
|
|
21
|
+
bin.n++;
|
|
22
|
+
bin.r += r;
|
|
23
|
+
bin.g += g;
|
|
24
|
+
bin.b += b;
|
|
25
|
+
}
|
|
26
|
+
else
|
|
27
|
+
bins.set(key, { n: 1, r, g, b });
|
|
28
|
+
total++;
|
|
29
|
+
}
|
|
30
|
+
if (!total)
|
|
31
|
+
return [];
|
|
32
|
+
const clusters = [];
|
|
33
|
+
for (const bin of [...bins.values()].sort((x, y) => y.n - x.n)) {
|
|
34
|
+
const center = [bin.r / bin.n, bin.g / bin.n, bin.b / bin.n];
|
|
35
|
+
const near = clusters.find(c => dist([c.r / c.n, c.g / c.n, c.b / c.n], center) < MERGE_DISTANCE);
|
|
36
|
+
if (near) {
|
|
37
|
+
near.n += bin.n;
|
|
38
|
+
near.r += bin.r;
|
|
39
|
+
near.g += bin.g;
|
|
40
|
+
near.b += bin.b;
|
|
41
|
+
}
|
|
42
|
+
else
|
|
43
|
+
clusters.push({ ...bin });
|
|
44
|
+
}
|
|
45
|
+
return clusters
|
|
46
|
+
.map(c => ({ rgb: [Math.round(c.r / c.n), Math.round(c.g / c.n), Math.round(c.b / c.n)], share: c.n / total }))
|
|
47
|
+
.filter(c => c.share >= MIN_SHARE)
|
|
48
|
+
.sort((a, b) => b.share - a.share)
|
|
49
|
+
.slice(0, max);
|
|
50
|
+
}
|
|
51
|
+
const channel = (v) => { const s = v / 255; return s <= 0.04045 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4; };
|
|
52
|
+
const luminance = (c) => 0.2126 * channel(c[0]) + 0.7152 * channel(c[1]) + 0.0722 * channel(c[2]);
|
|
53
|
+
/** WCAG contrast ratio of two colors. */
|
|
54
|
+
export const contrastOf = (a, b) => {
|
|
55
|
+
const [x, y] = [luminance(a), luminance(b)];
|
|
56
|
+
return (Math.max(x, y) + 0.05) / (Math.min(x, y) + 0.05);
|
|
57
|
+
};
|
|
58
|
+
const chroma = (c) => Math.max(c[0], c[1], c[2]) - Math.min(c[0], c[1], c[2]);
|
|
59
|
+
/** Each palette color's role, guessed from how it sits against the background. */
|
|
60
|
+
export function guessRoles(palette) {
|
|
61
|
+
if (!palette.length)
|
|
62
|
+
return [];
|
|
63
|
+
const [bg, ...rest] = palette;
|
|
64
|
+
const out = [{ color: bg, role: 'background' }];
|
|
65
|
+
const left = new Set(rest);
|
|
66
|
+
const take = (c, role) => { if (c) {
|
|
67
|
+
out.push({ color: c, role });
|
|
68
|
+
left.delete(c);
|
|
69
|
+
} };
|
|
70
|
+
// Text: a near-neutral color that stands out most against the background (readable: 3:1 or more);
|
|
71
|
+
// a strongly colored one is an accent, even when it is readable
|
|
72
|
+
take([...left].filter(c => contrastOf(c.rgb, bg.rgb) >= 3 && chroma(c.rgb) < 80).sort((a, b) => contrastOf(b.rgb, bg.rgb) - contrastOf(a.rgb, bg.rgb))[0], 'text');
|
|
73
|
+
// Accent: the most saturated, weighted by how much of the image it covers
|
|
74
|
+
take([...left].filter(c => chroma(c.rgb) >= 60).sort((a, b) => chroma(b.rgb) * Math.sqrt(b.share) - chroma(a.rgb) * Math.sqrt(a.share))[0], 'accent');
|
|
75
|
+
// Border: a faint line color, close to the background but not it
|
|
76
|
+
take([...left].filter(c => { const k = contrastOf(c.rgb, bg.rgb); return k > 1.05 && k < 1.8; })[0], 'border');
|
|
77
|
+
// The rest: surfaces close to the background, colorful ones as accents, the others as text
|
|
78
|
+
for (const c of [...left]) {
|
|
79
|
+
const k = contrastOf(c.rgb, bg.rgb);
|
|
80
|
+
take(c, k < 1.5 ? 'background' : chroma(c.rgb) >= 60 ? 'accent' : 'text');
|
|
81
|
+
}
|
|
82
|
+
return out;
|
|
83
|
+
}
|
|
84
|
+
const rgbText = (c) => `rgb(${c[0]}, ${c[1]}, ${c[2]})`;
|
|
85
|
+
/** "My Screenshot.png" -> "my-screenshot". */
|
|
86
|
+
export const imageSlug = (fileName) => fileName.replace(/\.[a-z0-9]+$/i, '').toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '').slice(0, 40) || 'image';
|
|
87
|
+
/**
|
|
88
|
+
* The color system estimated from an image: name image-<file>, source file:///<file name> (no path),
|
|
89
|
+
* method estimated; each role row's Uses is the color's share of the image in percent.
|
|
90
|
+
*/
|
|
91
|
+
export function imageColorSystem(palette, options) {
|
|
92
|
+
const roles = guessRoles(palette);
|
|
93
|
+
if (!roles.length)
|
|
94
|
+
return null;
|
|
95
|
+
return {
|
|
96
|
+
meta: { name: `image-${imageSlug(options.file)}`, scope: 'system', type: 'color', source: `file:///${encodeURIComponent(options.file || 'image')}`, captured: options.captured, method: 'estimated' },
|
|
97
|
+
roles: roles.map(({ color, role }) => ({ role, value: { computed: rgbText(color.rgb) }, count: Math.max(1, Math.round(color.share * 100)), properties: ['image'] })),
|
|
98
|
+
tokens: []
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/** The file name for an image's color system: image-<file>.system.color.design.md. */
|
|
102
|
+
export const imageFileName = (file) => `image-${imageSlug(file)}.system.color.design.md`;
|
|
103
|
+
//# sourceMappingURL=image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.js","sourceRoot":"","sources":["../../src/capture/image.ts"],"names":[],"mappings":"AAiBA,2GAA2G;AAC3G,MAAM,cAAc,GAAG,EAAE,CAAC;AAC1B,oEAAoE;AACpE,MAAM,SAAS,GAAG,KAAK,CAAC;AAExB,MAAM,IAAI,GAAG,CAAC,CAAoB,EAAE,CAAoB,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAE,GAAG,CAAC,CAAC,CAAC,CAAE,EAAE,CAAC,CAAC,CAAC,CAAE,GAAG,CAAC,CAAC,CAAC,CAAE,EAAE,CAAC,CAAC,CAAC,CAAE,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC;AAErH;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,IAAuB,EAAE,OAAO,GAA2B,EAAE;IAC3F,MAAM,GAAG,GAAG,OAAO,CAAC,SAAS,IAAI,CAAC,CAAC;IACnC,MAAM,IAAI,GAAG,IAAI,GAAG,EAA0D,CAAC;IAC/E,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG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;KACX,CAAC;AACJ,CAAC;AAED,sFAAsF;AACtF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,SAAS,SAAS,CAAC,IAAI,CAAC,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Capture files (design.md). Browser-safe: import it as `@luci-dev/format/capture` from the extension. */
|
|
2
|
+
export * from './schema.js';
|
|
3
|
+
export * from './values.js';
|
|
4
|
+
export * from './format.js';
|
|
5
|
+
export * from './collection.js';
|
|
6
|
+
export * from './read.js';
|
|
7
|
+
export * from './check.js';
|
|
8
|
+
export * from './rule.js';
|
|
9
|
+
export * from './spacingUnit.js';
|
|
10
|
+
export * from './merge.js';
|
|
11
|
+
export * from './baseline.js';
|
|
12
|
+
export * from './compare.js';
|
|
13
|
+
export * from './remap.js';
|
|
14
|
+
export * from './image.js';
|
|
15
|
+
export * from './stitch.js';
|
|
16
|
+
export * from './tokensExport.js';
|
|
17
|
+
export * from './layout.js';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/capture/index.ts"],"names":[],"mappings":"AAAA,2GAA2G;AAC3G,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Capture files (design.md). Browser-safe: import it as `@luci-dev/format/capture` from the extension. */
|
|
2
|
+
export * from './schema.js';
|
|
3
|
+
export * from './values.js';
|
|
4
|
+
export * from './format.js';
|
|
5
|
+
export * from './collection.js';
|
|
6
|
+
export * from './read.js';
|
|
7
|
+
export * from './check.js';
|
|
8
|
+
export * from './rule.js';
|
|
9
|
+
export * from './spacingUnit.js';
|
|
10
|
+
export * from './merge.js';
|
|
11
|
+
export * from './baseline.js';
|
|
12
|
+
export * from './compare.js';
|
|
13
|
+
export * from './remap.js';
|
|
14
|
+
export * from './image.js';
|
|
15
|
+
export * from './stitch.js';
|
|
16
|
+
export * from './tokensExport.js';
|
|
17
|
+
export * from './layout.js';
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/capture/index.ts"],"names":[],"mappings":"AAAA,2GAA2G;AAC3G,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Computed layout tree (v0.4.3): build, format and parse hierarchical layout trees
|
|
3
|
+
* with parent/child flex and grid relationships for component and section captures.
|
|
4
|
+
*/
|
|
5
|
+
import type { ComputedLayout, LayoutTreeNode } from './schema.js';
|
|
6
|
+
export interface LayoutNodeInput {
|
|
7
|
+
part: string;
|
|
8
|
+
element: string;
|
|
9
|
+
depth?: number;
|
|
10
|
+
parent?: string;
|
|
11
|
+
layout?: ComputedLayout;
|
|
12
|
+
}
|
|
13
|
+
/** Build a nested LayoutTreeNode hierarchy from a flat list of anatomy parts or structure nodes. */
|
|
14
|
+
export declare function buildLayoutTree(nodes: readonly LayoutNodeInput[]): LayoutTreeNode | undefined;
|
|
15
|
+
/** Format a ComputedLayout object into a readable inline description. */
|
|
16
|
+
export declare function formatLayoutDescription(layout?: ComputedLayout): string;
|
|
17
|
+
/** Format a LayoutTreeNode hierarchy into markdown bullet tree lines. */
|
|
18
|
+
export declare function formatLayoutTree(tree: LayoutTreeNode, indent?: string): string;
|
|
19
|
+
/** Flatten a LayoutTreeNode hierarchy back into an array of nodes with depth and parent pointers. */
|
|
20
|
+
export declare function flattenLayoutTree(tree: LayoutTreeNode): LayoutTreeNode[];
|
|
21
|
+
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../src/capture/layout.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElE,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB;AAED,oGAAoG;AACpG,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,eAAe,EAAE,GAAG,cAAc,GAAG,SAAS,CAoD7F;AAED,yEAAyE;AACzE,wBAAgB,uBAAuB,CAAC,MAAM,CAAC,EAAE,cAAc,GAAG,MAAM,CAwCvE;AAED,yEAAyE;AACzE,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,cAAc,EAAE,MAAM,SAAK,GAAG,MAAM,CAU1E;AAED,qGAAqG;AACrG,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,cAAc,GAAG,cAAc,EAAE,CAUxE"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/** Build a nested LayoutTreeNode hierarchy from a flat list of anatomy parts or structure nodes. */
|
|
2
|
+
export function buildLayoutTree(nodes) {
|
|
3
|
+
if (!nodes.length)
|
|
4
|
+
return undefined;
|
|
5
|
+
const rootNode = nodes[0];
|
|
6
|
+
const root = {
|
|
7
|
+
part: rootNode.part,
|
|
8
|
+
element: rootNode.element,
|
|
9
|
+
depth: 0,
|
|
10
|
+
...(rootNode.layout ? { layout: rootNode.layout } : {}),
|
|
11
|
+
children: []
|
|
12
|
+
};
|
|
13
|
+
const stack = [root];
|
|
14
|
+
for (let i = 1; i < nodes.length; i++) {
|
|
15
|
+
const item = nodes[i];
|
|
16
|
+
const depth = item.depth ?? (item.parent ? (stack.find(s => s.part === item.parent)?.depth ?? 0) + 1 : 1);
|
|
17
|
+
const node = {
|
|
18
|
+
part: item.part,
|
|
19
|
+
element: item.element,
|
|
20
|
+
depth,
|
|
21
|
+
...(item.parent ? { parent: item.parent } : {}),
|
|
22
|
+
...(item.layout ? { layout: item.layout } : {}),
|
|
23
|
+
children: []
|
|
24
|
+
};
|
|
25
|
+
let parentNode;
|
|
26
|
+
if (item.parent) {
|
|
27
|
+
for (let s = stack.length - 1; s >= 0; s--) {
|
|
28
|
+
if (stack[s].part === item.parent) {
|
|
29
|
+
parentNode = stack[s];
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (!parentNode) {
|
|
35
|
+
while (stack.length > 1 && stack[stack.length - 1].depth >= depth) {
|
|
36
|
+
stack.pop();
|
|
37
|
+
}
|
|
38
|
+
parentNode = stack[stack.length - 1];
|
|
39
|
+
}
|
|
40
|
+
if (!node.parent && parentNode) {
|
|
41
|
+
node.parent = parentNode.part;
|
|
42
|
+
}
|
|
43
|
+
parentNode.children.push(node);
|
|
44
|
+
stack.push(node);
|
|
45
|
+
}
|
|
46
|
+
return root;
|
|
47
|
+
}
|
|
48
|
+
/** Format a ComputedLayout object into a readable inline description. */
|
|
49
|
+
export function formatLayoutDescription(layout) {
|
|
50
|
+
if (!layout)
|
|
51
|
+
return '';
|
|
52
|
+
const parts = [];
|
|
53
|
+
if (layout.display) {
|
|
54
|
+
const mode = layout.display;
|
|
55
|
+
const details = [];
|
|
56
|
+
if (layout.direction && layout.direction !== 'row')
|
|
57
|
+
details.push(layout.direction);
|
|
58
|
+
if (layout.wrap && layout.wrap !== 'nowrap')
|
|
59
|
+
details.push(layout.wrap);
|
|
60
|
+
if (layout.columns)
|
|
61
|
+
details.push(`cols: ${layout.columns}`);
|
|
62
|
+
if (layout.rows)
|
|
63
|
+
details.push(`rows: ${layout.rows}`);
|
|
64
|
+
if (layout.gap)
|
|
65
|
+
details.push(`gap: ${layout.gap}`);
|
|
66
|
+
else if (layout.rowGap || layout.columnGap) {
|
|
67
|
+
if (layout.rowGap)
|
|
68
|
+
details.push(`row-gap: ${layout.rowGap}`);
|
|
69
|
+
if (layout.columnGap)
|
|
70
|
+
details.push(`col-gap: ${layout.columnGap}`);
|
|
71
|
+
}
|
|
72
|
+
if (layout.justifyContent)
|
|
73
|
+
details.push(`justify: ${layout.justifyContent}`);
|
|
74
|
+
if (layout.alignItems)
|
|
75
|
+
details.push(`align: ${layout.alignItems}`);
|
|
76
|
+
if (layout.alignContent)
|
|
77
|
+
details.push(`align-content: ${layout.alignContent}`);
|
|
78
|
+
if (layout.autoFlow && layout.autoFlow !== 'row')
|
|
79
|
+
details.push(`flow: ${layout.autoFlow}`);
|
|
80
|
+
parts.push(`${mode}${details.length ? ` (${details.join(', ')})` : ''}`);
|
|
81
|
+
}
|
|
82
|
+
if (layout.parentLayout) {
|
|
83
|
+
const itemDetails = [];
|
|
84
|
+
if (layout.flex)
|
|
85
|
+
itemDetails.push(`flex: ${layout.flex}`);
|
|
86
|
+
else {
|
|
87
|
+
if (layout.flexGrow && layout.flexGrow !== '0')
|
|
88
|
+
itemDetails.push(`grow: ${layout.flexGrow}`);
|
|
89
|
+
if (layout.flexShrink && layout.flexShrink !== '1')
|
|
90
|
+
itemDetails.push(`shrink: ${layout.flexShrink}`);
|
|
91
|
+
if (layout.flexBasis && layout.flexBasis !== 'auto')
|
|
92
|
+
itemDetails.push(`basis: ${layout.flexBasis}`);
|
|
93
|
+
}
|
|
94
|
+
if (layout.gridColumn)
|
|
95
|
+
itemDetails.push(`col: ${layout.gridColumn}`);
|
|
96
|
+
if (layout.gridRow)
|
|
97
|
+
itemDetails.push(`row: ${layout.gridRow}`);
|
|
98
|
+
if (layout.alignSelf && layout.alignSelf !== 'auto')
|
|
99
|
+
itemDetails.push(`align-self: ${layout.alignSelf}`);
|
|
100
|
+
if (layout.justifySelf && layout.justifySelf !== 'auto')
|
|
101
|
+
itemDetails.push(`justify-self: ${layout.justifySelf}`);
|
|
102
|
+
if (layout.order && layout.order !== '0')
|
|
103
|
+
itemDetails.push(`order: ${layout.order}`);
|
|
104
|
+
if (itemDetails.length)
|
|
105
|
+
parts.push(itemDetails.join(', '));
|
|
106
|
+
}
|
|
107
|
+
return parts.join('; ');
|
|
108
|
+
}
|
|
109
|
+
/** Format a LayoutTreeNode hierarchy into markdown bullet tree lines. */
|
|
110
|
+
export function formatLayoutTree(tree, indent = '') {
|
|
111
|
+
const desc = formatLayoutDescription(tree.layout);
|
|
112
|
+
const line = `${indent}- **${tree.part}** (${tree.element})${desc ? ` — ${desc}` : ''}`;
|
|
113
|
+
const lines = [line];
|
|
114
|
+
for (const child of tree.children) {
|
|
115
|
+
lines.push(formatLayoutTree(child, `${indent} `));
|
|
116
|
+
}
|
|
117
|
+
return lines.join('\n');
|
|
118
|
+
}
|
|
119
|
+
/** Flatten a LayoutTreeNode hierarchy back into an array of nodes with depth and parent pointers. */
|
|
120
|
+
export function flattenLayoutTree(tree) {
|
|
121
|
+
const out = [];
|
|
122
|
+
const walk = (node) => {
|
|
123
|
+
out.push(node);
|
|
124
|
+
for (const child of node.children) {
|
|
125
|
+
walk(child);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
walk(tree);
|
|
129
|
+
return out;
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.js","sourceRoot":"","sources":["../../src/capture/layout.ts"],"names":[],"mappings":"AAcA,oGAAoG;AACpG,MAAM,UAAU,eAAe,CAAC,KAAiC;IAC/D,IAAI,CAAC,KAAK,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IAEpC,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC;IAC3B,MAAM,IAAI,GAAmB;QAC3B,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,KAAK,EAAE,CAAC;QACR,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACvD,QAAQ,EAAE,EAAE;KACb,CAAC;IAEF,MAAM,KAAK,GAAqB,CAAC,IAAI,CAAC,CAAC;IAEvC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC;QACvB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,MAAM,CAAC,EAAE,KAAK,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,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AAM,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QAClC,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,CAAC,CAAC;IACrD,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,qGAAqG;AACrG,MAAM,UAAU,iBAAiB,CAAC,IAAoB;IACpD,MAAM,GAAG,GAAqB,EAAE,CAAC;IACjC,MAAM,IAAI,GAAG,CAAC,IAAoB,EAAE,EAAE;QACpC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACf,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClC,IAAI,CAAC,KAAK,CAAC,CAAC;QACd,CAAC;IACH,CAAC,CAAC;IACF,IAAI,CAAC,IAAI,CAAC,CAAC;IACX,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type Capture, type ColorSystem, type SpacingSystem, type SystemConflict, type TypographySystem } from './schema.js';
|
|
2
|
+
export type SystemCapture = TypographySystem | ColorSystem | SpacingSystem;
|
|
3
|
+
export type SystemType = SystemCapture['meta']['type'];
|
|
4
|
+
/** The pages a system covers: a site-level system's own list, else its source page. */
|
|
5
|
+
export declare const pagesOf: (c: SystemCapture) => string[];
|
|
6
|
+
/** The site's root address ("https://example.com/"), the source of a site-level system. */
|
|
7
|
+
export declare function siteRoot(url: string): string;
|
|
8
|
+
export declare const isSystem: (c: Capture) => c is SystemCapture;
|
|
9
|
+
/**
|
|
10
|
+
* Basket items that can merge: single-page systems of one type on one site, from two pages or more.
|
|
11
|
+
* When a page was captured twice, its latest capture counts. Site-level systems are results, not inputs.
|
|
12
|
+
*/
|
|
13
|
+
export declare function mergeGroups<T extends {
|
|
14
|
+
capture: Capture;
|
|
15
|
+
}>(items: readonly T[]): {
|
|
16
|
+
site: string;
|
|
17
|
+
type: SystemType;
|
|
18
|
+
items: T[];
|
|
19
|
+
pages: string[];
|
|
20
|
+
}[];
|
|
21
|
+
/**
|
|
22
|
+
* Merge one system from several pages of a site into a site-level system. Throws when the systems
|
|
23
|
+
* are of different types or sites, or cover fewer than two pages.
|
|
24
|
+
*/
|
|
25
|
+
export declare function mergeSystems<T extends SystemCapture>(captures: readonly T[], options?: {
|
|
26
|
+
captured?: string;
|
|
27
|
+
}): T;
|
|
28
|
+
/**
|
|
29
|
+
* Merges a collection of typography, color, and spacing captures from multiple pages of a site.
|
|
30
|
+
* For each system type: if 2+ pages exist, runs mergeSystems; if 1 page exists, returns it; if 0, returns null.
|
|
31
|
+
*/
|
|
32
|
+
export declare function mergeSiteSystems(captures: readonly SystemCapture[], options?: {
|
|
33
|
+
captured?: string;
|
|
34
|
+
name?: string;
|
|
35
|
+
}): {
|
|
36
|
+
site: string;
|
|
37
|
+
pages: string[];
|
|
38
|
+
typography: TypographySystem | null;
|
|
39
|
+
color: ColorSystem | null;
|
|
40
|
+
spacing: SpacingSystem | null;
|
|
41
|
+
conflicts: {
|
|
42
|
+
type: SystemType;
|
|
43
|
+
conflict: SystemConflict;
|
|
44
|
+
}[];
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=merge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../src/capture/merge.ts"],"names":[],"mappings":"AAUA,OAAO,EAAe,KAAK,OAAO,EAAsB,KAAK,WAAW,EAAE,KAAK,aAAa,EAAE,KAAK,cAAc,EAAkB,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG9K,MAAM,MAAM,aAAa,GAAG,gBAAgB,GAAG,WAAW,GAAG,aAAa,CAAC;AAC3E,MAAM,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;AAIvD,uFAAuF;AACvF,eAAO,MAAM,OAAO,MAAO,aAAa,K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