@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.
Files changed (147) hide show
  1. package/LICENSE +21 -0
  2. package/dist/agents.d.ts +25 -0
  3. package/dist/agents.d.ts.map +1 -0
  4. package/dist/agents.js +36 -0
  5. package/dist/agents.js.map +1 -0
  6. package/dist/capture/baseline.d.ts +53 -0
  7. package/dist/capture/baseline.d.ts.map +1 -0
  8. package/dist/capture/baseline.js +400 -0
  9. package/dist/capture/baseline.js.map +1 -0
  10. package/dist/capture/check.d.ts +111 -0
  11. package/dist/capture/check.d.ts.map +1 -0
  12. package/dist/capture/check.js +327 -0
  13. package/dist/capture/check.js.map +1 -0
  14. package/dist/capture/collection.d.ts +2647 -0
  15. package/dist/capture/collection.d.ts.map +1 -0
  16. package/dist/capture/collection.js +103 -0
  17. package/dist/capture/collection.js.map +1 -0
  18. package/dist/capture/compare.d.ts +50 -0
  19. package/dist/capture/compare.d.ts.map +1 -0
  20. package/dist/capture/compare.js +167 -0
  21. package/dist/capture/compare.js.map +1 -0
  22. package/dist/capture/format.d.ts +59 -0
  23. package/dist/capture/format.d.ts.map +1 -0
  24. package/dist/capture/format.js +540 -0
  25. package/dist/capture/format.js.map +1 -0
  26. package/dist/capture/image.d.ts +42 -0
  27. package/dist/capture/image.d.ts.map +1 -0
  28. package/dist/capture/image.js +103 -0
  29. package/dist/capture/image.js.map +1 -0
  30. package/dist/capture/index.d.ts +18 -0
  31. package/dist/capture/index.d.ts.map +1 -0
  32. package/dist/capture/index.js +18 -0
  33. package/dist/capture/index.js.map +1 -0
  34. package/dist/capture/layout.d.ts +21 -0
  35. package/dist/capture/layout.d.ts.map +1 -0
  36. package/dist/capture/layout.js +131 -0
  37. package/dist/capture/layout.js.map +1 -0
  38. package/dist/capture/merge.d.ts +46 -0
  39. package/dist/capture/merge.d.ts.map +1 -0
  40. package/dist/capture/merge.js +251 -0
  41. package/dist/capture/merge.js.map +1 -0
  42. package/dist/capture/read.d.ts +91 -0
  43. package/dist/capture/read.d.ts.map +1 -0
  44. package/dist/capture/read.js +179 -0
  45. package/dist/capture/read.js.map +1 -0
  46. package/dist/capture/remap.d.ts +34 -0
  47. package/dist/capture/remap.d.ts.map +1 -0
  48. package/dist/capture/remap.js +227 -0
  49. package/dist/capture/remap.js.map +1 -0
  50. package/dist/capture/rule.d.ts +19 -0
  51. package/dist/capture/rule.d.ts.map +1 -0
  52. package/dist/capture/rule.js +39 -0
  53. package/dist/capture/rule.js.map +1 -0
  54. package/dist/capture/schema.d.ts +3020 -0
  55. package/dist/capture/schema.d.ts.map +1 -0
  56. package/dist/capture/schema.js +488 -0
  57. package/dist/capture/schema.js.map +1 -0
  58. package/dist/capture/spacingUnit.d.ts +32 -0
  59. package/dist/capture/spacingUnit.d.ts.map +1 -0
  60. package/dist/capture/spacingUnit.js +49 -0
  61. package/dist/capture/spacingUnit.js.map +1 -0
  62. package/dist/capture/stitch.d.ts +11 -0
  63. package/dist/capture/stitch.d.ts.map +1 -0
  64. package/dist/capture/stitch.js +382 -0
  65. package/dist/capture/stitch.js.map +1 -0
  66. package/dist/capture/tokensExport.d.ts +37 -0
  67. package/dist/capture/tokensExport.d.ts.map +1 -0
  68. package/dist/capture/tokensExport.js +355 -0
  69. package/dist/capture/tokensExport.js.map +1 -0
  70. package/dist/capture/values.d.ts +47 -0
  71. package/dist/capture/values.d.ts.map +1 -0
  72. package/dist/capture/values.js +155 -0
  73. package/dist/capture/values.js.map +1 -0
  74. package/dist/feedback/index.d.ts +7 -0
  75. package/dist/feedback/index.d.ts.map +1 -0
  76. package/dist/feedback/index.js +7 -0
  77. package/dist/feedback/index.js.map +1 -0
  78. package/dist/feedback/layoutPrompt.d.ts +26 -0
  79. package/dist/feedback/layoutPrompt.d.ts.map +1 -0
  80. package/dist/feedback/layoutPrompt.js +38 -0
  81. package/dist/feedback/layoutPrompt.js.map +1 -0
  82. package/dist/feedback/parts.d.ts +17 -0
  83. package/dist/feedback/parts.d.ts.map +1 -0
  84. package/dist/feedback/parts.js +50 -0
  85. package/dist/feedback/parts.js.map +1 -0
  86. package/dist/feedback/prompt.d.ts +13 -0
  87. package/dist/feedback/prompt.d.ts.map +1 -0
  88. package/dist/feedback/prompt.js +114 -0
  89. package/dist/feedback/prompt.js.map +1 -0
  90. package/dist/feedback/schema.d.ts +504 -0
  91. package/dist/feedback/schema.d.ts.map +1 -0
  92. package/dist/feedback/schema.js +236 -0
  93. package/dist/feedback/schema.js.map +1 -0
  94. package/dist/feedback/wireframePrompt.d.ts +9 -0
  95. package/dist/feedback/wireframePrompt.d.ts.map +1 -0
  96. package/dist/feedback/wireframePrompt.js +24 -0
  97. package/dist/feedback/wireframePrompt.js.map +1 -0
  98. package/dist/home.d.ts +13 -0
  99. package/dist/home.d.ts.map +1 -0
  100. package/dist/home.js +19 -0
  101. package/dist/home.js.map +1 -0
  102. package/dist/index.d.ts +13 -0
  103. package/dist/index.d.ts.map +1 -0
  104. package/dist/index.js +13 -0
  105. package/dist/index.js.map +1 -0
  106. package/dist/markdown/sections.d.ts +24 -0
  107. package/dist/markdown/sections.d.ts.map +1 -0
  108. package/dist/markdown/sections.js +58 -0
  109. package/dist/markdown/sections.js.map +1 -0
  110. package/dist/memory/activeTask.d.ts +25 -0
  111. package/dist/memory/activeTask.d.ts.map +1 -0
  112. package/dist/memory/activeTask.js +33 -0
  113. package/dist/memory/activeTask.js.map +1 -0
  114. package/dist/memory/brainJson.d.ts +44 -0
  115. package/dist/memory/brainJson.d.ts.map +1 -0
  116. package/dist/memory/brainJson.js +44 -0
  117. package/dist/memory/brainJson.js.map +1 -0
  118. package/dist/memory/decision.d.ts +30 -0
  119. package/dist/memory/decision.d.ts.map +1 -0
  120. package/dist/memory/decision.js +86 -0
  121. package/dist/memory/decision.js.map +1 -0
  122. package/dist/memory/layout.d.ts +41 -0
  123. package/dist/memory/layout.d.ts.map +1 -0
  124. package/dist/memory/layout.js +76 -0
  125. package/dist/memory/layout.js.map +1 -0
  126. package/dist/memory/proposed.d.ts +29 -0
  127. package/dist/memory/proposed.d.ts.map +1 -0
  128. package/dist/memory/proposed.js +63 -0
  129. package/dist/memory/proposed.js.map +1 -0
  130. package/dist/product.d.ts +17 -0
  131. package/dist/product.d.ts.map +1 -0
  132. package/dist/product.js +17 -0
  133. package/dist/product.js.map +1 -0
  134. package/dist/result.d.ts +17 -0
  135. package/dist/result.d.ts.map +1 -0
  136. package/dist/result.js +20 -0
  137. package/dist/result.js.map +1 -0
  138. package/dist/skills/contract.d.ts +137 -0
  139. package/dist/skills/contract.d.ts.map +1 -0
  140. package/dist/skills/contract.js +131 -0
  141. package/dist/skills/contract.js.map +1 -0
  142. package/dist/skills/frontmatter.d.ts +31 -0
  143. package/dist/skills/frontmatter.d.ts.map +1 -0
  144. package/dist/skills/frontmatter.js +214 -0
  145. package/dist/skills/frontmatter.js.map +1 -0
  146. package/package.json +31 -3
  147. package/README.md +0 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../../src/capture/collection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAY,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAE1D,OAAO,EAAiB,KAAK,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAIhF,iEAAiE;AACjE,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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E,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CAClC;AAED,+EAA+E;AAC/E,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC,gBAAgB,CAAC,CAiB3E"}
@@ -0,0 +1,103 @@
1
+ /**
2
+ * The basket export (FR18, FR19): several captures, from any pages and sites, in one file with
3
+ * `scope: collection`. Items are grouped by type; each keeps its own source page. Browser-safe.
4
+ */
5
+ import { z } from 'zod';
6
+ import { parseFrontmatter } from '../skills/frontmatter.js';
7
+ import { fail, ok } from '../result.js';
8
+ import { CAPTURE_EXTENSION, cleanSource, deeperHeadings, formatCapture, sourceText, toCaptureName } from './format.js';
9
+ import { captureSchema } from './schema.js';
10
+ const isoDate = z.string().regex(/^\d{4}-\d{2}-\d{2}$/);
11
+ /** One basket item: a capture plus the name the user gave it. */
12
+ export const basketItemSchema = z.object({
13
+ id: z.string().min(1),
14
+ /** The name shown in the basket and used as the item's heading; the user can rename it. */
15
+ name: z.string().trim().min(1),
16
+ addedAt: isoDate,
17
+ capture: captureSchema,
18
+ /** The file as the user edited it by hand in the toolbar; exports use it instead of the generated text. */
19
+ edited: z.string().min(1).optional()
20
+ });
21
+ export const collectionSchema = z.object({
22
+ name: z.string().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),
23
+ captured: isoDate,
24
+ items: z.array(basketItemSchema).min(1)
25
+ });
26
+ /** Groups in export order. */
27
+ export const COLLECTION_GROUPS = ['Sections', 'Components', 'Text', 'Colors', 'Spacing', 'Systems', 'Pages'];
28
+ export function groupOf(capture) {
29
+ if (capture.meta.scope === 'page')
30
+ return 'Pages';
31
+ if (capture.meta.scope === 'section')
32
+ return 'Sections';
33
+ if (capture.meta.scope === 'component')
34
+ return 'Components';
35
+ if (capture.meta.scope === 'system')
36
+ return 'Systems';
37
+ return capture.meta.type === 'text' ? 'Text' : capture.meta.type === 'color' ? 'Colors' : 'Spacing';
38
+ }
39
+ /** An item's body (the hand-edited text when there is one) without frontmatter, headings one level down. */
40
+ function bodyOf(item, settings) {
41
+ const text = (item.edited ?? formatCapture(item.capture, settings)).replace(/\r\n/g, '\n');
42
+ const body = text.replace(/^---\n[\s\S]*?\n---\n+/, '');
43
+ return deeperHeadings(body).trim();
44
+ }
45
+ /** The basket as one file, by name: luci-basket.collection.design.md. */
46
+ export const collectionFileName = (name) => `${toCaptureName(name)}.collection${CAPTURE_EXTENSION}`;
47
+ /** The basket export. Throws when the collection does not match its schema. */
48
+ export function formatCollection(collection, settings = {}) {
49
+ const c = collectionSchema.parse(collection);
50
+ const sources = [...new Set(c.items.map(i => sourceText(i.capture.meta.source, settings)))];
51
+ const lines = [
52
+ '---',
53
+ `name: ${c.name}`,
54
+ 'scope: collection',
55
+ `captured: ${c.captured}`,
56
+ `items: ${c.items.length}`,
57
+ `sources: [${sources.map(s => JSON.stringify(s)).join(', ')}]`,
58
+ '---',
59
+ ''
60
+ ];
61
+ for (const group of COLLECTION_GROUPS) {
62
+ // Within a group, items from the same page stay together, in the order they were added
63
+ const items = c.items.filter(i => groupOf(i.capture) === group);
64
+ if (!items.length)
65
+ continue;
66
+ const order = [...new Set(items.map(i => cleanSource(i.capture.meta.source)))];
67
+ items.sort((a, b) => order.indexOf(cleanSource(a.capture.meta.source)) - order.indexOf(cleanSource(b.capture.meta.source)));
68
+ lines.push(`# ${group}`, '');
69
+ for (const item of items) {
70
+ const m = item.capture.meta;
71
+ lines.push(`## ${item.name}`, `- source: ${sourceText(m.source, settings)}`, ...(m.selector ? [`- selector: \`${m.selector.replace(/`/g, "'")}\``] : []), `- type: ${m.scope} ${m.type} · method: ${m.method} · captured: ${m.captured}`, '', bodyOf(item, settings), '');
72
+ }
73
+ }
74
+ return `${lines.join('\n').trimEnd()}\n`;
75
+ }
76
+ /** Read a basket export: its frontmatter and that its item sections add up. */
77
+ export function parseCollection(text) {
78
+ const fm = parseFrontmatter(text);
79
+ if (!fm.hasFrontmatter || fm.data['scope'] !== 'collection')
80
+ return fail('not a collection file (scope: collection)');
81
+ const items = Number(fm.data['items']);
82
+ const sources = Array.isArray(fm.data['sources']) ? fm.data['sources'] : [];
83
+ const groups = {};
84
+ let group = null;
85
+ for (const line of fm.content.split('\n')) {
86
+ const g = /^# (.+)$/.exec(line);
87
+ const h = /^## (.+)$/.exec(line);
88
+ if (g) {
89
+ group = g[1].trim();
90
+ groups[group] = [];
91
+ }
92
+ else if (h && group)
93
+ groups[group].push(h[1].trim());
94
+ }
95
+ const counted = Object.values(groups).reduce((n, list) => n + list.length, 0);
96
+ if (!Number.isInteger(items) || items !== counted)
97
+ return fail(`collection says ${fm.data['items']} items but has ${counted}`);
98
+ const unknown = Object.keys(groups).filter(g => !COLLECTION_GROUPS.includes(g));
99
+ if (unknown.length)
100
+ return fail(`collection has unknown groups: ${unknown.join(', ')}`);
101
+ return ok({ name: String(fm.data['name'] ?? ''), captured: String(fm.data['captured'] ?? ''), items, sources, groups });
102
+ }
103
+ //# sourceMappingURL=collection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collection.js","sourceRoot":"","sources":["../../src/capture/collection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,EAAE,EAAoB,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACvH,OAAO,EAAE,aAAa,EAAsC,MAAM,aAAa,CAAC;AAEhF,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;AAExD,iEAAiE;AACjE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,EAAE,EAAE,CAAC,CAAC,MAAM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AAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;QAAC,CAAC;aAAM,IAAI,CAAC,IAAI,KAAK;YAAE,MAAM,CAAC,KAAK,CAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9G,CAAC;IACD,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAC9E,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,KAAK,OAAO;QAAE,OAAO,IAAI,CAAC,mBAAmB,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,kBAAkB,OAAO,EAAE,CAAC,CAAC;IAC/H,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAE,iBAAuC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IACvG,IAAI,OAAO,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC,kCAAkC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACxF,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;AAC1H,CAAC"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Compare mode (v0.4): two captures side by side (two sites' buttons, two pages' type scales) and
3
+ * every value that differs, in plain rows: what, A, B. Values are compared by meaning, the way the
4
+ * design check compares them (colors in any notation, lengths within half a pixel, rem at the root
5
+ * size). Component files compare from their text (readComponentFile and the check's own rules);
6
+ * captures in the toolbar compare from their values, at any scope. Pure and browser-safe.
7
+ */
8
+ import { type ParseResult } from '../result.js';
9
+ import type { Capture } from './schema.js';
10
+ export interface CompareRow {
11
+ /** What is compared: "container padding-top", "hover: label color", "heading-1 size". */
12
+ what: string;
13
+ /** As each side has it ("not set" when it has none). */
14
+ a: string;
15
+ b: string;
16
+ }
17
+ export interface CompareResult {
18
+ a: {
19
+ name: string;
20
+ type: string;
21
+ source: string;
22
+ };
23
+ b: {
24
+ name: string;
25
+ type: string;
26
+ source: string;
27
+ };
28
+ /** Everything compared that is the same on both. */
29
+ same: string[];
30
+ differences: CompareRow[];
31
+ }
32
+ /** Two component files (as saved), compared part by part: parts, styles, states, motion and accessibility. */
33
+ export declare function compareComponentFiles(a: string, b: string): ParseResult<CompareResult>;
34
+ /** One capture's values as rows: what -> value (with its token) and the property that says how to compare it. */
35
+ type Flat = Map<string, {
36
+ value: string;
37
+ token?: string | undefined;
38
+ property: string;
39
+ }>;
40
+ /** A capture's values, flat. */
41
+ export declare function flattenCapture(c: Capture): Flat;
42
+ /** Two captures from the toolbar (any scope), value by value. */
43
+ export declare function compareCaptures(a: Capture, b: Capture): CompareResult;
44
+ /** The comparison as Markdown: what was compared, how many values are the same, and a table of the differences. */
45
+ export declare function formatCompareReport(result: CompareResult, names?: {
46
+ a: string;
47
+ b: string;
48
+ }): string;
49
+ export {};
50
+ //# sourceMappingURL=compare.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compare.d.ts","sourceRoot":"","sources":["../../src/capture/compare.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAY,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAG1D,OAAO,KAAK,EAAE,OAAO,EAA2E,MAAM,aAAa,CAAC;AAEpH,MAAM,WAAW,UAAU;IACzB,yFAAyF;IACzF,IAAI,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,aAAa;IAC5B,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAClD,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAClD,oDAAoD;IACpD,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B;AAKD,8GAA8G;AAC9G,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC,aAAa,CAAC,CAiBtF;AAED,iHAAiH;AACjH,KAAK,IAAI,GAAG,GAAG,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAkDzF,gCAAgC;AAChC,wBAAgB,cAAc,CAAC,CAAC,EAAE,OAAO,GAAG,IAAI,CAgB/C;AAYD,iEAAiE;AACjE,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,aAAa,CAcrE;AAID,mHAAmH;AACnH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,EAAE,KAAK,GAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAA2C,GAAG,MAAM,CAc3I"}
@@ -0,0 +1,167 @@
1
+ /**
2
+ * Compare mode (v0.4): two captures side by side (two sites' buttons, two pages' type scales) and
3
+ * every value that differs, in plain rows: what, A, B. Values are compared by meaning, the way the
4
+ * design check compares them (colors in any notation, lengths within half a pixel, rem at the root
5
+ * size). Component files compare from their text (readComponentFile and the check's own rules);
6
+ * captures in the toolbar compare from their values, at any scope. Pure and browser-safe.
7
+ */
8
+ import { fail, ok } from '../result.js';
9
+ import { checkComponent, sameValue } from './check.js';
10
+ import { readComponentFile } from './read.js';
11
+ const NONE = 'not set';
12
+ const shown = (v) => (v.token ? `${v.value} (${v.token})` : v.value);
13
+ /** Two component files (as saved), compared part by part: parts, styles, states, motion and accessibility. */
14
+ export function compareComponentFiles(a, b) {
15
+ const left = readComponentFile(a);
16
+ if (!left.ok)
17
+ return fail(`The first file is not a component capture: ${left.error}`);
18
+ const right = readComponentFile(b);
19
+ if (!right.ok)
20
+ return fail(`The second file is not a component capture: ${right.error}`);
21
+ const check = checkComponent(left.value, right.value);
22
+ const meta = (m) => ({ name: m.name, type: m.type, source: m.source });
23
+ return ok({
24
+ a: meta(left.value.meta),
25
+ b: meta(right.value.meta),
26
+ same: check.matches,
27
+ differences: check.differences.map(d => ({
28
+ what: `${d.state ? `${d.state}: ` : ''}${d.kind === 'part' ? `part ${d.part}` : `${d.part} ${d.property}`}`,
29
+ a: d.expected === 'none' || d.expected === 'no change' ? (d.kind === 'part' ? 'none' : d.expected) : d.expected,
30
+ b: d.actual
31
+ }))
32
+ });
33
+ }
34
+ const put = (out, what, property, v) => {
35
+ if (v)
36
+ out.set(what, { value: v.computed, ...(v.token ? { token: v.token } : {}), property });
37
+ };
38
+ const TEXT_FIELDS = [
39
+ ['family', 'font-family'], ['size', 'font-size'], ['weight', 'font-weight'], ['lineHeight', 'line-height'], ['letterSpacing', 'letter-spacing'],
40
+ ['color', 'color'], ['style', 'font-style'], ['transform', 'text-transform'], ['decoration', 'text-decoration']
41
+ ];
42
+ const textStyle = (out, prefix, s) => { for (const [k, p] of TEXT_FIELDS)
43
+ put(out, `${prefix}${p}`, p, s[k]); };
44
+ function component(out, c, prefix = '') {
45
+ for (const p of c.anatomy) {
46
+ out.set(`${prefix}part ${p.part}`, { value: p.element, property: 'part' });
47
+ for (const s of p.styles)
48
+ put(out, `${prefix}${p.part} ${s.property}`, s.property, s.value);
49
+ }
50
+ for (const st of c.states) {
51
+ for (const ch of st.changes)
52
+ put(out, `${prefix}${st.state}: ${ch.part ?? 'container'} ${ch.property}`, ch.property, ch.to);
53
+ }
54
+ for (const m of c.motion) {
55
+ out.set(`${prefix}${m.part ?? 'container'} ${m.kind} ${m.target}`, { value: `${m.duration} ${m.easing}${m.delay ? ` ${m.delay}` : ''}`, property: 'transition' });
56
+ }
57
+ for (const x of c.accessibility?.contrast ?? [])
58
+ out.set(`${prefix}${x.part ?? 'container'} text contrast`, { value: `${x.ratio}:1 (${x.level})`, property: 'contrast' });
59
+ if (c.accessibility?.target)
60
+ out.set(`${prefix}target size`, { value: `${c.accessibility.target.width}x${c.accessibility.target.height}px (${c.accessibility.target.level})`, property: 'target' });
61
+ }
62
+ function section(out, c) {
63
+ for (const s of c.structure) {
64
+ out.set(`part ${s.part}`, { value: s.component ? `${s.element}, component ${s.component.name}${s.count ? ` x${s.count}` : ''}` : s.element, property: 'part' });
65
+ for (const st of s.styles)
66
+ put(out, `${s.part} ${st.property}`, st.property, st.value);
67
+ }
68
+ }
69
+ function system(out, c, prefix = '') {
70
+ const m = c.meta;
71
+ if (m.scope === 'system' && m.type === 'typography' && 'families' in c) {
72
+ for (const r of c.roles)
73
+ textStyle(out, `${prefix}${r.role} `, r.style);
74
+ out.set(`${prefix}font sizes`, { value: c.scale.map(s => s.size.computed).join(', '), property: 'list' });
75
+ }
76
+ else if (m.scope === 'system' && m.type === 'color' && 'tokens' in c && 'roles' in c) {
77
+ for (const role of ['background', 'text', 'border', 'accent']) {
78
+ const values = c.roles.filter(r => r.role === role).map(r => r.value.computed);
79
+ if (values.length)
80
+ out.set(`${prefix}${role} colors`, { value: values.join(', '), property: 'list' });
81
+ }
82
+ }
83
+ else if (m.scope === 'system' && m.type === 'spacing' && 'baseUnit' in c) {
84
+ out.set(`${prefix}spacing scale`, { value: c.scale.map(s => s.value.computed).join(', '), property: 'list' });
85
+ out.set(`${prefix}base unit`, { value: c.baseUnit ? `${c.baseUnit.px}px` : 'none', property: 'length' });
86
+ }
87
+ }
88
+ /** A capture's values, flat. */
89
+ export function flattenCapture(c) {
90
+ const out = new Map();
91
+ const m = c.meta;
92
+ if (m.scope === 'component')
93
+ component(out, c);
94
+ else if (m.scope === 'section')
95
+ section(out, c);
96
+ else if (m.scope === 'page') {
97
+ const p = c;
98
+ for (const s of [p.typography, p.color, p.spacing])
99
+ if (s)
100
+ system(out, s);
101
+ for (const k of p.components)
102
+ component(out, k, `${k.meta.name}: `);
103
+ }
104
+ else if (m.scope === 'system')
105
+ system(out, c);
106
+ else if (m.type === 'text' && 'style' in c)
107
+ textStyle(out, '', c.style);
108
+ else if (m.type === 'color' && 'value' in c)
109
+ put(out, 'color', 'color', c.value);
110
+ else if (m.type === 'color' && 'colors' in c)
111
+ for (const col of c.colors)
112
+ put(out, col.role ?? 'color', col.role ?? 'color', col.value);
113
+ else if (m.type === 'spacing' && 'values' in c)
114
+ for (const v of c.values)
115
+ put(out, v.property, v.property, v.value);
116
+ else if (m.type === 'spacing' && 'kind' in c)
117
+ put(out, c.property ?? c.kind, c.property ?? 'padding', c.value);
118
+ return out;
119
+ }
120
+ /** Same values, comparing lists item by item. */
121
+ function same(property, a, b) {
122
+ if (property === 'list') {
123
+ const x = a.split(', '), y = b.split(', ');
124
+ return x.length === y.length && x.every((v, i) => sameValue(/^(rgb|#|hsl|oklch)/.test(v) ? 'color' : 'width', v, y[i]));
125
+ }
126
+ if (property === 'part' || property === 'contrast' || property === 'target' || property === 'transition')
127
+ return a === b;
128
+ return sameValue(property, a, b);
129
+ }
130
+ /** Two captures from the toolbar (any scope), value by value. */
131
+ export function compareCaptures(a, b) {
132
+ const fa = flattenCapture(a), fb = flattenCapture(b);
133
+ const out = {
134
+ a: { name: a.meta.name, type: a.meta.type, source: a.meta.source },
135
+ b: { name: b.meta.name, type: b.meta.type, source: b.meta.source },
136
+ same: [],
137
+ differences: []
138
+ };
139
+ for (const what of new Set([...fa.keys(), ...fb.keys()])) {
140
+ const x = fa.get(what), y = fb.get(what);
141
+ if (x && y && same(x.property, x.value, y.value)) {
142
+ out.same.push(what);
143
+ continue;
144
+ }
145
+ out.differences.push({ what, a: x ? shown(x) : NONE, b: y ? shown(y) : NONE });
146
+ }
147
+ return out;
148
+ }
149
+ const cell = (text) => text.replace(/\|/g, '\\|').replace(/\s*\n\s*/g, ' ');
150
+ /** The comparison as Markdown: what was compared, how many values are the same, and a table of the differences. */
151
+ export function formatCompareReport(result, names = { a: result.a.name, b: result.b.name }) {
152
+ const d = result.differences;
153
+ const out = [
154
+ `# Compare: ${names.a} and ${names.b}`,
155
+ `- A: ${result.a.name} (${result.a.type}), from ${result.a.source}`,
156
+ `- B: ${result.b.name} (${result.b.type}), from ${result.b.source}`,
157
+ `- ${result.same.length} value${result.same.length === 1 ? ' is' : 's are'} the same; ${d.length} differ${d.length === 1 ? 's' : ''}.`
158
+ ];
159
+ if (d.length) {
160
+ out.push('', '| What | A | B |', '| --- | --- | --- |', ...d.map(r => `| ${cell(r.what)} | ${cell(r.a)} | ${cell(r.b)} |`));
161
+ }
162
+ else {
163
+ out.push('', 'No differences: every value compared is the same.');
164
+ }
165
+ return `${out.join('\n')}\n`;
166
+ }
167
+ //# sourceMappingURL=compare.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compare.js","sourceRoot":"","sources":["../../src/capture/compare.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,IAAI,EAAE,EAAE,EAAoB,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAmB9C,MAAM,IAAI,GAAG,SAAS,CAAC;AACvB,MAAM,KAAK,GAAG,CAAC,CAAgD,EAAE,EAAE,CAAC,CA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,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAC9H,CAAC;SAAM,CAAC;QACN,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,mDAAmD,CAAC,CAAC;IACpE,CAAC;IACD,OAAO,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,59 @@
1
+ import { type ParseResult } from '../result.js';
2
+ import { type Accessibility, type Capture, type CaptureMeta, type CaptureSettings, type Responsive, type SiteStack } from './schema.js';
3
+ export declare const CAPTURE_EXTENSION = ".design.md";
4
+ /** The sections every file of a scope and type has, in order. */
5
+ export declare const CAPTURE_SECTIONS: Readonly<Record<string, readonly string[]>>;
6
+ /** Every component file has these; "Variants" is added for the whole-system output. */
7
+ export declare const COMPONENT_SECTIONS: readonly string[];
8
+ /** Every section file (scope section) has these. */
9
+ export declare const SECTION_SECTIONS: readonly string[];
10
+ /** "https://www.example.com/pricing?x=1#top" -> "https://www.example.com/pricing". */
11
+ export declare function cleanSource(url: string): string;
12
+ /** "https://www.lattice.com/pricing?x=1" -> "lattice.com" (with the port for a local server). */
13
+ export declare function siteName(url: string): string;
14
+ /**
15
+ * The source as a file writes it: the page (origin and path) by default, or only the site's name
16
+ * with the "site" setting. A page without a host (a local file) keeps its address.
17
+ */
18
+ export declare const sourceText: (url: string, settings?: CaptureSettings) => string;
19
+ /** "https://www.example.com/x" -> "example-com"; a local file -> "local". */
20
+ export declare function siteSlug(url: string): string;
21
+ /**
22
+ * Flat file name: example-com.token.color-primary.design.md, example-com.system.typography.design.md;
23
+ * a site-level system (v0.3.3, with pages): example-com.system.site-typography.design.md.
24
+ */
25
+ export declare function captureFileName(meta: Pick<CaptureMeta, 'source' | 'scope' | 'name' | 'type'> & {
26
+ pages?: readonly string[] | undefined;
27
+ }): string;
28
+ /** A name slug from free text: "Heading 1" -> "heading-1". */
29
+ export declare const toCaptureName: (text: string) => string;
30
+ export declare const CONFLICTS_NOTE = "- The same role or token has different values on these pages. Decide which one the site means before building with it.";
31
+ export declare const ACCESSIBILITY_NOTE = "- Measured on this page against WCAG 2.2. Check again wherever the colors, sizes or focus styles differ.";
32
+ /** Accessibility notes as one table: contrast per text part, target size, focus visible. */
33
+ export declare function accessibilitySection(a: Accessibility, s: CaptureSettings): string[];
34
+ /** Screenshot mode (v0.4): what an estimated color system says about itself. */
35
+ export declare const ESTIMATED_IMAGE_NOTE = "- Estimated from an image: an image has no custom properties, and every color here is a guess from its pixels (Share is its share of the picture). Text styles and spacing cannot be read from an image.";
36
+ export declare const IMAGES_NOTE = "- These are slots for your own images, framed as above. No image file or URL is included.";
37
+ export declare function formatStack(stack: SiteStack): string[];
38
+ export declare const RESPONSIVE_NOTE = "- Read at each width with the page's own styles: values as rendered there, \u2013 where it is not set. Each width stands for its range, up to the next media query listed.";
39
+ /** How it changes by width: one row per part and property that differs, then the media queries. */
40
+ export declare function responsiveSection(r: Responsive, s: CaptureSettings): string[];
41
+ export declare const SECTION_NOTE = "- Each component is described once, in its own file (listed under Components); this file places them. A button or field inside another component has its own file too, for its states. Text parts give their text style only, never the text.";
42
+ /** Headings `levels` deeper ("## Roles" -> "### Roles"), so a part can sit inside a larger file. */
43
+ export declare const deeperHeadings: (text: string, levels?: number) => string;
44
+ export declare const INSTRUCTIONS_HEADING = "## Your instructions";
45
+ /**
46
+ * Put the user's instructions into a capture file's text (e.g. one edited by hand): replace the
47
+ * "## Your instructions" section, or add it right after the frontmatter. Empty text removes it.
48
+ */
49
+ export declare function withInstructions(markdown: string, text: string | undefined): string;
50
+ /** The file text for a capture. Throws when the capture does not match its schema. */
51
+ export declare function formatCapture(capture: Capture, settings?: CaptureSettings): string;
52
+ export interface ParsedCapture {
53
+ meta: CaptureMeta;
54
+ /** Section bodies by heading (without "## "). */
55
+ sections: Record<string, string>;
56
+ }
57
+ /** Read a capture file: valid frontmatter and every section its scope and type need. */
58
+ export declare function parseCapture(text: string): ParseResult<ParsedCapture>;
59
+ //# sourceMappingURL=format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/capture/format.ts"],"names":[],"mappings":"AAMA,OAAO,EAAY,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAIL,KAAK,aAAa,EAClB,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,eAAe,EAQpB,KAAK,UAAU,EASf,KAAK,SAAS,EACf,MAAM,aAAa,CAAC;AAIrB,eAAO,MAAM,iBAAiB,eAAe,CAAC;AAE9C,iEAAiE;AACjE,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAQxE,CAAC;AAEF,uFAAuF;AACvF,eAAO,MAAM,kBAAkB,EAAE,SAAS,MAAM,EAA8C,CAAC;AAC/F,oDAAoD;AACpD,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAA0C,CAAC;AAEzF,sFAAsF;AACtF,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAI/C;AAED,iGAAiG;AACjG,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED;;;GAGG;AACH,eAAO,MAAM,UAAU,QAAS,MAAM,aAAY,eAAe,WACiB,CAAC;AAEnF,6EAA6E;AAC7E,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK5C;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC,GAAG;IAAE,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAA;CAAE,GAAG,MAAM,CAGjJ;AAED,8DAA8D;AAC9D,eAAO,MAAM,aAAa,SAAU,MAAM,WAA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