@ingcreators/annot-product-docs 0.3.0 → 0.4.1

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/dist/config.d.ts CHANGED
@@ -5,62 +5,20 @@ export declare const annotFrontmatterSchema: z.ZodObject<{
5
5
  title: z.ZodOptional<z.ZodString>;
6
6
  purpose: z.ZodOptional<z.ZodString>;
7
7
  meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
8
- xlsx: z.ZodOptional<z.ZodEffects<z.ZodObject<{
8
+ xlsx: z.ZodOptional<z.ZodObject<{
9
9
  book: z.ZodOptional<z.ZodString>;
10
10
  sheet: z.ZodOptional<z.ZodString>;
11
11
  sheets: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
12
- role: z.ZodOptional<z.ZodEnum<["cover", "history", "list", "screen", "reference"]>>;
12
+ role: z.ZodOptional<z.ZodEnum<{
13
+ screen: "screen";
14
+ cover: "cover";
15
+ history: "history";
16
+ list: "list";
17
+ reference: "reference";
18
+ }>>;
13
19
  order: z.ZodOptional<z.ZodNumber>;
14
- }, "strict", z.ZodTypeAny, {
15
- book?: string | undefined;
16
- sheet?: string | undefined;
17
- sheets?: Record<string, string> | undefined;
18
- role?: "screen" | "cover" | "history" | "list" | "reference" | undefined;
19
- order?: number | undefined;
20
- }, {
21
- book?: string | undefined;
22
- sheet?: string | undefined;
23
- sheets?: Record<string, string> | undefined;
24
- role?: "screen" | "cover" | "history" | "list" | "reference" | undefined;
25
- order?: number | undefined;
26
- }>, {
27
- book?: string | undefined;
28
- sheet?: string | undefined;
29
- sheets?: Record<string, string> | undefined;
30
- role?: "screen" | "cover" | "history" | "list" | "reference" | undefined;
31
- order?: number | undefined;
32
- }, {
33
- book?: string | undefined;
34
- sheet?: string | undefined;
35
- sheets?: Record<string, string> | undefined;
36
- role?: "screen" | "cover" | "history" | "list" | "reference" | undefined;
37
- order?: number | undefined;
38
- }>>;
39
- }, "strict", z.ZodTypeAny, {
40
- id: string;
41
- title?: string | undefined;
42
- purpose?: string | undefined;
43
- meta?: Record<string, unknown> | undefined;
44
- xlsx?: {
45
- book?: string | undefined;
46
- sheet?: string | undefined;
47
- sheets?: Record<string, string> | undefined;
48
- role?: "screen" | "cover" | "history" | "list" | "reference" | undefined;
49
- order?: number | undefined;
50
- } | undefined;
51
- }, {
52
- id: string;
53
- title?: string | undefined;
54
- purpose?: string | undefined;
55
- meta?: Record<string, unknown> | undefined;
56
- xlsx?: {
57
- book?: string | undefined;
58
- sheet?: string | undefined;
59
- sheets?: Record<string, string> | undefined;
60
- role?: "screen" | "cover" | "history" | "list" | "reference" | undefined;
61
- order?: number | undefined;
62
- } | undefined;
63
- }>;
20
+ }, z.core.$strict>>;
21
+ }, z.core.$strict>;
64
22
  export declare const annotDocsConfigSchema: z.ZodObject<{
65
23
  meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
66
24
  xlsx: z.ZodOptional<z.ZodObject<{
@@ -73,94 +31,18 @@ export declare const annotDocsConfigSchema: z.ZodObject<{
73
31
  list: z.ZodOptional<z.ZodString>;
74
32
  screen: z.ZodOptional<z.ZodString>;
75
33
  reference: z.ZodOptional<z.ZodString>;
76
- }, "strict", z.ZodTypeAny, {
77
- screen?: string | undefined;
78
- cover?: string | undefined;
79
- history?: string | undefined;
80
- list?: string | undefined;
81
- reference?: string | undefined;
82
- }, {
83
- screen?: string | undefined;
84
- cover?: string | undefined;
85
- history?: string | undefined;
86
- list?: string | undefined;
87
- reference?: string | undefined;
88
- }>>;
89
- }, "strict", z.ZodTypeAny, {
90
- template?: string | undefined;
91
- templateSheets?: {
92
- screen?: string | undefined;
93
- cover?: string | undefined;
94
- history?: string | undefined;
95
- list?: string | undefined;
96
- reference?: string | undefined;
97
- } | undefined;
98
- }, {
99
- template?: string | undefined;
100
- templateSheets?: {
101
- screen?: string | undefined;
102
- cover?: string | undefined;
103
- history?: string | undefined;
104
- list?: string | undefined;
105
- reference?: string | undefined;
106
- } | undefined;
107
- }>>>;
108
- }, "strict", z.ZodTypeAny, {
109
- defaultBook?: string | undefined;
110
- books?: Record<string, {
111
- template?: string | undefined;
112
- templateSheets?: {
113
- screen?: string | undefined;
114
- cover?: string | undefined;
115
- history?: string | undefined;
116
- list?: string | undefined;
117
- reference?: string | undefined;
118
- } | undefined;
119
- }> | undefined;
120
- }, {
121
- defaultBook?: string | undefined;
122
- books?: Record<string, {
123
- template?: string | undefined;
124
- templateSheets?: {
125
- screen?: string | undefined;
126
- cover?: string | undefined;
127
- history?: string | undefined;
128
- list?: string | undefined;
129
- reference?: string | undefined;
130
- } | undefined;
131
- }> | undefined;
132
- }>>;
133
- }, "strict", z.ZodTypeAny, {
134
- meta?: Record<string, unknown> | undefined;
135
- xlsx?: {
136
- defaultBook?: string | undefined;
137
- books?: Record<string, {
138
- template?: string | undefined;
139
- templateSheets?: {
140
- screen?: string | undefined;
141
- cover?: string | undefined;
142
- history?: string | undefined;
143
- list?: string | undefined;
144
- reference?: string | undefined;
145
- } | undefined;
146
- }> | undefined;
147
- } | undefined;
148
- }, {
149
- meta?: Record<string, unknown> | undefined;
150
- xlsx?: {
151
- defaultBook?: string | undefined;
152
- books?: Record<string, {
153
- template?: string | undefined;
154
- templateSheets?: {
155
- screen?: string | undefined;
156
- cover?: string | undefined;
157
- history?: string | undefined;
158
- list?: string | undefined;
159
- reference?: string | undefined;
160
- } | undefined;
161
- }> | undefined;
162
- } | undefined;
163
- }>;
34
+ }, z.core.$strict>>;
35
+ }, z.core.$strict>>>;
36
+ }, z.core.$strict>>;
37
+ editor: z.ZodOptional<z.ZodObject<{
38
+ embedMode: z.ZodOptional<z.ZodEnum<{
39
+ newTab: "newTab";
40
+ inline: "inline";
41
+ disabled: "disabled";
42
+ }>>;
43
+ cloudUrl: z.ZodOptional<z.ZodString>;
44
+ }, z.core.$strict>>;
45
+ }, z.core.$strict>;
164
46
  /**
165
47
  * Identity-with-validation helper.
166
48
  *
@@ -171,7 +53,7 @@ export declare const annotDocsConfigSchema: z.ZodObject<{
171
53
  * dropped by `tsc`'s structural matching.
172
54
  */
173
55
  export declare function defineConfig(config: AnnotDocsConfig): AnnotDocsConfig;
174
- export type { AnnotDocsConfig, AnnotFrontmatter, BookConfig, } from './types-config.js';
56
+ export type { AnnotDocsConfig, AnnotEditorConfig, AnnotFrontmatter, BookConfig, } from './types-config.js';
175
57
  /**
176
58
  * Convenience guard: does this AnnotFrontmatter declare a
177
59
  * `screen` role? Useful for filtering MDXs that have `<Screen>`
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Soft-deprecation shim for the legacy inline `<Overlay>` JSX
3
+ * form. Phase 2e of `docs/plans/living-spec-authoring-roadmap.md`.
4
+ *
5
+ * Policy (per OQ-08 of the roadmap):
6
+ *
7
+ * - Phase 2e (this module) — Build / lint paths emit a deduped
8
+ * warning when they encounter a `<Screen>` block whose overlays
9
+ * live inline as `<Overlay>` children rather than yaml + AnnotCallout.
10
+ * The warning points at `annot docs migrate-overlays-to-annotations`
11
+ * so authors can fix it with one command.
12
+ *
13
+ * - Removal target: ~3 months / 2-3 release cycles after Phase 2e
14
+ * lands, tracked in [the roadmap](../../../docs/plans/living-spec-authoring-roadmap.md)
15
+ * timeline. Removal is its own PR that deletes:
16
+ * - `OverlaySpec` from `./types.ts`
17
+ * - `Overlay.astro` from `@ingcreators/annot-product-docs-astro`
18
+ * - The inline-`<Overlay>` walker branch in `./mdx.ts`
19
+ * - The legacy path in `renderAnnotatedScreen` (yaml becomes
20
+ * the only renderer input)
21
+ *
22
+ * Until then, both forms work. The warning is `console.warn`-only
23
+ * — it doesn't fail the build by default (CI gating happens at
24
+ * `annot docs lint --ci`, not at Astro build time).
25
+ */
26
+ export interface LegacyOverlayUsage {
27
+ /** Absolute MDX path (or any stable identifier the caller has). */
28
+ mdxPath: string;
29
+ /** `<Screen id>` of the block using the legacy form. */
30
+ screenId: string;
31
+ /** Number of `<Overlay>` children seen on the screen. */
32
+ overlayCount: number;
33
+ }
34
+ /**
35
+ * Emit the deprecation warning. No-op when the same
36
+ * `(mdxPath, screenId)` pair has already warned in this process.
37
+ *
38
+ * The caller (Astro Image Service, lint CLI) decides WHEN to
39
+ * call this — typically when it sees `screen.overlays.length > 0
40
+ * && screen.annotations === undefined`.
41
+ *
42
+ * @param emit Optional warning emitter. Defaults to `console.warn`
43
+ * so the message lands on whichever transport the
44
+ * host already wires up (Astro logs / CLI stderr / etc.).
45
+ * Tests inject a spy.
46
+ */
47
+ export declare function warnLegacyOverlay(usage: LegacyOverlayUsage, emit?: (line: string) => void): void;
48
+ /**
49
+ * Render the warning message. Exported so tests + bespoke
50
+ * formatters (CI / GitHub Annotations / etc.) can drive it
51
+ * without going through `console.warn`.
52
+ */
53
+ export declare function formatLegacyOverlayWarning(usage: LegacyOverlayUsage): string;
54
+ /**
55
+ * Test-only: reset the per-process dedup cache. Lets tests
56
+ * exercise the dedup path with a clean slate.
57
+ */
58
+ export declare function _resetLegacyOverlayDedupForTests(): void;
package/dist/drift.d.ts CHANGED
@@ -1,7 +1,9 @@
1
+ import { ElementTree } from '@ingcreators/annot-core';
2
+ import { AnnotationSpec, OverlayEntry } from './annotations-yaml.js';
1
3
  import { SnapshotEntry } from './resolver.js';
2
4
  import { MatchKey, ScreenSpec } from './types.js';
3
5
  export type DriftSeverity = "error" | "warning" | "info";
4
- export type DriftKind = "added" | "removed" | "renamed" | "role-changed" | "duplicated" | "attribute-drift";
6
+ export type DriftKind = "added" | "removed" | "renamed" | "role-changed" | "duplicated" | "attribute-drift" | "description-missing" | "description-orphan";
5
7
  export interface DriftFinding {
6
8
  severity: DriftSeverity;
7
9
  kind: DriftKind;
@@ -25,6 +27,43 @@ export interface DetectDriftOptions {
25
27
  storedAttributesYaml?: string;
26
28
  /** Optional verbatim YAML of the freshly-captured attributes. */
27
29
  freshAttributesYaml?: string;
30
+ /**
31
+ * Phase 2c of `docs/plans/living-spec-authoring-roadmap.md`.
32
+ * When the screen carries `annotations="…"`, callers parse the
33
+ * yaml and pass its overlays here. The detector then:
34
+ * - Pulls match keys from this list instead of
35
+ * `screen.overlays` for the match-cycle (removed / renamed /
36
+ * role-changed / duplicated / added).
37
+ * - Emits new cross-ref findings: `description-missing` (yaml
38
+ * id has no `<AnnotCallout for>`) and `description-orphan`
39
+ * (`<AnnotCallout for>` references a yaml id that doesn't
40
+ * exist).
41
+ * Independent of `screen.overlays`: the legacy inline path stays
42
+ * inert when this is set.
43
+ */
44
+ yamlOverlays?: readonly OverlayEntry[];
45
+ /**
46
+ * Phase 3d of `docs/plans/living-spec-authoring-roadmap.md`.
47
+ * Optional sibling to {@link yamlOverlays} for the Phase 3
48
+ * `annotations[]` palette (rect / circle / arrow / text /
49
+ * callout / freehand / redact / focusMask). The detector walks
50
+ * the match keys reachable from each variant via
51
+ * {@link collectMatchKeysFromAnnotation} and feeds them through
52
+ * the same match-cycle as the overlays (`removed` / `renamed` /
53
+ * `role-changed` / `duplicated`). Free-coord entries
54
+ * (`bbox` / `point` / `at` / `path` / `center`) contribute zero
55
+ * match keys and are silently skipped.
56
+ *
57
+ * `annotations[]` IDs are NEVER referenced from `<AnnotCallout for>`
58
+ * — they're self-contained visual marking — so no
59
+ * `description-missing` / `description-orphan` findings fire for
60
+ * this source.
61
+ *
62
+ * Findings from this source attach a `match` derived from the
63
+ * annotation entry so authors can trace which annotation's match
64
+ * key triggered the finding.
65
+ */
66
+ yamlAnnotations?: readonly AnnotationSpec[];
28
67
  }
29
68
  /**
30
69
  * Compute the drift findings for one `<Screen>` block.
@@ -53,6 +92,45 @@ export declare function detectDriftFromYaml(args: {
53
92
  liveSnapshotYaml: string;
54
93
  storedAttributesYaml?: string;
55
94
  freshAttributesYaml?: string;
95
+ /** Phase 2c. See {@link DetectDriftOptions.yamlOverlays}. */
96
+ yamlOverlays?: readonly OverlayEntry[];
97
+ /** Phase 3d. See {@link DetectDriftOptions.yamlAnnotations}. */
98
+ yamlAnnotations?: readonly AnnotationSpec[];
99
+ }): DriftFinding[];
100
+ /**
101
+ * Convert an `ElementTree` (Phase 1a of
102
+ * `docs/plans/living-spec-authoring-roadmap.md`) into the
103
+ * `SnapshotEntry[]` shape the drift detector consumes. Pure data
104
+ * transform — walks the tree depth-first, emits one entry per node
105
+ * that has both `role` and `name` (decorative containers and
106
+ * synthetic roots are skipped, matching the legacy parser's filter).
107
+ *
108
+ * Phase 1i. Exposed for tests + callers that want to construct
109
+ * adapters in front of the existing `detectDrift` API without
110
+ * paying the YAML detour.
111
+ */
112
+ export declare function elementTreeToSnapshotEntries(tree: ElementTree): SnapshotEntry[];
113
+ /**
114
+ * Drift detection driven by an `ElementTree` (the canonical
115
+ * screen-capture model from Phase 1a) instead of the legacy
116
+ * YAML-parsed `SnapshotEntry[]`. Internally converts the tree
117
+ * via `elementTreeToSnapshotEntries` and dispatches to
118
+ * `detectDrift` — both paths produce identical findings for
119
+ * equivalent inputs.
120
+ *
121
+ * Phase 1i. Lets the CLI's `lint` flow consume the new PNG XMP
122
+ * `annot:elementTree` chunk directly (via `readElementTreePng`)
123
+ * without round-tripping through Playwright YAML.
124
+ */
125
+ export declare function detectDriftFromElementTree(args: {
126
+ screen: ScreenSpec;
127
+ liveElementTree: ElementTree;
128
+ storedAttributesYaml?: string;
129
+ freshAttributesYaml?: string;
130
+ /** Phase 2c. See {@link DetectDriftOptions.yamlOverlays}. */
131
+ yamlOverlays?: readonly OverlayEntry[];
132
+ /** Phase 3d. See {@link DetectDriftOptions.yamlAnnotations}. */
133
+ yamlAnnotations?: readonly AnnotationSpec[];
56
134
  }): DriftFinding[];
57
135
  /**
58
136
  * Summarise findings by severity. Used by the CLI to decide an
@@ -65,8 +143,10 @@ export declare function summariseDrift(findings: DriftFinding[]): {
65
143
  };
66
144
  /**
67
145
  * A `<Screen>` is drift-checkable when it has at least one
68
- * `<Overlay>`. Files without `<Screen>` blocks (cover / history /
69
- * list / reference MDXs) are skipped by the lint walker.
146
+ * `<Overlay>` (legacy form), an `annotations` ref (yaml form), or
147
+ * an `<AnnotCallout>` (yaml form, in case the author wrote callouts
148
+ * before the yaml). Files without `<Screen>` blocks (cover / history
149
+ * / list / reference MDXs) are skipped by the lint walker.
70
150
  */
71
151
  export declare function isLintableScreen(screen: ScreenSpec): boolean;
72
152
  /**
@@ -75,3 +155,18 @@ export declare function isLintableScreen(screen: ScreenSpec): boolean;
75
155
  * "skipped cover.mdx" path cheap.
76
156
  */
77
157
  export declare function lintableScreens(screens: ScreenSpec[]): ScreenSpec[];
158
+ /**
159
+ * Walk an `AnnotationSpec` and emit every `MatchKey` reachable
160
+ * from its match-anchored fields. Free-coord variants
161
+ * (bbox-only rect / center-only circle / point-only arrow
162
+ * endpoint / `at`-only text / bbox-only callout target / freehand /
163
+ * bbox-only redact / bbox-only focusMask cutout) contribute zero
164
+ * keys.
165
+ *
166
+ * Phase 3d of `docs/plans/living-spec-authoring-roadmap.md`.
167
+ * Exposed publicly so callers (the CLI, alternative drift
168
+ * detectors, future editor surfaces) can resolve the match keys
169
+ * a Phase 3a `AnnotationSpec[]` exposes without duplicating the
170
+ * per-variant traversal.
171
+ */
172
+ export declare function collectMatchKeysFromAnnotation(spec: AnnotationSpec): MatchKey[];
package/dist/index.d.ts CHANGED
@@ -1,14 +1,20 @@
1
+ export type { AnnotationBBox, AnnotationKind, AnnotationPoint, AnnotationSpec, AnnotationStyleFields, AnnotationsFile, ArrowAnnotation, ArrowEndpoint, CalloutAnnotation, CalloutTarget, CircleAnnotation, FocusMaskAnnotation, FocusMaskCutout, FreehandAnnotation, OverlayEntry, RectAnnotation, RedactAnnotation, RedactAnnotationStyle, TextAnchorPosition, TextAnnotation, } from './annotations-yaml.js';
2
+ export { ANNOTATION_KINDS, ANNOTATIONS_YAML_VERSION, AnnotationsYamlError, parseAnnotationsYaml, serializeAnnotationsYaml, } from './annotations-yaml.js';
1
3
  export { filterAnnotMdxFiles, main, walkMdx, } from './cli.js';
2
4
  export { annotDocsConfigSchema, annotFrontmatterSchema, defineConfig, isScreenRole, } from './config.js';
5
+ export type { LegacyOverlayUsage } from './deprecation.js';
6
+ export { _resetLegacyOverlayDedupForTests, formatLegacyOverlayWarning, warnLegacyOverlay, } from './deprecation.js';
3
7
  export type { DetectDriftOptions, DriftFinding, DriftKind, DriftSeverity, } from './drift.js';
4
- export { detectDrift, detectDriftFromYaml, isLintableScreen, lintableScreens, summariseDrift, } from './drift.js';
8
+ export { collectMatchKeysFromAnnotation, detectDrift, detectDriftFromElementTree, detectDriftFromYaml, elementTreeToSnapshotEntries, isLintableScreen, lintableScreens, summariseDrift, } from './drift.js';
5
9
  export type { ProductDocs, ProductDocsSyncOptions, Screen, ScreenCaptureOptions, } from './fixture.js';
6
10
  export { captureScreen, collectAttributesYaml, DEFAULT_ATTR_WHITELIST, syncProductDocs, test, } from './fixture.js';
7
11
  export type { ParseMdxOptions } from './mdx.js';
8
12
  export { parseMdx, parseMdxFile, updateCommentBlocks } from './mdx.js';
9
13
  export type { BoxedEntry } from './mdx-annotations.js';
10
- export { buildBadgeAnnotations, emptyAnnotationsSvg, parseSnapshotBoxes, resolveMdxAnnotations, svgFromBadges, svgFromBboxAnnotations, } from './mdx-annotations.js';
14
+ export { buildBadgeAnnotations, buildBadgeAnnotationsFromYaml, buildRasterRedactRegionsFromYaml, buildShapeAnnotationsFromYaml, elementTreeToBoxedEntries, emptyAnnotationsSvg, parseSnapshotBoxes, resolveMdxAnnotations, svgFromBadges, svgFromBboxAnnotations, } from './mdx-annotations.js';
15
+ export type { MigrateOverlaysOptions, OverlayMigrationFileResult, ScreenOverlayMigrationResult, } from './migrate-overlays-to-annotations.js';
16
+ export { buildAnnotationsFile, migrateOverlaysToAnnotationsFile, } from './migrate-overlays-to-annotations.js';
11
17
  export type { ResolveFailureKind, ResolveResult, SnapshotEntry, } from './resolver.js';
12
18
  export { parseSnapshot, resolveMatch, resolveOverlays, } from './resolver.js';
13
- export type { AnnotCommentBlocks, AnnotFrontmatter, AnnotFrontmatterRole, AnnotMeta, AnnotXlsxConfig, HistoryEntrySpec, MatchKey, OverlayIntent, OverlaySpec, ParsedMdx, ScreenListSpec, ScreenSpec, TransitionSpec, } from './types.js';
14
- export type { AnnotDocsConfig, BookConfig } from './types-config.js';
19
+ export type { AnnotCalloutSpec, AnnotCommentBlocks, AnnotFrontmatter, AnnotFrontmatterRole, AnnotMeta, AnnotXlsxConfig, HistoryEntrySpec, MatchKey, OverlayIntent, OverlaySpec, ParsedMdx, ScreenListSpec, ScreenSpec, TransitionSpec, } from './types.js';
20
+ export type { AnnotDocsConfig, AnnotEditorConfig, BookConfig } from './types-config.js';