@chromatic-com/playwright 0.14.3-7de78ce-20260522064559 → 0.14.4
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/index.js +40 -30
- package/dist/index.mjs +40 -30
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@ var path2 = require('path');
|
|
|
6
6
|
var fs = require('fs');
|
|
7
7
|
var promises = require('fs/promises');
|
|
8
8
|
var crypto = require('crypto');
|
|
9
|
+
var csf = require('storybook/internal/csf');
|
|
9
10
|
var analyticsNode = require('@segment/analytics-node');
|
|
10
11
|
|
|
11
12
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
@@ -3877,6 +3878,7 @@ __name(viewportToString, "viewportToString");
|
|
|
3877
3878
|
var sanitize = /* @__PURE__ */ __name((string) => {
|
|
3878
3879
|
return string.toLowerCase().replace(/[ ’–—―′¿'`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, "-").replace(/[\r\n]/g, "-").replace(/-+/g, "-").replace(/^-+/, "").replace(/-+$/, "");
|
|
3879
3880
|
}, "sanitize");
|
|
3881
|
+
var collapseNewlines = /* @__PURE__ */ __name((title) => title.replace(/[\r\n]+/g, " ").trim(), "collapseNewlines");
|
|
3880
3882
|
|
|
3881
3883
|
// ../shared/src/write-archive/snapshot-files.ts
|
|
3882
3884
|
var SNAPSHOT_FILE_EXT = "snapshot.json";
|
|
@@ -3895,49 +3897,57 @@ function snapshotFileName(snapshotId2, viewport) {
|
|
|
3895
3897
|
return fileNameParts.join(".");
|
|
3896
3898
|
}
|
|
3897
3899
|
__name(snapshotFileName, "snapshotFileName");
|
|
3898
|
-
|
|
3899
|
-
// ../shared/src/write-archive/stories-files.ts
|
|
3900
3900
|
var STORIES_FILE_EXT = "stories.json";
|
|
3901
|
+
var uniqueId = {
|
|
3902
|
+
value: 1
|
|
3903
|
+
};
|
|
3901
3904
|
function storiesFileName(testTitle) {
|
|
3902
3905
|
const fileName = [
|
|
3903
|
-
sanitize(testTitle)
|
|
3906
|
+
sanitize(testTitle) + "-" + uniqueId.value++,
|
|
3904
3907
|
STORIES_FILE_EXT
|
|
3905
3908
|
].join(".");
|
|
3906
3909
|
const maxByteLength = MAX_FILE_NAME_BYTE_LENGTH - 25;
|
|
3907
3910
|
return truncateFileName(fileName, maxByteLength);
|
|
3908
3911
|
}
|
|
3909
3912
|
__name(storiesFileName, "storiesFileName");
|
|
3910
|
-
function createStories(
|
|
3913
|
+
function createStories(storyTitle, domSnapshots, chromaticStorybookParams) {
|
|
3914
|
+
const title = collapseNewlines(storyTitle);
|
|
3911
3915
|
return {
|
|
3912
3916
|
title,
|
|
3913
|
-
stories: Object.entries(domSnapshots).map(([
|
|
3914
|
-
name
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
server: {
|
|
3923
|
-
id: snapshotId(title, name)
|
|
3924
|
-
},
|
|
3925
|
-
chromatic: {
|
|
3926
|
-
...chromaticStorybookParams,
|
|
3927
|
-
modes: buildStoryModesConfig([
|
|
3928
|
-
viewport
|
|
3929
|
-
])
|
|
3917
|
+
stories: Object.entries(domSnapshots).map(([snapshotName, { viewport }]) => {
|
|
3918
|
+
const name = collapseNewlines(snapshotName);
|
|
3919
|
+
return {
|
|
3920
|
+
name,
|
|
3921
|
+
// Viewport addon (Storybook 10+): `parameters.viewport.options` registers sizes; `globals.viewport`
|
|
3922
|
+
// selects the active one. See https://storybook.js.org/docs/essentials/viewport#defining-the-viewport-for-a-story
|
|
3923
|
+
// `defaultViewport` is not read by SB 10's types but our archive preview uses it as a fetch fallback.
|
|
3924
|
+
globals: {
|
|
3925
|
+
viewport: viewportToString(viewport)
|
|
3930
3926
|
},
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3927
|
+
parameters: {
|
|
3928
|
+
// Work-around for cases where "あ" in story name would cause Storybook to fail to load the story due to an invalid story ID.
|
|
3929
|
+
// See https://github.com/chromaui/chromatic-e2e/issues/365
|
|
3930
|
+
__id: csf.toId(title, csf.storyNameFromExport(name)),
|
|
3931
|
+
server: {
|
|
3932
|
+
id: snapshotId(title, name)
|
|
3933
|
+
},
|
|
3934
|
+
chromatic: {
|
|
3935
|
+
...chromaticStorybookParams,
|
|
3936
|
+
modes: buildStoryModesConfig([
|
|
3937
|
+
viewport
|
|
3938
|
+
])
|
|
3939
|
+
},
|
|
3940
|
+
viewport: {
|
|
3941
|
+
options: buildStoryViewportsConfig([
|
|
3942
|
+
viewport
|
|
3943
|
+
]),
|
|
3944
|
+
defaultViewport: viewportToString(findDefaultViewport([
|
|
3945
|
+
viewport
|
|
3946
|
+
]))
|
|
3947
|
+
}
|
|
3938
3948
|
}
|
|
3939
|
-
}
|
|
3940
|
-
})
|
|
3949
|
+
};
|
|
3950
|
+
})
|
|
3941
3951
|
};
|
|
3942
3952
|
}
|
|
3943
3953
|
__name(createStories, "createStories");
|
package/dist/index.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import path2, { join } from 'path';
|
|
|
5
5
|
import { existsSync, mkdirSync } from 'fs';
|
|
6
6
|
import { writeFile } from 'fs/promises';
|
|
7
7
|
import { createHash } from 'crypto';
|
|
8
|
+
import { toId, storyNameFromExport } from 'storybook/internal/csf';
|
|
8
9
|
import { Analytics } from '@segment/analytics-node';
|
|
9
10
|
|
|
10
11
|
const require$1 = createRequire(import.meta.url);
|
|
@@ -3871,6 +3872,7 @@ __name(viewportToString, "viewportToString");
|
|
|
3871
3872
|
var sanitize = /* @__PURE__ */ __name((string) => {
|
|
3872
3873
|
return string.toLowerCase().replace(/[ ’–—―′¿'`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, "-").replace(/[\r\n]/g, "-").replace(/-+/g, "-").replace(/^-+/, "").replace(/-+$/, "");
|
|
3873
3874
|
}, "sanitize");
|
|
3875
|
+
var collapseNewlines = /* @__PURE__ */ __name((title) => title.replace(/[\r\n]+/g, " ").trim(), "collapseNewlines");
|
|
3874
3876
|
|
|
3875
3877
|
// ../shared/src/write-archive/snapshot-files.ts
|
|
3876
3878
|
var SNAPSHOT_FILE_EXT = "snapshot.json";
|
|
@@ -3889,49 +3891,57 @@ function snapshotFileName(snapshotId2, viewport) {
|
|
|
3889
3891
|
return fileNameParts.join(".");
|
|
3890
3892
|
}
|
|
3891
3893
|
__name(snapshotFileName, "snapshotFileName");
|
|
3892
|
-
|
|
3893
|
-
// ../shared/src/write-archive/stories-files.ts
|
|
3894
3894
|
var STORIES_FILE_EXT = "stories.json";
|
|
3895
|
+
var uniqueId = {
|
|
3896
|
+
value: 1
|
|
3897
|
+
};
|
|
3895
3898
|
function storiesFileName(testTitle) {
|
|
3896
3899
|
const fileName = [
|
|
3897
|
-
sanitize(testTitle)
|
|
3900
|
+
sanitize(testTitle) + "-" + uniqueId.value++,
|
|
3898
3901
|
STORIES_FILE_EXT
|
|
3899
3902
|
].join(".");
|
|
3900
3903
|
const maxByteLength = MAX_FILE_NAME_BYTE_LENGTH - 25;
|
|
3901
3904
|
return truncateFileName(fileName, maxByteLength);
|
|
3902
3905
|
}
|
|
3903
3906
|
__name(storiesFileName, "storiesFileName");
|
|
3904
|
-
function createStories(
|
|
3907
|
+
function createStories(storyTitle, domSnapshots, chromaticStorybookParams) {
|
|
3908
|
+
const title = collapseNewlines(storyTitle);
|
|
3905
3909
|
return {
|
|
3906
3910
|
title,
|
|
3907
|
-
stories: Object.entries(domSnapshots).map(([
|
|
3908
|
-
name
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
server: {
|
|
3917
|
-
id: snapshotId(title, name)
|
|
3918
|
-
},
|
|
3919
|
-
chromatic: {
|
|
3920
|
-
...chromaticStorybookParams,
|
|
3921
|
-
modes: buildStoryModesConfig([
|
|
3922
|
-
viewport
|
|
3923
|
-
])
|
|
3911
|
+
stories: Object.entries(domSnapshots).map(([snapshotName, { viewport }]) => {
|
|
3912
|
+
const name = collapseNewlines(snapshotName);
|
|
3913
|
+
return {
|
|
3914
|
+
name,
|
|
3915
|
+
// Viewport addon (Storybook 10+): `parameters.viewport.options` registers sizes; `globals.viewport`
|
|
3916
|
+
// selects the active one. See https://storybook.js.org/docs/essentials/viewport#defining-the-viewport-for-a-story
|
|
3917
|
+
// `defaultViewport` is not read by SB 10's types but our archive preview uses it as a fetch fallback.
|
|
3918
|
+
globals: {
|
|
3919
|
+
viewport: viewportToString(viewport)
|
|
3924
3920
|
},
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3921
|
+
parameters: {
|
|
3922
|
+
// Work-around for cases where "あ" in story name would cause Storybook to fail to load the story due to an invalid story ID.
|
|
3923
|
+
// See https://github.com/chromaui/chromatic-e2e/issues/365
|
|
3924
|
+
__id: toId(title, storyNameFromExport(name)),
|
|
3925
|
+
server: {
|
|
3926
|
+
id: snapshotId(title, name)
|
|
3927
|
+
},
|
|
3928
|
+
chromatic: {
|
|
3929
|
+
...chromaticStorybookParams,
|
|
3930
|
+
modes: buildStoryModesConfig([
|
|
3931
|
+
viewport
|
|
3932
|
+
])
|
|
3933
|
+
},
|
|
3934
|
+
viewport: {
|
|
3935
|
+
options: buildStoryViewportsConfig([
|
|
3936
|
+
viewport
|
|
3937
|
+
]),
|
|
3938
|
+
defaultViewport: viewportToString(findDefaultViewport([
|
|
3939
|
+
viewport
|
|
3940
|
+
]))
|
|
3941
|
+
}
|
|
3932
3942
|
}
|
|
3933
|
-
}
|
|
3934
|
-
})
|
|
3943
|
+
};
|
|
3944
|
+
})
|
|
3935
3945
|
};
|
|
3936
3946
|
}
|
|
3937
3947
|
__name(createStories, "createStories");
|