@stencil/storybook-plugin 0.5.6 → 0.6.0-dev.1783515311.4f8a25b
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/README.md +42 -138
- package/dist/docs/{index.d.ts → index.d.mts} +2 -4
- package/dist/docs/index.d.mts.map +1 -0
- package/dist/{docs-DFb4MYCm.js → docs/index.mjs} +17 -30
- package/dist/docs/index.mjs.map +1 -0
- package/dist/{entry-preview-C1JSJAGq.js → entry-preview-6xYusSlJ.mjs} +19 -22
- package/dist/entry-preview-6xYusSlJ.mjs.map +1 -0
- package/dist/entry-preview-argtypes.d.mts +14 -0
- package/dist/entry-preview-argtypes.d.mts.map +1 -0
- package/dist/entry-preview-argtypes.mjs +165 -0
- package/dist/entry-preview-argtypes.mjs.map +1 -0
- package/dist/entry-preview-auto-docs.d.mts +1 -0
- package/dist/entry-preview-auto-docs.mjs +11 -0
- package/dist/entry-preview-auto-docs.mjs.map +1 -0
- package/dist/{entry-preview-docs.d.ts → entry-preview-docs.d.mts} +2 -4
- package/dist/entry-preview-docs.d.mts.map +1 -0
- package/dist/{entry-preview-docs.js → entry-preview-docs.mjs} +3 -4
- package/dist/entry-preview-docs.mjs.map +1 -0
- package/dist/{entry-preview.d.ts → entry-preview.d.mts} +2 -5
- package/dist/entry-preview.d.mts.map +1 -0
- package/dist/entry-preview.mjs +2 -0
- package/dist/framework-api-oAIB4EMV.mjs +27 -0
- package/dist/framework-api-oAIB4EMV.mjs.map +1 -0
- package/dist/index.d.mts +677 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +32 -0
- package/dist/index.mjs.map +1 -0
- package/dist/node/{index.d.ts → index.d.mts} +2 -4
- package/dist/node/index.d.mts.map +1 -0
- package/dist/node/{index.js → index.mjs} +2 -2
- package/dist/node/index.mjs.map +1 -0
- package/dist/{preset.d.ts → preset.d.mts} +2 -4
- package/dist/preset.d.mts.map +1 -0
- package/dist/preset.mjs +35 -0
- package/dist/preset.mjs.map +1 -0
- package/dist/{rollup-parseAst-t-4tfMPG.d.ts → rollup-parseAst-DL0ij9mb.d.mts} +1 -1
- package/dist/rollup-parseAst-DL0ij9mb.d.mts.map +1 -0
- package/dist/{types-BZP9npQ9.d.cts → types-KTmT9_JX.d.mts} +2 -2
- package/dist/types-KTmT9_JX.d.mts.map +1 -0
- package/dist/wizard.d.mts +7 -0
- package/dist/wizard.d.mts.map +1 -0
- package/dist/wizard.mjs +159 -0
- package/dist/wizard.mjs.map +1 -0
- package/package.json +34 -35
- package/preset.js +1 -2
- package/dist/chunk-CsX-DzYB.cjs +0 -42
- package/dist/docs/index.cjs +0 -4
- package/dist/docs/index.d.cts +0 -15
- package/dist/docs/index.d.cts.map +0 -1
- package/dist/docs/index.d.ts.map +0 -1
- package/dist/docs/index.js +0 -3
- package/dist/docs-DFb4MYCm.js.map +0 -1
- package/dist/docs-ONVKsKI9.cjs +0 -97
- package/dist/docs-ONVKsKI9.cjs.map +0 -1
- package/dist/entry-preview-C0ipNwpw.cjs +0 -85
- package/dist/entry-preview-C0ipNwpw.cjs.map +0 -1
- package/dist/entry-preview-C1JSJAGq.js.map +0 -1
- package/dist/entry-preview-argtypes.cjs +0 -182
- package/dist/entry-preview-argtypes.cjs.map +0 -1
- package/dist/entry-preview-argtypes.d.cts +0 -19
- package/dist/entry-preview-argtypes.d.cts.map +0 -1
- package/dist/entry-preview-argtypes.d.ts +0 -19
- package/dist/entry-preview-argtypes.d.ts.map +0 -1
- package/dist/entry-preview-argtypes.js +0 -181
- package/dist/entry-preview-argtypes.js.map +0 -1
- package/dist/entry-preview-docs.cjs +0 -19
- package/dist/entry-preview-docs.cjs.map +0 -1
- package/dist/entry-preview-docs.d.cts +0 -11
- package/dist/entry-preview-docs.d.cts.map +0 -1
- package/dist/entry-preview-docs.d.ts.map +0 -1
- package/dist/entry-preview-docs.js.map +0 -1
- package/dist/entry-preview.cjs +0 -6
- package/dist/entry-preview.d.cts +0 -20
- package/dist/entry-preview.d.cts.map +0 -1
- package/dist/entry-preview.d.ts.map +0 -1
- package/dist/entry-preview.js +0 -3
- package/dist/index.cjs +0 -9
- package/dist/index.d.cts +0 -65
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.ts +0 -40
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -5
- package/dist/node/index.cjs +0 -9
- package/dist/node/index.cjs.map +0 -1
- package/dist/node/index.d.cts +0 -9
- package/dist/node/index.d.cts.map +0 -1
- package/dist/node/index.d.ts.map +0 -1
- package/dist/node/index.js.map +0 -1
- package/dist/preset.cjs +0 -35
- package/dist/preset.cjs.map +0 -1
- package/dist/preset.d.cts +0 -11
- package/dist/preset.d.cts.map +0 -1
- package/dist/preset.d.ts.map +0 -1
- package/dist/preset.js +0 -32
- package/dist/preset.js.map +0 -1
- package/dist/rollup-parseAst-t-4tfMPG.d.ts.map +0 -1
- package/dist/src-BBcTbcCa.js +0 -55
- package/dist/src-BBcTbcCa.js.map +0 -1
- package/dist/src-D0dJRYm2.cjs +0 -91
- package/dist/src-D0dJRYm2.cjs.map +0 -1
- package/dist/types-BZP9npQ9.d.cts.map +0 -1
- package/dist/types-DqHtEV5w.d.ts +0 -71
- package/dist/types-DqHtEV5w.d.ts.map +0 -1
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { n as entry_preview_exports } from "./entry-preview-6xYusSlJ.mjs";
|
|
2
|
+
import "./rollup-parseAst-DL0ij9mb.d.mts";
|
|
3
|
+
import { a as setCustomElementsManifest, i as setCustomElements, n as isValidComponent, r as isValidMetaData, t as getCustomElements } from "./framework-api-oAIB4EMV.mjs";
|
|
4
|
+
import { setDefaultProjectAnnotations, setProjectAnnotations as setProjectAnnotations$1 } from "storybook/preview-api";
|
|
5
|
+
//#region src/portable-stories.tsx
|
|
6
|
+
/**
|
|
7
|
+
* Function that sets the globalConfig of your storybook. The global config is the preview module of
|
|
8
|
+
* your .storybook folder.
|
|
9
|
+
*
|
|
10
|
+
* It should be run a single time, so that your global config (e.g. decorators) is applied to your
|
|
11
|
+
* stories when using `composeStories` or `composeStory`.
|
|
12
|
+
*
|
|
13
|
+
* Example:
|
|
14
|
+
*
|
|
15
|
+
* ```jsx
|
|
16
|
+
* // setup-file.js
|
|
17
|
+
* import { setProjectAnnotations } from '@storybook/web-components';
|
|
18
|
+
* import projectAnnotations from './.storybook/preview';
|
|
19
|
+
*
|
|
20
|
+
* setProjectAnnotations(projectAnnotations);
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @param projectAnnotations - E.g. (import projectAnnotations from '../.storybook/preview')
|
|
24
|
+
*/
|
|
25
|
+
function setProjectAnnotations(projectAnnotations) {
|
|
26
|
+
setDefaultProjectAnnotations(entry_preview_exports);
|
|
27
|
+
return setProjectAnnotations$1(projectAnnotations);
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { getCustomElements, isValidComponent, isValidMetaData, setCustomElements, setCustomElementsManifest, setProjectAnnotations };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["stencilAnnotations","originalSetProjectAnnotations"],"sources":["../src/portable-stories.tsx"],"sourcesContent":["import type { NamedOrDefaultProjectAnnotations, NormalizedProjectAnnotations } from 'storybook/internal/types';\n\nimport {\n setProjectAnnotations as originalSetProjectAnnotations,\n setDefaultProjectAnnotations,\n} from 'storybook/preview-api';\n\nimport * as stencilAnnotations from './entry-preview';\nimport type { StencilRenderer } from './types';\n\n/**\n * Function that sets the globalConfig of your storybook. The global config is the preview module of\n * your .storybook folder.\n *\n * It should be run a single time, so that your global config (e.g. decorators) is applied to your\n * stories when using `composeStories` or `composeStory`.\n *\n * Example:\n *\n * ```jsx\n * // setup-file.js\n * import { setProjectAnnotations } from '@storybook/web-components';\n * import projectAnnotations from './.storybook/preview';\n *\n * setProjectAnnotations(projectAnnotations);\n * ```\n *\n * @param projectAnnotations - E.g. (import projectAnnotations from '../.storybook/preview')\n */\nexport function setProjectAnnotations(\n projectAnnotations: NamedOrDefaultProjectAnnotations<any> | NamedOrDefaultProjectAnnotations<any>[],\n): NormalizedProjectAnnotations<StencilRenderer<unknown>> {\n setDefaultProjectAnnotations(stencilAnnotations);\n return originalSetProjectAnnotations(projectAnnotations) as NormalizedProjectAnnotations<StencilRenderer<unknown>>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA6BA,SAAgB,sBACd,oBACwD;CACxD,6BAA6BA,qBAAkB;CAC/C,OAAOC,wBAA8B,kBAAkB;AACzD"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { StorybookConfig } from "../types-
|
|
1
|
+
import { l as StorybookConfig } from "../types-KTmT9_JX.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/node/index.d.ts
|
|
4
4
|
declare function defineMain(config: StorybookConfig): StorybookConfig;
|
|
5
|
-
//# sourceMappingURL=index.d.ts.map
|
|
6
|
-
|
|
7
5
|
//#endregion
|
|
8
6
|
export { defineMain };
|
|
9
|
-
//# sourceMappingURL=index.d.
|
|
7
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/node/index.ts"],"mappings":";;;iBAEgB,UAAA,CAAW,MAAA,EAAQ,eAAA,GAAe,eAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/node/index.ts"],"sourcesContent":["import type { StorybookConfig } from '../types';\n\nexport function defineMain(config: StorybookConfig) {\n return config;\n}\n"],"mappings":";AAEA,SAAgB,WAAW,QAAyB;CAClD,OAAO;AACT"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { StorybookConfig } from "./types-
|
|
1
|
+
import { l as StorybookConfig } from "./types-KTmT9_JX.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/preset.d.ts
|
|
4
4
|
declare const core: StorybookConfig['core'];
|
|
5
5
|
declare const viteFinal: StorybookConfig['viteFinal'];
|
|
6
6
|
declare const previewAnnotations: StorybookConfig['previewAnnotations'];
|
|
7
|
-
//# sourceMappingURL=preset.d.ts.map
|
|
8
|
-
|
|
9
7
|
//#endregion
|
|
10
8
|
export { core, previewAnnotations, viteFinal };
|
|
11
|
-
//# sourceMappingURL=preset.d.
|
|
9
|
+
//# sourceMappingURL=preset.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preset.d.mts","names":[],"sources":["../src/preset.ts"],"mappings":";;;cAUa,IAAA,EAAM,eAAe;AAAA,cAKrB,SAAA,EAAW,eAAe;AAAA,cAyB1B,kBAAA,EAAoB,eAAe"}
|
package/dist/preset.mjs
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { dirname, join } from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { unpluginStencil } from "@stencil/unplugin";
|
|
4
|
+
import { mergeConfig } from "vite";
|
|
5
|
+
//#region src/preset.ts
|
|
6
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
const renderer = join(__dirname, "entry-preview.mjs");
|
|
8
|
+
const core = {
|
|
9
|
+
builder: "@storybook/builder-vite",
|
|
10
|
+
renderer
|
|
11
|
+
};
|
|
12
|
+
const viteFinal = async (defaultConfig, { configType }) => {
|
|
13
|
+
const config = mergeConfig(defaultConfig, {
|
|
14
|
+
build: { target: "es2022" },
|
|
15
|
+
plugins: [unpluginStencil.vite({ docs: true })],
|
|
16
|
+
esbuild: { jsxDev: false },
|
|
17
|
+
oxc: { jsx: { development: false } }
|
|
18
|
+
});
|
|
19
|
+
if (configType === "DEVELOPMENT") return mergeConfig(config, { server: { watch: { ignored: [join(__dirname, "**")] } } });
|
|
20
|
+
return config;
|
|
21
|
+
};
|
|
22
|
+
const previewAnnotations = async (input = [], options) => {
|
|
23
|
+
const docsEnabled = Object.keys(await options.presets.apply("docs", {}, options)).length > 0;
|
|
24
|
+
return [
|
|
25
|
+
...input,
|
|
26
|
+
renderer,
|
|
27
|
+
join(__dirname, "entry-preview-auto-docs.mjs"),
|
|
28
|
+
join(__dirname, "entry-preview-argtypes.mjs"),
|
|
29
|
+
...docsEnabled ? [join(__dirname, "entry-preview-docs.mjs")] : []
|
|
30
|
+
];
|
|
31
|
+
};
|
|
32
|
+
//#endregion
|
|
33
|
+
export { core, previewAnnotations, viteFinal };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=preset.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preset.mjs","names":[],"sources":["../src/preset.ts"],"sourcesContent":["import { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { unpluginStencil } from '@stencil/unplugin';\nimport { mergeConfig } from 'vite';\n\nimport { StorybookConfig } from './types';\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\nconst renderer = join(__dirname, 'entry-preview.mjs');\n\nexport const core: StorybookConfig['core'] = {\n builder: '@storybook/builder-vite',\n renderer,\n};\n\nexport const viteFinal: StorybookConfig['viteFinal'] = async (defaultConfig, { configType }) => {\n const config = mergeConfig(defaultConfig, {\n build: { target: 'es2022' },\n plugins: [unpluginStencil.vite({ docs: true })],\n // Vite's dev-mode JSX transform injects React DevTools' `__self`/`__source` metadata into every\n // JSX element regardless of jsxFactory. Stencil's `h()` doesn't strip these, so they leak into the\n // DOM as a literal `__source=\"[object Object]\"` attribute on story-authored slot content.\n esbuild: { jsxDev: false },\n oxc: { jsx: { development: false } },\n });\n\n if (configType === 'DEVELOPMENT') {\n return mergeConfig(config, {\n server: {\n watch: {\n // Prevent Vite from watching this plugin's own dist/ during plugin development.\n ignored: [join(__dirname, '**')],\n },\n },\n });\n }\n\n return config;\n};\n\nexport const previewAnnotations: StorybookConfig['previewAnnotations'] = async (input = [], options) => {\n const docsEnabled = Object.keys(await options.presets.apply('docs', {}, options)).length > 0;\n return [\n ...input,\n renderer,\n join(__dirname, 'entry-preview-auto-docs.mjs'),\n join(__dirname, 'entry-preview-argtypes.mjs'),\n ...(docsEnabled ? [join(__dirname, 'entry-preview-docs.mjs')] : []),\n ];\n};\n"],"mappings":";;;;;AAOA,MAAM,YAAY,QAAQ,cAAc,OAAO,KAAK,GAAG,CAAC;AACxD,MAAM,WAAW,KAAK,WAAW,mBAAmB;AAEpD,MAAa,OAAgC;CAC3C,SAAS;CACT;AACF;AAEA,MAAa,YAA0C,OAAO,eAAe,EAAE,iBAAiB;CAC9F,MAAM,SAAS,YAAY,eAAe;EACxC,OAAO,EAAE,QAAQ,SAAS;EAC1B,SAAS,CAAC,gBAAgB,KAAK,EAAE,MAAM,KAAK,CAAC,CAAC;EAI9C,SAAS,EAAE,QAAQ,MAAM;EACzB,KAAK,EAAE,KAAK,EAAE,aAAa,MAAM,EAAE;CACrC,CAAC;CAED,IAAI,eAAe,eACjB,OAAO,YAAY,QAAQ,EACzB,QAAQ,EACN,OAAO,EAEL,SAAS,CAAC,KAAK,WAAW,IAAI,CAAC,EACjC,EACF,EACF,CAAC;CAGH,OAAO;AACT;AAEA,MAAa,qBAA4D,OAAO,QAAQ,CAAC,GAAG,YAAY;CACtG,MAAM,cAAc,OAAO,KAAK,MAAM,QAAQ,QAAQ,MAAM,QAAQ,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,SAAS;CAC3F,OAAO;EACL,GAAG;EACH;EACA,KAAK,WAAW,6BAA6B;EAC7C,KAAK,WAAW,4BAA4B;EAC5C,GAAI,cAAc,CAAC,KAAK,WAAW,wBAAwB,CAAC,IAAI,CAAC;CACnE;AACF"}
|
|
@@ -21,4 +21,4 @@ declare module 'rollup/parseAst' {
|
|
|
21
21
|
export function parseAst(code: string, options?: any): any;
|
|
22
22
|
export function parseAstAsync(code: string, options?: any): Promise<any>;
|
|
23
23
|
}
|
|
24
|
-
//# sourceMappingURL=rollup-parseAst-
|
|
24
|
+
//# sourceMappingURL=rollup-parseAst-DL0ij9mb.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rollup-parseAst-DL0ij9mb.d.mts","names":["parseAst","code","options","parseAstAsync","Promise"],"sources":["../@types/rollup-parseAst.d.ts"],"mappings":";;;;;;;;;;;;;;;AAoBqE;;;;;kBADnDA,QAAAA,CAASC,IAAAA,UAAcC,OAAAA;EAAAA,gBACvBC,aAAAA,CAAcF,IAAAA,UAAcC,OAAAA,SAAgB,OAAO;AAAA"}
|
|
@@ -67,5 +67,5 @@ declare global {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
//#endregion
|
|
70
|
-
export {
|
|
71
|
-
//# sourceMappingURL=types-
|
|
70
|
+
export { StencilRenderer as a, StoryObj as c, Preview as i, StorybookConfig$1 as l, Loader as n, StoryContext$1 as o, Meta as r, StoryFn as s, Decorator as t };
|
|
71
|
+
//# sourceMappingURL=types-KTmT9_JX.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-KTmT9_JX.d.mts","names":[],"sources":["../src/types.ts"],"mappings":";;;;;UAgBU,MAAA;EACR,QAAA;EACA,UAAA;EACA,YAAA;EACA,KAAA;AAAA;AAAA,KAGG,WAAA,kDAC4C,QAAA,GAAW,MAAA,GAAS,WAAA,KAAgB,OAAA,CAAQ,WAAA,IAAe,KAAA;AAAA,KAEvG,iBAAA,UAA2B,KAAA;EAC9B,QAAA;AAAA;EAII,QAAA,GAAW,WAAW;AAAA;AAAA,KAEvB,WAAA,WAAsB,KAAA,SAAc,MAAA,aACrC,IAAA,CAAK,KAAA,kCACW,KAAA,QAEd,KAAA,IACJ,iBAAA,CAAkB,KAAA;AAAA,KAEf,iBAAA;EACH,QAAA,CAAS,KAAA,EAAO,CAAA,EAAG,GAAA,iBAAoB,KAAA,UAAe,GAAA,GAAM,MAAA,GAAS,KAAA;AAAA;AAAA,KAElE,SAAA,oBAA6B,iBAAA,CAAkB,WAAA,CAAY,KA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"node:path";
|
|
2
|
+
import { access, mkdir, readFile, readdir, writeFile } from "node:fs/promises";
|
|
3
|
+
//#region src/wizard.ts
|
|
4
|
+
async function fileExists(path) {
|
|
5
|
+
try {
|
|
6
|
+
await access(path);
|
|
7
|
+
return true;
|
|
8
|
+
} catch {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
const STORYBOOK_MAIN = `import type { StorybookConfig } from '@stencil/storybook-plugin';
|
|
13
|
+
|
|
14
|
+
const config: StorybookConfig = {
|
|
15
|
+
stories: ['../src/**/*.stories.@(js|jsx|ts|tsx)'],
|
|
16
|
+
addons: ['@storybook/addon-links', '@storybook/addon-docs'],
|
|
17
|
+
framework: {
|
|
18
|
+
name: '@stencil/storybook-plugin',
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default config;
|
|
23
|
+
`;
|
|
24
|
+
const STORYBOOK_PREVIEW = `import type { Preview } from '@stencil/storybook-plugin';
|
|
25
|
+
|
|
26
|
+
export const parameters: Preview['parameters'] = {
|
|
27
|
+
actions: { argTypesRegex: '^on[A-Z].*' },
|
|
28
|
+
docs: {
|
|
29
|
+
source: {
|
|
30
|
+
excludeDecorators: true,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const tags: Preview['tags'] = ['autodocs'];
|
|
36
|
+
`;
|
|
37
|
+
const STORYBOOK_TSCONFIG = JSON.stringify({
|
|
38
|
+
extends: "../tsconfig.json",
|
|
39
|
+
compilerOptions: {
|
|
40
|
+
emitDecoratorMetadata: true,
|
|
41
|
+
experimentalDecorators: true,
|
|
42
|
+
resolveJsonModule: true,
|
|
43
|
+
module: "Preserve",
|
|
44
|
+
rootDir: "../"
|
|
45
|
+
},
|
|
46
|
+
exclude: [
|
|
47
|
+
"../**/*.spec.ts",
|
|
48
|
+
"../**/*.test.ts",
|
|
49
|
+
"../**/*.spec.tsx",
|
|
50
|
+
"../**/*.test.tsx"
|
|
51
|
+
],
|
|
52
|
+
include: [
|
|
53
|
+
"../src/**/*.stories.ts",
|
|
54
|
+
"../src/**/*.stories.tsx",
|
|
55
|
+
"../src/**/*.stories.mdx",
|
|
56
|
+
"**/*.ts",
|
|
57
|
+
"**/*.tsx",
|
|
58
|
+
"main.js"
|
|
59
|
+
]
|
|
60
|
+
}, null, 2);
|
|
61
|
+
function toPascalCase(tagName) {
|
|
62
|
+
return tagName.replace(/(^|-)([a-z])/g, (_, __, c) => c.toUpperCase());
|
|
63
|
+
}
|
|
64
|
+
async function generateExampleStories(srcDir) {
|
|
65
|
+
const componentsDir = join(srcDir, "components");
|
|
66
|
+
const entries = await readdir(componentsDir, { withFileTypes: true }).catch(() => []);
|
|
67
|
+
for (const entry of entries) {
|
|
68
|
+
if (!entry.isDirectory()) continue;
|
|
69
|
+
const componentFile = join(componentsDir, entry.name, `${entry.name}.tsx`);
|
|
70
|
+
if (!await fileExists(componentFile)) continue;
|
|
71
|
+
const source = await readFile(componentFile, "utf8");
|
|
72
|
+
if (!source.includes("@Component")) continue;
|
|
73
|
+
const tagName = source.match(/tag:\s*['"]([^'"]+)['"]/)?.[1] ?? entry.name;
|
|
74
|
+
const className = toPascalCase(tagName);
|
|
75
|
+
const storiesFile = join(componentsDir, entry.name, `${tagName}.stories.tsx`);
|
|
76
|
+
if (await fileExists(storiesFile)) continue;
|
|
77
|
+
await writeFile(storiesFile, storiesTemplate(tagName, className), "utf8");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
async function updatePackageJsonScripts(rootDir) {
|
|
81
|
+
const pkgPath = join(rootDir, "package.json");
|
|
82
|
+
const content = await readFile(pkgPath, "utf8");
|
|
83
|
+
const pkg = JSON.parse(content);
|
|
84
|
+
pkg["scripts"] ??= {};
|
|
85
|
+
if (!pkg["scripts"]["storybook"]) pkg["scripts"]["storybook"] = "storybook dev -p 6006";
|
|
86
|
+
if (!pkg["scripts"]["build-storybook"]) pkg["scripts"]["build-storybook"] = "storybook build";
|
|
87
|
+
await writeFile(pkgPath, JSON.stringify(pkg, null, 2) + "\n", "utf8");
|
|
88
|
+
}
|
|
89
|
+
function storiesTemplate(tagName, className) {
|
|
90
|
+
return `import type { Meta, StoryObj } from '@stencil/storybook-plugin';
|
|
91
|
+
import { ${className} } from './${tagName}';
|
|
92
|
+
|
|
93
|
+
const meta = {
|
|
94
|
+
title: '${className}',
|
|
95
|
+
component: ${className},
|
|
96
|
+
parameters: {
|
|
97
|
+
layout: 'centered',
|
|
98
|
+
},
|
|
99
|
+
} satisfies Meta;
|
|
100
|
+
|
|
101
|
+
export default meta;
|
|
102
|
+
type Story = StoryObj;
|
|
103
|
+
|
|
104
|
+
export const Primary: Story = {
|
|
105
|
+
args: {},
|
|
106
|
+
};
|
|
107
|
+
`;
|
|
108
|
+
}
|
|
109
|
+
const wizard = {
|
|
110
|
+
init: {
|
|
111
|
+
id: "@stencil/storybook-plugin",
|
|
112
|
+
displayName: "Storybook",
|
|
113
|
+
description: "Component development & documentation",
|
|
114
|
+
async run({ config, isNewProject, prompts, nypm }) {
|
|
115
|
+
const { intro, outro, confirm, isCancel, cancel, spinner } = prompts;
|
|
116
|
+
const rootDir = config.rootDir;
|
|
117
|
+
intro("Storybook - component development & documentation");
|
|
118
|
+
const storybookDir = join(rootDir, ".storybook");
|
|
119
|
+
if (await fileExists(storybookDir)) {
|
|
120
|
+
const overwrite = await confirm({
|
|
121
|
+
message: ".storybook/ already exists. Overwrite it?",
|
|
122
|
+
initialValue: false
|
|
123
|
+
});
|
|
124
|
+
if (isCancel(overwrite) || !overwrite) {
|
|
125
|
+
cancel("Skipping Storybook setup - existing config kept.");
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
const s = spinner();
|
|
130
|
+
s.start("Installing dependencies");
|
|
131
|
+
await nypm.addDependency([
|
|
132
|
+
"storybook",
|
|
133
|
+
"@storybook/addon-links",
|
|
134
|
+
"@storybook/addon-docs"
|
|
135
|
+
], {
|
|
136
|
+
cwd: rootDir,
|
|
137
|
+
dev: true
|
|
138
|
+
});
|
|
139
|
+
s.stop("Dependencies installed");
|
|
140
|
+
await mkdir(storybookDir, { recursive: true });
|
|
141
|
+
await writeFile(join(storybookDir, "main.ts"), STORYBOOK_MAIN, "utf8");
|
|
142
|
+
await writeFile(join(storybookDir, "preview.tsx"), STORYBOOK_PREVIEW, "utf8");
|
|
143
|
+
await writeFile(join(storybookDir, "tsconfig.json"), STORYBOOK_TSCONFIG + "\n", "utf8");
|
|
144
|
+
await updatePackageJsonScripts(rootDir);
|
|
145
|
+
if (isNewProject) await generateExampleStories(config.srcDir);
|
|
146
|
+
outro("Storybook configured! Run: npm run storybook");
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
generate: { fileTemplates: [{
|
|
150
|
+
label: "Story (.stories.tsx)",
|
|
151
|
+
extension: "stories.tsx",
|
|
152
|
+
selectedByDefault: true,
|
|
153
|
+
template: storiesTemplate
|
|
154
|
+
}] }
|
|
155
|
+
};
|
|
156
|
+
//#endregion
|
|
157
|
+
export { wizard };
|
|
158
|
+
|
|
159
|
+
//# sourceMappingURL=wizard.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wizard.mjs","names":[],"sources":["../src/wizard.ts"],"sourcesContent":["import type { StencilWizardPlugin, WizardContext } from '@stencil/cli';\nimport { access, mkdir, readFile, readdir, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\n\nasync function fileExists(path: string): Promise<boolean> {\n try {\n await access(path);\n return true;\n } catch {\n return false;\n }\n}\n\nconst STORYBOOK_MAIN = `import type { StorybookConfig } from '@stencil/storybook-plugin';\n\nconst config: StorybookConfig = {\n stories: ['../src/**/*.stories.@(js|jsx|ts|tsx)'],\n addons: ['@storybook/addon-links', '@storybook/addon-docs'],\n framework: {\n name: '@stencil/storybook-plugin',\n },\n};\n\nexport default config;\n`;\n\nconst STORYBOOK_PREVIEW = `import type { Preview } from '@stencil/storybook-plugin';\n\nexport const parameters: Preview['parameters'] = {\n actions: { argTypesRegex: '^on[A-Z].*' },\n docs: {\n source: {\n excludeDecorators: true,\n },\n },\n};\n\nexport const tags: Preview['tags'] = ['autodocs'];\n`;\n\nconst STORYBOOK_TSCONFIG = JSON.stringify(\n {\n extends: '../tsconfig.json',\n compilerOptions: {\n emitDecoratorMetadata: true,\n experimentalDecorators: true,\n resolveJsonModule: true,\n module: 'Preserve',\n rootDir: '../',\n },\n exclude: ['../**/*.spec.ts', '../**/*.test.ts', '../**/*.spec.tsx', '../**/*.test.tsx'],\n include: [\n '../src/**/*.stories.ts',\n '../src/**/*.stories.tsx',\n '../src/**/*.stories.mdx',\n '**/*.ts',\n '**/*.tsx',\n 'main.js',\n ],\n },\n null,\n 2,\n);\n\nfunction toPascalCase(tagName: string): string {\n return tagName.replace(/(^|-)([a-z])/g, (_, __, c: string) => c.toUpperCase());\n}\n\nasync function generateExampleStories(srcDir: string): Promise<void> {\n const componentsDir = join(srcDir, 'components');\n const entries = await readdir(componentsDir, { withFileTypes: true }).catch(() => []);\n\n for (const entry of entries) {\n if (!entry.isDirectory()) continue;\n const componentFile = join(componentsDir, entry.name, `${entry.name}.tsx`);\n if (!(await fileExists(componentFile))) continue;\n\n const source = await readFile(componentFile, 'utf8');\n if (!source.includes('@Component')) continue;\n\n const tagMatch = source.match(/tag:\\s*['\"]([^'\"]+)['\"]/);\n const tagName = tagMatch?.[1] ?? entry.name;\n const className = toPascalCase(tagName);\n\n const storiesFile = join(componentsDir, entry.name, `${tagName}.stories.tsx`);\n if (await fileExists(storiesFile)) continue;\n\n await writeFile(storiesFile, storiesTemplate(tagName, className), 'utf8');\n }\n}\n\nasync function updatePackageJsonScripts(rootDir: string): Promise<void> {\n const pkgPath = join(rootDir, 'package.json');\n const content = await readFile(pkgPath, 'utf8');\n const pkg = JSON.parse(content) as Record<string, any>;\n pkg['scripts'] ??= {};\n if (!pkg['scripts']['storybook']) pkg['scripts']['storybook'] = 'storybook dev -p 6006';\n if (!pkg['scripts']['build-storybook']) pkg['scripts']['build-storybook'] = 'storybook build';\n await writeFile(pkgPath, JSON.stringify(pkg, null, 2) + '\\n', 'utf8');\n}\n\nfunction storiesTemplate(tagName: string, className: string): string {\n return `import type { Meta, StoryObj } from '@stencil/storybook-plugin';\nimport { ${className} } from './${tagName}';\n\nconst meta = {\n title: '${className}',\n component: ${className},\n parameters: {\n layout: 'centered',\n },\n} satisfies Meta;\n\nexport default meta;\ntype Story = StoryObj;\n\nexport const Primary: Story = {\n args: {},\n};\n`;\n}\n\nexport const wizard: StencilWizardPlugin = {\n init: {\n id: '@stencil/storybook-plugin',\n displayName: 'Storybook',\n description: 'Component development & documentation',\n\n async run({ config, isNewProject, prompts, nypm }: WizardContext): Promise<void> {\n const { intro, outro, confirm, isCancel, cancel, spinner } = prompts;\n const rootDir = config.rootDir;\n\n intro('Storybook - component development & documentation');\n\n const storybookDir = join(rootDir, '.storybook');\n\n if (await fileExists(storybookDir)) {\n const overwrite = await confirm({\n message: '.storybook/ already exists. Overwrite it?',\n initialValue: false,\n });\n if (isCancel(overwrite) || !overwrite) {\n cancel('Skipping Storybook setup - existing config kept.');\n return;\n }\n }\n\n const s = spinner();\n s.start('Installing dependencies');\n await nypm.addDependency(['storybook', '@storybook/addon-links', '@storybook/addon-docs'], {\n cwd: rootDir,\n dev: true,\n });\n s.stop('Dependencies installed');\n\n await mkdir(storybookDir, { recursive: true });\n await writeFile(join(storybookDir, 'main.ts'), STORYBOOK_MAIN, 'utf8');\n await writeFile(join(storybookDir, 'preview.tsx'), STORYBOOK_PREVIEW, 'utf8');\n await writeFile(join(storybookDir, 'tsconfig.json'), STORYBOOK_TSCONFIG + '\\n', 'utf8');\n await updatePackageJsonScripts(rootDir);\n\n if (isNewProject) {\n await generateExampleStories(config.srcDir);\n }\n\n outro('Storybook configured! Run: npm run storybook');\n },\n },\n\n generate: {\n fileTemplates: [\n {\n label: 'Story (.stories.tsx)',\n extension: 'stories.tsx',\n selectedByDefault: true,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;GACrE,MAAM,UAAU,KAAK,cAAc,aAAa,GAAG,mBAAmB,MAAM;GAC5E,MAAM,UAAU,KAAK,cAAc,eAAe,GAAG,qBAAqB,MAAM,MAAM;GACtF,MAAM,yBAAyB,OAAO;GAEtC,IAAI,cACF,MAAM,uBAAuB,OAAO,MAAM;GAG5C,MAAM,8CAA8C;EACtD;CACF;CAEA,UAAU,EACR,eAAe,CACb;EACE,OAAO;EACP,WAAW;EACX,mBAAmB;EACnB,UAAU;CACZ,CACF,EACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stencil/storybook-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0-dev.1783515311.4f8a25b",
|
|
4
4
|
"description": "Storybook plugin for Stencil",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/stenciljs/storybook",
|
|
@@ -21,72 +21,71 @@
|
|
|
21
21
|
"framework"
|
|
22
22
|
],
|
|
23
23
|
"type": "module",
|
|
24
|
-
"
|
|
25
|
-
"module": "dist/index.js",
|
|
26
|
-
"types": "dist/index.d.ts",
|
|
24
|
+
"types": "dist/index.d.mts",
|
|
27
25
|
"files": [
|
|
28
26
|
"dist",
|
|
29
27
|
"template",
|
|
30
28
|
"@types",
|
|
31
29
|
"preset.js"
|
|
32
30
|
],
|
|
33
|
-
"//": "not sure why dist/preview is needed, but it is",
|
|
34
31
|
"exports": {
|
|
35
32
|
".": {
|
|
36
|
-
"types": "./dist/index.d.
|
|
37
|
-
"import": "./dist/index.
|
|
38
|
-
"require": "./dist/index.cjs"
|
|
33
|
+
"types": "./dist/index.d.mts",
|
|
34
|
+
"import": "./dist/index.mjs"
|
|
39
35
|
},
|
|
40
36
|
"./preset": {
|
|
41
|
-
"types": "./dist/preset.d.
|
|
42
|
-
"import": "./dist/preset.
|
|
43
|
-
"require": "./dist/preset.cjs"
|
|
37
|
+
"types": "./dist/preset.d.mts",
|
|
38
|
+
"import": "./dist/preset.mjs"
|
|
44
39
|
},
|
|
45
40
|
"./preview": {
|
|
46
|
-
"types": "./dist/preview.d.
|
|
47
|
-
"import": "./dist/preview.
|
|
48
|
-
"require": "./dist/preview.cjs"
|
|
49
|
-
},
|
|
50
|
-
"./dist/preview.js": {
|
|
51
|
-
"types": "./dist/preview.d.ts",
|
|
52
|
-
"import": "./dist/preview.js",
|
|
53
|
-
"require": "./dist/preview.cjs"
|
|
41
|
+
"types": "./dist/entry-preview.d.mts",
|
|
42
|
+
"import": "./dist/entry-preview.mjs"
|
|
54
43
|
},
|
|
55
44
|
"./node": {
|
|
56
|
-
"types": "./dist/node/index.d.
|
|
57
|
-
"import": "./dist/node/index.
|
|
58
|
-
|
|
45
|
+
"types": "./dist/node/index.d.mts",
|
|
46
|
+
"import": "./dist/node/index.mjs"
|
|
47
|
+
},
|
|
48
|
+
"./wizard": {
|
|
49
|
+
"types": "./dist/wizard.d.mts",
|
|
50
|
+
"import": "./dist/wizard.mjs"
|
|
59
51
|
},
|
|
60
52
|
"./package.json": "./package.json"
|
|
61
53
|
},
|
|
54
|
+
"stencil": {
|
|
55
|
+
"wizard": "./dist/wizard.mjs"
|
|
56
|
+
},
|
|
62
57
|
"scripts": {
|
|
63
58
|
"watch": "tsdown --watch",
|
|
64
59
|
"build": "tsdown"
|
|
65
60
|
},
|
|
66
61
|
"dependencies": {
|
|
67
|
-
"@
|
|
68
|
-
"@storybook/builder-vite": "^
|
|
62
|
+
"@stencil/unplugin": "^5.0.0 || >=5.0.0-alpha.19 <5.0.0-next.0",
|
|
63
|
+
"@storybook/builder-vite": "^10.4.6",
|
|
69
64
|
"@storybook/global": "^5.0.0",
|
|
70
|
-
"@storybook/html": "^
|
|
71
|
-
"preact-render-to-string": "^6.
|
|
72
|
-
"react-docgen-typescript": "^2.4.0"
|
|
73
|
-
"unplugin-stencil": "^0.4.1"
|
|
65
|
+
"@storybook/html": "^10.4.6",
|
|
66
|
+
"preact-render-to-string": "^6.7.0",
|
|
67
|
+
"react-docgen-typescript": "^2.4.0"
|
|
74
68
|
},
|
|
75
69
|
"peerDependencies": {
|
|
76
|
-
"@stencil/core": "
|
|
77
|
-
"storybook": "^
|
|
70
|
+
"@stencil/core": "catalog:",
|
|
71
|
+
"storybook": "^10.0.0"
|
|
78
72
|
},
|
|
79
73
|
"devDependencies": {
|
|
80
|
-
"@stencil/
|
|
81
|
-
"@
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
74
|
+
"@stencil/cli": "catalog:",
|
|
75
|
+
"@stencil/core": "catalog:",
|
|
76
|
+
"@types/node": "^26.1.0",
|
|
77
|
+
"custom-elements-manifest": "^2.1.0",
|
|
78
|
+
"tsdown": "^0.22.3",
|
|
79
|
+
"typescript": "^6.0.3",
|
|
80
|
+
"vite": "^8.1.3"
|
|
85
81
|
},
|
|
86
82
|
"engines": {
|
|
87
83
|
"node": ">=20"
|
|
88
84
|
},
|
|
89
85
|
"publishConfig": {
|
|
90
86
|
"access": "public"
|
|
87
|
+
},
|
|
88
|
+
"volta": {
|
|
89
|
+
"extends": "../../package.json"
|
|
91
90
|
}
|
|
92
91
|
}
|
package/preset.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export * from './dist/preset.js';
|
|
1
|
+
export { core, viteFinal, previewAnnotations } from './dist/preset.mjs';
|
package/dist/chunk-CsX-DzYB.cjs
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
//#region rolldown:runtime
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all) __defProp(target, name, {
|
|
10
|
-
get: all[name],
|
|
11
|
-
enumerable: true
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
var __copyProps = (to, from, except, desc) => {
|
|
15
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
16
|
-
key = keys[i];
|
|
17
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
18
|
-
get: ((k) => from[k]).bind(null, key),
|
|
19
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
return to;
|
|
23
|
-
};
|
|
24
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
25
|
-
value: mod,
|
|
26
|
-
enumerable: true
|
|
27
|
-
}) : target, mod));
|
|
28
|
-
|
|
29
|
-
//#endregion
|
|
30
|
-
|
|
31
|
-
Object.defineProperty(exports, '__export', {
|
|
32
|
-
enumerable: true,
|
|
33
|
-
get: function () {
|
|
34
|
-
return __export;
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
Object.defineProperty(exports, '__toESM', {
|
|
38
|
-
enumerable: true,
|
|
39
|
-
get: function () {
|
|
40
|
-
return __toESM;
|
|
41
|
-
}
|
|
42
|
-
});
|
package/dist/docs/index.cjs
DELETED
package/dist/docs/index.d.cts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { StencilRenderer } from "../types-BZP9npQ9.cjs";
|
|
2
|
-
import { VNode } from "@stencil/core";
|
|
3
|
-
import { DecoratorFunction } from "storybook/internal/types";
|
|
4
|
-
|
|
5
|
-
//#region src/docs/render-vnode.d.ts
|
|
6
|
-
type RenderMode = 'html' | 'jsx';
|
|
7
|
-
declare const renderVNode: (vnode: VNode, mode: RenderMode) => string;
|
|
8
|
-
//#endregion
|
|
9
|
-
//#region src/docs/source-decorator.d.ts
|
|
10
|
-
declare const sourceDecorator: DecoratorFunction<StencilRenderer<unknown>>;
|
|
11
|
-
//# sourceMappingURL=source-decorator.d.ts.map
|
|
12
|
-
|
|
13
|
-
//#endregion
|
|
14
|
-
export { renderVNode, sourceDecorator };
|
|
15
|
-
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/docs/render-vnode.ts","../../src/docs/source-decorator.ts"],"sourcesContent":[],"mappings":";;;;;KAEK,UAAA;cA2HQ,qBAAsB,aAAa;;;cC5GnC,iBAAiB,kBAAkB"}
|
package/dist/docs/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/docs/render-vnode.ts","../../src/docs/source-decorator.ts"],"sourcesContent":[],"mappings":";;;;;KAEK,UAAA;cA2HQ,qBAAsB,aAAa;;;cC5GnC,iBAAiB,kBAAkB"}
|
package/dist/docs/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"docs-DFb4MYCm.js","names":["str: string","node: VNode","options: RenderOptions","htmlToJsx: Record<string, string>","attrsStr","attrIndent","formattedAttrs","childrenString","vnode: VNode","mode: RenderMode","context: Parameters<DecoratorFunction<StencilRenderer<unknown>>>[1]","sourceDecorator: DecoratorFunction<StencilRenderer<unknown>>"],"sources":["../src/docs/render-vnode.ts","../src/docs/source-decorator.ts"],"sourcesContent":["import { type VNode } from '@stencil/core';\n\ntype RenderMode = 'html' | 'jsx';\n\ninterface RenderOptions {\n mode: RenderMode;\n}\n\nfunction kebabToPascal(str: string): string {\n return str\n .split('-')\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join('');\n}\n\nfunction vnodeToString(node: VNode, options: RenderOptions, indentLevel = 0): string {\n const LINE_WIDTH = 80;\n const indent = ' '.repeat(indentLevel);\n const { mode } = options;\n\n if (node.$text$ !== null) {\n return indent + node.$text$;\n }\n\n if (node.$tag$ === null) {\n return '';\n }\n\n // Convert tag name based on mode\n // Only convert to PascalCase if it's a custom element (has a dash)\n const tag =\n mode === 'jsx' && typeof node.$tag$ === 'string' && node.$tag$.includes('-')\n ? kebabToPascal(node.$tag$)\n : String(node.$tag$);\n\n // Process attributes as array (without leading spaces)\n const attrArray = node.$attrs$\n ? Object.entries(node.$attrs$)\n .filter(([_, value]) => value !== undefined)\n .map(([key, value]) => {\n // Convert HTML attributes to JSX equivalents\n let attrName = key;\n if (mode === 'jsx') {\n // Common HTML to JSX attribute conversions\n const htmlToJsx: Record<string, string> = {\n class: 'className',\n for: 'htmlFor',\n tabindex: 'tabIndex',\n };\n attrName = htmlToJsx[key] || key;\n }\n\n if (typeof value === 'function') {\n // Hide event handlers from source code\n return '';\n }\n\n if (typeof value === 'boolean') {\n return value ? attrName : '';\n }\n\n if (typeof value === 'string') {\n return `${attrName}=\"${value}\"`;\n }\n\n // For JSX, use curly braces for non-string values\n if (mode === 'jsx') {\n return `${attrName}={${JSON.stringify(value)}}`;\n }\n\n // For HTML, convert to string\n return `${attrName}=\"${value}\"`;\n })\n .filter((attr) => attr.trim())\n : [];\n\n const children = node.$children$ ?? [];\n\n // Self-closing tags for JSX when no children\n if (children.length === 0) {\n const attrsStr = attrArray.length > 0 ? ' ' + attrArray.join(' ') : '';\n const singleLine = mode === 'jsx'\n ? `${indent}<${tag}${attrsStr} />`\n : `${indent}<${tag}${attrsStr}></${tag}>`;\n\n // If single line fits within LINE_WIDTH, use it\n if (singleLine.length <= LINE_WIDTH) {\n return singleLine;\n }\n\n // Otherwise, break attributes to multiple lines\n const attrIndent = indent + ' ';\n const formattedAttrs = attrArray.length > 0\n ? '\\n' + attrArray.map((attr) => `${attrIndent}${attr}`).join('\\n') + '\\n' + indent\n : '';\n\n return mode === 'jsx'\n ? `${indent}<${tag}${formattedAttrs}/>`\n : `${indent}<${tag}${formattedAttrs}></${tag}>`;\n }\n\n // Tags with children\n const attrsStr = attrArray.length > 0 ? ' ' + attrArray.join(' ') : '';\n const openingTag = `${indent}<${tag}${attrsStr}>`;\n\n // Check if opening tag fits on one line\n if (openingTag.length <= LINE_WIDTH) {\n const childrenString = children\n .map((child) => vnodeToString(child, options, indentLevel + 1))\n .join('\\n');\n return `${openingTag}\\n${childrenString}\\n${indent}</${tag}>`;\n }\n\n // Break opening tag to multiple lines\n const attrIndent = indent + ' ';\n const formattedAttrs = attrArray.length > 0\n ? '\\n' + attrArray.map((attr) => `${attrIndent}${attr}`).join('\\n') + '\\n' + indent\n : '';\n const childrenString = children\n .map((child) => vnodeToString(child, options, indentLevel + 1))\n .join('\\n');\n\n return `${indent}<${tag}${formattedAttrs}>\\n${childrenString}\\n${indent}</${tag}>`;\n}\n\nexport const renderVNode = (vnode: VNode, mode: RenderMode) => {\n return vnodeToString(vnode, { mode });\n};\n","import { SourceType } from 'storybook/internal/docs-tools';\nimport { emitTransformCode, useEffect } from 'storybook/internal/preview-api';\nimport type { AnnotatedStoryFn, Args, DecoratorFunction } from 'storybook/internal/types';\nimport type { StencilRenderer } from '../types';\nimport { renderVNode } from './render-vnode';\n\ntype StoryFn<TArgs = Args> = AnnotatedStoryFn<StencilRenderer<unknown>, TArgs>;\n\nconst skip = (context: Parameters<DecoratorFunction<StencilRenderer<unknown>>>[1]) => {\n const sourceParams = context?.parameters.docs?.source;\n const isArgsStory = context?.parameters.__isArgsStory;\n\n if (sourceParams.type === SourceType.DYNAMIC) return false;\n\n return !isArgsStory || sourceParams?.code || sourceParams?.type === SourceType.CODE;\n};\n\nexport const sourceDecorator: DecoratorFunction<StencilRenderer<unknown>> = (storyFn, context) => {\n const story = storyFn();\n\n useEffect(() => {\n const renderedForSource = context?.parameters.docs?.source?.excludeDecorators\n ? (context.originalStoryFn as StoryFn)(context.args, context)\n : story;\n\n if (skip(context)) return;\n\n switch (context.parameters.docs.source.language) {\n case 'html': {\n emitTransformCode(renderVNode(renderedForSource, 'html'), context);\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