@variance-authority/presentation 0.1.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/CHANGELOG.md +32 -0
- package/LICENSE +21 -0
- package/README.md +319 -0
- package/dist/alignment.d.ts +9 -0
- package/dist/alignment.js +100 -0
- package/dist/alignment.js.map +1 -0
- package/dist/analyze.d.ts +20 -0
- package/dist/analyze.js +132 -0
- package/dist/analyze.js.map +1 -0
- package/dist/browser-agent-entry.d.ts +2 -0
- package/dist/browser-agent-entry.js +8 -0
- package/dist/browser-agent-entry.js.map +1 -0
- package/dist/browser-agent.bundle.js +3587 -0
- package/dist/browser-agent.d.ts +37 -0
- package/dist/browser-agent.js +130 -0
- package/dist/browser-agent.js.map +1 -0
- package/dist/bundle.d.ts +3 -0
- package/dist/bundle.js +20 -0
- package/dist/bundle.js.map +1 -0
- package/dist/compare.d.ts +4 -0
- package/dist/compare.js +49 -0
- package/dist/compare.js.map +1 -0
- package/dist/findings.d.ts +5 -0
- package/dist/findings.js +285 -0
- package/dist/findings.js.map +1 -0
- package/dist/focus.d.ts +17 -0
- package/dist/focus.js +84 -0
- package/dist/focus.js.map +1 -0
- package/dist/graph.d.ts +11 -0
- package/dist/graph.js +145 -0
- package/dist/graph.js.map +1 -0
- package/dist/hierarchy.d.ts +4 -0
- package/dist/hierarchy.js +171 -0
- package/dist/hierarchy.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/math.d.ts +24 -0
- package/dist/math.js +124 -0
- package/dist/math.js.map +1 -0
- package/dist/measure.d.ts +15 -0
- package/dist/measure.js +216 -0
- package/dist/measure.js.map +1 -0
- package/dist/model.d.ts +346 -0
- package/dist/model.js +2 -0
- package/dist/model.js.map +1 -0
- package/dist/paint.d.ts +12 -0
- package/dist/paint.js +192 -0
- package/dist/paint.js.map +1 -0
- package/dist/patterns.d.ts +10 -0
- package/dist/patterns.js +148 -0
- package/dist/patterns.js.map +1 -0
- package/dist/playwright.d.ts +27 -0
- package/dist/playwright.js +108 -0
- package/dist/playwright.js.map +1 -0
- package/dist/report.d.ts +17 -0
- package/dist/report.js +126 -0
- package/dist/report.js.map +1 -0
- package/dist/spacing.d.ts +4 -0
- package/dist/spacing.js +112 -0
- package/dist/spacing.js.map +1 -0
- package/dist/telemetry.d.ts +4 -0
- package/dist/telemetry.js +73 -0
- package/dist/telemetry.js.map +1 -0
- package/mark.svg +30 -0
- package/package.json +62 -0
- package/skills/variance-presentation/SKILL.md +463 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyze.js","sourceRoot":"","sources":["../src/analyze.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,GAIZ,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAY7C;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CACjC,OAAmB,EACnB,OAAO,GAA+B,EAAE;IAExC,MAAM,OAAO,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;IACzC,MAAM,aAAa,GAAG,WAAW,CAAC,eAAe,CAAC,OAAO,CAAU,CAAC,CAAC;IACrE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;QAC5B,MAAM,IAAI,GAAG;YACX,aAAa,EAAE,CAAU;YACzB,aAAa;YACb,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,GAAG,OAAO,CAAC,OAAO,CAAC;YACnB,QAAQ,EAAE;gBACR,OAAO;gBACP,GA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AAQ,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC;QACzE,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,IAAI,WAAW,KAAK,EAAE,CAAC,CAAC,CAAC;IACzF,CAAC;AACH,CAAC","sourcesContent":["import {\n digestValue,\n type AccessibilitySnapshot,\n type RawCapture,\n type RawNode,\n} from '@variance-authority/core';\nimport { detectFindings } from './findings.js';\nimport { buildGraph } from './graph.js';\nimport { measureGraph } from './measure.js';\nimport type { PresentationReport } from './model.js';\nimport { paintInstructions } from './paint.js';\nimport { inferPatterns } from './patterns.js';\nimport { telemetryOf } from './telemetry.js';\n\nexport interface AnalyzePresentationOptions {\n /**\n * Browser-computed ARIA evidence observed beside this capture.\n *\n * Omit only when it was not observed. `roots: ['']` and partial roots are\n * readings and remain byte-for-byte present in the report.\n */\n readonly accessibility?: AccessibilitySnapshot;\n}\n\n/**\n * Derive machine-readable presentation relationships from one browser capture.\n *\n * Telemetry is descriptive and never creates a finding by itself. Findings are\n * limited to measured relationships; this function does not recommend a layout,\n * remove information, or produce an overall quality score.\n */\nexport function analyzePresentation(\n capture: RawCapture,\n options: AnalyzePresentationOptions = {},\n): PresentationReport {\n const anchors = semanticAnchors(capture);\n const contentDigest = digestValue(contentEvidence(capture) as never);\n if (!capture.profile.layout) {\n const body = {\n formatVersion: 1 as const,\n contentDigest,\n subject: capture.subject,\n ...fontsOf(capture),\n semantic: {\n anchors,\n ...(options.accessibility === undefined ? {} : { browserAccessibility: options.accessibility }),\n },\n telemetry: telemetryOf(capture, [], undefined),\n graph: { nodes: [], relations: [] },\n };\n return { ...body, digest: digestValue(body as never) };\n }\n assertLayout(capture);\n const graph = buildGraph(capture);\n const measured = measureGraph(graph);\n const inferred = inferPatterns(graph, measured);\n const findings = detectFindings(graph, measured, inferred.patterns);\n const relations = [...measured.relations, ...inferred.peerRelations];\n const paint = paintInstructions({\n nodes: measured.nodes,\n relations,\n axes: measured.axes,\n baselines: measured.baselines,\n prominence: measured.prominence,\n surfaces: measured.surfaces,\n patterns: inferred.patterns,\n findings,\n });\n const body = {\n formatVersion: 1 as const,\n contentDigest,\n subject: capture.subject,\n ...fontsOf(capture),\n semantic: {\n anchors,\n ...(options.accessibility === undefined ? {} : { browserAccessibility: options.accessibility }),\n },\n telemetry: telemetryOf(capture, measured.nodes, inferred.patterns),\n graph: { nodes: measured.nodes, relations },\n spacing: measured.spacing,\n axes: measured.axes,\n baselines: measured.baselines,\n prominence: measured.prominence,\n surfaces: measured.surfaces,\n patterns: inferred.patterns,\n findings,\n paint,\n };\n return { ...body, digest: digestValue(body as never) };\n}\n\n/**\n * Carry the caller-established font identities onto the report.\n *\n * The live entry accepts a `fonts` option and threads it into the capture, and\n * the capture is then analyzed and dropped — so through that door the option\n * had no observable consequence at all. It has one here. Fonts are a render\n * input of the more consequential kind: a substitution moves every metric on\n * the page without changing a byte of code, so a reading taken under different\n * pinned identities is a different reading and the digest says so.\n *\n * Sorted, because the order a caller happened to list them in is not part of\n * their identity — the same position `normalize` takes on the environment key.\n * Absent rather than empty when none were established, matching the capture,\n * which says the same thing a second way with its `unverified-fonts` caveat.\n * The content digest is deliberately untouched: font identity is presentation,\n * and content identity is what has to survive presentation moving.\n */\nfunction fontsOf(capture: RawCapture): { fonts?: readonly string[] } {\n const fonts = capture.environment.fonts;\n return fonts.length === 0 ? {} : { fonts: [...fonts].sort() };\n}\n\nfunction contentEvidence(capture: RawCapture): unknown {\n const read = (node: RawNode): unknown => ({\n tag: node.tag,\n ...(node.aria === undefined ? {} : { aria: node.aria }),\n ...(node.text === undefined ? {} : { text: node.text }),\n children: node.children.map(read),\n ...(node.shadowChildren === undefined ? {} : { shadowChildren: node.shadowChildren.map(read) }),\n });\n return {\n root: read(capture.root),\n ...(capture.portals === undefined ? {} : { portals: capture.portals.map(read) }),\n };\n}\n\nfunction semanticAnchors(capture: RawCapture): string[] {\n const anchors: string[] = [];\n [capture.root, ...(capture.portals ?? [])].forEach((root, rootIndex) => walk(root, rootIndex, '0'));\n return anchors;\n\n function walk(node: RawNode, root: number, path: string): void {\n if (\n node.tag !== '#text' &&\n node.aria !== undefined &&\n (node.aria.role !== null || node.aria.name !== null)\n ) {\n const role = node.aria?.role ?? node.tag;\n const name = node.aria?.name ?? '';\n anchors.push(`r${root}:${path} ${role}${name.length > 0 ? ` \"${name}\"` : ''}`);\n }\n node.children.forEach((child, index) => walk(child, root, `${path}/${index}`));\n node.shadowChildren?.forEach((child, index) => walk(child, root, `${path}/shadow:${index}`));\n }\n}\n\nfunction assertLayout(capture: RawCapture): void {\n [capture.root, ...(capture.portals ?? [])].forEach((root, rootIndex) => walk(root, `r${rootIndex}:0`));\n\n function walk(node: RawNode, path: string): void {\n if (node.tag !== '#text' && node.rect === undefined) {\n throw new Error(\n `the ${capture.profile.id} capture claims layout is observable but ${path} has no rect; ` +\n 'an absent measurement cannot be analyzed as an empty box',\n );\n }\n node.children.forEach((child, index) => walk(child, `${path}/${index}`));\n node.shadowChildren?.forEach((child, index) => walk(child, `${path}/shadow:${index}`));\n }\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { acquirePresentation, clearPresentationPaint, paintPresentation, PRESENTATION_AGENT, PRESENTATION_AGENT_VERSION, } from './browser-agent.js';
|
|
2
|
+
globalThis[PRESENTATION_AGENT] = {
|
|
3
|
+
acquire: acquirePresentation,
|
|
4
|
+
paint: paintPresentation,
|
|
5
|
+
clear: clearPresentationPaint,
|
|
6
|
+
version: PRESENTATION_AGENT_VERSION,
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=browser-agent-entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-agent-entry.js","sourceRoot":"","sources":["../src/browser-agent-entry.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,0BAA0B,GAE3B,MAAM,oBAAoB,CAAC;AAE3B,UAAoE,CAAC,kBAAkB,CAAC,GAAG;IAC1F,OAAO,EAAE,mBAAmB;IAC5B,KAAK,EAAE,iBAAiB;IACxB,KAAK,EAAE,sBAAsB;IAC7B,OAAO,EAAE,0BAA0B;CACpC,CAAC","sourcesContent":["import {\n acquirePresentation,\n clearPresentationPaint,\n paintPresentation,\n PRESENTATION_AGENT,\n PRESENTATION_AGENT_VERSION,\n type InstalledPresentationAgent,\n} from './browser-agent.js';\n\n(globalThis as unknown as Record<string, InstalledPresentationAgent>)[PRESENTATION_AGENT] = {\n acquire: acquirePresentation,\n paint: paintPresentation,\n clear: clearPresentationPaint,\n version: PRESENTATION_AGENT_VERSION,\n};\n"]}
|