@cappa/plugin-storybook 0.4.2 → 0.4.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/browser.d.cts +6 -0
- package/dist/browser.d.ts +6 -0
- package/package.json +15 -12
- package/.turbo/turbo-build.log +0 -53
- package/CHANGELOG.md +0 -361
- package/src/cappa/plugin.test.ts +0 -530
- package/src/cappa/plugin.ts +0 -438
- package/src/cappa/storybook-url.test.ts +0 -43
- package/src/cappa/storybook-url.ts +0 -55
- package/src/cappa/util.test.ts +0 -47
- package/src/cappa/util.ts +0 -100
- package/src/index.cjs.ts +0 -5
- package/src/index.esm.ts +0 -9
- package/src/storybook/addon/browser.ts +0 -6
- package/src/storybook/addon/decorator.ts +0 -30
- package/src/storybook/addon/preview.ts +0 -10
- package/src/storybook/util.ts +0 -25
- package/src/types.ts +0 -30
- package/tsconfig.json +0 -13
- package/tsup.config.ts +0 -39
- package/vitest.config.ts +0 -8
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { makeDecorator } from "storybook/preview-api";
|
|
2
|
-
import { waitForExposed } from "../util";
|
|
3
|
-
import { isCappa } from "./browser";
|
|
4
|
-
|
|
5
|
-
export const withCappaDecorator = makeDecorator({
|
|
6
|
-
name: "withCappa",
|
|
7
|
-
parameterName: "cappa",
|
|
8
|
-
skipIfNoParametersOrOptions: false,
|
|
9
|
-
wrapper: (getStory, context, { parameters }) => {
|
|
10
|
-
if (isCappa()) {
|
|
11
|
-
(window as any).__cappa_screenshot = true;
|
|
12
|
-
|
|
13
|
-
// Set indicator if this story has a play function
|
|
14
|
-
if (context.playFunction != null) {
|
|
15
|
-
(window as any).__cappa_has_play_function = true;
|
|
16
|
-
}
|
|
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
|
-
}
|
|
27
|
-
|
|
28
|
-
return getStory(context);
|
|
29
|
-
},
|
|
30
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { withCappaDecorator } from "./decorator";
|
|
2
|
-
|
|
3
|
-
export const decorators = [withCappaDecorator];
|
|
4
|
-
|
|
5
|
-
export const parameters = {};
|
|
6
|
-
|
|
7
|
-
export const afterEach = () => {
|
|
8
|
-
// Set the flag to indicate that the play function has completed
|
|
9
|
-
(window as any).playAfterEach = true;
|
|
10
|
-
};
|
package/src/storybook/util.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Wait for a function to be exposed on the window object
|
|
3
|
-
* @param name - The name of the function to wait for
|
|
4
|
-
* @param timeoutMs - The timeout in milliseconds
|
|
5
|
-
* @returns The function or rejects if the function is not exposed within the timeout
|
|
6
|
-
*/
|
|
7
|
-
export const waitForExposed = (
|
|
8
|
-
name: string,
|
|
9
|
-
timeoutMs = 5000,
|
|
10
|
-
): Promise<(id: string, parameters: any) => void> => {
|
|
11
|
-
return new Promise((resolve, reject) => {
|
|
12
|
-
const start = performance.now();
|
|
13
|
-
|
|
14
|
-
const t = setInterval(() => {
|
|
15
|
-
const fn = (window as any)[name];
|
|
16
|
-
if (typeof fn === "function") {
|
|
17
|
-
clearInterval(t);
|
|
18
|
-
resolve(fn);
|
|
19
|
-
} else if (performance.now() - start > timeoutMs) {
|
|
20
|
-
clearInterval(t);
|
|
21
|
-
reject(new Error(`Timed out waiting for ${name}`));
|
|
22
|
-
}
|
|
23
|
-
}, 16);
|
|
24
|
-
});
|
|
25
|
-
};
|
package/src/types.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export interface StorybookRenderOptions {
|
|
2
|
-
viewMode?: "story" | "docs";
|
|
3
|
-
args?: Record<string, unknown>;
|
|
4
|
-
globals?: Record<string, string | number | boolean>;
|
|
5
|
-
query?: Record<string, string | number | boolean>;
|
|
6
|
-
fullscreen?: boolean;
|
|
7
|
-
singleStory?: boolean;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface ScreenshotVariantOverrideStorybook {
|
|
11
|
-
fullPage?: boolean;
|
|
12
|
-
delay?: number;
|
|
13
|
-
skip?: boolean;
|
|
14
|
-
mask?: string[];
|
|
15
|
-
omitBackground?: boolean;
|
|
16
|
-
viewport?: { width: number; height: number };
|
|
17
|
-
args?: Record<string, unknown>;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface ScreenshotVariantOptionsStorybook {
|
|
21
|
-
id: string;
|
|
22
|
-
label?: string;
|
|
23
|
-
filename?: string;
|
|
24
|
-
options?: ScreenshotVariantOverrideStorybook;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface ScreenshotOptionsStorybook
|
|
28
|
-
extends ScreenshotVariantOverrideStorybook {
|
|
29
|
-
variants?: ScreenshotVariantOptionsStorybook[];
|
|
30
|
-
}
|
package/tsconfig.json
DELETED
package/tsup.config.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "tsup";
|
|
2
|
-
|
|
3
|
-
export default defineConfig([
|
|
4
|
-
{
|
|
5
|
-
entry: { index: "src/index.esm.ts" },
|
|
6
|
-
format: ["esm"],
|
|
7
|
-
dts: { entry: "src/index.esm.ts" },
|
|
8
|
-
splitting: false,
|
|
9
|
-
external: ["./preview.js"],
|
|
10
|
-
sourcemap: false,
|
|
11
|
-
clean: true,
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
entry: { index: "src/index.cjs.ts" },
|
|
15
|
-
format: ["cjs"],
|
|
16
|
-
dts: { entry: "src/index.cjs.ts" },
|
|
17
|
-
splitting: false,
|
|
18
|
-
external: ["./preview.js"],
|
|
19
|
-
sourcemap: false,
|
|
20
|
-
clean: true,
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
entry: ["src/storybook/addon/preview.ts"],
|
|
24
|
-
target: "node16",
|
|
25
|
-
format: ["esm"],
|
|
26
|
-
splitting: false,
|
|
27
|
-
sourcemap: false,
|
|
28
|
-
clean: true,
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
entry: ["src/storybook/addon/browser.ts"],
|
|
32
|
-
target: "es2015",
|
|
33
|
-
format: ["esm", "cjs"],
|
|
34
|
-
dts: true,
|
|
35
|
-
splitting: false,
|
|
36
|
-
sourcemap: false,
|
|
37
|
-
clean: true,
|
|
38
|
-
},
|
|
39
|
-
]);
|