@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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @cappa/plugin-storybook@0.3.1 build /home/runner/work/cappa/cappa/packages/plugins/plugin-storybook
2
+ > @cappa/plugin-storybook@0.3.3 build /home/runner/work/cappa/cappa/packages/plugins/plugin-storybook
3
3
  > tsup
4
4
 
5
5
  CLI Building entry: {"index":"src/index.esm.ts"}
@@ -20,24 +20,24 @@
20
20
  CLI Using tsup config: /home/runner/work/cappa/cappa/packages/plugins/plugin-storybook/tsup.config.ts
21
21
  CLI Target: esnext
22
22
  CLI Target: esnext
23
- CLI Target: node16
24
- CLI Target: es2015
25
23
  CLI Cleaning output folder
26
24
  ESM Build start
27
25
  CLI Cleaning output folder
28
26
  CJS Build start
27
+ CLI Target: node16
28
+ CLI Target: es2015
29
29
  CLI Cleaning output folder
30
30
  ESM Build start
31
31
  CLI Cleaning output folder
32
32
  ESM Build start
33
- ESM dist/preview.js 1.41 KB
34
- ESM ⚡️ Build success in 36ms
35
33
  ESM dist/browser.js 138.00 B
36
- ESM ⚡️ Build success in 34ms
37
- ESM dist/index.js 12.25 KB
38
- ESM ⚡️ Build success in 42ms
34
+ ESM ⚡️ Build success in 26ms
35
+ ESM dist/preview.js 1.58 KB
36
+ ESM ⚡️ Build success in 41ms
39
37
  CJS dist/index.cjs 13.98 KB
40
- CJS ⚡️ Build success in 48ms
38
+ CJS ⚡️ Build success in 45ms
39
+ ESM dist/index.js 12.25 KB
40
+ ESM ⚡️ Build success in 54ms
41
41
  DTS Build start
42
- DTS ⚡️ Build success in 3692ms
42
+ DTS ⚡️ Build success in 3394ms
43
43
  DTS dist/index.d.ts 2.63 KB
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
- window.__cappa_screenshot = true;
28
- if (context.playFunction != null) {
29
- window.__cappa_has_play_function = true;
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.1",
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.0",
47
+ "@cappa/core": "0.3.1",
44
48
  "@cappa/logger": "0.0.4"
45
49
  },
46
50
  "devDependencies": {
47
- "@vitest/coverage-v8": "3.2.4",
48
- "@vitest/ui": "3.2.4",
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": "3.2.4",
57
+ "vitest": "4.0.6",
53
58
  "storybook": "^10.0.2"
54
59
  },
55
60
  "scripts": {
package/src/index.esm.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { fileURLToPath } from "node:url";
2
+
2
3
  export const previewAnnotations = [
3
4
  fileURLToPath(new URL("./preview.js", import.meta.url)),
4
5
  ];
@@ -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
- (window as any).__cappa_screenshot = true;
10
+ if (isCappa()) {
11
+ (window as any).__cappa_screenshot = true;
10
12
 
11
- // Set indicator if this story has a play function
12
- if (context.playFunction != null) {
13
- (window as any).__cappa_has_play_function = true;
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
  },
package/tsconfig.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "extends": "../../config-ts/bundler.json",
3
3
  "compilerOptions": {
4
4
  "baseUrl": ".",
5
- "types": ["vitest"]
5
+ "types": ["vitest", "node"]
6
6
  },
7
7
  "include": [
8
8
  "src/**/*",