@ingcreators/annot-product-docs 0.1.0 → 0.2.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 +105 -0
- package/README.md +4 -4
- package/dist/cli.d.ts +29 -0
- package/dist/config.d.ts +184 -0
- package/dist/drift.d.ts +77 -0
- package/dist/fixture.d.ts +81 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +860 -0
- package/dist/mdx.d.ts +41 -0
- package/dist/resolver.d.ts +58 -0
- package/dist/types-config.d.ts +18 -0
- package/dist/types.d.ts +106 -0
- package/package.json +6 -6
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# @ingcreators/annot-product-docs
|
|
2
|
+
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 2e92c97: First publish of the living-product-docs package family. Phases
|
|
8
|
+
1-5 + 7 of `docs/plans/living-product-docs.md` landed across
|
|
9
|
+
PRs 876-899; this entry flips the three packages from
|
|
10
|
+
`private: true` to publishable and stamps `0.1.0`.
|
|
11
|
+
|
|
12
|
+
### `@ingcreators/annot-product-docs`
|
|
13
|
+
- MDX parser (`parseMdx` / `parseMdxFile`) — Remark / unified
|
|
14
|
+
pipeline that walks `.mdx` files with `annot:` frontmatter
|
|
15
|
+
and extracts `<Screen>` / `<Overlay>` / `<Transition>` /
|
|
16
|
+
`<HistoryEntry>` / `<ScreenList>` JSX components.
|
|
17
|
+
- Match resolver (`parseSnapshot` / `resolveMatch` /
|
|
18
|
+
`resolveOverlays`) for the Playwright `aria-snapshot`
|
|
19
|
+
YAML, honouring `match.under` disambiguation and emitting
|
|
20
|
+
`not-found` / `ambiguous` / `renamed` / `role-changed` /
|
|
21
|
+
`live-mismatch` diagnostics.
|
|
22
|
+
- `screen` fixture extending `@ingcreators/annot-playwright`
|
|
23
|
+
with `screen.capture({ id, mdxPath })` that re-syncs
|
|
24
|
+
`annot:snapshot` + `annot:attributes` MDX comment blocks
|
|
25
|
+
in place.
|
|
26
|
+
- Drift detector (`detectDrift` / `detectDriftFromYaml`) — six
|
|
27
|
+
finding kinds (added / removed / renamed / role-changed /
|
|
28
|
+
duplicated / attribute-drift) with severity buckets.
|
|
29
|
+
- `annot-docs` CLI (`init` / `sync` / `lint`) with `--json`
|
|
30
|
+
/ `--ci` / `--fix` flags + a sample GitHub Actions workflow
|
|
31
|
+
emitting GitHub annotations on PR diff views.
|
|
32
|
+
|
|
33
|
+
### `@ingcreators/annot-product-docs-astro`
|
|
34
|
+
- `productDocsIntegration()` Astro 5.x integration factory.
|
|
35
|
+
- 7 docs components: `<Screen>`, `<Overlay>`, `<Transition>`,
|
|
36
|
+
`<TransitionTable>`, `<HistoryEntry>`, `<ScreenList>`,
|
|
37
|
+
`<TransitionGraph>`. Shipped as `.astro` source under
|
|
38
|
+
`./components/*.astro` exports.
|
|
39
|
+
- Image Service (`renderAnnotatedScreen` + SHA-keyed
|
|
40
|
+
`createFileCache` / `createMemoryCache`) that composes the
|
|
41
|
+
base screenshot with overlay callouts at build time.
|
|
42
|
+
|
|
43
|
+
### `@ingcreators/annot-product-docs-xlsx`
|
|
44
|
+
- MDX → normalised bundle extractor; per-role default layout
|
|
45
|
+
(cover / history / list / screen / reference); customer-
|
|
46
|
+
template support with `{var}` placeholder substitution
|
|
47
|
+
(including `{annot:date}` special vars + `{name:format}`
|
|
48
|
+
date formatting); Excel Named Range writers
|
|
49
|
+
(`annotImage` / `annotItemTable` / `annotHistory` /
|
|
50
|
+
`annotList` / `annotSnapshot` / `annotAttributes`).
|
|
51
|
+
- `annot-docs-xlsx render` CLI with multi-book emit + per-book
|
|
52
|
+
template config.
|
|
53
|
+
|
|
54
|
+
### Patch Changes
|
|
55
|
+
|
|
56
|
+
- 657a685: **Republish with `dist/` included.** The `0.1.0` tarballs of all
|
|
57
|
+
three packages shipped to npm without their `dist/` directory —
|
|
58
|
+
the `publish.yml` workflow's pre-pack `pnpm build` step had only
|
|
59
|
+
filtered four other packages, so `pnpm pack` packed the three
|
|
60
|
+
`product-docs*` packages against empty `dist/`s. The
|
|
61
|
+
`publishConfig.main` (`./dist/index.js`) consequently pointed at
|
|
62
|
+
a missing file, breaking `npm install` for every consumer.
|
|
63
|
+
|
|
64
|
+
The source fix landed in
|
|
65
|
+
[#947](https://github.com/ingcreators/annot/pull/947) with two
|
|
66
|
+
defences:
|
|
67
|
+
1. Three new `--filter` lines in the workflow's build step so
|
|
68
|
+
all seven publishable packages get built before pack.
|
|
69
|
+
2. A per-package `prepack` script (`pnpm run build`) so even a
|
|
70
|
+
misconfigured workflow (or a manual `pnpm pack` / `pnpm
|
|
71
|
+
publish`) refreshes `dist/` before packing.
|
|
72
|
+
|
|
73
|
+
No source-code changes in any of the three packages — only the
|
|
74
|
+
packaging is fixed. This patch publish exists solely to deliver
|
|
75
|
+
working tarballs to the registry; the public API surface is
|
|
76
|
+
byte-identical to `0.1.0`.
|
|
77
|
+
|
|
78
|
+
Verified locally:
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
$ pnpm --filter @ingcreators/annot-product-docs pack --dry-run
|
|
82
|
+
Tarball Contents
|
|
83
|
+
bin/annot-docs.mjs
|
|
84
|
+
dist/cli.d.ts
|
|
85
|
+
dist/config.d.ts
|
|
86
|
+
dist/drift.d.ts
|
|
87
|
+
dist/fixture.d.ts
|
|
88
|
+
dist/index.d.ts
|
|
89
|
+
dist/index.js
|
|
90
|
+
dist/mdx.d.ts
|
|
91
|
+
dist/resolver.d.ts
|
|
92
|
+
dist/types-config.d.ts
|
|
93
|
+
dist/types.d.ts
|
|
94
|
+
LICENSE
|
|
95
|
+
package.json
|
|
96
|
+
README.md
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Before the fix the same command produced 4 files (LICENSE +
|
|
100
|
+
README + package.json + bin/annot-docs.mjs), no compiled code.
|
|
101
|
+
|
|
102
|
+
- Updated dependencies [806badc]
|
|
103
|
+
- Updated dependencies [df1a429]
|
|
104
|
+
- @ingcreators/annot-annotator@0.5.0
|
|
105
|
+
- @ingcreators/annot-playwright@0.3.1
|
package/README.md
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
[](https://github.com/ingcreators/annot/blob/main/LICENSE)
|
|
5
5
|
|
|
6
6
|
Living product docs core. Turn a Playwright tour suite into
|
|
7
|
-
always-fresh user manuals +
|
|
8
|
-
between MDX and live UI caught as a CI lint step.
|
|
7
|
+
always-fresh user manuals + Excel screen specifications, with
|
|
8
|
+
drift between MDX and live UI caught as a CI lint step.
|
|
9
9
|
|
|
10
10
|
Phase 1 of
|
|
11
|
-
[`docs/plans/living-product-docs.md`](https://github.com/ingcreators/annot/blob/main/docs/plans/living-product-docs.md).
|
|
11
|
+
[`docs/plans/_done/living-product-docs.md`](https://github.com/ingcreators/annot/blob/main/docs/plans/_done/living-product-docs.md).
|
|
12
12
|
|
|
13
13
|
## Install
|
|
14
14
|
|
|
@@ -99,7 +99,7 @@ annot-docs lint --fix # auto-refresh stored blocks for files
|
|
|
99
99
|
|
|
100
100
|
The companion adapters consume the MDXs:
|
|
101
101
|
- [`@ingcreators/annot-product-docs-astro`](../product-docs-astro) renders an Astro docs site.
|
|
102
|
-
- [`@ingcreators/annot-product-docs-xlsx`](../product-docs-xlsx) emits Excel
|
|
102
|
+
- [`@ingcreators/annot-product-docs-xlsx`](../product-docs-xlsx) emits Excel screen specifications.
|
|
103
103
|
|
|
104
104
|
## Tier
|
|
105
105
|
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Page } from 'playwright-core';
|
|
2
|
+
export interface CliOptions {
|
|
3
|
+
cwd?: string;
|
|
4
|
+
/** Write target for diagnostic output (defaults to process.stderr). */
|
|
5
|
+
stderr?: (line: string) => void;
|
|
6
|
+
stdout?: (line: string) => void;
|
|
7
|
+
/** Override Playwright launch (used in tests). Returns an already-open `Page`. */
|
|
8
|
+
newPage?: (url: string) => Promise<{
|
|
9
|
+
page: Page;
|
|
10
|
+
close: () => Promise<void>;
|
|
11
|
+
}>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* `main(argv)` entrypoint. Returns the process exit code so the
|
|
15
|
+
* bin script (`bin/annot-docs.mjs`) can `process.exit(...)`. Also
|
|
16
|
+
* usable from vitest by passing custom `stdout` / `stderr` / `cwd`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function main(argv: string[], options?: CliOptions): Promise<number>;
|
|
19
|
+
/**
|
|
20
|
+
* Walk the directory tree below `root` and return every `*.mdx`
|
|
21
|
+
* absolute path. Uses `readdir({ withFileTypes: true })` for a
|
|
22
|
+
* single syscall per directory — no external glob dep.
|
|
23
|
+
*/
|
|
24
|
+
export declare function walkMdx(root: string): Promise<string[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Filter a list of MDX paths down to the ones with `annot:`
|
|
27
|
+
* frontmatter — i.e. the files the CLI should act on.
|
|
28
|
+
*/
|
|
29
|
+
export declare function filterAnnotMdxFiles(paths: string[]): Promise<string[]>;
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { AnnotDocsConfig, AnnotFrontmatter } from './types-config.js';
|
|
3
|
+
export declare const annotFrontmatterSchema: z.ZodObject<{
|
|
4
|
+
id: z.ZodString;
|
|
5
|
+
title: z.ZodOptional<z.ZodString>;
|
|
6
|
+
purpose: z.ZodOptional<z.ZodString>;
|
|
7
|
+
meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
8
|
+
xlsx: z.ZodOptional<z.ZodEffects<z.ZodObject<{
|
|
9
|
+
book: z.ZodOptional<z.ZodString>;
|
|
10
|
+
sheet: z.ZodOptional<z.ZodString>;
|
|
11
|
+
sheets: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
12
|
+
role: z.ZodOptional<z.ZodEnum<["cover", "history", "list", "screen", "reference"]>>;
|
|
13
|
+
order: z.ZodOptional<z.ZodNumber>;
|
|
14
|
+
}, "strict", z.ZodTypeAny, {
|
|
15
|
+
role?: "cover" | "history" | "list" | "screen" | "reference" | undefined;
|
|
16
|
+
book?: string | undefined;
|
|
17
|
+
sheet?: string | undefined;
|
|
18
|
+
sheets?: Record<string, string> | undefined;
|
|
19
|
+
order?: number | undefined;
|
|
20
|
+
}, {
|
|
21
|
+
role?: "cover" | "history" | "list" | "screen" | "reference" | undefined;
|
|
22
|
+
book?: string | undefined;
|
|
23
|
+
sheet?: string | undefined;
|
|
24
|
+
sheets?: Record<string, string> | undefined;
|
|
25
|
+
order?: number | undefined;
|
|
26
|
+
}>, {
|
|
27
|
+
role?: "cover" | "history" | "list" | "screen" | "reference" | undefined;
|
|
28
|
+
book?: string | undefined;
|
|
29
|
+
sheet?: string | undefined;
|
|
30
|
+
sheets?: Record<string, string> | undefined;
|
|
31
|
+
order?: number | undefined;
|
|
32
|
+
}, {
|
|
33
|
+
role?: "cover" | "history" | "list" | "screen" | "reference" | undefined;
|
|
34
|
+
book?: string | undefined;
|
|
35
|
+
sheet?: string | undefined;
|
|
36
|
+
sheets?: Record<string, string> | 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
|
+
role?: "cover" | "history" | "list" | "screen" | "reference" | undefined;
|
|
46
|
+
book?: string | undefined;
|
|
47
|
+
sheet?: string | undefined;
|
|
48
|
+
sheets?: Record<string, string> | 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
|
+
role?: "cover" | "history" | "list" | "screen" | "reference" | undefined;
|
|
58
|
+
book?: string | undefined;
|
|
59
|
+
sheet?: string | undefined;
|
|
60
|
+
sheets?: Record<string, string> | undefined;
|
|
61
|
+
order?: number | undefined;
|
|
62
|
+
} | undefined;
|
|
63
|
+
}>;
|
|
64
|
+
export declare const annotDocsConfigSchema: z.ZodObject<{
|
|
65
|
+
meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
66
|
+
xlsx: z.ZodOptional<z.ZodObject<{
|
|
67
|
+
defaultBook: z.ZodOptional<z.ZodString>;
|
|
68
|
+
books: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
69
|
+
template: z.ZodOptional<z.ZodString>;
|
|
70
|
+
templateSheets: z.ZodOptional<z.ZodObject<{
|
|
71
|
+
cover: z.ZodOptional<z.ZodString>;
|
|
72
|
+
history: z.ZodOptional<z.ZodString>;
|
|
73
|
+
list: z.ZodOptional<z.ZodString>;
|
|
74
|
+
screen: z.ZodOptional<z.ZodString>;
|
|
75
|
+
reference: z.ZodOptional<z.ZodString>;
|
|
76
|
+
}, "strict", z.ZodTypeAny, {
|
|
77
|
+
cover?: string | undefined;
|
|
78
|
+
history?: string | undefined;
|
|
79
|
+
list?: string | undefined;
|
|
80
|
+
screen?: string | undefined;
|
|
81
|
+
reference?: string | undefined;
|
|
82
|
+
}, {
|
|
83
|
+
cover?: string | undefined;
|
|
84
|
+
history?: string | undefined;
|
|
85
|
+
list?: string | undefined;
|
|
86
|
+
screen?: string | undefined;
|
|
87
|
+
reference?: string | undefined;
|
|
88
|
+
}>>;
|
|
89
|
+
}, "strict", z.ZodTypeAny, {
|
|
90
|
+
template?: string | undefined;
|
|
91
|
+
templateSheets?: {
|
|
92
|
+
cover?: string | undefined;
|
|
93
|
+
history?: string | undefined;
|
|
94
|
+
list?: string | undefined;
|
|
95
|
+
screen?: string | undefined;
|
|
96
|
+
reference?: string | undefined;
|
|
97
|
+
} | undefined;
|
|
98
|
+
}, {
|
|
99
|
+
template?: string | undefined;
|
|
100
|
+
templateSheets?: {
|
|
101
|
+
cover?: string | undefined;
|
|
102
|
+
history?: string | undefined;
|
|
103
|
+
list?: string | undefined;
|
|
104
|
+
screen?: 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
|
+
cover?: string | undefined;
|
|
114
|
+
history?: string | undefined;
|
|
115
|
+
list?: string | undefined;
|
|
116
|
+
screen?: 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
|
+
cover?: string | undefined;
|
|
126
|
+
history?: string | undefined;
|
|
127
|
+
list?: string | undefined;
|
|
128
|
+
screen?: 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
|
+
cover?: string | undefined;
|
|
141
|
+
history?: string | undefined;
|
|
142
|
+
list?: string | undefined;
|
|
143
|
+
screen?: 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
|
+
cover?: string | undefined;
|
|
156
|
+
history?: string | undefined;
|
|
157
|
+
list?: string | undefined;
|
|
158
|
+
screen?: string | undefined;
|
|
159
|
+
reference?: string | undefined;
|
|
160
|
+
} | undefined;
|
|
161
|
+
}> | undefined;
|
|
162
|
+
} | undefined;
|
|
163
|
+
}>;
|
|
164
|
+
/**
|
|
165
|
+
* Identity-with-validation helper.
|
|
166
|
+
*
|
|
167
|
+
* Project config files (`annot-docs.config.ts`) call this so
|
|
168
|
+
* editor tooling (TypeScript) sees the precise type. The runtime
|
|
169
|
+
* call also runs the Zod schema, so typos in the config object
|
|
170
|
+
* fail loudly at module load time rather than silently being
|
|
171
|
+
* dropped by `tsc`'s structural matching.
|
|
172
|
+
*/
|
|
173
|
+
export declare function defineConfig(config: AnnotDocsConfig): AnnotDocsConfig;
|
|
174
|
+
export type { AnnotDocsConfig, AnnotFrontmatter, BookConfig, } from './types-config.js';
|
|
175
|
+
/**
|
|
176
|
+
* Convenience guard: does this AnnotFrontmatter declare a
|
|
177
|
+
* `screen` role? Useful for filtering MDXs that have `<Screen>`
|
|
178
|
+
* blocks (and therefore drift-checkable) from cover / history /
|
|
179
|
+
* list MDXs.
|
|
180
|
+
*
|
|
181
|
+
* Defaults to `true` when `xlsx.role` is unset because plain MDXs
|
|
182
|
+
* with `<Screen>` blocks default to the `screen` role.
|
|
183
|
+
*/
|
|
184
|
+
export declare function isScreenRole(fm: AnnotFrontmatter): boolean;
|
package/dist/drift.d.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { SnapshotEntry } from './resolver.js';
|
|
2
|
+
import { MatchKey, ScreenSpec } from './types.js';
|
|
3
|
+
export type DriftSeverity = "error" | "warning" | "info";
|
|
4
|
+
export type DriftKind = "added" | "removed" | "renamed" | "role-changed" | "duplicated" | "attribute-drift";
|
|
5
|
+
export interface DriftFinding {
|
|
6
|
+
severity: DriftSeverity;
|
|
7
|
+
kind: DriftKind;
|
|
8
|
+
/** The screen id the finding pertains to. */
|
|
9
|
+
screenId: string;
|
|
10
|
+
/** Human-readable description. */
|
|
11
|
+
message: string;
|
|
12
|
+
/** The `MatchKey` from the source MDX, if relevant. */
|
|
13
|
+
match?: MatchKey;
|
|
14
|
+
/** Suggested replacement (used by `--fix` flows in Phase 4). */
|
|
15
|
+
suggestion?: {
|
|
16
|
+
role?: string;
|
|
17
|
+
name?: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export interface DetectDriftOptions {
|
|
21
|
+
screen: ScreenSpec;
|
|
22
|
+
/** Parsed Playwright aria-snapshot entries against the current page. */
|
|
23
|
+
liveSnapshot: SnapshotEntry[];
|
|
24
|
+
/** Optional verbatim YAML of the stored `annot:attributes` block. */
|
|
25
|
+
storedAttributesYaml?: string;
|
|
26
|
+
/** Optional verbatim YAML of the freshly-captured attributes. */
|
|
27
|
+
freshAttributesYaml?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Compute the drift findings for one `<Screen>` block.
|
|
31
|
+
*
|
|
32
|
+
* Severity policy:
|
|
33
|
+
* - **error** stops `annot docs lint --ci` (non-zero exit). Removed
|
|
34
|
+
* + duplicated belong here because they fail rendering.
|
|
35
|
+
* - **warning** logs but doesn't fail CI by default. Added + renamed
|
|
36
|
+
* + role-changed belong here because they're authoring tasks (the
|
|
37
|
+
* doc author decides whether the new element warrants an
|
|
38
|
+
* `<Overlay>`).
|
|
39
|
+
* - **info** is silent unless `--verbose`; attribute-drift is here
|
|
40
|
+
* because `annot docs sync` rewrites the block automatically on
|
|
41
|
+
* the next CI run.
|
|
42
|
+
*/
|
|
43
|
+
export declare function detectDrift(opts: DetectDriftOptions): DriftFinding[];
|
|
44
|
+
/**
|
|
45
|
+
* Convenience: parse the stored snapshot YAML + dispatch.
|
|
46
|
+
*
|
|
47
|
+
* Used by the CLI when comparing the persisted `annot:snapshot`
|
|
48
|
+
* comment block against a fresh page snapshot — e.g. for an
|
|
49
|
+
* offline `annot docs lint --offline` mode (Phase 4 polish).
|
|
50
|
+
*/
|
|
51
|
+
export declare function detectDriftFromYaml(args: {
|
|
52
|
+
screen: ScreenSpec;
|
|
53
|
+
liveSnapshotYaml: string;
|
|
54
|
+
storedAttributesYaml?: string;
|
|
55
|
+
freshAttributesYaml?: string;
|
|
56
|
+
}): DriftFinding[];
|
|
57
|
+
/**
|
|
58
|
+
* Summarise findings by severity. Used by the CLI to decide an
|
|
59
|
+
* exit code.
|
|
60
|
+
*/
|
|
61
|
+
export declare function summariseDrift(findings: DriftFinding[]): {
|
|
62
|
+
errors: number;
|
|
63
|
+
warnings: number;
|
|
64
|
+
infos: number;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* 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.
|
|
70
|
+
*/
|
|
71
|
+
export declare function isLintableScreen(screen: ScreenSpec): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Filter the list of `ScreenSpec`s in a parsed MDX to just the
|
|
74
|
+
* ones drift detection should touch. Helps the CLI keep the
|
|
75
|
+
* "skipped cover.mdx" path cheap.
|
|
76
|
+
*/
|
|
77
|
+
export declare function lintableScreens(screens: ScreenSpec[]): ScreenSpec[];
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Locator, Page } from '@playwright/test';
|
|
2
|
+
import { OverlaySpec } from './types.js';
|
|
3
|
+
export interface ScreenCaptureOptions {
|
|
4
|
+
/** Must match a `<Screen id="...">` JSX block in the MDX file. */
|
|
5
|
+
id: string;
|
|
6
|
+
/** Absolute or cwd-relative path to the `.mdx` file. */
|
|
7
|
+
mdxPath: string;
|
|
8
|
+
/**
|
|
9
|
+
* Override the locator used as the snapshot root. Defaults to
|
|
10
|
+
* the page's `body` element. Useful when the test is scoped to
|
|
11
|
+
* a specific dialog or section.
|
|
12
|
+
*/
|
|
13
|
+
rootLocator?: Locator;
|
|
14
|
+
/**
|
|
15
|
+
* Override the HTML attribute whitelist for `annot:attributes`
|
|
16
|
+
* collection. Default is `DEFAULT_ATTR_WHITELIST` — covers the
|
|
17
|
+
* common form-control + accessibility attrs.
|
|
18
|
+
*/
|
|
19
|
+
attributeWhitelist?: readonly string[];
|
|
20
|
+
}
|
|
21
|
+
export interface Screen {
|
|
22
|
+
capture(opts: ScreenCaptureOptions): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* HTML attributes captured into the `annot:attributes` block by
|
|
26
|
+
* default. Focused on form-control + accessibility shape — the
|
|
27
|
+
* stuff a screen-specifications spreadsheet / operation manual cares about per element.
|
|
28
|
+
*
|
|
29
|
+
* Hosts can override per-call via `opts.attributeWhitelist`.
|
|
30
|
+
*/
|
|
31
|
+
export declare const DEFAULT_ATTR_WHITELIST: readonly string[];
|
|
32
|
+
/**
|
|
33
|
+
* `test = annotatorTest.extend({ screen })` — drop-in for
|
|
34
|
+
* `@playwright/test`'s `test` plus a `screen` fixture for the
|
|
35
|
+
* docs flow. Tour files (`tests/docs/*.spec.ts`) import this
|
|
36
|
+
* `test` instead of `@playwright/test`:
|
|
37
|
+
*
|
|
38
|
+
* ```ts
|
|
39
|
+
* import { test } from "@ingcreators/annot-product-docs";
|
|
40
|
+
*
|
|
41
|
+
* test("login flow", async ({ page, screen }) => {
|
|
42
|
+
* await page.goto("/login");
|
|
43
|
+
* await screen.capture({
|
|
44
|
+
* id: "login",
|
|
45
|
+
* mdxPath: "docs/books/screen-spec/screens/SC-001-login.mdx",
|
|
46
|
+
* });
|
|
47
|
+
* });
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare const test: import('@playwright/test').TestType<import('@playwright/test').PlaywrightTestArgs & import('@playwright/test').PlaywrightTestOptions & {
|
|
51
|
+
annotator: import('@ingcreators/annot-playwright').PlaywrightAnnotator;
|
|
52
|
+
} & {
|
|
53
|
+
screen: Screen;
|
|
54
|
+
}, import('@playwright/test').PlaywrightWorkerArgs & import('@playwright/test').PlaywrightWorkerOptions>;
|
|
55
|
+
/**
|
|
56
|
+
* Standalone capture helper — same behaviour as
|
|
57
|
+
* `screen.capture(...)` but takes the `Page` directly. Exported
|
|
58
|
+
* so callers who build their own Playwright fixture (e.g.
|
|
59
|
+
* composing additional fixtures on top) can still drive the
|
|
60
|
+
* docs-sync flow.
|
|
61
|
+
*
|
|
62
|
+
* Idempotent: if `mdxPath` already has `annot:snapshot` /
|
|
63
|
+
* `annot:attributes` blocks, they're replaced in place; if not,
|
|
64
|
+
* they're appended. Files without `annot:` frontmatter throw —
|
|
65
|
+
* the fixture refuses to touch non-annot MDX.
|
|
66
|
+
*/
|
|
67
|
+
export declare function captureScreen(page: Page, opts: ScreenCaptureOptions): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Walk the overlays in a `<Screen>`, resolve each one's `match`
|
|
70
|
+
* against the live page, and emit a YAML block of the form:
|
|
71
|
+
*
|
|
72
|
+
* role "Name":
|
|
73
|
+
* attrA: value
|
|
74
|
+
* attrB: value
|
|
75
|
+
*
|
|
76
|
+
* Only overlays whose `match` resolves to exactly one element
|
|
77
|
+
* contribute a section. Overlays with zero hits or multiple
|
|
78
|
+
* hits are skipped (the drift detector in Phase 1 PR 4 raises
|
|
79
|
+
* those — duplicating the diagnostic here would be noisy).
|
|
80
|
+
*/
|
|
81
|
+
export declare function collectAttributesYaml(page: Page, overlays: OverlaySpec[], whitelist: readonly string[]): Promise<string>;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { filterAnnotMdxFiles, main, walkMdx, } from './cli.js';
|
|
2
|
+
export { annotDocsConfigSchema, annotFrontmatterSchema, defineConfig, isScreenRole, } from './config.js';
|
|
3
|
+
export type { DetectDriftOptions, DriftFinding, DriftKind, DriftSeverity, } from './drift.js';
|
|
4
|
+
export { detectDrift, detectDriftFromYaml, isLintableScreen, lintableScreens, summariseDrift, } from './drift.js';
|
|
5
|
+
export type { Screen, ScreenCaptureOptions } from './fixture.js';
|
|
6
|
+
export { captureScreen, collectAttributesYaml, DEFAULT_ATTR_WHITELIST, test, } from './fixture.js';
|
|
7
|
+
export type { ParseMdxOptions } from './mdx.js';
|
|
8
|
+
export { parseMdx, parseMdxFile, updateCommentBlocks } from './mdx.js';
|
|
9
|
+
export type { ResolveFailureKind, ResolveResult, SnapshotEntry, } from './resolver.js';
|
|
10
|
+
export { parseSnapshot, resolveMatch, resolveOverlays, } from './resolver.js';
|
|
11
|
+
export type { AnnotCommentBlocks, AnnotFrontmatter, AnnotFrontmatterRole, AnnotMeta, AnnotXlsxConfig, HistoryEntrySpec, MatchKey, OverlayIntent, OverlaySpec, ParsedMdx, ScreenListSpec, ScreenSpec, TransitionSpec, } from './types.js';
|
|
12
|
+
export type { AnnotDocsConfig, BookConfig } from './types-config.js';
|