@visual-check/cli 0.1.2 → 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/dist/addon-child/image-files.js +1 -1
- package/dist/addon-child/image-files.js.map +1 -1
- package/dist/agent-skill/skill-files.d.ts +4 -0
- package/dist/agent-skill/skill-files.d.ts.map +1 -1
- package/dist/agent-skill/skill-files.js +4 -0
- package/dist/agent-skill/skill-files.js.map +1 -1
- package/dist/baselines/baseline-error.d.ts +15 -2
- package/dist/baselines/baseline-error.d.ts.map +1 -1
- package/dist/baselines/baseline-error.js +32 -2
- package/dist/baselines/baseline-error.js.map +1 -1
- package/dist/capture/capture-session.d.ts +161 -30
- package/dist/capture/capture-session.d.ts.map +1 -1
- package/dist/capture/capture-session.js +263 -70
- package/dist/capture/capture-session.js.map +1 -1
- package/dist/capture/driver/cdp/cdp-page.d.ts.map +1 -1
- package/dist/capture/driver/cdp/cdp-page.js +120 -31
- package/dist/capture/driver/cdp/cdp-page.js.map +1 -1
- package/dist/capture/driver/cdp/failed-loads.d.ts +16 -0
- package/dist/capture/driver/cdp/failed-loads.d.ts.map +1 -0
- package/dist/capture/driver/cdp/failed-loads.js +71 -0
- package/dist/capture/driver/cdp/failed-loads.js.map +1 -0
- package/dist/capture/driver/cdp/launch-arguments.d.ts +7 -1
- package/dist/capture/driver/cdp/launch-arguments.d.ts.map +1 -1
- package/dist/capture/driver/cdp/launch-arguments.js +8 -1
- package/dist/capture/driver/cdp/launch-arguments.js.map +1 -1
- package/dist/capture/driver/driver.d.ts +88 -4
- package/dist/capture/driver/driver.d.ts.map +1 -1
- package/dist/capture/driver/driver.js +33 -0
- package/dist/capture/driver/driver.js.map +1 -1
- package/dist/capture/page-script.d.ts +7 -6
- package/dist/capture/page-script.d.ts.map +1 -1
- package/dist/capture/page-script.js +10 -9
- package/dist/capture/page-script.js.map +1 -1
- package/dist/capture/prepare-capture.d.ts +50 -3
- package/dist/capture/prepare-capture.d.ts.map +1 -1
- package/dist/capture/prepare-capture.js +157 -16
- package/dist/capture/prepare-capture.js.map +1 -1
- package/dist/commands/check-storybooks.d.ts +5 -4
- package/dist/commands/check-storybooks.d.ts.map +1 -1
- package/dist/commands/check-storybooks.js +11 -8
- package/dist/commands/check-storybooks.js.map +1 -1
- package/dist/commands/consistency-output.d.ts.map +1 -1
- package/dist/commands/consistency-output.js +3 -3
- package/dist/commands/consistency-output.js.map +1 -1
- package/dist/commands/failed-loads-hint.d.ts +7 -0
- package/dist/commands/failed-loads-hint.d.ts.map +1 -0
- package/dist/commands/failed-loads-hint.js +16 -0
- package/dist/commands/failed-loads-hint.js.map +1 -0
- package/dist/commands/local-update.d.ts +22 -0
- package/dist/commands/local-update.d.ts.map +1 -0
- package/dist/commands/local-update.js +39 -0
- package/dist/commands/local-update.js.map +1 -0
- package/dist/commands/network-warning.d.ts.map +1 -1
- package/dist/commands/network-warning.js +2 -18
- package/dist/commands/network-warning.js.map +1 -1
- package/dist/commands/plan-snapshots.d.ts +23 -8
- package/dist/commands/plan-snapshots.d.ts.map +1 -1
- package/dist/commands/plan-snapshots.js +15 -9
- package/dist/commands/plan-snapshots.js.map +1 -1
- package/dist/commands/report-entries.d.ts +5 -2
- package/dist/commands/report-entries.d.ts.map +1 -1
- package/dist/commands/report-entries.js +63 -15
- package/dist/commands/report-entries.js.map +1 -1
- package/dist/commands/run-browser.d.ts +5 -5
- package/dist/commands/run-browser.d.ts.map +1 -1
- package/dist/commands/run-browser.js +1 -0
- package/dist/commands/run-browser.js.map +1 -1
- package/dist/commands/run-cli.d.ts +16 -5
- package/dist/commands/run-cli.d.ts.map +1 -1
- package/dist/commands/run-cli.js +74 -54
- package/dist/commands/run-cli.js.map +1 -1
- package/dist/commands/run-report.d.ts +3 -3
- package/dist/commands/run-report.d.ts.map +1 -1
- package/dist/commands/run-report.js +4 -2
- package/dist/commands/run-report.js.map +1 -1
- package/dist/commands/run-snapshots.d.ts +7 -4
- package/dist/commands/run-snapshots.d.ts.map +1 -1
- package/dist/commands/run-snapshots.js +49 -17
- package/dist/commands/run-snapshots.js.map +1 -1
- package/dist/commands/snapshot-result.d.ts +66 -9
- package/dist/commands/snapshot-result.d.ts.map +1 -1
- package/dist/commands/snapshot-result.js +46 -6
- package/dist/commands/snapshot-result.js.map +1 -1
- package/dist/commands/stop-message.d.ts.map +1 -1
- package/dist/commands/stop-message.js +6 -1
- package/dist/commands/stop-message.js.map +1 -1
- package/dist/commands/stopped-run.d.ts +10 -5
- package/dist/commands/stopped-run.d.ts.map +1 -1
- package/dist/commands/stopped-run.js +35 -22
- package/dist/commands/stopped-run.js.map +1 -1
- package/dist/commands/take-snapshot.d.ts +9 -6
- package/dist/commands/take-snapshot.d.ts.map +1 -1
- package/dist/commands/take-snapshot.js +16 -7
- package/dist/commands/take-snapshot.js.map +1 -1
- package/dist/commands/test-snapshot.d.ts +2 -2
- package/dist/commands/test-snapshot.d.ts.map +1 -1
- package/dist/commands/test-snapshot.js.map +1 -1
- package/dist/commands/update-baselines.d.ts.map +1 -1
- package/dist/commands/update-baselines.js +3 -2
- package/dist/commands/update-baselines.js.map +1 -1
- package/dist/commands/update-snapshot.d.ts +22 -4
- package/dist/commands/update-snapshot.d.ts.map +1 -1
- package/dist/commands/update-snapshot.js +79 -18
- package/dist/commands/update-snapshot.js.map +1 -1
- package/dist/config/checks.d.ts +26 -0
- package/dist/config/checks.d.ts.map +1 -1
- package/dist/config/checks.js +68 -6
- package/dist/config/checks.js.map +1 -1
- package/dist/config/define-config.d.ts +38 -2
- package/dist/config/define-config.d.ts.map +1 -1
- package/dist/config/define-config.js.map +1 -1
- package/dist/config/resolve-config.d.ts +15 -2
- package/dist/config/resolve-config.d.ts.map +1 -1
- package/dist/config/resolve-config.js +6 -0
- package/dist/config/resolve-config.js.map +1 -1
- package/dist/config/story-options.d.ts +32 -4
- package/dist/config/story-options.d.ts.map +1 -1
- package/dist/config/story-options.js +38 -7
- package/dist/config/story-options.js.map +1 -1
- package/dist/config/unrunnable-regexp.d.ts +22 -0
- package/dist/config/unrunnable-regexp.d.ts.map +1 -0
- package/dist/config/unrunnable-regexp.js +25 -0
- package/dist/config/unrunnable-regexp.js.map +1 -0
- package/dist/config/validate-config.d.ts.map +1 -1
- package/dist/config/validate-config.js +6 -21
- package/dist/config/validate-config.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/init/find-storybooks.d.ts +5 -0
- package/dist/init/find-storybooks.d.ts.map +1 -1
- package/dist/init/find-storybooks.js +8 -1
- package/dist/init/find-storybooks.js.map +1 -1
- package/dist/init/ignored-skill.d.ts +50 -0
- package/dist/init/ignored-skill.d.ts.map +1 -0
- package/dist/init/ignored-skill.js +61 -0
- package/dist/init/ignored-skill.js.map +1 -0
- package/dist/init/install.d.ts +24 -9
- package/dist/init/install.d.ts.map +1 -1
- package/dist/init/install.js +66 -26
- package/dist/init/install.js.map +1 -1
- package/dist/init/package-manager.d.ts +6 -0
- package/dist/init/package-manager.d.ts.map +1 -1
- package/dist/init/package-manager.js +4 -0
- package/dist/init/package-manager.js.map +1 -1
- package/dist/init/run-init.d.ts +17 -4
- package/dist/init/run-init.d.ts.map +1 -1
- package/dist/init/run-init.js +31 -11
- package/dist/init/run-init.js.map +1 -1
- package/dist/init/workspace.d.ts +2 -0
- package/dist/init/workspace.d.ts.map +1 -1
- package/dist/init/workspace.js +2 -0
- package/dist/init/workspace.js.map +1 -1
- package/dist/page-errors/judge-page-errors.d.ts +50 -0
- package/dist/page-errors/judge-page-errors.d.ts.map +1 -0
- package/dist/page-errors/judge-page-errors.js +39 -0
- package/dist/page-errors/judge-page-errors.js.map +1 -0
- package/dist/page-errors/page-error-policy.d.ts +36 -0
- package/dist/page-errors/page-error-policy.d.ts.map +1 -0
- package/dist/page-errors/page-error-policy.js +15 -0
- package/dist/page-errors/page-error-policy.js.map +1 -0
- package/dist/real-network-requests/judge-real-requests.d.ts +26 -0
- package/dist/real-network-requests/judge-real-requests.d.ts.map +1 -0
- package/dist/real-network-requests/judge-real-requests.js +17 -0
- package/dist/real-network-requests/judge-real-requests.js.map +1 -0
- package/dist/real-network-requests/real-request-policy.d.ts +29 -0
- package/dist/real-network-requests/real-request-policy.d.ts.map +1 -0
- package/dist/real-network-requests/real-request-policy.js +10 -0
- package/dist/real-network-requests/real-request-policy.js.map +1 -0
- package/dist/real-network-requests/silenced-hosts.d.ts +9 -0
- package/dist/real-network-requests/silenced-hosts.d.ts.map +1 -0
- package/dist/real-network-requests/silenced-hosts.js +28 -0
- package/dist/real-network-requests/silenced-hosts.js.map +1 -0
- package/dist/report/report-document.d.ts +154 -9
- package/dist/report/report-document.d.ts.map +1 -1
- package/dist/report/report-document.js +1 -1
- package/dist/report/report-document.js.map +1 -1
- package/dist/report/report-folder.d.ts +7 -3
- package/dist/report/report-folder.d.ts.map +1 -1
- package/dist/report/report-folder.js +5 -5
- package/dist/report/report-folder.js.map +1 -1
- package/dist/reporter/end-block.d.ts +32 -3
- package/dist/reporter/end-block.d.ts.map +1 -1
- package/dist/reporter/end-block.js +55 -3
- package/dist/reporter/end-block.js.map +1 -1
- package/dist/reporter/page-errors-block.d.ts +52 -0
- package/dist/reporter/page-errors-block.d.ts.map +1 -0
- package/dist/reporter/page-errors-block.js +98 -0
- package/dist/reporter/page-errors-block.js.map +1 -0
- package/dist/reporter/real-requests-block.d.ts +33 -0
- package/dist/reporter/real-requests-block.d.ts.map +1 -0
- package/dist/reporter/real-requests-block.js +53 -0
- package/dist/reporter/real-requests-block.js.map +1 -0
- package/dist/step-summary/step-summary.d.ts +27 -7
- package/dist/step-summary/step-summary.d.ts.map +1 -1
- package/dist/step-summary/step-summary.js +107 -15
- package/dist/step-summary/step-summary.js.map +1 -1
- package/dist/storybook/options-encoding.d.ts +18 -5
- package/dist/storybook/options-encoding.d.ts.map +1 -1
- package/dist/storybook/options-encoding.js +12 -4
- package/dist/storybook/options-encoding.js.map +1 -1
- package/dist/storybook/options-read.d.ts +3 -2
- package/dist/storybook/options-read.d.ts.map +1 -1
- package/dist/storybook/options-read.js +17 -0
- package/dist/storybook/options-read.js.map +1 -1
- package/dist/storybook/read-stories.d.ts +15 -0
- package/dist/storybook/read-stories.d.ts.map +1 -1
- package/dist/storybook/read-stories.js +60 -14
- package/dist/storybook/read-stories.js.map +1 -1
- package/package.json +2 -1
- package/skill/SKILL.md +25 -7
|
@@ -15,7 +15,26 @@ import { pageRootsFunction } from './page-roots.js';
|
|
|
15
15
|
* whole pixels and cut at the page's edge: the left and top edges rounded down and kept at 0 or more, the right and
|
|
16
16
|
* bottom edges kept within the document's scrollable area, read from its root element's `scrollWidth` and
|
|
17
17
|
* `scrollHeight`, and rounded up. When that size can't be read, the right and bottom edges aren't cut. A box of zero
|
|
18
|
-
* width or height, before or after that, or one that can't be read, gives `found: 'zero-size'`.
|
|
18
|
+
* width or height, before or after that, or one that can't be read, gives `found: 'zero-size'`. Then it measures
|
|
19
|
+
* the overflow, content the capture would cut, as how far it reaches past each side, in CSS pixels. For the full
|
|
20
|
+
* page, that's the right side only: the root element's `scrollWidth` less its `clientWidth`, unless the root
|
|
21
|
+
* element or `body` has a computed `overflow-x` of `hidden` or `clip`, as the page cuts that itself. The capture
|
|
22
|
+
* takes the content's full height, and content left of the page's edge can't be scrolled to. For the element, the
|
|
23
|
+
* left and top sides are how far its border box, with the page's scroll, reaches past the page's left and top
|
|
24
|
+
* edges, where its box is cut. The right side is how far its content spills past its border box's right edge,
|
|
25
|
+
* only when its computed `overflow-x` is `visible` and its `direction` is `ltr`, as a right-to-left element's
|
|
26
|
+
* `scrollWidth` counts content spilling left: the content's right edge is its border box's left edge, with the
|
|
27
|
+
* page's scroll, plus its `clientLeft` and its `scrollWidth`. Those are lengths of the element's own layout, so when
|
|
28
|
+
* its border box is drawn a whole pixel or more wider or narrower than its `offsetWidth`, as a transform or zoom
|
|
29
|
+
* draws it, they're scaled by the drawn width over `offsetWidth`. Both edges are kept within the document's
|
|
30
|
+
* scrollable area when its size can be read. The bottom side is the same with `overflow-y`, `clientTop`,
|
|
31
|
+
* `scrollHeight` and `offsetHeight`, whatever the direction. Chrome's `scrollWidth` and `scrollHeight` of an element that doesn't clip cover descendants
|
|
32
|
+
* spilling right or down, transformed or absolutely positioned ones included, but not `position: fixed` ones, the
|
|
33
|
+
* top layer or a `box-shadow`, and scrollable overflow never reaches left or up, so content spilling left or up
|
|
34
|
+
* from an element isn't measured. A side counts when it's at least one whole CSS pixel, as Chrome rounds
|
|
35
|
+
* `scrollWidth` and `clientWidth` to whole pixels, and is rounded up. A side whose values can't be read, or aren't
|
|
36
|
+
* finite, doesn't count, nor does the full page's when the root element's or `body`'s style can't be read. When the
|
|
37
|
+
* element is missing or a selector is invalid, there's no overflow.
|
|
19
38
|
* 2. Finds the masks' boxes. A selector mask covers each element of the top document that matches it and has an
|
|
20
39
|
* area, by its border box, with the page's scroll, not rounded. A selector that throws gives
|
|
21
40
|
* `{ outcome: 'invalid-selector', of: 'mask', name, message }`. Then the remote content search runs once, with the
|
|
@@ -46,7 +65,8 @@ import { pageRootsFunction } from './page-roots.js';
|
|
|
46
65
|
* `findRemote` is true and the search answered, it adds `remote`, the remote content found, maybe none: each item's
|
|
47
66
|
* `host`, with its port when the URL has one, and its box, `x`, `y`, `width` and `height`, in CSS pixels of the top
|
|
48
67
|
* document, as the search gives them. Without `remote`, the remote content is unknown. When the top document shows a
|
|
49
|
-
* grid, it adds `grid`, the widest grid's width and the tallest grid's height. When
|
|
68
|
+
* grid, it adds `grid`, the widest grid's width and the tallest grid's height. When at least one side of the overflow
|
|
69
|
+
* counts, it adds `overflow`, `{ top, right, bottom, left }`, 0 on a side that doesn't. When the element is missing, a
|
|
50
70
|
* selector is invalid or the search for a host mask timed out, it paints nothing and hides no caret. It never throws. A
|
|
51
71
|
* mask must never fail open: when finding the masks' boxes or painting them throws, as when the search for a host mask
|
|
52
72
|
* rejects or an element can't be created, it answers `{ outcome: 'paint-failed', message }` and hides no caret, with
|
|
@@ -107,6 +127,94 @@ export const prepareCaptureFunction = `(context) => {
|
|
|
107
127
|
return valid(width) && valid(height) ? { width, height } : undefined
|
|
108
128
|
}
|
|
109
129
|
|
|
130
|
+
// A number a getter reads, or undefined when it can't be read or isn't a finite number.
|
|
131
|
+
const numberOf = (getter) => {
|
|
132
|
+
const value = read(getter, undefined)
|
|
133
|
+
return typeof value === 'number' && Number.isFinite(value) ? value : undefined
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// The computed value of a CSS property of an element of the top document, or undefined when it can't be read.
|
|
137
|
+
const computedOf = (element, property) => {
|
|
138
|
+
const value = read(() => document.defaultView.getComputedStyle(element).getPropertyValue(property), undefined)
|
|
139
|
+
return typeof value === 'string' ? value : undefined
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// How far content reaches past a side of the capture, in CSS pixels: rounded up when it's at least one whole pixel,
|
|
143
|
+
// and 0 when it's less or unknown, as Chrome rounds scrollWidth and clientWidth to whole pixels.
|
|
144
|
+
const excessOf = (excess) =>
|
|
145
|
+
typeof excess === 'number' && Number.isFinite(excess) && excess >= 1 ? Math.ceil(excess) : 0
|
|
146
|
+
|
|
147
|
+
// The overflow on each side, or undefined when no side counts.
|
|
148
|
+
const overflowOf = ({ top, right, bottom, left }) => {
|
|
149
|
+
const overflow = { top: excessOf(top), right: excessOf(right), bottom: excessOf(bottom), left: excessOf(left) }
|
|
150
|
+
return Object.values(overflow).some((side) => side > 0) ? overflow : undefined
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// The full page's overflow: how far its content reaches past the viewport's right edge, or undefined when nothing
|
|
154
|
+
// does, the root element or body clips it with overflow-x hidden or clip, or that can't be read.
|
|
155
|
+
const pageOverflowOf = () => {
|
|
156
|
+
const root = read(() => document.documentElement, undefined)
|
|
157
|
+
const body = read(() => document.body, undefined)
|
|
158
|
+
const clips = (element) => {
|
|
159
|
+
const value = computedOf(element, 'overflow-x')
|
|
160
|
+
return value === undefined || value === 'hidden' || value === 'clip'
|
|
161
|
+
}
|
|
162
|
+
if (!isObject(root) || [root, body].filter(isObject).some(clips)) {
|
|
163
|
+
return undefined
|
|
164
|
+
}
|
|
165
|
+
const scrollWidth = numberOf(() => root.scrollWidth)
|
|
166
|
+
const clientWidth = numberOf(() => root.clientWidth)
|
|
167
|
+
if (scrollWidth === undefined || clientWidth === undefined) {
|
|
168
|
+
return undefined
|
|
169
|
+
}
|
|
170
|
+
return overflowOf({ top: 0, right: scrollWidth - clientWidth, bottom: 0, left: 0 })
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Whether an element lets its content spill along an axis: its computed overflow on that axis is visible, and, along
|
|
174
|
+
// x, its direction is ltr, as a right-to-left element's scrollWidth counts content spilling left.
|
|
175
|
+
const spillsOn = (element, axis) =>
|
|
176
|
+
computedOf(element, axis === 'x' ? 'overflow-x' : 'overflow-y') === 'visible' &&
|
|
177
|
+
(axis === 'y' || computedOf(element, 'direction') === 'ltr')
|
|
178
|
+
|
|
179
|
+
// How a length in an element's own layout maps to the document along an axis: its border box's drawn extent over its
|
|
180
|
+
// layout size, offsetWidth or offsetHeight, when they differ by a whole pixel or more, as a transform or zoom makes
|
|
181
|
+
// them, and 1 otherwise, as the layout size is rounded to whole pixels. Undefined when the layout size can't be read.
|
|
182
|
+
const scaleOf = (element, axis, extent) => {
|
|
183
|
+
const layout = numberOf(() => (axis === 'x' ? element.offsetWidth : element.offsetHeight))
|
|
184
|
+
if (layout === undefined || layout <= 0) {
|
|
185
|
+
return undefined
|
|
186
|
+
}
|
|
187
|
+
return Math.abs(extent - layout) < 1 ? 1 : extent / layout
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// How far an element's content spills past its border box's far edge along an axis, from its border box's near and
|
|
191
|
+
// far edges in document coordinates, or undefined when the element doesn't let it spill or it can't be read. The
|
|
192
|
+
// content's end is clientLeft and scrollWidth past the near edge, or clientTop and scrollHeight, lengths of the
|
|
193
|
+
// element's own layout, scaled to the document, so a transform or zoom neither makes a spill nor hides one. Both
|
|
194
|
+
// ends are kept within the document's scrollable area, limit, when it's known.
|
|
195
|
+
const spillOf = (element, axis, near, far, limit) => {
|
|
196
|
+
if (!spillsOn(element, axis)) {
|
|
197
|
+
return undefined
|
|
198
|
+
}
|
|
199
|
+
const border = numberOf(() => (axis === 'x' ? element.clientLeft : element.clientTop))
|
|
200
|
+
const content = numberOf(() => (axis === 'x' ? element.scrollWidth : element.scrollHeight))
|
|
201
|
+
const scale = scaleOf(element, axis, far - near)
|
|
202
|
+
if (border === undefined || content === undefined || scale === undefined) {
|
|
203
|
+
return undefined
|
|
204
|
+
}
|
|
205
|
+
const within = (end) => (limit === undefined ? end : Math.min(end, limit))
|
|
206
|
+
return within(near + (border + content) * scale) - within(far)
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// An element's overflow, from its border box in document coordinates, or undefined when no side counts.
|
|
210
|
+
const elementOverflowOf = (element, box, size) =>
|
|
211
|
+
overflowOf({
|
|
212
|
+
top: -box.top,
|
|
213
|
+
right: spillOf(element, 'x', box.left, box.right, size === undefined ? undefined : size.width),
|
|
214
|
+
bottom: spillOf(element, 'y', box.top, box.bottom, size === undefined ? undefined : size.height),
|
|
215
|
+
left: -box.left,
|
|
216
|
+
})
|
|
217
|
+
|
|
110
218
|
// An element's border box, with the page's scroll, or undefined when it has no area or can't be read.
|
|
111
219
|
const documentBoxOf = (element, scroll) => {
|
|
112
220
|
const rect = read(() => element.getBoundingClientRect(), undefined)
|
|
@@ -122,7 +230,8 @@ export const prepareCaptureFunction = `(context) => {
|
|
|
122
230
|
}
|
|
123
231
|
}
|
|
124
232
|
|
|
125
|
-
// The box of the element the selector matches first, out to whole pixels,
|
|
233
|
+
// The box of the element the selector matches first, out to whole pixels, with its overflow when a side counts, or
|
|
234
|
+
// why there's none.
|
|
126
235
|
const elementBoxOf = (selector, scroll) => {
|
|
127
236
|
let element
|
|
128
237
|
try {
|
|
@@ -147,7 +256,7 @@ export const prepareCaptureFunction = `(context) => {
|
|
|
147
256
|
if (width <= 0 || height <= 0) {
|
|
148
257
|
return { outcome: 'element-missing', found: 'zero-size' }
|
|
149
258
|
}
|
|
150
|
-
return { box: { x, y, width, height } }
|
|
259
|
+
return { box: { x, y, width, height }, overflow: elementOverflowOf(element, box, size) }
|
|
151
260
|
}
|
|
152
261
|
|
|
153
262
|
// The boxes of the elements a selector mask covers, or why there are none.
|
|
@@ -330,7 +439,7 @@ export const prepareCaptureFunction = `(context) => {
|
|
|
330
439
|
const { element, masks, maskColor, findRemote } = request
|
|
331
440
|
const scroll = pageScrollOf()
|
|
332
441
|
const grid = gridOf()
|
|
333
|
-
const measured = element === null ? { box: null } : elementBoxOf(element, scroll)
|
|
442
|
+
const measured = element === null ? { box: null, overflow: pageOverflowOf() } : elementBoxOf(element, scroll)
|
|
334
443
|
if (measured.outcome !== undefined) {
|
|
335
444
|
return measured
|
|
336
445
|
}
|
|
@@ -346,6 +455,7 @@ export const prepareCaptureFunction = `(context) => {
|
|
|
346
455
|
...ready,
|
|
347
456
|
...(painted.remote === undefined ? {} : { remote: painted.remote }),
|
|
348
457
|
...(grid === undefined ? {} : { grid }),
|
|
458
|
+
...(measured.overflow === undefined ? {} : { overflow: measured.overflow }),
|
|
349
459
|
}
|
|
350
460
|
}
|
|
351
461
|
}`;
|
|
@@ -409,27 +519,58 @@ function readGrid(value) {
|
|
|
409
519
|
return [width, height].every((side) => Number.isFinite(side) && side >= 0) ? { grid: { width, height } } : undefined;
|
|
410
520
|
}
|
|
411
521
|
/**
|
|
412
|
-
* Reads
|
|
413
|
-
*
|
|
522
|
+
* Reads the overflow the page gives with an answer that's ready, keeping its four sides only. Gives
|
|
523
|
+
* `{ overflow: undefined }` when there's none, and `undefined` when it's not four finite sides of 0 or more.
|
|
414
524
|
*/
|
|
415
|
-
function
|
|
416
|
-
|
|
525
|
+
function readOverflow(value) {
|
|
526
|
+
if (value === undefined) {
|
|
527
|
+
return { overflow: undefined };
|
|
528
|
+
}
|
|
529
|
+
if (typeof value !== 'object' || value === null) {
|
|
530
|
+
return undefined;
|
|
531
|
+
}
|
|
532
|
+
const { top, right, bottom, left } = { ...value };
|
|
533
|
+
if (typeof top !== 'number' || typeof right !== 'number' || typeof bottom !== 'number' || typeof left !== 'number') {
|
|
534
|
+
return undefined;
|
|
535
|
+
}
|
|
536
|
+
return [top, right, bottom, left].every((side) => Number.isFinite(side) && side >= 0)
|
|
537
|
+
? { overflow: { top, right, bottom, left } }
|
|
538
|
+
: undefined;
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* Reads what the page gives besides the box with an answer that's ready: the remote content, the grids and the
|
|
542
|
+
* overflow, each only when the page gives it. Gives `undefined` when any of them isn't what the page gives.
|
|
543
|
+
*/
|
|
544
|
+
function readExtras(answer) {
|
|
417
545
|
const read = readRemote(answer.remote);
|
|
418
546
|
const readGrids = readGrid(answer.grid);
|
|
419
|
-
|
|
547
|
+
const readOverflows = readOverflow(answer.overflow);
|
|
548
|
+
if (read === undefined || readGrids === undefined || readOverflows === undefined) {
|
|
549
|
+
return undefined;
|
|
550
|
+
}
|
|
551
|
+
return {
|
|
552
|
+
...(read.remote === undefined ? {} : { remote: read.remote }),
|
|
553
|
+
...(readGrids.grid === undefined ? {} : { grid: readGrids.grid }),
|
|
554
|
+
...(readOverflows.overflow === undefined ? {} : { overflow: readOverflows.overflow }),
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* Reads an answer of the page that's ready, with the element's box or none, and the remote content, the grids and the
|
|
559
|
+
* overflow when it gives them. Gives `undefined` for any other answer.
|
|
560
|
+
*/
|
|
561
|
+
function readReady(answer) {
|
|
562
|
+
const { box } = answer;
|
|
563
|
+
const extras = readExtras(answer);
|
|
564
|
+
if (answer.outcome !== 'ready' || extras === undefined) {
|
|
420
565
|
return undefined;
|
|
421
566
|
}
|
|
422
567
|
if (box !== null && !isCaptureBox(box)) {
|
|
423
568
|
return undefined;
|
|
424
569
|
}
|
|
425
|
-
|
|
570
|
+
return {
|
|
426
571
|
outcome: 'ready',
|
|
427
572
|
box: box === null ? null : { x: box.x, y: box.y, width: box.width, height: box.height },
|
|
428
|
-
|
|
429
|
-
return {
|
|
430
|
-
...ready,
|
|
431
|
-
...(read.remote === undefined ? {} : { remote: read.remote }),
|
|
432
|
-
...(readGrids.grid === undefined ? {} : { grid: readGrids.grid }),
|
|
573
|
+
...extras,
|
|
433
574
|
};
|
|
434
575
|
}
|
|
435
576
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepare-capture.js","sourceRoot":"","sources":["../../src/capture/prepare-capture.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"prepare-capture.js","sourceRoot":"","sources":["../../src/capture/prepare-capture.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAqHnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0EG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;;gFAE0C,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8X/F,CAAA;AA8FF;;GAEG;AACH,SAAS,Y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E,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE;QAC5D,CAAC,CAAC,SAAS,CAAA;AACf,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,MAAM,MAAM,GAA4B,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;IACvG,MAAM,IAAI,GAAG,SAAS,CAAC,MAAM,CAAC,IAAI,YAAY,CAAC,MAAM,CAAC,IAAI,WAAW,CAAC,MAAM,CAAC,CAAA;IAE7E,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM,IAAI,KAAK,CACb,+EAA+E,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CACxG,CAAA;AACH,CAAC"}
|
|
@@ -59,10 +59,11 @@ interface UnreachableStorybook {
|
|
|
59
59
|
url: string;
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
62
|
-
* Checks every Storybook in the run: the version of its installed `storybook`, then its stories from `index.json
|
|
63
|
-
* Each Storybook that passes comes back with
|
|
64
|
-
* config order, with the Storybooks where nothing answers, by
|
|
65
|
-
* of them unreachable, the problems end with a line that
|
|
62
|
+
* Checks every Storybook in the run: the version of its installed `storybook`, then its stories from `index.json`, then
|
|
63
|
+
* that its story page doesn't redirect. Each Storybook that passes comes back with its version and stories. Every
|
|
64
|
+
* Storybook is checked, and every problem is reported, in config order, with the Storybooks where nothing answers, by
|
|
65
|
+
* name and URL. With several Storybooks in the run and one of them unreachable, the problems end with a line that
|
|
66
|
+
* suggests `--storybook`.
|
|
66
67
|
*
|
|
67
68
|
* @throws {Error} When a check fails in a way that isn't a Storybook's problem.
|
|
68
69
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-storybooks.d.ts","sourceRoot":"","sources":["../../src/commands/check-storybooks.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"check-storybooks.d.ts","sourceRoot":"","sources":["../../src/commands/check-storybooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,KAAK,EAAE,MAAM,8BAA8B,CAAA;AAItF;;GAEG;AACH,UAAU,cAAc;IACtB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;CACZ;AAED;;GAEG;AACH,UAAU,gBAAgB,CAAC,CAAC,SAAS,cAAc;IACjD;;OAEG;IACH,SAAS,EAAE,CAAC,CAAA;IACZ;;OAEG;IACH,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B;;OAEG;IACH,OAAO,EAAE,KAAK,EAAE,CAAA;CACjB;AAED;;;GAGG;AACH,KAAK,eAAe,CAAC,CAAC,SAAS,cAAc,IACzC;IAAE,UAAU,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,GACzD;IAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;IAAC,WAAW,EAAE,oBAAoB,EAAE,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAAA;AAEnF;;GAEG;AACH,UAAU,oBAAoB;IAC5B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;CACZ;AAqCD;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CAAC,CAAC,SAAS,cAAc,EAC5D,UAAU,EAAE,CAAC,EAAE,EACf,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAwB7B"}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { readStories } from '../storybook/read-stories.js';
|
|
1
|
+
import { checkStoryPage, readStories } from '../storybook/read-stories.js';
|
|
2
2
|
import { StorybookError, StorybookUnreachableError } from '../storybook/storybook-error.js';
|
|
3
3
|
import { checkStorybookVersion } from '../storybook/storybook-version.js';
|
|
4
4
|
/**
|
|
5
|
-
* Checks one Storybook's version, then reads its stories
|
|
6
|
-
* its `index.json` isn't read. A Storybook's own error becomes a problem; any other error is thrown.
|
|
5
|
+
* Checks one Storybook's version, then reads its stories, then checks that its story page doesn't redirect. A version
|
|
6
|
+
* that is too old is the Storybook's problem, and its `index.json` isn't read. A Storybook's own error becomes a problem; any other error is thrown.
|
|
7
7
|
*/
|
|
8
8
|
async function checkOneStorybook(storybook, cwd) {
|
|
9
9
|
let warning;
|
|
10
10
|
try {
|
|
11
11
|
const check = checkStorybookVersion(storybook, cwd);
|
|
12
12
|
warning = check.warning;
|
|
13
|
-
|
|
13
|
+
const stories = await readStories(storybook, cwd);
|
|
14
|
+
await checkStoryPage(storybook);
|
|
15
|
+
return { storybook, version: check.version, stories, warning };
|
|
14
16
|
}
|
|
15
17
|
catch (error) {
|
|
16
18
|
if (error instanceof StorybookError) {
|
|
@@ -20,10 +22,11 @@ async function checkOneStorybook(storybook, cwd) {
|
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
/**
|
|
23
|
-
* Checks every Storybook in the run: the version of its installed `storybook`, then its stories from `index.json
|
|
24
|
-
* Each Storybook that passes comes back with
|
|
25
|
-
* config order, with the Storybooks where nothing answers, by
|
|
26
|
-
* of them unreachable, the problems end with a line that
|
|
25
|
+
* Checks every Storybook in the run: the version of its installed `storybook`, then its stories from `index.json`, then
|
|
26
|
+
* that its story page doesn't redirect. Each Storybook that passes comes back with its version and stories. Every
|
|
27
|
+
* Storybook is checked, and every problem is reported, in config order, with the Storybooks where nothing answers, by
|
|
28
|
+
* name and URL. With several Storybooks in the run and one of them unreachable, the problems end with a line that
|
|
29
|
+
* suggests `--storybook`.
|
|
27
30
|
*
|
|
28
31
|
* @throws {Error} When a check fails in a way that isn't a Storybook's problem.
|
|
29
32
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-storybooks.js","sourceRoot":"","sources":["../../src/commands/check-storybooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAc,MAAM,8BAA8B,CAAA;
|
|
1
|
+
{"version":3,"file":"check-storybooks.js","sourceRoot":"","sources":["../../src/commands/check-storybooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAc,MAAM,8BAA8B,CAAA;AACtF,OAAO,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAA;AAC3F,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAA;AAqEzE;;;GAGG;AACH,KAAK,UAAU,iBAAiB,CAA2B,SAAY,EAAE,GAAW;IAClF,IAAI,OAA2B,CAAA;IAE/B,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,qBAAqB,CAAC,SAAS,EAAE,GAAG,CAAC,CAAA;QAEnD,OAAO,GAAG,KAAK,CAAC,OAAO,CAAA;QAEvB,MAAM,OAAO,GAAG,MAAM,WAAW,CAAC,SAAS,EAAE,GAAG,CAAC,CAAA;QAEjD,MAAM,cAAc,CAAC,SAAS,CAAC,CAAA;QAE/B,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAA;IAChE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,cAAc,EAAE,CAAC;YACpC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,YAAY,yBAAyB,EAAE,OAAO,EAAE,CAAA;QAChH,CAAC;QAED,MAAM,KAAK,CAAA;IACb,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,UAAe,EACf,GAAW;IAEX,MA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CAAA;IAC9E,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAA;AAC5C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consistency-output.d.ts","sourceRoot":"","sources":["../../src/commands/consistency-output.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,gBAAgB,EAAgB,KAAK,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AACrG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAE1D,OAAO,
|
|
1
|
+
{"version":3,"file":"consistency-output.d.ts","sourceRoot":"","sources":["../../src/commands/consistency-output.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,gBAAgB,EAAgB,KAAK,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AACrG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAE1D,OAAO,EAGL,KAAK,cAAc,EAGpB,MAAM,sBAAsB,CAAA;AAE7B;;GAEG;AACH,UAAU,WAAW;IACnB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,OAAO,EAAE,SAAS,eAAe,EAAE,CAAA;IACnC;;OAEG;IACH,KAAK,EAAE,gBAAgB,CAAA;CACxB;AAED;;GAEG;AACH,UAAU,iBAAiB;IACzB;;OAEG;IACH,UAAU,EAAE,OAAO,CAAA;IACnB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,KAAK,EAAE,eAAe,EAAE,CAAA;IACxB;;OAEG;IACH,OAAO,EAAE,cAAc,EAAE,CAAA;CAC1B;AAOD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,kBAAkB,EAAE,GAAG,MAAM,EAAE,CAQ9F;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,WAAW,GAAG,iBAAiB,CA6BpG"}
|
|
@@ -4,7 +4,7 @@ import { displayPathOf } from '../report/display-path.js';
|
|
|
4
4
|
import { countsLineOf, orphanLabelOf } from '../reporter/counts-line.js';
|
|
5
5
|
import { isConsistent } from './consistency-check.js';
|
|
6
6
|
import { failMark, snapshotCountOf, snapshotLineOf } from './run-output.js';
|
|
7
|
-
import { brokenResultOf, missingResultOf } from './snapshot-result.js';
|
|
7
|
+
import { brokenResultOf, missingResultOf, withNothingJudged, } from './snapshot-result.js';
|
|
8
8
|
/**
|
|
9
9
|
* The line that ends the consistency output when the check found nothing.
|
|
10
10
|
*/
|
|
@@ -29,9 +29,9 @@ export function orphanLinesOf(cwd, storybooks) {
|
|
|
29
29
|
export function consistencyOutputOf({ version, cwd, planned, check }) {
|
|
30
30
|
const findings = planned.flatMap((item) => {
|
|
31
31
|
if ('broken' in item) {
|
|
32
|
-
return [{ item, result: brokenResultOf(item.broken, { attempts: 0 }) }];
|
|
32
|
+
return [{ item, result: withNothingJudged(brokenResultOf(item.broken, { attempts: 0 })) }];
|
|
33
33
|
}
|
|
34
|
-
return check.missing.has(item) ? [{ item, result: missingResultOf() }] : [];
|
|
34
|
+
return check.missing.has(item) ? [{ item, result: withNothingJudged(missingResultOf()) }] : [];
|
|
35
35
|
});
|
|
36
36
|
const results = findings.map(({ result }) => result);
|
|
37
37
|
const orphanLines = orphanLinesOf(cwd, check.storybooks);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consistency-output.js","sourceRoot":"","sources":["../../src/commands/consistency-output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,EAAE,Y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AC;QACnE,GAAG,WAAW;QACd,UAAU,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC;KACnD,CAAA;IAED,OAAO;QACL,UAAU;QACV,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;QACjD,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC;QACvC,OAAO;KACR,CAAA;AACH,CAAC;AAED;;GAEG;AACH,SAAS,OAAO,CAAC,OAAkC,EAAE,MAAsB;IACzE,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,MAAM,CAAA;AACpE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gives the hint for a broken story whose page couldn't load some of Storybook's own files, in one line, for the report
|
|
3
|
+
* and `test`'s end block: the server dropped the connection, which a server that can't take many connections at once
|
|
4
|
+
* does under parallel workers, what to serve the build with instead, and the CI docs page.
|
|
5
|
+
*/
|
|
6
|
+
export declare function failedLoadsHintMessageOf(): string;
|
|
7
|
+
//# sourceMappingURL=failed-loads-hint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"failed-loads-hint.d.ts","sourceRoot":"","sources":["../../src/commands/failed-loads-hint.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,wBAAgB,wBAAwB,IAAI,MAAM,CAMjD"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { docsUrlOf } from '../docs-site/docs-url.js';
|
|
2
|
+
/**
|
|
3
|
+
* The docs page about running visual-check in CI, which says how to serve a static Storybook build.
|
|
4
|
+
*/
|
|
5
|
+
const ciDocsUrl = docsUrlOf('ci');
|
|
6
|
+
/**
|
|
7
|
+
* Gives the hint for a broken story whose page couldn't load some of Storybook's own files, in one line, for the report
|
|
8
|
+
* and `test`'s end block: the server dropped the connection, which a server that can't take many connections at once
|
|
9
|
+
* does under parallel workers, what to serve the build with instead, and the CI docs page.
|
|
10
|
+
*/
|
|
11
|
+
export function failedLoadsHintMessageOf() {
|
|
12
|
+
return ("Storybook's server dropped the connection or never answered. A server that can't take many connections at once, " +
|
|
13
|
+
'such as python3 -m http.server, does this under parallel workers. Serve the static build with npx http-server ' +
|
|
14
|
+
`instead, or run fewer --workers. See ${ciDocsUrl}`);
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=failed-loads-hint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"failed-loads-hint.js","sourceRoot":"","sources":["../../src/commands/failed-loads-hint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAEpD;;GAEG;AACH,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,CAAA;AAEjC;;;;GAIG;AACH,MAAM,UAAU,wBAAwB;IACtC,OAAO,CACL,kHAAkH;QAClH,gHAAgH;QAChH,wCAAwC,SAAS,EAAE,CACpD,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Platform } from '../config/define-config.js';
|
|
2
|
+
import { type Manifest } from '../init/package-manager.js';
|
|
3
|
+
import type { LocalUpdate } from '../step-summary/step-summary.js';
|
|
4
|
+
/**
|
|
5
|
+
* Gives the name of the manifest's first script, in order, whose command is exactly `visual-check update` after
|
|
6
|
+
* trimming and whose name holds no backtick or line break, so it fits in a code span as written, or `undefined` when
|
|
7
|
+
* none is.
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export declare function updateScriptOf(manifest: Manifest): string | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Gives how the person updates the baselines on their machine: the script in the `package.json` beside the config
|
|
14
|
+
* that runs `visual-check update`, none when that file is missing or isn't valid JSON, and whether the browser runs in
|
|
15
|
+
* Docker, which it does on every platform but `host`. For a setup `init` made, that `package.json` is the workspace
|
|
16
|
+
* root's, where `init` wrote the scripts. With `--config` naming a config in a subfolder, or a config above the
|
|
17
|
+
* workspace root, it usually holds no such script, and the summary names plain `visual-check update`.
|
|
18
|
+
*
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export declare function localUpdateOf(configPath: string, platform: Platform): LocalUpdate;
|
|
22
|
+
//# sourceMappingURL=local-update.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-update.d.ts","sourceRoot":"","sources":["../../src/commands/local-update.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAgB,KAAK,QAAQ,EAAa,MAAM,4BAA4B,CAAA;AAEnF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAalE;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS,CAMrE;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,WAAW,CAIjF"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { dirname, join } from 'node:path';
|
|
2
|
+
import { isJsonObject, scriptsOf } from '../init/package-manager.js';
|
|
3
|
+
import { readJsonFile } from '../init/workspace.js';
|
|
4
|
+
/**
|
|
5
|
+
* The command a script must run, after trimming, to be the one the step summary names.
|
|
6
|
+
*/
|
|
7
|
+
const updateCommand = 'visual-check update';
|
|
8
|
+
/**
|
|
9
|
+
* What a script's name must not hold for the step summary to name it: a backtick or a line break, the only characters
|
|
10
|
+
* that break a Markdown code span.
|
|
11
|
+
*/
|
|
12
|
+
const codeSpanBreaker = /[`\r\n]/;
|
|
13
|
+
/**
|
|
14
|
+
* Gives the name of the manifest's first script, in order, whose command is exactly `visual-check update` after
|
|
15
|
+
* trimming and whose name holds no backtick or line break, so it fits in a code span as written, or `undefined` when
|
|
16
|
+
* none is.
|
|
17
|
+
*
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
export function updateScriptOf(manifest) {
|
|
21
|
+
const found = Object.entries(scriptsOf(manifest)).find(([name, command]) => {
|
|
22
|
+
return command.trim() === updateCommand && !codeSpanBreaker.test(name);
|
|
23
|
+
});
|
|
24
|
+
return found?.[0];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Gives how the person updates the baselines on their machine: the script in the `package.json` beside the config
|
|
28
|
+
* that runs `visual-check update`, none when that file is missing or isn't valid JSON, and whether the browser runs in
|
|
29
|
+
* Docker, which it does on every platform but `host`. For a setup `init` made, that `package.json` is the workspace
|
|
30
|
+
* root's, where `init` wrote the scripts. With `--config` naming a config in a subfolder, or a config above the
|
|
31
|
+
* workspace root, it usually holds no such script, and the summary names plain `visual-check update`.
|
|
32
|
+
*
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
35
|
+
export function localUpdateOf(configPath, platform) {
|
|
36
|
+
const manifest = readJsonFile(join(dirname(configPath), 'package.json'));
|
|
37
|
+
return { script: isJsonObject(manifest) ? updateScriptOf(manifest) : undefined, docker: platform !== 'host' };
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=local-update.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-update.js","sourceRoot":"","sources":["../../src/commands/local-update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEzC,OAAO,EAAE,YAAY,EAAiB,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACnF,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAGnD;;GAEG;AACH,MAAM,aAAa,GAAG,qBAAqB,CAAA;AAE3C;;;GAGG;AACH,MAAM,eAAe,GAAG,SAAS,CAAA;AAEjC;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,QAAkB;IAC/C,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,EAAE;QACzE,OAAO,OAAO,CAAC,IAAI,EAAE,KAAK,aAAa,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACxE,CAAC,CAAC,CAAA;IAEF,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,CAAA;AACnB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAAC,UAAkB,EAAE,QAAkB;IAClE,MAAM,QAAQ,GAAG,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,cAAc,CAAC,CAAC,CAAA;IAExE,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,KAAK,MAAM,EAAE,CAAA;AAC/G,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network-warning.d.ts","sourceRoot":"","sources":["../../src/commands/network-warning.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAA;
|
|
1
|
+
{"version":3,"file":"network-warning.d.ts","sourceRoot":"","sources":["../../src/commands/network-warning.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAA;AAE/D,OAAO,KAAK,EAAkB,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAOjF;;;GAGG;AACH,UAAU,UAAU;IAClB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,KAAK,EAAE,UAAU,CAAA;CAClB;AA6ED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,UAAU,EAAE,EAAE,YAAY,EAAE,SAAS,MAAM,EAAE,GAAG,aAAa,EAAE,CAoBhH;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,GAAG,MAAM,CAEzE"}
|
|
@@ -1,24 +1,8 @@
|
|
|
1
|
+
import { isSilenced } from '../real-network-requests/silenced-hosts.js';
|
|
1
2
|
/**
|
|
2
3
|
* The stories shown in a host's line, before the line ends the list with `, …`.
|
|
3
4
|
*/
|
|
4
5
|
const listedStoryCount = 3;
|
|
5
|
-
/**
|
|
6
|
-
* Whether the entry silences the host. Both are compared in lower case. An exact entry silences the host it names, with
|
|
7
|
-
* or without a port: it matches the host as a page reports it, such as `localhost:6006`, and its hostname, such as
|
|
8
|
-
* `localhost`. `*.example.com` silences the subdomains of `example.com` at any depth, by the host or its hostname, so
|
|
9
|
-
* `*.example.com:8443` works too, but not `example.com` itself or a host that only ends the same, such as
|
|
10
|
-
* `badexample.com`.
|
|
11
|
-
*/
|
|
12
|
-
function silences(entry, host) {
|
|
13
|
-
const lowerEntry = entry.toLowerCase();
|
|
14
|
-
const lowerHost = host.toLowerCase();
|
|
15
|
-
const hostname = lowerHost.replace(/:\d+$/, '');
|
|
16
|
-
if (lowerEntry.startsWith('*.')) {
|
|
17
|
-
const suffix = lowerEntry.slice(1);
|
|
18
|
-
return lowerHost.endsWith(suffix) || hostname.endsWith(suffix);
|
|
19
|
-
}
|
|
20
|
-
return lowerEntry === lowerHost || lowerEntry === hostname;
|
|
21
|
-
}
|
|
22
6
|
/**
|
|
23
7
|
* Gives the stories of each host, once per Storybook and story, in the order the snapshots come in, each named by its
|
|
24
8
|
* ID or, with `labelled`, by its Storybook's name and ID. Hosts in `silenceHosts` are left out.
|
|
@@ -27,7 +11,7 @@ function storiesByHostOf(taken, labelled, hostsOf, silenceHosts) {
|
|
|
27
11
|
const byHost = new Map();
|
|
28
12
|
for (const { storybook, storyId, hosts } of taken) {
|
|
29
13
|
for (const host of hostsOf(hosts)) {
|
|
30
|
-
if (
|
|
14
|
+
if (isSilenced(host, silenceHosts)) {
|
|
31
15
|
continue;
|
|
32
16
|
}
|
|
33
17
|
const stories = byHost.get(host) ?? new Map();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network-warning.js","sourceRoot":"","sources":["../../src/commands/network-warning.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"network-warning.js","sourceRoot":"","sources":["../../src/commands/network-warning.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAA;AAGvE;;GAEG;AACH,MAAM,gBAAgB,GAAG,CAAC,CAAA;AAmC1B;;;GAGG;AACH,SAAS,eAAe,CACtB,KAA4B,EAC5B,QAAiB,EACjB,OAAwC,EACxC,YAA+B;IAE/B,MAAM,MAAM,GAAG,IAAI,GAAG,EAAsC,CAAA;IAE5D,KAAK,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,KAAK,EAAE,CAAC;QAClD,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAClC,IAAI,UAAU,CAAC,IAAI,EAAE,YAAY,CAAC,EAAE,CAAC;gBACnC,SAAQ;YACV,CAAC;YAED,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,EAAyB,CAAA;YAEpE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,EAAE;gBAChD,GAAG,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,E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