@cappa/plugin-storybook 0.3.1 → 0.3.3
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/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +13 -0
- package/dist/preview.js +18 -11
- package/package.json +10 -5
- package/src/index.esm.ts +1 -0
- package/src/storybook/addon/decorator.ts +16 -13
- package/tsconfig.json +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @cappa/plugin-storybook@0.3.
|
|
2
|
+
> @cappa/plugin-storybook@0.3.3 build /home/runner/work/cappa/cappa/packages/plugins/plugin-storybook
|
|
3
3
|
> tsup
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: {"index":"src/index.esm.ts"}
|
|
@@ -20,24 +20,24 @@
|
|
|
20
20
|
[34mCLI[39m Using tsup config: /home/runner/work/cappa/cappa/packages/plugins/plugin-storybook/tsup.config.ts
|
|
21
21
|
[34mCLI[39m Target: esnext
|
|
22
22
|
[34mCLI[39m Target: esnext
|
|
23
|
-
[34mCLI[39m Target: node16
|
|
24
|
-
[34mCLI[39m Target: es2015
|
|
25
23
|
[34mCLI[39m Cleaning output folder
|
|
26
24
|
[34mESM[39m Build start
|
|
27
25
|
[34mCLI[39m Cleaning output folder
|
|
28
26
|
[34mCJS[39m Build start
|
|
27
|
+
[34mCLI[39m Target: node16
|
|
28
|
+
[34mCLI[39m Target: es2015
|
|
29
29
|
[34mCLI[39m Cleaning output folder
|
|
30
30
|
[34mESM[39m Build start
|
|
31
31
|
[34mCLI[39m Cleaning output folder
|
|
32
32
|
[34mESM[39m Build start
|
|
33
|
-
[32mESM[39m [1mdist/preview.js [22m[32m1.41 KB[39m
|
|
34
|
-
[32mESM[39m ⚡️ Build success in 36ms
|
|
35
33
|
[32mESM[39m [1mdist/browser.js [22m[32m138.00 B[39m
|
|
36
|
-
[32mESM[39m ⚡️ Build success in
|
|
37
|
-
[32mESM[39m [1mdist/
|
|
38
|
-
[32mESM[39m ⚡️ Build success in
|
|
34
|
+
[32mESM[39m ⚡️ Build success in 26ms
|
|
35
|
+
[32mESM[39m [1mdist/preview.js [22m[32m1.58 KB[39m
|
|
36
|
+
[32mESM[39m ⚡️ Build success in 41ms
|
|
39
37
|
[32mCJS[39m [1mdist/index.cjs [22m[32m13.98 KB[39m
|
|
40
|
-
[32mCJS[39m ⚡️ Build success in
|
|
38
|
+
[32mCJS[39m ⚡️ Build success in 45ms
|
|
39
|
+
[32mESM[39m [1mdist/index.js [22m[32m12.25 KB[39m
|
|
40
|
+
[32mESM[39m ⚡️ Build success in 54ms
|
|
41
41
|
[34mDTS[39m Build start
|
|
42
|
-
[32mDTS[39m ⚡️ Build success in
|
|
42
|
+
[32mDTS[39m ⚡️ Build success in 3394ms
|
|
43
43
|
[32mDTS[39m [1mdist/index.d.ts [22m[32m2.63 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @cappa/plugin-storybook
|
|
2
2
|
|
|
3
|
+
## 0.3.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [772d0f6]
|
|
8
|
+
- @cappa/core@0.3.1
|
|
9
|
+
|
|
10
|
+
## 0.3.2
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- c2614bc: fix: only run storybook exposed code when in cappa
|
|
15
|
+
|
|
3
16
|
## 0.3.1
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/preview.js
CHANGED
|
@@ -18,24 +18,31 @@ var waitForExposed = (name, timeoutMs = 5e3) => {
|
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
+
// src/storybook/addon/browser.ts
|
|
22
|
+
var isCappa = () => {
|
|
23
|
+
return navigator.userAgent.includes("CappaStorybook");
|
|
24
|
+
};
|
|
25
|
+
|
|
21
26
|
// src/storybook/addon/decorator.ts
|
|
22
27
|
var withCappaDecorator = makeDecorator({
|
|
23
28
|
name: "withCappa",
|
|
24
29
|
parameterName: "cappa",
|
|
25
30
|
skipIfNoParametersOrOptions: false,
|
|
26
31
|
wrapper: (getStory, context, { parameters: parameters2 }) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
queueMicrotask(async () => {
|
|
32
|
-
try {
|
|
33
|
-
const cappaParameters = await waitForExposed("__cappa_parameters");
|
|
34
|
-
cappaParameters(context.id, parameters2 ?? {});
|
|
35
|
-
} catch (error) {
|
|
36
|
-
console.error("Cappa decorator error:", error);
|
|
32
|
+
if (isCappa()) {
|
|
33
|
+
window.__cappa_screenshot = true;
|
|
34
|
+
if (context.playFunction != null) {
|
|
35
|
+
window.__cappa_has_play_function = true;
|
|
37
36
|
}
|
|
38
|
-
|
|
37
|
+
queueMicrotask(async () => {
|
|
38
|
+
try {
|
|
39
|
+
const cappaParameters = await waitForExposed("__cappa_parameters");
|
|
40
|
+
cappaParameters(context.id, parameters2 ?? {});
|
|
41
|
+
} catch (error) {
|
|
42
|
+
console.error("Cappa decorator error:", error);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
39
46
|
return getStory(context);
|
|
40
47
|
}
|
|
41
48
|
});
|
package/package.json
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cappa/plugin-storybook",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Storybook plugin for Cappa - takes screenshots of Storybook stories",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/tim-richter/cappa.git"
|
|
11
|
+
},
|
|
8
12
|
"license": "MIT",
|
|
9
13
|
"author": "Tim Richter",
|
|
10
14
|
"type": "module",
|
|
@@ -40,16 +44,17 @@
|
|
|
40
44
|
"@swc/core": "^1.14.0",
|
|
41
45
|
"chalk": "^5.6.2",
|
|
42
46
|
"minimatch": "^10.1.1",
|
|
43
|
-
"@cappa/core": "0.3.
|
|
47
|
+
"@cappa/core": "0.3.1",
|
|
44
48
|
"@cappa/logger": "0.0.4"
|
|
45
49
|
},
|
|
46
50
|
"devDependencies": {
|
|
47
|
-
"@
|
|
48
|
-
"@vitest/
|
|
51
|
+
"@types/node": "24.9.2",
|
|
52
|
+
"@vitest/coverage-v8": "4.0.6",
|
|
53
|
+
"@vitest/ui": "4.0.6",
|
|
49
54
|
"playwright-core": "^1.56.1",
|
|
50
55
|
"tsup": "8.5.0",
|
|
51
56
|
"typescript": "5.9.3",
|
|
52
|
-
"vitest": "
|
|
57
|
+
"vitest": "4.0.6",
|
|
53
58
|
"storybook": "^10.0.2"
|
|
54
59
|
},
|
|
55
60
|
"scripts": {
|
package/src/index.esm.ts
CHANGED
|
@@ -1,26 +1,29 @@
|
|
|
1
1
|
import { makeDecorator } from "storybook/preview-api";
|
|
2
2
|
import { waitForExposed } from "../util";
|
|
3
|
+
import { isCappa } from "./browser";
|
|
3
4
|
|
|
4
5
|
export const withCappaDecorator = makeDecorator({
|
|
5
6
|
name: "withCappa",
|
|
6
7
|
parameterName: "cappa",
|
|
7
8
|
skipIfNoParametersOrOptions: false,
|
|
8
9
|
wrapper: (getStory, context, { parameters }) => {
|
|
9
|
-
(
|
|
10
|
+
if (isCappa()) {
|
|
11
|
+
(window as any).__cappa_screenshot = true;
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
queueMicrotask(async () => {
|
|
17
|
-
try {
|
|
18
|
-
const cappaParameters = await waitForExposed("__cappa_parameters");
|
|
19
|
-
cappaParameters(context.id, parameters ?? {});
|
|
20
|
-
} catch (error) {
|
|
21
|
-
console.error("Cappa decorator error:", error);
|
|
13
|
+
// Set indicator if this story has a play function
|
|
14
|
+
if (context.playFunction != null) {
|
|
15
|
+
(window as any).__cappa_has_play_function = true;
|
|
22
16
|
}
|
|
23
|
-
|
|
17
|
+
|
|
18
|
+
queueMicrotask(async () => {
|
|
19
|
+
try {
|
|
20
|
+
const cappaParameters = await waitForExposed("__cappa_parameters");
|
|
21
|
+
cappaParameters(context.id, parameters ?? {});
|
|
22
|
+
} catch (error) {
|
|
23
|
+
console.error("Cappa decorator error:", error);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
24
27
|
|
|
25
28
|
return getStory(context);
|
|
26
29
|
},
|