@ingcreators/annot-product-docs 0.2.0 → 0.3.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.
@@ -0,0 +1,91 @@
1
+ import { BboxAnnotation, BboxNumberedBadgeAnnotation } from '@ingcreators/annot-annotator';
2
+ import { OverlaySpec } from './types.js';
3
+ /** A parsed entry of an aria-snapshot YAML line carrying both a
4
+ * `[ref=…]` marker and a `[box=x,y,w,h]` marker. */
5
+ export interface BoxedEntry {
6
+ role: string;
7
+ name: string;
8
+ ref: string;
9
+ box: {
10
+ x: number;
11
+ y: number;
12
+ width: number;
13
+ height: number;
14
+ };
15
+ }
16
+ /**
17
+ * Parse aria-snapshot YAML for entries that carry both `[ref=…]`
18
+ * and `[box=x,y,w,h]` markers. `box` is the Playwright addition
19
+ * available when `ariaSnapshot({ boxes: true })` was passed.
20
+ *
21
+ * Exposed for unit testing. Returns an empty array if no entries
22
+ * have boxes — callers fall back to a non-annotated render.
23
+ */
24
+ export declare function parseSnapshotBoxes(yaml: string): BoxedEntry[];
25
+ /**
26
+ * Resolve a screen's `<Overlay match>` blocks against the parsed
27
+ * `BoxedEntry[]` from its snapshot YAML, emitting typed
28
+ * `BboxNumberedBadgeAnnotation`s ready for
29
+ * `createAnnotator().toPng()` / `.toEditablePng()`.
30
+ *
31
+ * Overlays with no matching boxed entry are skipped silently —
32
+ * the drift detector (`detectDrift`) surfaces those upstream.
33
+ */
34
+ export declare function buildBadgeAnnotations(overlays: readonly OverlaySpec[], boxed: readonly BoxedEntry[], dims: {
35
+ width: number;
36
+ height: number;
37
+ }): BboxNumberedBadgeAnnotation[];
38
+ /**
39
+ * Resolve the `<Overlay>` blocks inside `screenId` against the MDX
40
+ * file's stored `annot:snapshot` block and return a typed
41
+ * annotation array ready to feed into
42
+ * `createAnnotator().toEditablePng()`.
43
+ *
44
+ * Used by the Playwright screenshot hook (Tier C) and the Astro
45
+ * Image Service (Tier B-render). Throws the same diagnostics
46
+ * `renderAnnotatedScreen` would (no annot frontmatter / no
47
+ * matching `<Screen id>`).
48
+ *
49
+ * Returns an empty array when no `<Overlay>` matches a bbox marker
50
+ * — e.g. the snapshot was never captured, or `<Overlay match>`
51
+ * targets an element that's no longer in the page.
52
+ */
53
+ export declare function resolveMdxAnnotations(opts: {
54
+ mdxPath: string;
55
+ screenId: string;
56
+ dims: {
57
+ width: number;
58
+ height: number;
59
+ };
60
+ cwd?: string;
61
+ }): Promise<BboxNumberedBadgeAnnotation[]>;
62
+ /**
63
+ * Wrap a `BboxNumberedBadgeAnnotation[]` (or any compatible badge
64
+ * subset) into a single-root `<svg>` ready for the annotator's
65
+ * `annotationsSvg` input.
66
+ *
67
+ * Mirrors the more general `svgFromBboxAnnotations` below but
68
+ * stays specifically typed to the badge shape so the Astro Image
69
+ * Service's `buildBadgeAnnotations()` output flows in without an
70
+ * extra cast.
71
+ */
72
+ export declare function svgFromBadges(badges: BboxNumberedBadgeAnnotation[]): string;
73
+ /**
74
+ * Wrap a generic `BboxAnnotation[]` (the union DSL accepted by
75
+ * `@ingcreators/annot-annotator`) into a single-root `<svg>` ready
76
+ * for the annotator's `annotationsSvg` input. Mirrors `svgFromBadges`
77
+ * but stays type-permissive — the Playwright fixture's inline
78
+ * overlays can be any `BboxAnnotation` shape, not just numbered
79
+ * badges.
80
+ *
81
+ * Returns the empty wrapper `<svg/>` when `annotations` is empty —
82
+ * lets the editor open the file with no annotations layer rather
83
+ * than throwing.
84
+ */
85
+ export declare function svgFromBboxAnnotations(annotations: BboxAnnotation[]): string;
86
+ /**
87
+ * Minimal SVG fragment for the "editable wrap, no overlays" case.
88
+ * The editor's import path reads `annotationsSvg` from the XMP and
89
+ * reconstructs an empty annotations layer — fine to be wrapper-only.
90
+ */
91
+ export declare function emptyAnnotationsSvg(): string;
@@ -0,0 +1,17 @@
1
+ declare module "@ingcreators/annot-playwright" {
2
+ interface AnnotScreenshotOptions {
3
+ /**
4
+ * Refresh the MDX `annot:snapshot` block and resolve the
5
+ * `<Screen id>`'s `<Overlay>` blocks into bbox-keyed badge
6
+ * annotations. The MDX file is rewritten in-place with the
7
+ * current page's aria-snapshot before overlays resolve, so a
8
+ * single `page.screenshot({ annot: { mdx } })` call covers the
9
+ * "refresh + capture + bake + write" pipeline.
10
+ */
11
+ mdx?: {
12
+ id: string;
13
+ path: string;
14
+ };
15
+ }
16
+ }
17
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ingcreators/annot-product-docs",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Living product docs core — parse `.mdx` files with `annot:` frontmatter, resolve `<Overlay match>` keys against live Playwright `aria-snapshot` trees, run drift detection against the rendered UI, and ship a Playwright `screen` fixture that re-captures + re-syncs MDX snapshot blocks. Tier A (Node-only). Phase 1 of docs/plans/living-product-docs.md.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "ingcreators",
@@ -66,7 +66,7 @@
66
66
  "unist-util-visit": "^5.0.0",
67
67
  "zod": "^3.25.0",
68
68
  "@ingcreators/annot-annotator": "0.5.0",
69
- "@ingcreators/annot-playwright": "0.3.1"
69
+ "@ingcreators/annot-playwright": "0.4.0"
70
70
  },
71
71
  "peerDependencies": {
72
72
  "@playwright/test": "^1.40.0"