viewev 0.0.0-stage → 0.1.0-beta.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/LICENSE +21 -0
- package/README.md +148 -2
- package/assets/logo/Logo-horizontal.png +0 -0
- package/dist/adapters/storybook/index.d.ts +5 -0
- package/dist/adapters/storybook/index.js +4 -0
- package/dist/adapters/storybook/index.js.map +1 -0
- package/dist/adapters/storybook/provider.d.ts +24 -0
- package/dist/adapters/storybook/provider.js +114 -0
- package/dist/adapters/storybook/provider.js.map +1 -0
- package/dist/adapters/storybook/scenarios.d.ts +30 -0
- package/dist/adapters/storybook/scenarios.js +64 -0
- package/dist/adapters/storybook/scenarios.js.map +1 -0
- package/dist/adapters/storybook/static-server.d.ts +10 -0
- package/dist/adapters/storybook/static-server.js +105 -0
- package/dist/adapters/storybook/static-server.js.map +1 -0
- package/dist/adapters/storybook/storybook-index.d.ts +32 -0
- package/dist/adapters/storybook/storybook-index.js +35 -0
- package/dist/adapters/storybook/storybook-index.js.map +1 -0
- package/dist/baselines/environment-check.d.ts +7 -0
- package/dist/baselines/environment-check.js +24 -0
- package/dist/baselines/environment-check.js.map +1 -0
- package/dist/baselines/environment-key.d.ts +8 -0
- package/dist/baselines/environment-key.js +12 -0
- package/dist/baselines/environment-key.js.map +1 -0
- package/dist/baselines/file-store.d.ts +12 -0
- package/dist/baselines/file-store.js +81 -0
- package/dist/baselines/file-store.js.map +1 -0
- package/dist/baselines/git-store.d.ts +16 -0
- package/dist/baselines/git-store.js +150 -0
- package/dist/baselines/git-store.js.map +1 -0
- package/dist/baselines/memory-store.d.ts +3 -0
- package/dist/baselines/memory-store.js +15 -0
- package/dist/baselines/memory-store.js.map +1 -0
- package/dist/baselines/metadata.d.ts +16 -0
- package/dist/baselines/metadata.js +84 -0
- package/dist/baselines/metadata.js.map +1 -0
- package/dist/baselines/types.d.ts +33 -0
- package/dist/baselines/types.js +2 -0
- package/dist/baselines/types.js.map +1 -0
- package/dist/browser/playwright/capturer.d.ts +2 -0
- package/dist/browser/playwright/capturer.js +142 -0
- package/dist/browser/playwright/capturer.js.map +1 -0
- package/dist/browser/playwright/environment.d.ts +4 -0
- package/dist/browser/playwright/environment.js +36 -0
- package/dist/browser/playwright/environment.js.map +1 -0
- package/dist/browser/playwright/index.d.ts +1 -0
- package/dist/browser/playwright/index.js +2 -0
- package/dist/browser/playwright/index.js.map +1 -0
- package/dist/browser/types.d.ts +43 -0
- package/dist/browser/types.js +2 -0
- package/dist/browser/types.js.map +1 -0
- package/dist/ci/github-summary.d.ts +5 -0
- package/dist/ci/github-summary.js +110 -0
- package/dist/ci/github-summary.js.map +1 -0
- package/dist/cli/baseline-ref.d.ts +6 -0
- package/dist/cli/baseline-ref.js +11 -0
- package/dist/cli/baseline-ref.js.map +1 -0
- package/dist/cli/bin.d.ts +2 -0
- package/dist/cli/bin.js +13 -0
- package/dist/cli/bin.js.map +1 -0
- package/dist/cli/commands/baseline.d.ts +3 -0
- package/dist/cli/commands/baseline.js +90 -0
- package/dist/cli/commands/baseline.js.map +1 -0
- package/dist/cli/commands/capture.d.ts +3 -0
- package/dist/cli/commands/capture.js +42 -0
- package/dist/cli/commands/capture.js.map +1 -0
- package/dist/cli/commands/config.d.ts +3 -0
- package/dist/cli/commands/config.js +25 -0
- package/dist/cli/commands/config.js.map +1 -0
- package/dist/cli/commands/doctor.d.ts +3 -0
- package/dist/cli/commands/doctor.js +19 -0
- package/dist/cli/commands/doctor.js.map +1 -0
- package/dist/cli/commands/report.d.ts +3 -0
- package/dist/cli/commands/report.js +16 -0
- package/dist/cli/commands/report.js.map +1 -0
- package/dist/cli/commands/scenarios.d.ts +3 -0
- package/dist/cli/commands/scenarios.js +30 -0
- package/dist/cli/commands/scenarios.js.map +1 -0
- package/dist/cli/commands/test.d.ts +3 -0
- package/dist/cli/commands/test.js +285 -0
- package/dist/cli/commands/test.js.map +1 -0
- package/dist/cli/context.d.ts +21 -0
- package/dist/cli/context.js +22 -0
- package/dist/cli/context.js.map +1 -0
- package/dist/cli/doctor.d.ts +12 -0
- package/dist/cli/doctor.js +113 -0
- package/dist/cli/doctor.js.map +1 -0
- package/dist/cli/format.d.ts +17 -0
- package/dist/cli/format.js +128 -0
- package/dist/cli/format.js.map +1 -0
- package/dist/cli/impact.d.ts +16 -0
- package/dist/cli/impact.js +63 -0
- package/dist/cli/impact.js.map +1 -0
- package/dist/cli/program.d.ts +11 -0
- package/dist/cli/program.js +70 -0
- package/dist/cli/program.js.map +1 -0
- package/dist/cli/session.d.ts +27 -0
- package/dist/cli/session.js +53 -0
- package/dist/cli/session.js.map +1 -0
- package/dist/comparison/compare.d.ts +11 -0
- package/dist/comparison/compare.js +41 -0
- package/dist/comparison/compare.js.map +1 -0
- package/dist/comparison/types.d.ts +34 -0
- package/dist/comparison/types.js +2 -0
- package/dist/comparison/types.js.map +1 -0
- package/dist/config/load.d.ts +23 -0
- package/dist/config/load.js +93 -0
- package/dist/config/load.js.map +1 -0
- package/dist/config/schema.d.ts +473 -0
- package/dist/config/schema.js +157 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/core/artifacts.d.ts +6 -0
- package/dist/core/artifacts.js +2 -0
- package/dist/core/artifacts.js.map +1 -0
- package/dist/core/baseline-run.d.ts +37 -0
- package/dist/core/baseline-run.js +85 -0
- package/dist/core/baseline-run.js.map +1 -0
- package/dist/core/capture-settings.d.ts +6 -0
- package/dist/core/capture-settings.js +21 -0
- package/dist/core/capture-settings.js.map +1 -0
- package/dist/core/discovery.d.ts +3 -0
- package/dist/core/discovery.js +17 -0
- package/dist/core/discovery.js.map +1 -0
- package/dist/core/impact.d.ts +19 -0
- package/dist/core/impact.js +28 -0
- package/dist/core/impact.js.map +1 -0
- package/dist/core/pool.d.ts +5 -0
- package/dist/core/pool.js +21 -0
- package/dist/core/pool.js.map +1 -0
- package/dist/core/result.d.ts +117 -0
- package/dist/core/result.js +53 -0
- package/dist/core/result.js.map +1 -0
- package/dist/core/selection.d.ts +8 -0
- package/dist/core/selection.js +8 -0
- package/dist/core/selection.js.map +1 -0
- package/dist/core/test-run.d.ts +40 -0
- package/dist/core/test-run.js +141 -0
- package/dist/core/test-run.js.map +1 -0
- package/dist/impact/git.d.ts +17 -0
- package/dist/impact/git.js +55 -0
- package/dist/impact/git.js.map +1 -0
- package/dist/impact/storybook.d.ts +16 -0
- package/dist/impact/storybook.js +324 -0
- package/dist/impact/storybook.js.map +1 -0
- package/dist/impact/types.d.ts +28 -0
- package/dist/impact/types.js +23 -0
- package/dist/impact/types.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/reference/build.d.ts +10 -0
- package/dist/reference/build.js +36 -0
- package/dist/reference/build.js.map +1 -0
- package/dist/reference/git-worktree.d.ts +8 -0
- package/dist/reference/git-worktree.js +77 -0
- package/dist/reference/git-worktree.js.map +1 -0
- package/dist/reference/open.d.ts +13 -0
- package/dist/reference/open.js +66 -0
- package/dist/reference/open.js.map +1 -0
- package/dist/reporting/artifacts.d.ts +8 -0
- package/dist/reporting/artifacts.js +23 -0
- package/dist/reporting/artifacts.js.map +1 -0
- package/dist/reporting/html.d.ts +4 -0
- package/dist/reporting/html.js +251 -0
- package/dist/reporting/html.js.map +1 -0
- package/dist/reporting/report.d.ts +12 -0
- package/dist/reporting/report.js +55 -0
- package/dist/reporting/report.js.map +1 -0
- package/dist/reporting/results-json.d.ts +36 -0
- package/dist/reporting/results-json.js +38 -0
- package/dist/reporting/results-json.js.map +1 -0
- package/dist/scenarios/glob.d.ts +7 -0
- package/dist/scenarios/glob.js +21 -0
- package/dist/scenarios/glob.js.map +1 -0
- package/dist/scenarios/model.d.ts +61 -0
- package/dist/scenarios/model.js +31 -0
- package/dist/scenarios/model.js.map +1 -0
- package/dist/scenarios/schema.d.ts +8 -0
- package/dist/scenarios/schema.js +70 -0
- package/dist/scenarios/schema.js.map +1 -0
- package/dist/shared/environment.d.ts +23 -0
- package/dist/shared/environment.js +2 -0
- package/dist/shared/environment.js.map +1 -0
- package/dist/shared/errors.d.ts +23 -0
- package/dist/shared/errors.js +29 -0
- package/dist/shared/errors.js.map +1 -0
- package/dist/shared/png.d.ts +3 -0
- package/dist/shared/png.js +14 -0
- package/dist/shared/png.js.map +1 -0
- package/dist/shared/size.d.ts +4 -0
- package/dist/shared/size.js +2 -0
- package/dist/shared/size.js.map +1 -0
- package/docs/architecture.md +176 -0
- package/docs/ci.md +86 -0
- package/docs/impact.md +61 -0
- package/docs/publishing.md +35 -0
- package/package.json +58 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 viewev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,149 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="assets/logo/Logo-horizontal.png" alt="Viewev" width="320" />
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
# Viewev
|
|
6
|
+
|
|
7
|
+
**Visual evaluation for the web.** Open-source visual regression testing for web interfaces.
|
|
8
|
+
|
|
9
|
+
Viewev captures screenshots of your UI, compares a pull request with a fresh capture of its target
|
|
10
|
+
branch, and shows you exactly what changed. It is product-agnostic, framework-agnostic and
|
|
11
|
+
local-first: no hosted service, no database, no accounts.
|
|
12
|
+
|
|
13
|
+
## Install the beta
|
|
14
|
+
|
|
15
|
+
Requires Node.js 20 or later. Install the beta as a development dependency:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install --save-dev viewev@beta
|
|
19
|
+
# or
|
|
20
|
+
yarn add --dev viewev@beta
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Install Chromium once with `npx playwright install chromium` (npm) or
|
|
24
|
+
`yarn exec playwright install chromium` (Yarn).
|
|
25
|
+
|
|
26
|
+
> **Status: early development (beta).** Pull request comparison can build and capture the target
|
|
27
|
+
> branch on demand; see [docs/ci.md](docs/ci.md).
|
|
28
|
+
|
|
29
|
+
Version tags publish automatically to npm after the release checks pass. See
|
|
30
|
+
[docs/publishing.md](docs/publishing.md) to configure npm trusted publishing and publish a beta.
|
|
31
|
+
|
|
32
|
+
## Typical PR workflow
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
viewev test # compare with the configured target branch, write a static HTML report
|
|
36
|
+
viewev test --compare-ref origin/release # choose a target branch for this run
|
|
37
|
+
viewev report # re-render the last report
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Pull request checks use a fresh target-branch capture and do not require checked-in image
|
|
41
|
+
baselines. The image-baseline commands below remain available as an optional legacy workflow.
|
|
42
|
+
|
|
43
|
+
Available today:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
viewev config check # validate the config file
|
|
47
|
+
viewev scenarios list [--filter <glob...>] # list the scenarios that would be captured
|
|
48
|
+
viewev test [--filter <glob...>] [-v] # compare against the configured target branch
|
|
49
|
+
viewev test [--compare-ref <ref>] # build and capture a Git ref as the reference
|
|
50
|
+
viewev test --base-ref <ref> # legacy mode: read committed image baselines
|
|
51
|
+
viewev test --baseline-dir <dir> --proposed-dir <dir> # use an explicitly checked-out baseline directory
|
|
52
|
+
viewev baseline create # create missing baselines only
|
|
53
|
+
viewev baseline update --filter <glob...> # approve changed screenshots (or --all)
|
|
54
|
+
viewev baseline prune [--yes] # list or delete baselines with no scenario
|
|
55
|
+
viewev report # render the HTML report again from the last run
|
|
56
|
+
viewev doctor # check Node.js, config, Chromium and Storybook
|
|
57
|
+
viewev capture --out <dir> # capture screenshots only (debugging aid)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
When `reference` is configured, `viewev test` creates a disposable checkout of the target branch,
|
|
61
|
+
runs its configured build commands, captures affected scenarios from that branch and compares
|
|
62
|
+
them with the current UI. Reference images live in memory for that run and are never committed.
|
|
63
|
+
Viewev writes a self-contained HTML report to
|
|
64
|
+
`.viewev/report/index.html` (expected, actual and difference images, with a switch between
|
|
65
|
+
expected and actual) plus `results.json`; both are ready to upload as CI artifacts. Exit codes:
|
|
66
|
+
`0` passed, `1` regressions or scenarios without a matching target-branch scenario, `2` execution
|
|
67
|
+
errors, `3` configuration or usage errors.
|
|
68
|
+
|
|
69
|
+
On GitHub Actions pull requests, Viewev uses `GITHUB_BASE_REF` automatically. The target ref must
|
|
70
|
+
be available locally; use `actions/checkout` with `fetch-depth: 0`. Each project supplies commands
|
|
71
|
+
to install and build its target-branch UI because Viewev does not assume a package manager or build
|
|
72
|
+
system. The commands run in a disposable checkout.
|
|
73
|
+
|
|
74
|
+
For example, to use `origin/main` outside GitHub pull request jobs:
|
|
75
|
+
|
|
76
|
+
```js
|
|
77
|
+
export default defineConfig({
|
|
78
|
+
provider: { type: 'storybook', staticDir: 'storybook-static' },
|
|
79
|
+
reference: {
|
|
80
|
+
baseRef: 'origin/main',
|
|
81
|
+
build: [
|
|
82
|
+
{ command: 'yarn', args: ['install', '--immutable'] },
|
|
83
|
+
{ command: 'yarn', args: ['build-storybook'] },
|
|
84
|
+
],
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
The `build` commands run from the target checkout root, in order. The Storybook output must be at
|
|
90
|
+
the configured `provider.staticDir` path. Storybook impact analysis follows story imports through
|
|
91
|
+
JavaScript, TypeScript and stylesheets; changes it cannot map confidently run all scenarios.
|
|
92
|
+
|
|
93
|
+
`capture` needs Chromium. Install it once with `npx playwright-core install chromium`.
|
|
94
|
+
With `provider.staticDir`, Viewev serves a built Storybook itself; with `provider.url`, it uses a
|
|
95
|
+
running one. Stories tagged `viewev-skip` are not captured.
|
|
96
|
+
|
|
97
|
+
## Configuration
|
|
98
|
+
|
|
99
|
+
Create `viewev.config.mjs` (or `.js`, `.json`) next to your project:
|
|
100
|
+
|
|
101
|
+
```js
|
|
102
|
+
import { defineConfig } from 'viewev';
|
|
103
|
+
|
|
104
|
+
export default defineConfig({
|
|
105
|
+
provider: { type: 'storybook', staticDir: 'storybook-static' },
|
|
106
|
+
viewport: { width: 1280, height: 720 },
|
|
107
|
+
});
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Everything except `provider` has a default. Unknown keys are rejected, so typos are caught.
|
|
111
|
+
|
|
112
|
+
### Variants
|
|
113
|
+
|
|
114
|
+
To capture every story more than once, for example in several themes or at a small width, add
|
|
115
|
+
`variants`. Each story becomes one scenario per variant, with ids like
|
|
116
|
+
`button--primary@g100`:
|
|
117
|
+
|
|
118
|
+
```js
|
|
119
|
+
variants: [
|
|
120
|
+
{ name: 'g10', globals: { 'backgrounds.value': 'g10' } },
|
|
121
|
+
{ name: 'g100', globals: { 'backgrounds.value': 'g100' } },
|
|
122
|
+
{ name: 'sm', viewport: { width: 320, height: 568 } },
|
|
123
|
+
],
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
`globals` are Storybook globals, passed to the story as `globals=key:value`. Use
|
|
127
|
+
`--filter '*@g100'` to run one variant.
|
|
128
|
+
|
|
129
|
+
## Platforms
|
|
130
|
+
|
|
131
|
+
Viewev runs on macOS, Linux and Windows. Fresh branch comparisons capture both refs in the same
|
|
132
|
+
run and environment. Optional local image baselines are stored per environment (`linux-chromium`,
|
|
133
|
+
`darwin-chromium`, `win32-chromium`).
|
|
134
|
+
|
|
135
|
+
## Development
|
|
136
|
+
|
|
137
|
+
Requires Node.js 20 or later.
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
npm install
|
|
141
|
+
npm run typecheck
|
|
142
|
+
npm run lint
|
|
143
|
+
npm test
|
|
144
|
+
npm run build
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## License
|
|
148
|
+
|
|
149
|
+
[MIT](LICENSE)
|
|
Binary file
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { openStorybook } from './provider.js';
|
|
2
|
+
export type { OpenStorybookOptions, StorybookSource } from './provider.js';
|
|
3
|
+
export { READY_SELECTOR, SKIP_TAG, storyUrl, toScenarioId, toStorybookScenarios, } from './scenarios.js';
|
|
4
|
+
export { startStaticServer } from './static-server.js';
|
|
5
|
+
export type { StaticServer } from './static-server.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adapters/storybook/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,EACL,cAAc,EACd,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,oBAAoB,GACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ScenarioProvider } from '../../scenarios/model.js';
|
|
2
|
+
import type { Size } from '../../shared/size.js';
|
|
3
|
+
import type { StorybookVariant } from './scenarios.js';
|
|
4
|
+
export interface OpenStorybookOptions {
|
|
5
|
+
/** URL of a running Storybook. Exactly one of `url` and `staticDir` must be set. */
|
|
6
|
+
readonly url?: string;
|
|
7
|
+
/** Absolute path of a built Storybook directory. */
|
|
8
|
+
readonly staticDir?: string;
|
|
9
|
+
readonly viewport: Size;
|
|
10
|
+
/** Render every story once per variant. Empty or missing means once, without a variant. */
|
|
11
|
+
readonly variants?: readonly StorybookVariant[];
|
|
12
|
+
}
|
|
13
|
+
export interface StorybookSource {
|
|
14
|
+
readonly provider: ScenarioProvider;
|
|
15
|
+
/** Where the Storybook is reachable, with a trailing slash. */
|
|
16
|
+
readonly baseUrl: string;
|
|
17
|
+
/** Stops the built-in server, if one was started. Safe to call more than once. */
|
|
18
|
+
close(): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Prepares a Storybook for discovery and capture. A running Storybook is used as is; a built
|
|
22
|
+
* one is served from a loopback HTTP server that lives until `close()` is called.
|
|
23
|
+
*/
|
|
24
|
+
export declare function openStorybook(options: OpenStorybookOptions): Promise<StorybookSource>;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { stat } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { ConfigError, ExitCode, ViewevError } from '../../shared/errors.js';
|
|
4
|
+
import { toStorybookScenarios } from './scenarios.js';
|
|
5
|
+
import { startStaticServer } from './static-server.js';
|
|
6
|
+
import { parseStorybookIndex } from './storybook-index.js';
|
|
7
|
+
const INDEX_FILES = ['index.json', 'stories.json'];
|
|
8
|
+
const REQUEST_TIMEOUT_MS = 15_000;
|
|
9
|
+
function describeFetchError(error) {
|
|
10
|
+
if (error instanceof Error) {
|
|
11
|
+
const cause = error.cause;
|
|
12
|
+
return cause instanceof Error ? cause.message : error.message;
|
|
13
|
+
}
|
|
14
|
+
return String(error);
|
|
15
|
+
}
|
|
16
|
+
async function fetchIndex(baseUrl, parent) {
|
|
17
|
+
const controller = new AbortController();
|
|
18
|
+
const timer = setTimeout(() => controller.abort(new Error('timed out')), REQUEST_TIMEOUT_MS);
|
|
19
|
+
const forward = () => controller.abort(parent.reason);
|
|
20
|
+
if (parent.aborted)
|
|
21
|
+
forward();
|
|
22
|
+
else
|
|
23
|
+
parent.addEventListener('abort', forward, { once: true });
|
|
24
|
+
try {
|
|
25
|
+
for (const file of INDEX_FILES) {
|
|
26
|
+
const url = new URL(file, baseUrl);
|
|
27
|
+
let response;
|
|
28
|
+
try {
|
|
29
|
+
response = await fetch(url, { signal: controller.signal });
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
throw new ViewevError(`Could not reach Storybook at ${baseUrl}: ${describeFetchError(error)}. Is it running?`, ExitCode.ExecutionError, { cause: error });
|
|
33
|
+
}
|
|
34
|
+
if (response.status === 404)
|
|
35
|
+
continue;
|
|
36
|
+
if (!response.ok) {
|
|
37
|
+
throw new ViewevError(`Storybook returned HTTP ${response.status} for ${url.toString()}.`, ExitCode.ExecutionError);
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
return { file, json: (await response.json()) };
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
throw new ViewevError(`${url.toString()} did not contain valid JSON.`, ExitCode.ExecutionError, { cause: error });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
finally {
|
|
49
|
+
clearTimeout(timer);
|
|
50
|
+
parent.removeEventListener('abort', forward);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async function loadEntries(baseUrl, signal) {
|
|
54
|
+
const found = await fetchIndex(baseUrl, signal);
|
|
55
|
+
if (found === undefined) {
|
|
56
|
+
throw new ViewevError(`No ${INDEX_FILES.join(' or ')} found at ${baseUrl}. ` +
|
|
57
|
+
'Storybook 6.4 or later generates it; make sure the URL points at the Storybook root.', ExitCode.ExecutionError);
|
|
58
|
+
}
|
|
59
|
+
return parseStorybookIndex(found.json, new URL(found.file, baseUrl).toString());
|
|
60
|
+
}
|
|
61
|
+
async function assertBuiltStorybook(directory) {
|
|
62
|
+
const iframe = path.join(directory, 'iframe.html');
|
|
63
|
+
try {
|
|
64
|
+
if ((await stat(iframe)).isFile())
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
// fall through to the error below
|
|
69
|
+
}
|
|
70
|
+
throw new ConfigError(`No built Storybook found in ${directory} (iframe.html is missing). ` +
|
|
71
|
+
'Run "storybook build" first, or point provider.url at a running Storybook.');
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Prepares a Storybook for discovery and capture. A running Storybook is used as is; a built
|
|
75
|
+
* one is served from a loopback HTTP server that lives until `close()` is called.
|
|
76
|
+
*/
|
|
77
|
+
export async function openStorybook(options) {
|
|
78
|
+
let server;
|
|
79
|
+
let baseUrl;
|
|
80
|
+
if (options.staticDir !== undefined) {
|
|
81
|
+
await assertBuiltStorybook(options.staticDir);
|
|
82
|
+
server = await startStaticServer(options.staticDir);
|
|
83
|
+
baseUrl = server.url;
|
|
84
|
+
}
|
|
85
|
+
else if (options.url !== undefined) {
|
|
86
|
+
baseUrl = options.url.endsWith('/') ? options.url : `${options.url}/`;
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
throw new ConfigError('The Storybook provider needs either "url" or "staticDir".');
|
|
90
|
+
}
|
|
91
|
+
const provider = {
|
|
92
|
+
name: 'storybook',
|
|
93
|
+
async discover(context) {
|
|
94
|
+
const entries = await loadEntries(baseUrl, context.signal);
|
|
95
|
+
return toStorybookScenarios(entries, {
|
|
96
|
+
baseUrl,
|
|
97
|
+
viewport: options.viewport,
|
|
98
|
+
...(options.variants !== undefined ? { variants: options.variants } : {}),
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
let closed = false;
|
|
103
|
+
return {
|
|
104
|
+
provider,
|
|
105
|
+
baseUrl,
|
|
106
|
+
close: async () => {
|
|
107
|
+
if (closed)
|
|
108
|
+
return;
|
|
109
|
+
closed = true;
|
|
110
|
+
await server?.close();
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../src/adapters/storybook/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,IAAI,MAAM,WAAW,CAAC;AAM7B,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAG3D,MAAM,WAAW,GAAG,CAAC,YAAY,EAAE,cAAc,CAAU,CAAC;AAC5D,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAoBlC,SAAS,kBAAkB,CAAC,KAAc;IACxC,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QAC1B,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC;IAChE,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AAED,KAAK,UAAU,UAAU,CACvB,OAAe,EACf,MAAmB;IAEnB,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;IACzC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,K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E,CAAC;QACxB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { VisualScenario } from '../../scenarios/model.js';
|
|
2
|
+
import type { Size } from '../../shared/size.js';
|
|
3
|
+
import type { StorybookEntry } from './storybook-index.js';
|
|
4
|
+
/** Stories carrying this tag are not captured. */
|
|
5
|
+
export declare const SKIP_TAG = "viewev-skip";
|
|
6
|
+
/**
|
|
7
|
+
* Storybook marks the preview body with `sb-show-main` once a story has rendered, and with
|
|
8
|
+
* `sb-show-errordisplay` when rendering failed. Both are DOM class names, not internal APIs.
|
|
9
|
+
*/
|
|
10
|
+
export declare const READY_SELECTOR = "body.sb-show-main:not(.sb-show-errordisplay)";
|
|
11
|
+
/** One way of rendering every story, for example a theme or a narrow viewport. */
|
|
12
|
+
export interface StorybookVariant {
|
|
13
|
+
readonly name: string;
|
|
14
|
+
readonly globals?: Readonly<Record<string, string>>;
|
|
15
|
+
readonly viewport?: Size;
|
|
16
|
+
}
|
|
17
|
+
export interface ConversionOptions {
|
|
18
|
+
readonly baseUrl: string;
|
|
19
|
+
readonly viewport: Size;
|
|
20
|
+
/** Empty or missing means every story is captured once, without a variant. */
|
|
21
|
+
readonly variants?: readonly StorybookVariant[];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Builds the preview URL of a story. `globals` use Storybook's own URL syntax
|
|
25
|
+
* (`globals=key:value;key:value`), which the config schema restricts to safe characters.
|
|
26
|
+
*/
|
|
27
|
+
export declare function storyUrl(baseUrl: string, storyId: string, globals?: Readonly<Record<string, string>>): string;
|
|
28
|
+
/** Storybook ids are already close to Viewev ids; this removes anything file systems dislike. */
|
|
29
|
+
export declare function toScenarioId(storyId: string): string;
|
|
30
|
+
export declare function toStorybookScenarios(entries: readonly StorybookEntry[], options: ConversionOptions): VisualScenario[];
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/** Stories carrying this tag are not captured. */
|
|
2
|
+
export const SKIP_TAG = 'viewev-skip';
|
|
3
|
+
/**
|
|
4
|
+
* Storybook marks the preview body with `sb-show-main` once a story has rendered, and with
|
|
5
|
+
* `sb-show-errordisplay` when rendering failed. Both are DOM class names, not internal APIs.
|
|
6
|
+
*/
|
|
7
|
+
export const READY_SELECTOR = 'body.sb-show-main:not(.sb-show-errordisplay)';
|
|
8
|
+
/**
|
|
9
|
+
* Builds the preview URL of a story. `globals` use Storybook's own URL syntax
|
|
10
|
+
* (`globals=key:value;key:value`), which the config schema restricts to safe characters.
|
|
11
|
+
*/
|
|
12
|
+
export function storyUrl(baseUrl, storyId, globals) {
|
|
13
|
+
const base = baseUrl.endsWith('/') ? baseUrl : `${baseUrl}/`;
|
|
14
|
+
const url = new URL('iframe.html', base);
|
|
15
|
+
url.searchParams.set('id', storyId);
|
|
16
|
+
url.searchParams.set('viewMode', 'story');
|
|
17
|
+
if (globals !== undefined && Object.keys(globals).length > 0) {
|
|
18
|
+
url.searchParams.set('globals', Object.entries(globals)
|
|
19
|
+
.map(([key, value]) => `${key}:${value}`)
|
|
20
|
+
.join(';'));
|
|
21
|
+
}
|
|
22
|
+
return url.toString();
|
|
23
|
+
}
|
|
24
|
+
/** Storybook ids are already close to Viewev ids; this removes anything file systems dislike. */
|
|
25
|
+
export function toScenarioId(storyId) {
|
|
26
|
+
return storyId
|
|
27
|
+
.normalize('NFKD')
|
|
28
|
+
.replace(/[\u0300-\u036f]/g, '')
|
|
29
|
+
.toLowerCase()
|
|
30
|
+
.replace(/[^a-z0-9._@-]+/g, '-')
|
|
31
|
+
.replace(/^[^a-z0-9]+/, '');
|
|
32
|
+
}
|
|
33
|
+
function isCapturableStory(entry) {
|
|
34
|
+
if (entry.type !== undefined && entry.type !== 'story')
|
|
35
|
+
return false;
|
|
36
|
+
if (entry.subtype === 'test')
|
|
37
|
+
return false;
|
|
38
|
+
return !(entry.tags ?? []).includes(SKIP_TAG);
|
|
39
|
+
}
|
|
40
|
+
export function toStorybookScenarios(entries, options) {
|
|
41
|
+
const variants = options.variants !== undefined && options.variants.length > 0 ? options.variants : [undefined];
|
|
42
|
+
return entries.filter(isCapturableStory).flatMap((entry) => variants.map((variant) => {
|
|
43
|
+
const baseId = toScenarioId(entry.id);
|
|
44
|
+
return {
|
|
45
|
+
id: (variant === undefined ? baseId : `${baseId}@${variant.name}`),
|
|
46
|
+
name: `${entry.title} / ${entry.name}` + (variant === undefined ? '' : ` [${variant.name}]`),
|
|
47
|
+
group: entry.title
|
|
48
|
+
.split('/')
|
|
49
|
+
.map((segment) => segment.trim())
|
|
50
|
+
.filter((segment) => segment.length > 0),
|
|
51
|
+
target: { kind: 'url', url: storyUrl(options.baseUrl, entry.id, variant?.globals) },
|
|
52
|
+
origin: {
|
|
53
|
+
provider: 'storybook',
|
|
54
|
+
ref: entry.id,
|
|
55
|
+
...(entry.importPath !== undefined ? { source: entry.importPath } : {}),
|
|
56
|
+
},
|
|
57
|
+
viewport: variant?.viewport ?? options.viewport,
|
|
58
|
+
...(variant !== undefined ? { variant: { name: variant.name } } : {}),
|
|
59
|
+
capture: { waitForSelector: READY_SELECTOR },
|
|
60
|
+
...(entry.tags !== undefined ? { tags: entry.tags } : {}),
|
|
61
|
+
};
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=scenarios.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scenarios.js","sourceRoot":"","sources":["../../../src/adapters/storybook/scenarios.ts"],"names":[],"mappings":"AAIA,kDAAkD;AAClD,MAAM,CAAC,MAAM,QAAQ,GAAG,aAAa,CAAC;AAEtC;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,8CAA8C,CAAC;AAgB7E;;;GAGG;AACH,MAAM,UAAU,QAAQ,CACtB,OAAe,EACf,OAAe,EACf,OAA0C;IAE1C,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,OA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AAE;gBACb,GAAG,CAAC,KAAK,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACxE;YACD,QAAQ,EAAE,OAAO,EAAE,QAAQ,IAAI,OAAO,CAAC,QAAQ;YAC/C,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACrE,OAAO,EAAE,EAAE,eAAe,EAAE,cAAc,EAAE;YAC5C,GAAG,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC1D,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface StaticServer {
|
|
2
|
+
/** Base URL with a trailing slash, for example http://127.0.0.1:51234/ */
|
|
3
|
+
readonly url: string;
|
|
4
|
+
close(): Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Serves a directory over HTTP on the loopback interface. A built Storybook cannot be opened
|
|
8
|
+
* from file:// URLs, so Viewev serves it itself rather than requiring an extra tool.
|
|
9
|
+
*/
|
|
10
|
+
export declare function startStaticServer(directory: string): Promise<StaticServer>;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { createReadStream } from 'node:fs';
|
|
2
|
+
import { stat } from 'node:fs/promises';
|
|
3
|
+
import { createServer } from 'node:http';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
const MIME_TYPES = {
|
|
6
|
+
'.html': 'text/html; charset=utf-8',
|
|
7
|
+
'.js': 'text/javascript; charset=utf-8',
|
|
8
|
+
'.mjs': 'text/javascript; charset=utf-8',
|
|
9
|
+
'.css': 'text/css; charset=utf-8',
|
|
10
|
+
'.json': 'application/json; charset=utf-8',
|
|
11
|
+
'.map': 'application/json; charset=utf-8',
|
|
12
|
+
'.txt': 'text/plain; charset=utf-8',
|
|
13
|
+
'.svg': 'image/svg+xml',
|
|
14
|
+
'.png': 'image/png',
|
|
15
|
+
'.jpg': 'image/jpeg',
|
|
16
|
+
'.jpeg': 'image/jpeg',
|
|
17
|
+
'.gif': 'image/gif',
|
|
18
|
+
'.webp': 'image/webp',
|
|
19
|
+
'.ico': 'image/x-icon',
|
|
20
|
+
'.woff': 'font/woff',
|
|
21
|
+
'.woff2': 'font/woff2',
|
|
22
|
+
'.ttf': 'font/ttf',
|
|
23
|
+
'.otf': 'font/otf',
|
|
24
|
+
'.wasm': 'application/wasm',
|
|
25
|
+
};
|
|
26
|
+
function send(response, status, message) {
|
|
27
|
+
response.writeHead(status, { 'Content-Type': 'text/plain; charset=utf-8' });
|
|
28
|
+
response.end(message);
|
|
29
|
+
}
|
|
30
|
+
function isOutside(root, target) {
|
|
31
|
+
const relative = path.relative(root, target);
|
|
32
|
+
return relative === '..' || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative);
|
|
33
|
+
}
|
|
34
|
+
async function handle(root, request, response) {
|
|
35
|
+
if (request.method !== 'GET' && request.method !== 'HEAD') {
|
|
36
|
+
send(response, 405, 'Method not allowed');
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
let pathname;
|
|
40
|
+
try {
|
|
41
|
+
pathname = decodeURIComponent(new URL(request.url ?? '/', 'http://localhost').pathname);
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
send(response, 400, 'Bad request');
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (pathname.includes('\0')) {
|
|
48
|
+
send(response, 400, 'Bad request');
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
// Never serve anything outside the root, whatever the separators or dot segments.
|
|
52
|
+
let target = path.resolve(root, `.${pathname}`);
|
|
53
|
+
if (isOutside(root, target)) {
|
|
54
|
+
send(response, 403, 'Forbidden');
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
if ((await stat(target)).isDirectory())
|
|
59
|
+
target = path.join(target, 'index.html');
|
|
60
|
+
const info = await stat(target);
|
|
61
|
+
if (!info.isFile())
|
|
62
|
+
throw new Error('not a file');
|
|
63
|
+
response.writeHead(200, {
|
|
64
|
+
'Content-Type': MIME_TYPES[path.extname(target).toLowerCase()] ?? 'application/octet-stream',
|
|
65
|
+
'Content-Length': info.size,
|
|
66
|
+
'Cache-Control': 'no-store',
|
|
67
|
+
});
|
|
68
|
+
if (request.method === 'HEAD') {
|
|
69
|
+
response.end();
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const stream = createReadStream(target);
|
|
73
|
+
stream.on('error', () => response.destroy());
|
|
74
|
+
stream.pipe(response);
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
send(response, 404, 'Not found');
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Serves a directory over HTTP on the loopback interface. A built Storybook cannot be opened
|
|
82
|
+
* from file:// URLs, so Viewev serves it itself rather than requiring an extra tool.
|
|
83
|
+
*/
|
|
84
|
+
export async function startStaticServer(directory) {
|
|
85
|
+
const root = path.resolve(directory);
|
|
86
|
+
const server = createServer((request, response) => {
|
|
87
|
+
void handle(root, request, response);
|
|
88
|
+
});
|
|
89
|
+
await new Promise((resolve, reject) => {
|
|
90
|
+
server.once('error', reject);
|
|
91
|
+
server.listen(0, '127.0.0.1', () => {
|
|
92
|
+
server.off('error', reject);
|
|
93
|
+
resolve();
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
const { port } = server.address();
|
|
97
|
+
return {
|
|
98
|
+
url: `http://127.0.0.1:${port}/`,
|
|
99
|
+
close: () => new Promise((resolve) => {
|
|
100
|
+
server.close(() => resolve());
|
|
101
|
+
server.closeAllConnections();
|
|
102
|
+
}),
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=static-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"static-server.js","sourceRoot":"","sources":["../../../src/adapters/storybook/static-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAGzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,UAAU,GAAqC;IACnD,OAAO,EAAE,0BAA0B;IACnC,KAAK,EAAE,gCAAgC;IACvC,MAAM,EAAE,gCAAgC;IACxC,MAAM,EAAE,yBAAyB;IACjC,OAAO,EAAE,iCAAiC;IAC1C,MAAM,EAAE,iCAAiC;IACzC,MAAM,EAAE,2BAA2B;IACnC,MAAM,EAAE,eAAe;IACvB,MAAM,EAAE,WAAW;IACnB,MAAM,EAAE,YAAY;IACpB,OAAO,EAAE,YAAY;IACrB,MAAM,EAAE,WAAW;IACnB,OAAO,EAAE,YAAY;IACrB,MAAM,EAAE,cAAc;IACtB,OAAO,EAAE,WAAW;IACpB,QAAQ,EAAE,YAAY;IACtB,MAAM,EAAE,UAAU;IAClB,MAAM,EAAE,UAAU;IAClB,OAAO,EAAE,kBAAkB;CAC5B,CAAC;AAQF,SAAS,IAAI,CAAC,QAAwB,EAAE,MAAc,EAAE,OAAe;IACrE,QAAQ,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,cAAc,EAAE,2BAA2B,EAAE,CAAC,CAAC;IAC5E,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AACxB,CAAC;AAED,SAAS,SAAS,CAAC,IAAY,EAAE,MAAc;IAC7C,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CA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AM,CAAC,CAAC;QAC7B,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,WAAW,EAAE,GAAG,EAAE;YACjC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YAC5B,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC,OAAO,EAAiB,CAAC;IACjD,OAAO;QACL,GAAG,EAAE,oBAAoB,IAAI,GAAG;QAChC,KAAK,EAAE,GAAG,EAAE,CACV,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;YAC5B,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;YAC9B,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAC/B,CAAC,CAAC;KACL,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
declare const entrySchema: z.ZodObject<{
|
|
3
|
+
id: z.ZodString;
|
|
4
|
+
title: z.ZodString;
|
|
5
|
+
name: z.ZodString;
|
|
6
|
+
/** Absent in very old indexes, where every entry is a story. */
|
|
7
|
+
type: z.ZodOptional<z.ZodString>;
|
|
8
|
+
subtype: z.ZodOptional<z.ZodString>;
|
|
9
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
10
|
+
importPath: z.ZodOptional<z.ZodString>;
|
|
11
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
12
|
+
id: z.ZodString;
|
|
13
|
+
title: z.ZodString;
|
|
14
|
+
name: z.ZodString;
|
|
15
|
+
/** Absent in very old indexes, where every entry is a story. */
|
|
16
|
+
type: z.ZodOptional<z.ZodString>;
|
|
17
|
+
subtype: z.ZodOptional<z.ZodString>;
|
|
18
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
19
|
+
importPath: z.ZodOptional<z.ZodString>;
|
|
20
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
21
|
+
id: z.ZodString;
|
|
22
|
+
title: z.ZodString;
|
|
23
|
+
name: z.ZodString;
|
|
24
|
+
/** Absent in very old indexes, where every entry is a story. */
|
|
25
|
+
type: z.ZodOptional<z.ZodString>;
|
|
26
|
+
subtype: z.ZodOptional<z.ZodString>;
|
|
27
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
28
|
+
importPath: z.ZodOptional<z.ZodString>;
|
|
29
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
30
|
+
export type StorybookEntry = z.infer<typeof entrySchema>;
|
|
31
|
+
export declare function parseStorybookIndex(json: unknown, source: string): StorybookEntry[];
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ExitCode, ViewevError } from '../../shared/errors.js';
|
|
3
|
+
/*
|
|
4
|
+
* Reads Storybook's generated index (index.json, or stories.json from older versions).
|
|
5
|
+
* Only documented, stable fields are used; everything else is ignored.
|
|
6
|
+
*/
|
|
7
|
+
const entrySchema = z
|
|
8
|
+
.object({
|
|
9
|
+
id: z.string().min(1),
|
|
10
|
+
title: z.string(),
|
|
11
|
+
name: z.string(),
|
|
12
|
+
/** Absent in very old indexes, where every entry is a story. */
|
|
13
|
+
type: z.string().optional(),
|
|
14
|
+
subtype: z.string().optional(),
|
|
15
|
+
tags: z.array(z.string()).optional(),
|
|
16
|
+
importPath: z.string().min(1).optional(),
|
|
17
|
+
})
|
|
18
|
+
.passthrough();
|
|
19
|
+
const indexSchema = z
|
|
20
|
+
.object({
|
|
21
|
+
entries: z.record(entrySchema).optional(),
|
|
22
|
+
stories: z.record(entrySchema).optional(),
|
|
23
|
+
})
|
|
24
|
+
.passthrough();
|
|
25
|
+
export function parseStorybookIndex(json, source) {
|
|
26
|
+
const parsed = indexSchema.safeParse(json);
|
|
27
|
+
const entries = parsed.success ? (parsed.data.entries ?? parsed.data.stories) : undefined;
|
|
28
|
+
if (entries === undefined) {
|
|
29
|
+
const detail = parsed.success ? 'it has neither "entries" nor "stories"' : parsed.error.message;
|
|
30
|
+
throw new ViewevError(`${source} is not a Storybook index (${detail}). Storybook 6.4 or later is required.`, ExitCode.ExecutionError);
|
|
31
|
+
}
|
|
32
|
+
// Sorted so discovery order never depends on how Storybook happened to write the file.
|
|
33
|
+
return Object.values(entries).sort((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=storybook-index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storybook-index.js","sourceRoot":"","sources":["../../../src/adapters/storybook/storybook-index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE/D;;;GAGG;AAEH,MAAM,WAAW,GAAG,CAAC;KAClB,MAAM,CAAC;IACN,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACrB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,gEAAgE;IAChE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IACpC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CACzC,CAAC;KACD,WAAW,EAAE,CAAC;AAEjB,MAAM,WAAW,GAAG,CAAC;KAClB,MAAM,CAAC;IACN,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE;IACzC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE;CAC1C,CAAC;KACD,WAAW,EAAE,CAAC;AAIjB,MAAM,UAAU,mBAAmB,CAAC,IAAa,EAAE,MAAc;IAC/D,MAAM,MAAM,GAAG,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC3C,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1F,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,wCAAwC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC;QAChG,MAAM,IAAI,WAAW,CACnB,GAAG,MAAM,8BAA8B,MAAM,wCAAwC,EACrF,QAAQ,CAAC,cAAc,CACxB,CAAC;IACJ,CAAC;IACD,uFAAuF;IACvF,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACzF,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { EnvironmentInfo } from '../shared/environment.js';
|
|
2
|
+
/**
|
|
3
|
+
* Describes how two environments differ in ways that can change rendering: the browser and
|
|
4
|
+
* automation versions, the CPU architecture and the operating system. The OS release and
|
|
5
|
+
* whether a container was used are recorded but do not count as differences.
|
|
6
|
+
*/
|
|
7
|
+
export declare function environmentDifferences(baseline: EnvironmentInfo, current: EnvironmentInfo): string[];
|