@chromatic-com/playwright 0.14.0 → 0.14.1-431e625-20260518134753
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/bin/archive-storybook.js +4 -30
- package/dist/bin/build-archive-storybook.js +4 -30
- package/dist/index.d.mts +16 -4
- package/dist/index.d.ts +16 -4
- package/dist/index.js +96 -90
- package/dist/index.mjs +96 -90
- package/dist/storybook-config/main.mjs +0 -76
- package/dist/storybook-config/preview.mjs +10 -24
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@ var child_process = require('child_process');
|
|
|
5
5
|
var path = require('path');
|
|
6
6
|
var fs = require('fs');
|
|
7
7
|
var module$1 = require('module');
|
|
8
|
+
require('crypto');
|
|
8
9
|
|
|
9
10
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
10
11
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -20,32 +21,20 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
20
21
|
return require.apply(this, arguments);
|
|
21
22
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
22
23
|
});
|
|
23
|
-
var __defProp2 = Object.defineProperty;
|
|
24
|
-
var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name", { value, configurable: true }), "__name");
|
|
25
|
-
var __require2 = /* @__PURE__ */ ((x) => typeof __require !== "undefined" ? __require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
26
|
-
get: (a, b) => (typeof __require !== "undefined" ? __require : a)[b]
|
|
27
|
-
}) : x)(function(x) {
|
|
28
|
-
if (typeof __require !== "undefined")
|
|
29
|
-
return __require.apply(this, arguments);
|
|
30
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
31
|
-
});
|
|
32
24
|
function rootDir() {
|
|
33
25
|
return process.cwd();
|
|
34
26
|
}
|
|
35
27
|
__name(rootDir, "rootDir");
|
|
36
|
-
__name2(rootDir, "rootDir");
|
|
37
28
|
function outputDirOverride() {
|
|
38
29
|
const { CHROMATIC_ARCHIVE_LOCATION } = process.env;
|
|
39
30
|
return CHROMATIC_ARCHIVE_LOCATION;
|
|
40
31
|
}
|
|
41
32
|
__name(outputDirOverride, "outputDirOverride");
|
|
42
|
-
__name2(outputDirOverride, "outputDirOverride");
|
|
43
33
|
function archivesDir(defaultOutputDir) {
|
|
44
34
|
const outputDir = outputDirOverride() || defaultOutputDir;
|
|
45
35
|
return path__default.default.resolve(rootDir(), outputDir, "chromatic-archives");
|
|
46
36
|
}
|
|
47
37
|
__name(archivesDir, "archivesDir");
|
|
48
|
-
__name2(archivesDir, "archivesDir");
|
|
49
38
|
function checkArchivesDirExists(defaultOutputDir) {
|
|
50
39
|
const dir = archivesDir(defaultOutputDir);
|
|
51
40
|
if (!fs.existsSync(dir)) {
|
|
@@ -55,8 +44,9 @@ Please make sure that you have run your E2E tests, or have set the CHROMATIC_ARC
|
|
|
55
44
|
}
|
|
56
45
|
}
|
|
57
46
|
__name(checkArchivesDirExists, "checkArchivesDirExists");
|
|
58
|
-
|
|
59
|
-
|
|
47
|
+
|
|
48
|
+
// ../shared/src/archive-storybook/index.ts
|
|
49
|
+
var req = __require.resolve ? __require : module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('out.js', document.baseURI).href)));
|
|
60
50
|
function archiveStorybook(processArgs, configDir2, defaultOutputDir) {
|
|
61
51
|
checkArchivesDirExists(defaultOutputDir);
|
|
62
52
|
child_process.execFileSync("node", [
|
|
@@ -70,28 +60,12 @@ function archiveStorybook(processArgs, configDir2, defaultOutputDir) {
|
|
|
70
60
|
});
|
|
71
61
|
}
|
|
72
62
|
__name(archiveStorybook, "archiveStorybook");
|
|
73
|
-
__name2(archiveStorybook, "archiveStorybook");
|
|
74
|
-
function buildArchiveStorybook(processArgs, configDir2, defaultOutputDir) {
|
|
75
|
-
checkArchivesDirExists(defaultOutputDir);
|
|
76
|
-
child_process.execFileSync("node", [
|
|
77
|
-
binPath(),
|
|
78
|
-
"build",
|
|
79
|
-
...processArgs,
|
|
80
|
-
"-c",
|
|
81
|
-
configDir2
|
|
82
|
-
], {
|
|
83
|
-
stdio: "inherit"
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
__name(buildArchiveStorybook, "buildArchiveStorybook");
|
|
87
|
-
__name2(buildArchiveStorybook, "buildArchiveStorybook");
|
|
88
63
|
function binPath() {
|
|
89
64
|
const filename = req.resolve("storybook/package.json");
|
|
90
65
|
const packageJson = JSON.parse(fs.readFileSync(filename, "utf8"));
|
|
91
66
|
return path.resolve(path.dirname(filename), packageJson.bin);
|
|
92
67
|
}
|
|
93
68
|
__name(binPath, "binPath");
|
|
94
|
-
__name2(binPath, "binPath");
|
|
95
69
|
|
|
96
70
|
// src/constants.ts
|
|
97
71
|
var DEFAULT_OUTPUT_DIR = "test-results";
|
|
@@ -5,6 +5,7 @@ var child_process = require('child_process');
|
|
|
5
5
|
var path = require('path');
|
|
6
6
|
var fs = require('fs');
|
|
7
7
|
var module$1 = require('module');
|
|
8
|
+
require('crypto');
|
|
8
9
|
|
|
9
10
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
10
11
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -20,32 +21,20 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
20
21
|
return require.apply(this, arguments);
|
|
21
22
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
22
23
|
});
|
|
23
|
-
var __defProp2 = Object.defineProperty;
|
|
24
|
-
var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name", { value, configurable: true }), "__name");
|
|
25
|
-
var __require2 = /* @__PURE__ */ ((x) => typeof __require !== "undefined" ? __require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
26
|
-
get: (a, b) => (typeof __require !== "undefined" ? __require : a)[b]
|
|
27
|
-
}) : x)(function(x) {
|
|
28
|
-
if (typeof __require !== "undefined")
|
|
29
|
-
return __require.apply(this, arguments);
|
|
30
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
31
|
-
});
|
|
32
24
|
function rootDir() {
|
|
33
25
|
return process.cwd();
|
|
34
26
|
}
|
|
35
27
|
__name(rootDir, "rootDir");
|
|
36
|
-
__name2(rootDir, "rootDir");
|
|
37
28
|
function outputDirOverride() {
|
|
38
29
|
const { CHROMATIC_ARCHIVE_LOCATION } = process.env;
|
|
39
30
|
return CHROMATIC_ARCHIVE_LOCATION;
|
|
40
31
|
}
|
|
41
32
|
__name(outputDirOverride, "outputDirOverride");
|
|
42
|
-
__name2(outputDirOverride, "outputDirOverride");
|
|
43
33
|
function archivesDir(defaultOutputDir) {
|
|
44
34
|
const outputDir = outputDirOverride() || defaultOutputDir;
|
|
45
35
|
return path__default.default.resolve(rootDir(), outputDir, "chromatic-archives");
|
|
46
36
|
}
|
|
47
37
|
__name(archivesDir, "archivesDir");
|
|
48
|
-
__name2(archivesDir, "archivesDir");
|
|
49
38
|
function checkArchivesDirExists(defaultOutputDir) {
|
|
50
39
|
const dir = archivesDir(defaultOutputDir);
|
|
51
40
|
if (!fs.existsSync(dir)) {
|
|
@@ -55,22 +44,9 @@ Please make sure that you have run your E2E tests, or have set the CHROMATIC_ARC
|
|
|
55
44
|
}
|
|
56
45
|
}
|
|
57
46
|
__name(checkArchivesDirExists, "checkArchivesDirExists");
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
checkArchivesDirExists(defaultOutputDir);
|
|
62
|
-
child_process.execFileSync("node", [
|
|
63
|
-
binPath(),
|
|
64
|
-
"dev",
|
|
65
|
-
...processArgs,
|
|
66
|
-
"-c",
|
|
67
|
-
configDir2
|
|
68
|
-
], {
|
|
69
|
-
stdio: "inherit"
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
__name(archiveStorybook, "archiveStorybook");
|
|
73
|
-
__name2(archiveStorybook, "archiveStorybook");
|
|
47
|
+
|
|
48
|
+
// ../shared/src/archive-storybook/index.ts
|
|
49
|
+
var req = __require.resolve ? __require : module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('out.js', document.baseURI).href)));
|
|
74
50
|
function buildArchiveStorybook(processArgs, configDir2, defaultOutputDir) {
|
|
75
51
|
checkArchivesDirExists(defaultOutputDir);
|
|
76
52
|
child_process.execFileSync("node", [
|
|
@@ -84,14 +60,12 @@ function buildArchiveStorybook(processArgs, configDir2, defaultOutputDir) {
|
|
|
84
60
|
});
|
|
85
61
|
}
|
|
86
62
|
__name(buildArchiveStorybook, "buildArchiveStorybook");
|
|
87
|
-
__name2(buildArchiveStorybook, "buildArchiveStorybook");
|
|
88
63
|
function binPath() {
|
|
89
64
|
const filename = req.resolve("storybook/package.json");
|
|
90
65
|
const packageJson = JSON.parse(fs.readFileSync(filename, "utf8"));
|
|
91
66
|
return path.resolve(path.dirname(filename), packageJson.bin);
|
|
92
67
|
}
|
|
93
68
|
__name(binPath, "binPath");
|
|
94
|
-
__name2(binPath, "binPath");
|
|
95
69
|
|
|
96
70
|
// src/constants.ts
|
|
97
71
|
var DEFAULT_OUTPUT_DIR = "test-results";
|
package/dist/index.d.mts
CHANGED
|
@@ -1,14 +1,26 @@
|
|
|
1
|
-
import { a } from './types-DBnTR0hb.js';
|
|
2
|
-
export { a as ChromaticConfig } from './types-DBnTR0hb.js';
|
|
3
1
|
import * as playwright_test from 'playwright/test';
|
|
4
2
|
import { Page, TestInfo } from '@playwright/test';
|
|
5
3
|
export { expect } from '@playwright/test';
|
|
6
4
|
|
|
5
|
+
interface ChromaticConfig {
|
|
6
|
+
delay?: number;
|
|
7
|
+
diffIncludeAntiAliasing?: boolean;
|
|
8
|
+
diffThreshold?: number;
|
|
9
|
+
disableAutoSnapshot?: boolean;
|
|
10
|
+
forcedColors?: string;
|
|
11
|
+
pauseAnimationAtEnd?: boolean;
|
|
12
|
+
prefersReducedMotion?: string;
|
|
13
|
+
resourceArchiveTimeout?: number;
|
|
14
|
+
assetDomains?: string[];
|
|
15
|
+
cropToViewport?: boolean;
|
|
16
|
+
ignoreSelectors?: string[];
|
|
17
|
+
}
|
|
18
|
+
|
|
7
19
|
declare function takeSnapshot(page: Page, testInfo: TestInfo): Promise<void>;
|
|
8
20
|
declare function takeSnapshot(page: Page, name: string, testInfo: TestInfo): Promise<void>;
|
|
9
21
|
|
|
10
|
-
declare const test: playwright_test.TestType<playwright_test.PlaywrightTestArgs & playwright_test.PlaywrightTestOptions &
|
|
22
|
+
declare const test: playwright_test.TestType<playwright_test.PlaywrightTestArgs & playwright_test.PlaywrightTestOptions & ChromaticConfig & {
|
|
11
23
|
chromaticSnapshot: void;
|
|
12
24
|
}, playwright_test.PlaywrightWorkerArgs & playwright_test.PlaywrightWorkerOptions>;
|
|
13
25
|
|
|
14
|
-
export { takeSnapshot, test };
|
|
26
|
+
export { type ChromaticConfig, takeSnapshot, test };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,26 @@
|
|
|
1
|
-
import { a } from './types-DBnTR0hb.js';
|
|
2
|
-
export { a as ChromaticConfig } from './types-DBnTR0hb.js';
|
|
3
1
|
import * as playwright_test from 'playwright/test';
|
|
4
2
|
import { Page, TestInfo } from '@playwright/test';
|
|
5
3
|
export { expect } from '@playwright/test';
|
|
6
4
|
|
|
5
|
+
interface ChromaticConfig {
|
|
6
|
+
delay?: number;
|
|
7
|
+
diffIncludeAntiAliasing?: boolean;
|
|
8
|
+
diffThreshold?: number;
|
|
9
|
+
disableAutoSnapshot?: boolean;
|
|
10
|
+
forcedColors?: string;
|
|
11
|
+
pauseAnimationAtEnd?: boolean;
|
|
12
|
+
prefersReducedMotion?: string;
|
|
13
|
+
resourceArchiveTimeout?: number;
|
|
14
|
+
assetDomains?: string[];
|
|
15
|
+
cropToViewport?: boolean;
|
|
16
|
+
ignoreSelectors?: string[];
|
|
17
|
+
}
|
|
18
|
+
|
|
7
19
|
declare function takeSnapshot(page: Page, testInfo: TestInfo): Promise<void>;
|
|
8
20
|
declare function takeSnapshot(page: Page, name: string, testInfo: TestInfo): Promise<void>;
|
|
9
21
|
|
|
10
|
-
declare const test: playwright_test.TestType<playwright_test.PlaywrightTestArgs & playwright_test.PlaywrightTestOptions &
|
|
22
|
+
declare const test: playwright_test.TestType<playwright_test.PlaywrightTestArgs & playwright_test.PlaywrightTestOptions & ChromaticConfig & {
|
|
11
23
|
chromaticSnapshot: void;
|
|
12
24
|
}, playwright_test.PlaywrightWorkerArgs & playwright_test.PlaywrightWorkerOptions>;
|
|
13
25
|
|
|
14
|
-
export { takeSnapshot, test };
|
|
26
|
+
export { type ChromaticConfig, takeSnapshot, test };
|
package/dist/index.js
CHANGED
|
@@ -15,7 +15,13 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
15
15
|
var path2__default = /*#__PURE__*/_interopDefault(path2);
|
|
16
16
|
|
|
17
17
|
const require$1 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('out.js', document.baseURI).href)));
|
|
18
|
+
var __create = Object.create;
|
|
18
19
|
var __defProp = Object.defineProperty;
|
|
20
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
21
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
22
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
23
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
24
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
19
25
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
20
26
|
var __require = /* @__PURE__ */ ((x) => typeof require$1 !== "undefined" ? require$1 : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
21
27
|
get: (a, b) => (typeof require$1 !== "undefined" ? require$1 : a)[b]
|
|
@@ -24,37 +30,31 @@ var __require = /* @__PURE__ */ ((x) => typeof require$1 !== "undefined" ? requi
|
|
|
24
30
|
return require$1.apply(this, arguments);
|
|
25
31
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
26
32
|
});
|
|
27
|
-
var
|
|
28
|
-
var __defProp2 = Object.defineProperty;
|
|
29
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
30
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
31
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
32
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
33
|
-
var __defNormalProp = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value, "__defNormalProp");
|
|
34
|
-
var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name", { value, configurable: true }), "__name");
|
|
35
|
-
var __commonJS = /* @__PURE__ */ __name((cb, mod) => /* @__PURE__ */ __name(function __require2() {
|
|
33
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
36
34
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
37
|
-
}
|
|
38
|
-
var __copyProps =
|
|
35
|
+
};
|
|
36
|
+
var __copyProps = (to, from, except, desc) => {
|
|
39
37
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
40
38
|
for (let key of __getOwnPropNames(from))
|
|
41
39
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
42
|
-
|
|
40
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
43
41
|
}
|
|
44
42
|
return to;
|
|
45
|
-
}
|
|
46
|
-
var __toESM =
|
|
43
|
+
};
|
|
44
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
47
45
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
48
46
|
// file that has been converted to a CommonJS file using a Babel-
|
|
49
47
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
50
48
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
51
|
-
!mod || !mod.__esModule ?
|
|
49
|
+
!mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
52
50
|
mod
|
|
53
|
-
))
|
|
54
|
-
var __publicField =
|
|
51
|
+
));
|
|
52
|
+
var __publicField = (obj, key, value) => {
|
|
55
53
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
56
54
|
return value;
|
|
57
|
-
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// ../../node_modules/mime/Mime.js
|
|
58
58
|
var require_Mime = __commonJS({
|
|
59
59
|
"../../node_modules/mime/Mime.js"(exports$1, module) {
|
|
60
60
|
function Mime() {
|
|
@@ -68,7 +68,6 @@ var require_Mime = __commonJS({
|
|
|
68
68
|
this.getExtension = this.getExtension.bind(this);
|
|
69
69
|
}
|
|
70
70
|
__name(Mime, "Mime");
|
|
71
|
-
__name2(Mime, "Mime");
|
|
72
71
|
Mime.prototype.define = function(typeMap, force) {
|
|
73
72
|
for (let type in typeMap) {
|
|
74
73
|
let extensions = typeMap[type].map(function(t) {
|
|
@@ -106,6 +105,8 @@ var require_Mime = __commonJS({
|
|
|
106
105
|
module.exports = Mime;
|
|
107
106
|
}
|
|
108
107
|
});
|
|
108
|
+
|
|
109
|
+
// ../../node_modules/mime/types/standard.js
|
|
109
110
|
var require_standard = __commonJS({
|
|
110
111
|
"../../node_modules/mime/types/standard.js"(exports$1, module) {
|
|
111
112
|
module.exports = {
|
|
@@ -1127,6 +1128,8 @@ var require_standard = __commonJS({
|
|
|
1127
1128
|
};
|
|
1128
1129
|
}
|
|
1129
1130
|
});
|
|
1131
|
+
|
|
1132
|
+
// ../../node_modules/mime/types/other.js
|
|
1130
1133
|
var require_other = __commonJS({
|
|
1131
1134
|
"../../node_modules/mime/types/other.js"(exports$1, module) {
|
|
1132
1135
|
module.exports = {
|
|
@@ -3241,23 +3244,27 @@ var require_other = __commonJS({
|
|
|
3241
3244
|
};
|
|
3242
3245
|
}
|
|
3243
3246
|
});
|
|
3247
|
+
|
|
3248
|
+
// ../../node_modules/mime/index.js
|
|
3244
3249
|
var require_mime = __commonJS({
|
|
3245
3250
|
"../../node_modules/mime/index.js"(exports$1, module) {
|
|
3246
3251
|
var Mime = require_Mime();
|
|
3247
3252
|
module.exports = new Mime(require_standard(), require_other());
|
|
3248
3253
|
}
|
|
3249
3254
|
});
|
|
3255
|
+
|
|
3256
|
+
// ../../node_modules/srcset/index.js
|
|
3250
3257
|
var require_srcset = __commonJS({
|
|
3251
3258
|
"../../node_modules/srcset/index.js"(exports$1) {
|
|
3252
3259
|
var imageCandidateRegex = /\s*([^,]\S*[^,](?:\s+[^,]+)?)\s*(?:,|$)/;
|
|
3253
|
-
var duplicateDescriptorCheck = /* @__PURE__ */
|
|
3260
|
+
var duplicateDescriptorCheck = /* @__PURE__ */ __name((allDescriptors, value, postfix) => {
|
|
3254
3261
|
allDescriptors[postfix] = allDescriptors[postfix] || {};
|
|
3255
3262
|
if (allDescriptors[postfix][value]) {
|
|
3256
3263
|
throw new Error(`No more than one image candidate is allowed for a given descriptor: ${value}${postfix}`);
|
|
3257
3264
|
}
|
|
3258
3265
|
allDescriptors[postfix][value] = true;
|
|
3259
3266
|
}, "duplicateDescriptorCheck");
|
|
3260
|
-
var fallbackDescriptorDuplicateCheck = /* @__PURE__ */
|
|
3267
|
+
var fallbackDescriptorDuplicateCheck = /* @__PURE__ */ __name((allDescriptors) => {
|
|
3261
3268
|
if (allDescriptors.fallback) {
|
|
3262
3269
|
throw new Error("Only one fallback image candidate is allowed");
|
|
3263
3270
|
}
|
|
@@ -3266,14 +3273,14 @@ var require_srcset = __commonJS({
|
|
|
3266
3273
|
}
|
|
3267
3274
|
allDescriptors.fallback = true;
|
|
3268
3275
|
}, "fallbackDescriptorDuplicateCheck");
|
|
3269
|
-
var descriptorCountCheck = /* @__PURE__ */
|
|
3276
|
+
var descriptorCountCheck = /* @__PURE__ */ __name((allDescriptors, currentDescriptors) => {
|
|
3270
3277
|
if (currentDescriptors.length === 0) {
|
|
3271
3278
|
fallbackDescriptorDuplicateCheck(allDescriptors);
|
|
3272
3279
|
} else if (currentDescriptors.length > 1) {
|
|
3273
3280
|
throw new Error(`Image candidate may have no more than one descriptor, found ${currentDescriptors.length}: ${currentDescriptors.join(" ")}`);
|
|
3274
3281
|
}
|
|
3275
3282
|
}, "descriptorCountCheck");
|
|
3276
|
-
var validDescriptorCheck = /* @__PURE__ */
|
|
3283
|
+
var validDescriptorCheck = /* @__PURE__ */ __name((value, postfix, descriptor) => {
|
|
3277
3284
|
if (Number.isNaN(value)) {
|
|
3278
3285
|
throw new TypeError(`${descriptor || value} is not a valid number`);
|
|
3279
3286
|
}
|
|
@@ -3385,22 +3392,40 @@ var require_srcset = __commonJS({
|
|
|
3385
3392
|
};
|
|
3386
3393
|
}
|
|
3387
3394
|
});
|
|
3395
|
+
|
|
3396
|
+
// ../shared/src/utils/logger.ts
|
|
3388
3397
|
var logger = process.env.LOG ? console : {
|
|
3389
3398
|
log: (..._args) => {
|
|
3390
3399
|
},
|
|
3391
3400
|
warn: (..._args) => {
|
|
3392
3401
|
}
|
|
3393
3402
|
};
|
|
3394
|
-
|
|
3395
|
-
|
|
3403
|
+
|
|
3404
|
+
// ../shared/src/resource-archiver/index.ts
|
|
3405
|
+
var _ResourceArchiver = class _ResourceArchiver {
|
|
3396
3406
|
constructor(cdpClient, allowedDomains, httpCredentials) {
|
|
3397
3407
|
__publicField(this, "archive", {});
|
|
3398
3408
|
__publicField(this, "client");
|
|
3409
|
+
/**
|
|
3410
|
+
Specifies which domains (origins) we should archive resources for (by default we only archive same-origin resources).
|
|
3411
|
+
Useful in situations where the environment running the archived storybook (e.g. in CI) may be restricted to an intranet or other domain restrictions
|
|
3412
|
+
*/
|
|
3399
3413
|
__publicField(this, "assetDomains");
|
|
3414
|
+
/**
|
|
3415
|
+
* We assume the first URL loaded after @watch is called is the base URL of the
|
|
3416
|
+
* page and we only save resources that are loaded from the same protocol/host/port combination.
|
|
3417
|
+
* We also skip archiving this page because we only care about resources requested by this page.
|
|
3418
|
+
*/
|
|
3400
3419
|
__publicField(this, "firstUrl");
|
|
3420
|
+
/**
|
|
3421
|
+
* HTTP Basic Auth credentials to use when accessing protected resources.
|
|
3422
|
+
*/
|
|
3401
3423
|
__publicField(this, "httpCredentials");
|
|
3424
|
+
/**
|
|
3425
|
+
* Currently active requests
|
|
3426
|
+
*/
|
|
3402
3427
|
__publicField(this, "pendingRequests", /* @__PURE__ */ new Set());
|
|
3403
|
-
__publicField(this, "authRequired", /* @__PURE__ */
|
|
3428
|
+
__publicField(this, "authRequired", /* @__PURE__ */ __name(async ({ requestId, request }) => {
|
|
3404
3429
|
await this.clientSend(request, "Fetch.continueWithAuth", {
|
|
3405
3430
|
requestId,
|
|
3406
3431
|
authChallengeResponse: {
|
|
@@ -3409,7 +3434,7 @@ var _ResourceArchiver = (_a = class {
|
|
|
3409
3434
|
}
|
|
3410
3435
|
});
|
|
3411
3436
|
}, "authRequired"));
|
|
3412
|
-
__publicField(this, "requestPaused", /* @__PURE__ */
|
|
3437
|
+
__publicField(this, "requestPaused", /* @__PURE__ */ __name(async ({ requestId, request, responseStatusCode, responseStatusText, responseErrorReason, responseHeaders }) => {
|
|
3413
3438
|
this.pendingRequests.delete(requestId);
|
|
3414
3439
|
if (!request.method.match(/get/i)) {
|
|
3415
3440
|
await this.clientSend(request, "Fetch.continueRequest", {
|
|
@@ -3522,8 +3547,8 @@ var _ResourceArchiver = (_a = class {
|
|
|
3522
3547
|
requestId
|
|
3523
3548
|
});
|
|
3524
3549
|
}
|
|
3525
|
-
}
|
|
3526
|
-
|
|
3550
|
+
};
|
|
3551
|
+
__name(_ResourceArchiver, "ResourceArchiver");
|
|
3527
3552
|
var ResourceArchiver = _ResourceArchiver;
|
|
3528
3553
|
function ensureDir(directory) {
|
|
3529
3554
|
if (!fs.existsSync(directory)) {
|
|
@@ -3533,7 +3558,6 @@ function ensureDir(directory) {
|
|
|
3533
3558
|
}
|
|
3534
3559
|
}
|
|
3535
3560
|
__name(ensureDir, "ensureDir");
|
|
3536
|
-
__name2(ensureDir, "ensureDir");
|
|
3537
3561
|
async function outputFile(filePath, data) {
|
|
3538
3562
|
ensureDir(path2__default.default.dirname(filePath));
|
|
3539
3563
|
return promises.writeFile(filePath, data, {
|
|
@@ -3541,19 +3565,16 @@ async function outputFile(filePath, data) {
|
|
|
3541
3565
|
});
|
|
3542
3566
|
}
|
|
3543
3567
|
__name(outputFile, "outputFile");
|
|
3544
|
-
__name2(outputFile, "outputFile");
|
|
3545
3568
|
async function outputJSONFile(filePath, data) {
|
|
3546
3569
|
return outputFile(filePath, JSON.stringify(data));
|
|
3547
3570
|
}
|
|
3548
3571
|
__name(outputJSONFile, "outputJSONFile");
|
|
3549
|
-
__name2(outputJSONFile, "outputJSONFile");
|
|
3550
3572
|
function hash(data) {
|
|
3551
3573
|
return crypto.createHash("shake256", {
|
|
3552
3574
|
outputLength: 2
|
|
3553
3575
|
}).update(data).digest("hex");
|
|
3554
3576
|
}
|
|
3555
3577
|
__name(hash, "hash");
|
|
3556
|
-
__name2(hash, "hash");
|
|
3557
3578
|
var MAX_FILE_NAME_BYTE_LENGTH = 255;
|
|
3558
3579
|
function truncateFileName(filePath, maxByteLength = MAX_FILE_NAME_BYTE_LENGTH) {
|
|
3559
3580
|
const encoder = new TextEncoder();
|
|
@@ -3582,8 +3603,7 @@ function truncateFileName(filePath, maxByteLength = MAX_FILE_NAME_BYTE_LENGTH) {
|
|
|
3582
3603
|
].join("/");
|
|
3583
3604
|
}
|
|
3584
3605
|
__name(truncateFileName, "truncateFileName");
|
|
3585
|
-
|
|
3586
|
-
var removeLocalhostFromBaseUrl = /* @__PURE__ */ __name2((href) => {
|
|
3606
|
+
var removeLocalhostFromBaseUrl = /* @__PURE__ */ __name((href) => {
|
|
3587
3607
|
let baseUrl;
|
|
3588
3608
|
try {
|
|
3589
3609
|
baseUrl = new URL(href);
|
|
@@ -3595,6 +3615,8 @@ var removeLocalhostFromBaseUrl = /* @__PURE__ */ __name2((href) => {
|
|
|
3595
3615
|
return href;
|
|
3596
3616
|
}
|
|
3597
3617
|
}, "removeLocalhostFromBaseUrl");
|
|
3618
|
+
|
|
3619
|
+
// ../shared/src/write-archive/archive-file.ts
|
|
3598
3620
|
var import_mime = __toESM(require_mime());
|
|
3599
3621
|
var RESERVED_PATHNAMES = [
|
|
3600
3622
|
// This is a list of filenames that are reserved for Storybook as a dev target.
|
|
@@ -3608,12 +3630,13 @@ var RESERVED_PATHNAMES = [
|
|
|
3608
3630
|
"/runtime~main.iframe.bundle.js",
|
|
3609
3631
|
"/sb-preview/runtime.js"
|
|
3610
3632
|
];
|
|
3611
|
-
var
|
|
3612
|
-
var _ArchiveFile = (_a2 = class {
|
|
3633
|
+
var _ArchiveFile = class _ArchiveFile {
|
|
3613
3634
|
constructor(url, response, pageUrl) {
|
|
3635
|
+
// The URL to the asset being archived.
|
|
3614
3636
|
__publicField(this, "url");
|
|
3615
3637
|
__publicField(this, "response");
|
|
3616
3638
|
__publicField(this, "shortenedFileNameLength");
|
|
3639
|
+
// The URL to page being tested.
|
|
3617
3640
|
__publicField(this, "pageUrl");
|
|
3618
3641
|
this.url = new URL(url);
|
|
3619
3642
|
this.response = response;
|
|
@@ -3688,27 +3711,33 @@ var _ArchiveFile = (_a2 = class {
|
|
|
3688
3711
|
}
|
|
3689
3712
|
return pathname;
|
|
3690
3713
|
}
|
|
3691
|
-
}
|
|
3692
|
-
|
|
3714
|
+
};
|
|
3715
|
+
__name(_ArchiveFile, "ArchiveFile");
|
|
3693
3716
|
var ArchiveFile = _ArchiveFile;
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3717
|
+
|
|
3718
|
+
// ../../node_modules/@rrweb/types/dist/types.js
|
|
3719
|
+
var NodeType = /* @__PURE__ */ ((NodeType2) => {
|
|
3720
|
+
NodeType2[NodeType2["Document"] = 0] = "Document";
|
|
3721
|
+
NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
|
|
3722
|
+
NodeType2[NodeType2["Element"] = 2] = "Element";
|
|
3723
|
+
NodeType2[NodeType2["Text"] = 3] = "Text";
|
|
3724
|
+
NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
|
|
3725
|
+
NodeType2[NodeType2["Comment"] = 5] = "Comment";
|
|
3726
|
+
return NodeType2;
|
|
3702
3727
|
})(NodeType || {});
|
|
3728
|
+
|
|
3729
|
+
// ../shared/src/write-archive/dom-snapshot.ts
|
|
3703
3730
|
var import_srcset = __toESM(require_srcset());
|
|
3731
|
+
|
|
3732
|
+
// ../shared/src/utils/nodes.ts
|
|
3704
3733
|
function isIframeSerializedNode(node) {
|
|
3705
3734
|
return node.type === NodeType.Element && node.tagName === "iframe" && "contentDocument" in node && !!node.contentDocument;
|
|
3706
3735
|
}
|
|
3707
3736
|
__name(isIframeSerializedNode, "isIframeSerializedNode");
|
|
3708
|
-
|
|
3737
|
+
|
|
3738
|
+
// ../shared/src/write-archive/dom-snapshot.ts
|
|
3709
3739
|
var CSS_URL_REGEX = /url\((?!['"]?(?:data):)['"]?([^'")]*)['"]?\)/gi;
|
|
3710
|
-
var
|
|
3711
|
-
var _DOMSnapshot = (_a3 = class {
|
|
3740
|
+
var _DOMSnapshot = class _DOMSnapshot {
|
|
3712
3741
|
constructor({ snapshot, pseudoClassIds }) {
|
|
3713
3742
|
__publicField(this, "snapshot");
|
|
3714
3743
|
__publicField(this, "pseudoClassIds");
|
|
@@ -3835,26 +3864,22 @@ var _DOMSnapshot = (_a3 = class {
|
|
|
3835
3864
|
});
|
|
3836
3865
|
return currentSrc;
|
|
3837
3866
|
}
|
|
3838
|
-
}
|
|
3839
|
-
|
|
3867
|
+
};
|
|
3868
|
+
__name(_DOMSnapshot, "DOMSnapshot");
|
|
3840
3869
|
var DOMSnapshot = _DOMSnapshot;
|
|
3870
|
+
|
|
3871
|
+
// ../shared/src/utils/viewport.ts
|
|
3841
3872
|
function viewportToString(viewport) {
|
|
3842
3873
|
return `w${viewport.width}h${viewport.height}`;
|
|
3843
3874
|
}
|
|
3844
3875
|
__name(viewportToString, "viewportToString");
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
return {
|
|
3849
|
-
width: Number(matcher[1]),
|
|
3850
|
-
height: Number(matcher[2])
|
|
3851
|
-
};
|
|
3852
|
-
}
|
|
3853
|
-
__name(parseViewport, "parseViewport");
|
|
3854
|
-
__name2(parseViewport, "parseViewport");
|
|
3855
|
-
var sanitize = /* @__PURE__ */ __name2((string) => {
|
|
3876
|
+
|
|
3877
|
+
// ../shared/src/write-archive/storybook-sanitize.ts
|
|
3878
|
+
var sanitize = /* @__PURE__ */ __name((string) => {
|
|
3856
3879
|
return string.toLowerCase().replace(/[ ’–—―′¿'`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, "-").replace(/[\r\n]/g, "-").replace(/-+/g, "-").replace(/^-+/, "").replace(/-+$/, "");
|
|
3857
3880
|
}, "sanitize");
|
|
3881
|
+
|
|
3882
|
+
// ../shared/src/write-archive/snapshot-files.ts
|
|
3858
3883
|
var SNAPSHOT_FILE_EXT = "snapshot.json";
|
|
3859
3884
|
function snapshotId(testTitle, snapshotName) {
|
|
3860
3885
|
const fullSnapshotId = `${sanitize(testTitle)}-${sanitize(snapshotName)}`;
|
|
@@ -3862,7 +3887,6 @@ function snapshotId(testTitle, snapshotName) {
|
|
|
3862
3887
|
return truncateFileName(fullSnapshotId, maxByteLength);
|
|
3863
3888
|
}
|
|
3864
3889
|
__name(snapshotId, "snapshotId");
|
|
3865
|
-
__name2(snapshotId, "snapshotId");
|
|
3866
3890
|
function snapshotFileName(snapshotId2, viewport) {
|
|
3867
3891
|
const fileNameParts = [
|
|
3868
3892
|
snapshotId2,
|
|
@@ -3872,7 +3896,8 @@ function snapshotFileName(snapshotId2, viewport) {
|
|
|
3872
3896
|
return fileNameParts.join(".");
|
|
3873
3897
|
}
|
|
3874
3898
|
__name(snapshotFileName, "snapshotFileName");
|
|
3875
|
-
|
|
3899
|
+
|
|
3900
|
+
// ../shared/src/write-archive/stories-files.ts
|
|
3876
3901
|
var STORIES_FILE_EXT = "stories.json";
|
|
3877
3902
|
function storiesFileName(testTitle) {
|
|
3878
3903
|
const fileName = [
|
|
@@ -3883,7 +3908,6 @@ function storiesFileName(testTitle) {
|
|
|
3883
3908
|
return truncateFileName(fileName, maxByteLength);
|
|
3884
3909
|
}
|
|
3885
3910
|
__name(storiesFileName, "storiesFileName");
|
|
3886
|
-
__name2(storiesFileName, "storiesFileName");
|
|
3887
3911
|
function createStories(title, domSnapshots, chromaticStorybookParams) {
|
|
3888
3912
|
return {
|
|
3889
3913
|
title,
|
|
@@ -3918,7 +3942,6 @@ function createStories(title, domSnapshots, chromaticStorybookParams) {
|
|
|
3918
3942
|
};
|
|
3919
3943
|
}
|
|
3920
3944
|
__name(createStories, "createStories");
|
|
3921
|
-
__name2(createStories, "createStories");
|
|
3922
3945
|
function buildStoryModesConfig(viewports) {
|
|
3923
3946
|
return viewports.reduce((modes, viewport) => {
|
|
3924
3947
|
const viewportName = viewportToString(viewport);
|
|
@@ -3929,7 +3952,6 @@ function buildStoryModesConfig(viewports) {
|
|
|
3929
3952
|
}, {});
|
|
3930
3953
|
}
|
|
3931
3954
|
__name(buildStoryModesConfig, "buildStoryModesConfig");
|
|
3932
|
-
__name2(buildStoryModesConfig, "buildStoryModesConfig");
|
|
3933
3955
|
function buildStoryViewportsConfig(viewports) {
|
|
3934
3956
|
return viewports.reduce((viewportsConfig, viewport) => {
|
|
3935
3957
|
const viewportName = viewportToString(viewport);
|
|
@@ -3945,7 +3967,6 @@ function buildStoryViewportsConfig(viewports) {
|
|
|
3945
3967
|
}, {});
|
|
3946
3968
|
}
|
|
3947
3969
|
__name(buildStoryViewportsConfig, "buildStoryViewportsConfig");
|
|
3948
|
-
__name2(buildStoryViewportsConfig, "buildStoryViewportsConfig");
|
|
3949
3970
|
function viewportAddonType(viewport) {
|
|
3950
3971
|
if (viewport.width < 600) {
|
|
3951
3972
|
return "mobile";
|
|
@@ -3956,9 +3977,8 @@ function viewportAddonType(viewport) {
|
|
|
3956
3977
|
return "desktop";
|
|
3957
3978
|
}
|
|
3958
3979
|
__name(viewportAddonType, "viewportAddonType");
|
|
3959
|
-
__name2(viewportAddonType, "viewportAddonType");
|
|
3960
3980
|
function findDefaultViewport(viewports) {
|
|
3961
|
-
const compareFn = /* @__PURE__ */
|
|
3981
|
+
const compareFn = /* @__PURE__ */ __name((vp1, vp2) => {
|
|
3962
3982
|
if (vp1.width < vp2.width) {
|
|
3963
3983
|
return 1;
|
|
3964
3984
|
}
|
|
@@ -3970,7 +3990,8 @@ function findDefaultViewport(viewports) {
|
|
|
3970
3990
|
return viewports.sort(compareFn)[0];
|
|
3971
3991
|
}
|
|
3972
3992
|
__name(findDefaultViewport, "findDefaultViewport");
|
|
3973
|
-
|
|
3993
|
+
|
|
3994
|
+
// ../shared/src/write-archive/index.ts
|
|
3974
3995
|
async function writeTestResult(e2eTestInfo, domSnapshots, archive, chromaticStorybookParams) {
|
|
3975
3996
|
const { titlePath, outputDir, pageUrl } = e2eTestInfo;
|
|
3976
3997
|
const titlePathWithoutFileExtensions = titlePath.map((pathPart) => (
|
|
@@ -4015,7 +4036,6 @@ async function writeTestResult(e2eTestInfo, domSnapshots, archive, chromaticStor
|
|
|
4015
4036
|
}
|
|
4016
4037
|
}
|
|
4017
4038
|
__name(writeTestResult, "writeTestResult");
|
|
4018
|
-
__name2(writeTestResult, "writeTestResult");
|
|
4019
4039
|
var analytics = new analyticsNode.Analytics({
|
|
4020
4040
|
writeKey: process.env.SEGMENT_WRITE_KEY || "cwWhBWso2gwzyenW29CnCp30Kjz4DogE"
|
|
4021
4041
|
});
|
|
@@ -4028,7 +4048,6 @@ function track(event, properties) {
|
|
|
4028
4048
|
});
|
|
4029
4049
|
}
|
|
4030
4050
|
__name(track, "track");
|
|
4031
|
-
__name2(track, "track");
|
|
4032
4051
|
var hasTrackedRun = false;
|
|
4033
4052
|
function trackRun(properties = {}) {
|
|
4034
4053
|
if (hasTrackedRun)
|
|
@@ -4037,7 +4056,6 @@ function trackRun(properties = {}) {
|
|
|
4037
4056
|
hasTrackedRun = true;
|
|
4038
4057
|
}
|
|
4039
4058
|
__name(trackRun, "trackRun");
|
|
4040
|
-
__name2(trackRun, "trackRun");
|
|
4041
4059
|
var hasTrackedComplete = false;
|
|
4042
4060
|
function trackComplete(properties = {}) {
|
|
4043
4061
|
if (hasTrackedComplete)
|
|
@@ -4046,21 +4064,9 @@ function trackComplete(properties = {}) {
|
|
|
4046
4064
|
hasTrackedComplete = true;
|
|
4047
4065
|
}
|
|
4048
4066
|
__name(trackComplete, "trackComplete");
|
|
4049
|
-
__name2(trackComplete, "trackComplete");
|
|
4050
|
-
var DEFAULT_GLOBAL_RESOURCE_ARCHIVE_TIMEOUT_MS = 1e4;
|
|
4051
4067
|
|
|
4052
|
-
//
|
|
4053
|
-
var
|
|
4054
|
-
NodeType22[NodeType22["Document"] = 0] = "Document";
|
|
4055
|
-
NodeType22[NodeType22["DocumentType"] = 1] = "DocumentType";
|
|
4056
|
-
NodeType22[NodeType22["Element"] = 2] = "Element";
|
|
4057
|
-
NodeType22[NodeType22["Text"] = 3] = "Text";
|
|
4058
|
-
NodeType22[NodeType22["CDATA"] = 4] = "CDATA";
|
|
4059
|
-
NodeType22[NodeType22["Comment"] = 5] = "Comment";
|
|
4060
|
-
return NodeType22;
|
|
4061
|
-
})(NodeType2 || {});
|
|
4062
|
-
|
|
4063
|
-
// src/takeSnapshot.ts
|
|
4068
|
+
// ../shared/src/constants.ts
|
|
4069
|
+
var DEFAULT_GLOBAL_RESOURCE_ARCHIVE_TIMEOUT_MS = 1e4;
|
|
4064
4070
|
var rrweb = fs.readFileSync(__require.resolve("@chromaui/rrweb-snapshot"), "utf8");
|
|
4065
4071
|
var chromaticSnapshots = /* @__PURE__ */ new Map();
|
|
4066
4072
|
async function takeSnapshot(page, nameOrTestInfo, maybeTestInfo) {
|
|
@@ -4193,7 +4199,7 @@ async function executeSnapshotScript(context) {
|
|
|
4193
4199
|
}
|
|
4194
4200
|
__name(executeSnapshotScript, "executeSnapshotScript");
|
|
4195
4201
|
function findIframes(node) {
|
|
4196
|
-
if (node.type ===
|
|
4202
|
+
if (node.type === NodeType.Element && node.tagName === "iframe") {
|
|
4197
4203
|
return [
|
|
4198
4204
|
node
|
|
4199
4205
|
];
|
package/dist/index.mjs
CHANGED
|
@@ -9,7 +9,13 @@ import { Analytics } from '@segment/analytics-node';
|
|
|
9
9
|
import { dedent } from 'ts-dedent';
|
|
10
10
|
|
|
11
11
|
const require$1 = createRequire(import.meta.url);
|
|
12
|
+
var __create = Object.create;
|
|
12
13
|
var __defProp = Object.defineProperty;
|
|
14
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
15
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
16
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
17
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
18
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
19
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
14
20
|
var __require = /* @__PURE__ */ ((x) => typeof require$1 !== "undefined" ? require$1 : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
15
21
|
get: (a, b) => (typeof require$1 !== "undefined" ? require$1 : a)[b]
|
|
@@ -18,37 +24,31 @@ var __require = /* @__PURE__ */ ((x) => typeof require$1 !== "undefined" ? requi
|
|
|
18
24
|
return require$1.apply(this, arguments);
|
|
19
25
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
20
26
|
});
|
|
21
|
-
var
|
|
22
|
-
var __defProp2 = Object.defineProperty;
|
|
23
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
24
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
25
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
26
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
27
|
-
var __defNormalProp = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value, "__defNormalProp");
|
|
28
|
-
var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name", { value, configurable: true }), "__name");
|
|
29
|
-
var __commonJS = /* @__PURE__ */ __name((cb, mod) => /* @__PURE__ */ __name(function __require2() {
|
|
27
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
30
28
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
31
|
-
}
|
|
32
|
-
var __copyProps =
|
|
29
|
+
};
|
|
30
|
+
var __copyProps = (to, from, except, desc) => {
|
|
33
31
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
34
32
|
for (let key of __getOwnPropNames(from))
|
|
35
33
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
36
|
-
|
|
34
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
37
35
|
}
|
|
38
36
|
return to;
|
|
39
|
-
}
|
|
40
|
-
var __toESM =
|
|
37
|
+
};
|
|
38
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
41
39
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
42
40
|
// file that has been converted to a CommonJS file using a Babel-
|
|
43
41
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
44
42
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
45
|
-
!mod || !mod.__esModule ?
|
|
43
|
+
!mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
46
44
|
mod
|
|
47
|
-
))
|
|
48
|
-
var __publicField =
|
|
45
|
+
));
|
|
46
|
+
var __publicField = (obj, key, value) => {
|
|
49
47
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
50
48
|
return value;
|
|
51
|
-
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// ../../node_modules/mime/Mime.js
|
|
52
52
|
var require_Mime = __commonJS({
|
|
53
53
|
"../../node_modules/mime/Mime.js"(exports$1, module) {
|
|
54
54
|
function Mime() {
|
|
@@ -62,7 +62,6 @@ var require_Mime = __commonJS({
|
|
|
62
62
|
this.getExtension = this.getExtension.bind(this);
|
|
63
63
|
}
|
|
64
64
|
__name(Mime, "Mime");
|
|
65
|
-
__name2(Mime, "Mime");
|
|
66
65
|
Mime.prototype.define = function(typeMap, force) {
|
|
67
66
|
for (let type in typeMap) {
|
|
68
67
|
let extensions = typeMap[type].map(function(t) {
|
|
@@ -100,6 +99,8 @@ var require_Mime = __commonJS({
|
|
|
100
99
|
module.exports = Mime;
|
|
101
100
|
}
|
|
102
101
|
});
|
|
102
|
+
|
|
103
|
+
// ../../node_modules/mime/types/standard.js
|
|
103
104
|
var require_standard = __commonJS({
|
|
104
105
|
"../../node_modules/mime/types/standard.js"(exports$1, module) {
|
|
105
106
|
module.exports = {
|
|
@@ -1121,6 +1122,8 @@ var require_standard = __commonJS({
|
|
|
1121
1122
|
};
|
|
1122
1123
|
}
|
|
1123
1124
|
});
|
|
1125
|
+
|
|
1126
|
+
// ../../node_modules/mime/types/other.js
|
|
1124
1127
|
var require_other = __commonJS({
|
|
1125
1128
|
"../../node_modules/mime/types/other.js"(exports$1, module) {
|
|
1126
1129
|
module.exports = {
|
|
@@ -3235,23 +3238,27 @@ var require_other = __commonJS({
|
|
|
3235
3238
|
};
|
|
3236
3239
|
}
|
|
3237
3240
|
});
|
|
3241
|
+
|
|
3242
|
+
// ../../node_modules/mime/index.js
|
|
3238
3243
|
var require_mime = __commonJS({
|
|
3239
3244
|
"../../node_modules/mime/index.js"(exports$1, module) {
|
|
3240
3245
|
var Mime = require_Mime();
|
|
3241
3246
|
module.exports = new Mime(require_standard(), require_other());
|
|
3242
3247
|
}
|
|
3243
3248
|
});
|
|
3249
|
+
|
|
3250
|
+
// ../../node_modules/srcset/index.js
|
|
3244
3251
|
var require_srcset = __commonJS({
|
|
3245
3252
|
"../../node_modules/srcset/index.js"(exports$1) {
|
|
3246
3253
|
var imageCandidateRegex = /\s*([^,]\S*[^,](?:\s+[^,]+)?)\s*(?:,|$)/;
|
|
3247
|
-
var duplicateDescriptorCheck = /* @__PURE__ */
|
|
3254
|
+
var duplicateDescriptorCheck = /* @__PURE__ */ __name((allDescriptors, value, postfix) => {
|
|
3248
3255
|
allDescriptors[postfix] = allDescriptors[postfix] || {};
|
|
3249
3256
|
if (allDescriptors[postfix][value]) {
|
|
3250
3257
|
throw new Error(`No more than one image candidate is allowed for a given descriptor: ${value}${postfix}`);
|
|
3251
3258
|
}
|
|
3252
3259
|
allDescriptors[postfix][value] = true;
|
|
3253
3260
|
}, "duplicateDescriptorCheck");
|
|
3254
|
-
var fallbackDescriptorDuplicateCheck = /* @__PURE__ */
|
|
3261
|
+
var fallbackDescriptorDuplicateCheck = /* @__PURE__ */ __name((allDescriptors) => {
|
|
3255
3262
|
if (allDescriptors.fallback) {
|
|
3256
3263
|
throw new Error("Only one fallback image candidate is allowed");
|
|
3257
3264
|
}
|
|
@@ -3260,14 +3267,14 @@ var require_srcset = __commonJS({
|
|
|
3260
3267
|
}
|
|
3261
3268
|
allDescriptors.fallback = true;
|
|
3262
3269
|
}, "fallbackDescriptorDuplicateCheck");
|
|
3263
|
-
var descriptorCountCheck = /* @__PURE__ */
|
|
3270
|
+
var descriptorCountCheck = /* @__PURE__ */ __name((allDescriptors, currentDescriptors) => {
|
|
3264
3271
|
if (currentDescriptors.length === 0) {
|
|
3265
3272
|
fallbackDescriptorDuplicateCheck(allDescriptors);
|
|
3266
3273
|
} else if (currentDescriptors.length > 1) {
|
|
3267
3274
|
throw new Error(`Image candidate may have no more than one descriptor, found ${currentDescriptors.length}: ${currentDescriptors.join(" ")}`);
|
|
3268
3275
|
}
|
|
3269
3276
|
}, "descriptorCountCheck");
|
|
3270
|
-
var validDescriptorCheck = /* @__PURE__ */
|
|
3277
|
+
var validDescriptorCheck = /* @__PURE__ */ __name((value, postfix, descriptor) => {
|
|
3271
3278
|
if (Number.isNaN(value)) {
|
|
3272
3279
|
throw new TypeError(`${descriptor || value} is not a valid number`);
|
|
3273
3280
|
}
|
|
@@ -3379,22 +3386,40 @@ var require_srcset = __commonJS({
|
|
|
3379
3386
|
};
|
|
3380
3387
|
}
|
|
3381
3388
|
});
|
|
3389
|
+
|
|
3390
|
+
// ../shared/src/utils/logger.ts
|
|
3382
3391
|
var logger = process.env.LOG ? console : {
|
|
3383
3392
|
log: (..._args) => {
|
|
3384
3393
|
},
|
|
3385
3394
|
warn: (..._args) => {
|
|
3386
3395
|
}
|
|
3387
3396
|
};
|
|
3388
|
-
|
|
3389
|
-
|
|
3397
|
+
|
|
3398
|
+
// ../shared/src/resource-archiver/index.ts
|
|
3399
|
+
var _ResourceArchiver = class _ResourceArchiver {
|
|
3390
3400
|
constructor(cdpClient, allowedDomains, httpCredentials) {
|
|
3391
3401
|
__publicField(this, "archive", {});
|
|
3392
3402
|
__publicField(this, "client");
|
|
3403
|
+
/**
|
|
3404
|
+
Specifies which domains (origins) we should archive resources for (by default we only archive same-origin resources).
|
|
3405
|
+
Useful in situations where the environment running the archived storybook (e.g. in CI) may be restricted to an intranet or other domain restrictions
|
|
3406
|
+
*/
|
|
3393
3407
|
__publicField(this, "assetDomains");
|
|
3408
|
+
/**
|
|
3409
|
+
* We assume the first URL loaded after @watch is called is the base URL of the
|
|
3410
|
+
* page and we only save resources that are loaded from the same protocol/host/port combination.
|
|
3411
|
+
* We also skip archiving this page because we only care about resources requested by this page.
|
|
3412
|
+
*/
|
|
3394
3413
|
__publicField(this, "firstUrl");
|
|
3414
|
+
/**
|
|
3415
|
+
* HTTP Basic Auth credentials to use when accessing protected resources.
|
|
3416
|
+
*/
|
|
3395
3417
|
__publicField(this, "httpCredentials");
|
|
3418
|
+
/**
|
|
3419
|
+
* Currently active requests
|
|
3420
|
+
*/
|
|
3396
3421
|
__publicField(this, "pendingRequests", /* @__PURE__ */ new Set());
|
|
3397
|
-
__publicField(this, "authRequired", /* @__PURE__ */
|
|
3422
|
+
__publicField(this, "authRequired", /* @__PURE__ */ __name(async ({ requestId, request }) => {
|
|
3398
3423
|
await this.clientSend(request, "Fetch.continueWithAuth", {
|
|
3399
3424
|
requestId,
|
|
3400
3425
|
authChallengeResponse: {
|
|
@@ -3403,7 +3428,7 @@ var _ResourceArchiver = (_a = class {
|
|
|
3403
3428
|
}
|
|
3404
3429
|
});
|
|
3405
3430
|
}, "authRequired"));
|
|
3406
|
-
__publicField(this, "requestPaused", /* @__PURE__ */
|
|
3431
|
+
__publicField(this, "requestPaused", /* @__PURE__ */ __name(async ({ requestId, request, responseStatusCode, responseStatusText, responseErrorReason, responseHeaders }) => {
|
|
3407
3432
|
this.pendingRequests.delete(requestId);
|
|
3408
3433
|
if (!request.method.match(/get/i)) {
|
|
3409
3434
|
await this.clientSend(request, "Fetch.continueRequest", {
|
|
@@ -3516,8 +3541,8 @@ var _ResourceArchiver = (_a = class {
|
|
|
3516
3541
|
requestId
|
|
3517
3542
|
});
|
|
3518
3543
|
}
|
|
3519
|
-
}
|
|
3520
|
-
|
|
3544
|
+
};
|
|
3545
|
+
__name(_ResourceArchiver, "ResourceArchiver");
|
|
3521
3546
|
var ResourceArchiver = _ResourceArchiver;
|
|
3522
3547
|
function ensureDir(directory) {
|
|
3523
3548
|
if (!existsSync(directory)) {
|
|
@@ -3527,7 +3552,6 @@ function ensureDir(directory) {
|
|
|
3527
3552
|
}
|
|
3528
3553
|
}
|
|
3529
3554
|
__name(ensureDir, "ensureDir");
|
|
3530
|
-
__name2(ensureDir, "ensureDir");
|
|
3531
3555
|
async function outputFile(filePath, data) {
|
|
3532
3556
|
ensureDir(path2.dirname(filePath));
|
|
3533
3557
|
return writeFile(filePath, data, {
|
|
@@ -3535,19 +3559,16 @@ async function outputFile(filePath, data) {
|
|
|
3535
3559
|
});
|
|
3536
3560
|
}
|
|
3537
3561
|
__name(outputFile, "outputFile");
|
|
3538
|
-
__name2(outputFile, "outputFile");
|
|
3539
3562
|
async function outputJSONFile(filePath, data) {
|
|
3540
3563
|
return outputFile(filePath, JSON.stringify(data));
|
|
3541
3564
|
}
|
|
3542
3565
|
__name(outputJSONFile, "outputJSONFile");
|
|
3543
|
-
__name2(outputJSONFile, "outputJSONFile");
|
|
3544
3566
|
function hash(data) {
|
|
3545
3567
|
return createHash("shake256", {
|
|
3546
3568
|
outputLength: 2
|
|
3547
3569
|
}).update(data).digest("hex");
|
|
3548
3570
|
}
|
|
3549
3571
|
__name(hash, "hash");
|
|
3550
|
-
__name2(hash, "hash");
|
|
3551
3572
|
var MAX_FILE_NAME_BYTE_LENGTH = 255;
|
|
3552
3573
|
function truncateFileName(filePath, maxByteLength = MAX_FILE_NAME_BYTE_LENGTH) {
|
|
3553
3574
|
const encoder = new TextEncoder();
|
|
@@ -3576,8 +3597,7 @@ function truncateFileName(filePath, maxByteLength = MAX_FILE_NAME_BYTE_LENGTH) {
|
|
|
3576
3597
|
].join("/");
|
|
3577
3598
|
}
|
|
3578
3599
|
__name(truncateFileName, "truncateFileName");
|
|
3579
|
-
|
|
3580
|
-
var removeLocalhostFromBaseUrl = /* @__PURE__ */ __name2((href) => {
|
|
3600
|
+
var removeLocalhostFromBaseUrl = /* @__PURE__ */ __name((href) => {
|
|
3581
3601
|
let baseUrl;
|
|
3582
3602
|
try {
|
|
3583
3603
|
baseUrl = new URL(href);
|
|
@@ -3589,6 +3609,8 @@ var removeLocalhostFromBaseUrl = /* @__PURE__ */ __name2((href) => {
|
|
|
3589
3609
|
return href;
|
|
3590
3610
|
}
|
|
3591
3611
|
}, "removeLocalhostFromBaseUrl");
|
|
3612
|
+
|
|
3613
|
+
// ../shared/src/write-archive/archive-file.ts
|
|
3592
3614
|
var import_mime = __toESM(require_mime());
|
|
3593
3615
|
var RESERVED_PATHNAMES = [
|
|
3594
3616
|
// This is a list of filenames that are reserved for Storybook as a dev target.
|
|
@@ -3602,12 +3624,13 @@ var RESERVED_PATHNAMES = [
|
|
|
3602
3624
|
"/runtime~main.iframe.bundle.js",
|
|
3603
3625
|
"/sb-preview/runtime.js"
|
|
3604
3626
|
];
|
|
3605
|
-
var
|
|
3606
|
-
var _ArchiveFile = (_a2 = class {
|
|
3627
|
+
var _ArchiveFile = class _ArchiveFile {
|
|
3607
3628
|
constructor(url, response, pageUrl) {
|
|
3629
|
+
// The URL to the asset being archived.
|
|
3608
3630
|
__publicField(this, "url");
|
|
3609
3631
|
__publicField(this, "response");
|
|
3610
3632
|
__publicField(this, "shortenedFileNameLength");
|
|
3633
|
+
// The URL to page being tested.
|
|
3611
3634
|
__publicField(this, "pageUrl");
|
|
3612
3635
|
this.url = new URL(url);
|
|
3613
3636
|
this.response = response;
|
|
@@ -3682,27 +3705,33 @@ var _ArchiveFile = (_a2 = class {
|
|
|
3682
3705
|
}
|
|
3683
3706
|
return pathname;
|
|
3684
3707
|
}
|
|
3685
|
-
}
|
|
3686
|
-
|
|
3708
|
+
};
|
|
3709
|
+
__name(_ArchiveFile, "ArchiveFile");
|
|
3687
3710
|
var ArchiveFile = _ArchiveFile;
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3711
|
+
|
|
3712
|
+
// ../../node_modules/@rrweb/types/dist/types.js
|
|
3713
|
+
var NodeType = /* @__PURE__ */ ((NodeType2) => {
|
|
3714
|
+
NodeType2[NodeType2["Document"] = 0] = "Document";
|
|
3715
|
+
NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
|
|
3716
|
+
NodeType2[NodeType2["Element"] = 2] = "Element";
|
|
3717
|
+
NodeType2[NodeType2["Text"] = 3] = "Text";
|
|
3718
|
+
NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
|
|
3719
|
+
NodeType2[NodeType2["Comment"] = 5] = "Comment";
|
|
3720
|
+
return NodeType2;
|
|
3696
3721
|
})(NodeType || {});
|
|
3722
|
+
|
|
3723
|
+
// ../shared/src/write-archive/dom-snapshot.ts
|
|
3697
3724
|
var import_srcset = __toESM(require_srcset());
|
|
3725
|
+
|
|
3726
|
+
// ../shared/src/utils/nodes.ts
|
|
3698
3727
|
function isIframeSerializedNode(node) {
|
|
3699
3728
|
return node.type === NodeType.Element && node.tagName === "iframe" && "contentDocument" in node && !!node.contentDocument;
|
|
3700
3729
|
}
|
|
3701
3730
|
__name(isIframeSerializedNode, "isIframeSerializedNode");
|
|
3702
|
-
|
|
3731
|
+
|
|
3732
|
+
// ../shared/src/write-archive/dom-snapshot.ts
|
|
3703
3733
|
var CSS_URL_REGEX = /url\((?!['"]?(?:data):)['"]?([^'")]*)['"]?\)/gi;
|
|
3704
|
-
var
|
|
3705
|
-
var _DOMSnapshot = (_a3 = class {
|
|
3734
|
+
var _DOMSnapshot = class _DOMSnapshot {
|
|
3706
3735
|
constructor({ snapshot, pseudoClassIds }) {
|
|
3707
3736
|
__publicField(this, "snapshot");
|
|
3708
3737
|
__publicField(this, "pseudoClassIds");
|
|
@@ -3829,26 +3858,22 @@ var _DOMSnapshot = (_a3 = class {
|
|
|
3829
3858
|
});
|
|
3830
3859
|
return currentSrc;
|
|
3831
3860
|
}
|
|
3832
|
-
}
|
|
3833
|
-
|
|
3861
|
+
};
|
|
3862
|
+
__name(_DOMSnapshot, "DOMSnapshot");
|
|
3834
3863
|
var DOMSnapshot = _DOMSnapshot;
|
|
3864
|
+
|
|
3865
|
+
// ../shared/src/utils/viewport.ts
|
|
3835
3866
|
function viewportToString(viewport) {
|
|
3836
3867
|
return `w${viewport.width}h${viewport.height}`;
|
|
3837
3868
|
}
|
|
3838
3869
|
__name(viewportToString, "viewportToString");
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
return {
|
|
3843
|
-
width: Number(matcher[1]),
|
|
3844
|
-
height: Number(matcher[2])
|
|
3845
|
-
};
|
|
3846
|
-
}
|
|
3847
|
-
__name(parseViewport, "parseViewport");
|
|
3848
|
-
__name2(parseViewport, "parseViewport");
|
|
3849
|
-
var sanitize = /* @__PURE__ */ __name2((string) => {
|
|
3870
|
+
|
|
3871
|
+
// ../shared/src/write-archive/storybook-sanitize.ts
|
|
3872
|
+
var sanitize = /* @__PURE__ */ __name((string) => {
|
|
3850
3873
|
return string.toLowerCase().replace(/[ ’–—―′¿'`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, "-").replace(/[\r\n]/g, "-").replace(/-+/g, "-").replace(/^-+/, "").replace(/-+$/, "");
|
|
3851
3874
|
}, "sanitize");
|
|
3875
|
+
|
|
3876
|
+
// ../shared/src/write-archive/snapshot-files.ts
|
|
3852
3877
|
var SNAPSHOT_FILE_EXT = "snapshot.json";
|
|
3853
3878
|
function snapshotId(testTitle, snapshotName) {
|
|
3854
3879
|
const fullSnapshotId = `${sanitize(testTitle)}-${sanitize(snapshotName)}`;
|
|
@@ -3856,7 +3881,6 @@ function snapshotId(testTitle, snapshotName) {
|
|
|
3856
3881
|
return truncateFileName(fullSnapshotId, maxByteLength);
|
|
3857
3882
|
}
|
|
3858
3883
|
__name(snapshotId, "snapshotId");
|
|
3859
|
-
__name2(snapshotId, "snapshotId");
|
|
3860
3884
|
function snapshotFileName(snapshotId2, viewport) {
|
|
3861
3885
|
const fileNameParts = [
|
|
3862
3886
|
snapshotId2,
|
|
@@ -3866,7 +3890,8 @@ function snapshotFileName(snapshotId2, viewport) {
|
|
|
3866
3890
|
return fileNameParts.join(".");
|
|
3867
3891
|
}
|
|
3868
3892
|
__name(snapshotFileName, "snapshotFileName");
|
|
3869
|
-
|
|
3893
|
+
|
|
3894
|
+
// ../shared/src/write-archive/stories-files.ts
|
|
3870
3895
|
var STORIES_FILE_EXT = "stories.json";
|
|
3871
3896
|
function storiesFileName(testTitle) {
|
|
3872
3897
|
const fileName = [
|
|
@@ -3877,7 +3902,6 @@ function storiesFileName(testTitle) {
|
|
|
3877
3902
|
return truncateFileName(fileName, maxByteLength);
|
|
3878
3903
|
}
|
|
3879
3904
|
__name(storiesFileName, "storiesFileName");
|
|
3880
|
-
__name2(storiesFileName, "storiesFileName");
|
|
3881
3905
|
function createStories(title, domSnapshots, chromaticStorybookParams) {
|
|
3882
3906
|
return {
|
|
3883
3907
|
title,
|
|
@@ -3912,7 +3936,6 @@ function createStories(title, domSnapshots, chromaticStorybookParams) {
|
|
|
3912
3936
|
};
|
|
3913
3937
|
}
|
|
3914
3938
|
__name(createStories, "createStories");
|
|
3915
|
-
__name2(createStories, "createStories");
|
|
3916
3939
|
function buildStoryModesConfig(viewports) {
|
|
3917
3940
|
return viewports.reduce((modes, viewport) => {
|
|
3918
3941
|
const viewportName = viewportToString(viewport);
|
|
@@ -3923,7 +3946,6 @@ function buildStoryModesConfig(viewports) {
|
|
|
3923
3946
|
}, {});
|
|
3924
3947
|
}
|
|
3925
3948
|
__name(buildStoryModesConfig, "buildStoryModesConfig");
|
|
3926
|
-
__name2(buildStoryModesConfig, "buildStoryModesConfig");
|
|
3927
3949
|
function buildStoryViewportsConfig(viewports) {
|
|
3928
3950
|
return viewports.reduce((viewportsConfig, viewport) => {
|
|
3929
3951
|
const viewportName = viewportToString(viewport);
|
|
@@ -3939,7 +3961,6 @@ function buildStoryViewportsConfig(viewports) {
|
|
|
3939
3961
|
}, {});
|
|
3940
3962
|
}
|
|
3941
3963
|
__name(buildStoryViewportsConfig, "buildStoryViewportsConfig");
|
|
3942
|
-
__name2(buildStoryViewportsConfig, "buildStoryViewportsConfig");
|
|
3943
3964
|
function viewportAddonType(viewport) {
|
|
3944
3965
|
if (viewport.width < 600) {
|
|
3945
3966
|
return "mobile";
|
|
@@ -3950,9 +3971,8 @@ function viewportAddonType(viewport) {
|
|
|
3950
3971
|
return "desktop";
|
|
3951
3972
|
}
|
|
3952
3973
|
__name(viewportAddonType, "viewportAddonType");
|
|
3953
|
-
__name2(viewportAddonType, "viewportAddonType");
|
|
3954
3974
|
function findDefaultViewport(viewports) {
|
|
3955
|
-
const compareFn = /* @__PURE__ */
|
|
3975
|
+
const compareFn = /* @__PURE__ */ __name((vp1, vp2) => {
|
|
3956
3976
|
if (vp1.width < vp2.width) {
|
|
3957
3977
|
return 1;
|
|
3958
3978
|
}
|
|
@@ -3964,7 +3984,8 @@ function findDefaultViewport(viewports) {
|
|
|
3964
3984
|
return viewports.sort(compareFn)[0];
|
|
3965
3985
|
}
|
|
3966
3986
|
__name(findDefaultViewport, "findDefaultViewport");
|
|
3967
|
-
|
|
3987
|
+
|
|
3988
|
+
// ../shared/src/write-archive/index.ts
|
|
3968
3989
|
async function writeTestResult(e2eTestInfo, domSnapshots, archive, chromaticStorybookParams) {
|
|
3969
3990
|
const { titlePath, outputDir, pageUrl } = e2eTestInfo;
|
|
3970
3991
|
const titlePathWithoutFileExtensions = titlePath.map((pathPart) => (
|
|
@@ -4009,7 +4030,6 @@ async function writeTestResult(e2eTestInfo, domSnapshots, archive, chromaticStor
|
|
|
4009
4030
|
}
|
|
4010
4031
|
}
|
|
4011
4032
|
__name(writeTestResult, "writeTestResult");
|
|
4012
|
-
__name2(writeTestResult, "writeTestResult");
|
|
4013
4033
|
var analytics = new Analytics({
|
|
4014
4034
|
writeKey: process.env.SEGMENT_WRITE_KEY || "cwWhBWso2gwzyenW29CnCp30Kjz4DogE"
|
|
4015
4035
|
});
|
|
@@ -4022,7 +4042,6 @@ function track(event, properties) {
|
|
|
4022
4042
|
});
|
|
4023
4043
|
}
|
|
4024
4044
|
__name(track, "track");
|
|
4025
|
-
__name2(track, "track");
|
|
4026
4045
|
var hasTrackedRun = false;
|
|
4027
4046
|
function trackRun(properties = {}) {
|
|
4028
4047
|
if (hasTrackedRun)
|
|
@@ -4031,7 +4050,6 @@ function trackRun(properties = {}) {
|
|
|
4031
4050
|
hasTrackedRun = true;
|
|
4032
4051
|
}
|
|
4033
4052
|
__name(trackRun, "trackRun");
|
|
4034
|
-
__name2(trackRun, "trackRun");
|
|
4035
4053
|
var hasTrackedComplete = false;
|
|
4036
4054
|
function trackComplete(properties = {}) {
|
|
4037
4055
|
if (hasTrackedComplete)
|
|
@@ -4040,21 +4058,9 @@ function trackComplete(properties = {}) {
|
|
|
4040
4058
|
hasTrackedComplete = true;
|
|
4041
4059
|
}
|
|
4042
4060
|
__name(trackComplete, "trackComplete");
|
|
4043
|
-
__name2(trackComplete, "trackComplete");
|
|
4044
|
-
var DEFAULT_GLOBAL_RESOURCE_ARCHIVE_TIMEOUT_MS = 1e4;
|
|
4045
4061
|
|
|
4046
|
-
//
|
|
4047
|
-
var
|
|
4048
|
-
NodeType22[NodeType22["Document"] = 0] = "Document";
|
|
4049
|
-
NodeType22[NodeType22["DocumentType"] = 1] = "DocumentType";
|
|
4050
|
-
NodeType22[NodeType22["Element"] = 2] = "Element";
|
|
4051
|
-
NodeType22[NodeType22["Text"] = 3] = "Text";
|
|
4052
|
-
NodeType22[NodeType22["CDATA"] = 4] = "CDATA";
|
|
4053
|
-
NodeType22[NodeType22["Comment"] = 5] = "Comment";
|
|
4054
|
-
return NodeType22;
|
|
4055
|
-
})(NodeType2 || {});
|
|
4056
|
-
|
|
4057
|
-
// src/takeSnapshot.ts
|
|
4062
|
+
// ../shared/src/constants.ts
|
|
4063
|
+
var DEFAULT_GLOBAL_RESOURCE_ARCHIVE_TIMEOUT_MS = 1e4;
|
|
4058
4064
|
var rrweb = readFileSync(__require.resolve("@chromaui/rrweb-snapshot"), "utf8");
|
|
4059
4065
|
var chromaticSnapshots = /* @__PURE__ */ new Map();
|
|
4060
4066
|
async function takeSnapshot(page, nameOrTestInfo, maybeTestInfo) {
|
|
@@ -4187,7 +4193,7 @@ async function executeSnapshotScript(context) {
|
|
|
4187
4193
|
}
|
|
4188
4194
|
__name(executeSnapshotScript, "executeSnapshotScript");
|
|
4189
4195
|
function findIframes(node) {
|
|
4190
|
-
if (node.type ===
|
|
4196
|
+
if (node.type === NodeType.Element && node.tagName === "iframe") {
|
|
4191
4197
|
return [
|
|
4192
4198
|
node
|
|
4193
4199
|
];
|
|
@@ -1,98 +1,22 @@
|
|
|
1
1
|
import path2 from 'path';
|
|
2
2
|
import { fileURLToPath, pathToFileURL } from 'url';
|
|
3
|
-
import { existsSync, mkdirSync } from 'fs';
|
|
4
|
-
import { writeFile } from 'fs/promises';
|
|
5
|
-
import { createHash } from 'crypto';
|
|
6
3
|
|
|
7
4
|
var __defProp = Object.defineProperty;
|
|
8
5
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
-
var __defProp2 = Object.defineProperty;
|
|
10
|
-
var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name", { value, configurable: true }), "__name");
|
|
11
6
|
function rootDir() {
|
|
12
7
|
return process.cwd();
|
|
13
8
|
}
|
|
14
9
|
__name(rootDir, "rootDir");
|
|
15
|
-
__name2(rootDir, "rootDir");
|
|
16
10
|
function outputDirOverride() {
|
|
17
11
|
const { CHROMATIC_ARCHIVE_LOCATION } = process.env;
|
|
18
12
|
return CHROMATIC_ARCHIVE_LOCATION;
|
|
19
13
|
}
|
|
20
14
|
__name(outputDirOverride, "outputDirOverride");
|
|
21
|
-
__name2(outputDirOverride, "outputDirOverride");
|
|
22
15
|
function archivesDir(defaultOutputDir) {
|
|
23
16
|
const outputDir = outputDirOverride() || defaultOutputDir;
|
|
24
17
|
return path2.resolve(rootDir(), outputDir, "chromatic-archives");
|
|
25
18
|
}
|
|
26
19
|
__name(archivesDir, "archivesDir");
|
|
27
|
-
__name2(archivesDir, "archivesDir");
|
|
28
|
-
function checkArchivesDirExists(defaultOutputDir) {
|
|
29
|
-
const dir = archivesDir(defaultOutputDir);
|
|
30
|
-
if (!existsSync(dir)) {
|
|
31
|
-
throw new Error(`Chromatic archives directory cannot be found: ${dir}
|
|
32
|
-
|
|
33
|
-
Please make sure that you have run your E2E tests, or have set the CHROMATIC_ARCHIVE_LOCATION env var if the output directory for the tests is not in the standard location.`);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
__name(checkArchivesDirExists, "checkArchivesDirExists");
|
|
37
|
-
__name2(checkArchivesDirExists, "checkArchivesDirExists");
|
|
38
|
-
function ensureDir(directory) {
|
|
39
|
-
if (!existsSync(directory)) {
|
|
40
|
-
mkdirSync(directory, {
|
|
41
|
-
recursive: true
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
__name(ensureDir, "ensureDir");
|
|
46
|
-
__name2(ensureDir, "ensureDir");
|
|
47
|
-
async function outputFile(filePath, data) {
|
|
48
|
-
ensureDir(path2.dirname(filePath));
|
|
49
|
-
return writeFile(filePath, data, {
|
|
50
|
-
mode: 511
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
__name(outputFile, "outputFile");
|
|
54
|
-
__name2(outputFile, "outputFile");
|
|
55
|
-
async function outputJSONFile(filePath, data) {
|
|
56
|
-
return outputFile(filePath, JSON.stringify(data));
|
|
57
|
-
}
|
|
58
|
-
__name(outputJSONFile, "outputJSONFile");
|
|
59
|
-
__name2(outputJSONFile, "outputJSONFile");
|
|
60
|
-
function hash(data) {
|
|
61
|
-
return createHash("shake256", {
|
|
62
|
-
outputLength: 2
|
|
63
|
-
}).update(data).digest("hex");
|
|
64
|
-
}
|
|
65
|
-
__name(hash, "hash");
|
|
66
|
-
__name2(hash, "hash");
|
|
67
|
-
var MAX_FILE_NAME_BYTE_LENGTH = 255;
|
|
68
|
-
function truncateFileName(filePath, maxByteLength = MAX_FILE_NAME_BYTE_LENGTH) {
|
|
69
|
-
const encoder = new TextEncoder();
|
|
70
|
-
const decoder = new TextDecoder();
|
|
71
|
-
const filePathParts = filePath.split("/");
|
|
72
|
-
const fileName = filePathParts.pop();
|
|
73
|
-
const fileNameByteArray = encoder.encode(fileName);
|
|
74
|
-
if (fileNameByteArray.byteLength <= maxByteLength) {
|
|
75
|
-
return filePath;
|
|
76
|
-
}
|
|
77
|
-
const hashedFileName = hash(fileName);
|
|
78
|
-
const [baseName, ...extensions] = fileName.split(".");
|
|
79
|
-
const baseNameByteArray = encoder.encode(baseName);
|
|
80
|
-
const ext = extensions.join(".");
|
|
81
|
-
const extLength = ext.length === 0 ? 0 : encoder.encode(ext).byteLength + 1;
|
|
82
|
-
const lengthHashAndExt = encoder.encode(hashedFileName).byteLength + extLength;
|
|
83
|
-
const truncatedBaseNameByteArray = baseNameByteArray.slice(0, maxByteLength - lengthHashAndExt);
|
|
84
|
-
const truncatedBaseName = decoder.decode(truncatedBaseNameByteArray);
|
|
85
|
-
const truncatedFileName = [
|
|
86
|
-
`${truncatedBaseName}${hashedFileName}`,
|
|
87
|
-
ext
|
|
88
|
-
].filter(Boolean).join(".");
|
|
89
|
-
return [
|
|
90
|
-
...filePathParts,
|
|
91
|
-
truncatedFileName
|
|
92
|
-
].join("/");
|
|
93
|
-
}
|
|
94
|
-
__name(truncateFileName, "truncateFileName");
|
|
95
|
-
__name2(truncateFileName, "truncateFileName");
|
|
96
20
|
|
|
97
21
|
// src/constants.ts
|
|
98
22
|
var DEFAULT_OUTPUT_DIR = "test-results";
|
|
@@ -4,43 +4,29 @@ var __defProp = Object.defineProperty;
|
|
|
4
4
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
5
|
|
|
6
6
|
// ../../node_modules/@rrweb/types/dist/types.js
|
|
7
|
-
var NodeType = /* @__PURE__ */ ((
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return
|
|
7
|
+
var NodeType = /* @__PURE__ */ ((NodeType2) => {
|
|
8
|
+
NodeType2[NodeType2["Document"] = 0] = "Document";
|
|
9
|
+
NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
|
|
10
|
+
NodeType2[NodeType2["Element"] = 2] = "Element";
|
|
11
|
+
NodeType2[NodeType2["Text"] = 3] = "Text";
|
|
12
|
+
NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
|
|
13
|
+
NodeType2[NodeType2["Comment"] = 5] = "Comment";
|
|
14
|
+
return NodeType2;
|
|
15
15
|
})(NodeType || {});
|
|
16
16
|
|
|
17
|
-
// ../shared/
|
|
18
|
-
var __defProp2 = Object.defineProperty;
|
|
19
|
-
var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name", { value, configurable: true }), "__name");
|
|
20
|
-
var NodeType2 = /* @__PURE__ */ ((NodeType22) => {
|
|
21
|
-
NodeType22[NodeType22["Document"] = 0] = "Document";
|
|
22
|
-
NodeType22[NodeType22["DocumentType"] = 1] = "DocumentType";
|
|
23
|
-
NodeType22[NodeType22["Element"] = 2] = "Element";
|
|
24
|
-
NodeType22[NodeType22["Text"] = 3] = "Text";
|
|
25
|
-
NodeType22[NodeType22["CDATA"] = 4] = "CDATA";
|
|
26
|
-
NodeType22[NodeType22["Comment"] = 5] = "Comment";
|
|
27
|
-
return NodeType22;
|
|
28
|
-
})(NodeType2 || {});
|
|
17
|
+
// ../shared/src/utils/nodes.ts
|
|
29
18
|
function isIframeSerializedNode(node) {
|
|
30
|
-
return node.type ===
|
|
19
|
+
return node.type === NodeType.Element && node.tagName === "iframe" && "contentDocument" in node && !!node.contentDocument;
|
|
31
20
|
}
|
|
32
21
|
__name(isIframeSerializedNode, "isIframeSerializedNode");
|
|
33
|
-
__name2(isIframeSerializedNode, "isIframeSerializedNode");
|
|
34
22
|
function isElement(node) {
|
|
35
23
|
return node?.nodeType === Node.ELEMENT_NODE;
|
|
36
24
|
}
|
|
37
25
|
__name(isElement, "isElement");
|
|
38
|
-
__name2(isElement, "isElement");
|
|
39
26
|
function isIframeElement(node) {
|
|
40
27
|
return isElement(node) && node.tagName.toLowerCase() === "iframe";
|
|
41
28
|
}
|
|
42
29
|
__name(isIframeElement, "isIframeElement");
|
|
43
|
-
__name2(isIframeElement, "isIframeElement");
|
|
44
30
|
|
|
45
31
|
// ../shared/storybook-config/preview.ts
|
|
46
32
|
var pageUrl = new URL(window.location.href);
|