@analogjs/storybook-angular 3.0.0-alpha.1 → 3.0.0-alpha.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@analogjs/storybook-angular",
3
- "version": "3.0.0-alpha.1",
3
+ "version": "3.0.0-alpha.10",
4
4
  "description": "Storybook Integration for Angular & Vite",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -42,7 +42,7 @@
42
42
  "@storybook/angular": "^10.0.0",
43
43
  "@analogjs/vite-plugin-angular": "*",
44
44
  "storybook": "^10.0.0",
45
- "vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-beta.0"
45
+ "vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
46
46
  },
47
47
  "engines": {
48
48
  "node": ">=20.0.0"
@@ -65,7 +65,5 @@
65
65
  "publishConfig": {
66
66
  "access": "public",
67
67
  "provenance": true
68
- },
69
- "types": "./src/index.d.ts",
70
- "module": "./src/index.js"
71
- }
68
+ }
69
+ }
package/src/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { type AngularOptions, type Parameters as AngularParameters, type AngularRenderer, type Decorator, type IStory, type Loader, type Meta, type Preview, type StoryContext, type StoryFn, type StoryObj, applicationConfig, argsToTemplate, componentWrapperDecorator, moduleMetadata, setProjectAnnotations, } from '@storybook/angular';
2
- export { type FrameworkOptions, type StorybookConfig } from './types';
1
+ export { type AngularOptions, type Parameters as AngularParameters, type AngularRenderer, type Decorator, type IStory, type Loader, type Meta, type Preview, type StoryContext, type StoryFn, type StoryObj, applicationConfig, argsToTemplate, componentWrapperDecorator, moduleMetadata, setProjectAnnotations } from "@storybook/angular";
2
+ export { type FrameworkOptions, type StorybookConfig } from "./types";
package/src/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { applicationConfig, argsToTemplate, componentWrapperDecorator, moduleMetadata, setProjectAnnotations, } from '@storybook/angular';
2
- //# sourceMappingURL=index.js.map
1
+ import { applicationConfig, argsToTemplate, componentWrapperDecorator, moduleMetadata, setProjectAnnotations } from "@storybook/angular";
2
+ export { applicationConfig, argsToTemplate, componentWrapperDecorator, moduleMetadata, setProjectAnnotations };
@@ -1,2 +1,2 @@
1
- import BuildStorybookBuilder from '@storybook/angular/builders/build-storybook';
1
+ import BuildStorybookBuilder from "@storybook/angular/builders/build-storybook";
2
2
  export default BuildStorybookBuilder;
@@ -1,3 +1,7 @@
1
- import BuildStorybookBuilder from '@storybook/angular/builders/build-storybook';
2
- export default BuildStorybookBuilder;
1
+ import BuildStorybookBuilder from "@storybook/angular/builders/build-storybook";
2
+ //#region packages/storybook-angular/src/lib/build-storybook/build-storybook.ts
3
+ var build_storybook_default = BuildStorybookBuilder;
4
+ //#endregion
5
+ export { build_storybook_default as default };
6
+
3
7
  //# sourceMappingURL=build-storybook.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"build-storybook.js","sourceRoot":"","sources":["../../../../../../packages/storybook-angular/src/lib/build-storybook/build-storybook.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,MAAM,6CAA6C,CAAC;AAEhF,eAAe,qBAAqB,CAAC"}
1
+ {"version":3,"file":"build-storybook.js","names":[],"sources":["../../../../../../packages/storybook-angular/src/lib/build-storybook/build-storybook.ts"],"sourcesContent":["import BuildStorybookBuilder from '@storybook/angular/builders/build-storybook';\n\nexport default BuildStorybookBuilder;\n"],"mappings":";;AAEA,IAAA,0BAAe"}
@@ -1,4 +1,4 @@
1
- export declare const previewAnnotations: (entries: any[], options: any) => Promise<any[]>;
1
+ export declare const previewAnnotations: (entries: string[] | undefined, options: any) => Promise<string[]>;
2
2
  export declare const core: (config: any, options: any) => Promise<any>;
3
- export declare const viteFinal: (config: any, options: any) => Promise<Record<string, any>>;
4
- export { addons } from '@storybook/angular/preset';
3
+ export declare const viteFinal: (config: any, options: any) => Promise<any>;
4
+ export { addons } from "@storybook/angular/preset";
package/src/lib/preset.js CHANGED
@@ -1,174 +1,121 @@
1
- import { resolve } from 'node:path';
2
- import { core as PresetCore } from '@storybook/angular/preset';
3
- import { fileURLToPath } from 'node:url';
4
- export const previewAnnotations = async (entries = [], options) => {
5
- const config = fileURLToPath(import.meta.resolve('@storybook/angular/client/config'));
6
- const annotations = [...entries, config];
7
- if (options.enableProdMode) {
8
- const previewProdPath = fileURLToPath(import.meta.resolve('@storybook/angular/client/preview-prod'));
9
- annotations.unshift(previewProdPath);
10
- }
11
- const docsConfig = await options.presets.apply('docs', {}, options);
12
- const docsEnabled = Object.keys(docsConfig).length > 0;
13
- if (docsEnabled) {
14
- const docsConfigPath = fileURLToPath(import.meta.resolve('@storybook/angular/client/docs/config'));
15
- annotations.push(docsConfigPath);
16
- }
17
- return annotations;
1
+ import { resolve } from "node:path";
2
+ import { addons, core as core$1 } from "@storybook/angular/preset";
3
+ import { fileURLToPath } from "node:url";
4
+ import * as vite from "vite";
5
+ //#region packages/storybook-angular/src/lib/preset.ts
6
+ var previewAnnotations = async (entries = [], options) => {
7
+ const config = fileURLToPath(import.meta.resolve("@storybook/angular/client/config"));
8
+ const annotations = [...entries, config];
9
+ if (options.enableProdMode) {
10
+ const previewProdPath = fileURLToPath(import.meta.resolve("@storybook/angular/client/preview-prod"));
11
+ annotations.unshift(previewProdPath);
12
+ }
13
+ const docsConfig = await options.presets.apply("docs", {}, options);
14
+ if (Object.keys(docsConfig).length > 0) {
15
+ const docsConfigPath = fileURLToPath(import.meta.resolve("@storybook/angular/client/docs/config"));
16
+ annotations.push(docsConfigPath);
17
+ }
18
+ return annotations;
18
19
  };
19
- export const core = async (config, options) => {
20
- const presetCore = await PresetCore(config, options);
21
- return {
22
- ...presetCore,
23
- builder: {
24
- name: import.meta.resolve('@storybook/builder-vite'),
25
- options: { ...presetCore.options },
26
- },
27
- };
20
+ var core = async (config, options) => {
21
+ const presetCore = await core$1(config, options);
22
+ return {
23
+ ...presetCore,
24
+ builder: {
25
+ name: import.meta.resolve("@storybook/builder-vite"),
26
+ options: { ...presetCore.options }
27
+ }
28
+ };
28
29
  };
29
30
  async function resolveExperimentalZoneless(frameworkOptions, angularBuilderOptions) {
30
- // 1. Explicit framework option (user's .storybook/main.ts)
31
- if (typeof frameworkOptions?.experimentalZoneless === 'boolean') {
32
- return frameworkOptions.experimentalZoneless;
33
- }
34
- // 2. Angular builder options (set by start-storybook/build-storybook)
35
- if (typeof angularBuilderOptions?.experimentalZoneless === 'boolean') {
36
- return angularBuilderOptions.experimentalZoneless;
37
- }
38
- // 3. Auto-detect Angular 21+ (matches @storybook/angular builder behavior)
39
- try {
40
- const { VERSION } = await import('@angular/core');
41
- return !!(VERSION.major && Number(VERSION.major) >= 21);
42
- }
43
- catch {
44
- return false;
45
- }
31
+ if (typeof frameworkOptions?.experimentalZoneless === "boolean") return frameworkOptions.experimentalZoneless;
32
+ if (typeof angularBuilderOptions?.experimentalZoneless === "boolean") return angularBuilderOptions.experimentalZoneless;
33
+ try {
34
+ const { VERSION } = await import("@angular/core");
35
+ return !!(VERSION.major && Number(VERSION.major) >= 21);
36
+ } catch {
37
+ return false;
38
+ }
46
39
  }
47
- export const viteFinal = async (config, options) => {
48
- // Remove any loaded analogjs plugins from a vite.config.(m)ts file
49
- config.plugins = (config.plugins ?? [])
50
- .flat()
51
- .filter((plugin) => !plugin.name.includes('analogjs'));
52
- // Merge custom configuration into the default config
53
- const { mergeConfig, normalizePath } = await import('vite');
54
- const { default: angular } = await import('@analogjs/vite-plugin-angular');
55
- // @ts-ignore
56
- const framework = await options.presets.apply('framework');
57
- const experimentalZoneless = await resolveExperimentalZoneless(framework.options, options?.angularBuilderOptions);
58
- return mergeConfig(config, {
59
- // Add dependencies to pre-optimization
60
- optimizeDeps: {
61
- include: [
62
- '@storybook/angular/client',
63
- '@analogjs/storybook-angular',
64
- '@angular/compiler',
65
- '@angular/platform-browser',
66
- '@angular/platform-browser/animations',
67
- 'tslib',
68
- ...(experimentalZoneless ? [] : ['zone.js']),
69
- ],
70
- },
71
- plugins: [
72
- angular({
73
- jit: typeof framework.options?.jit !== 'undefined'
74
- ? framework.options?.jit
75
- : true,
76
- liveReload: typeof framework.options?.liveReload !== 'undefined'
77
- ? framework.options?.liveReload
78
- : false,
79
- tsconfig: typeof framework.options?.tsconfig !== 'undefined'
80
- ? framework.options?.tsconfig
81
- : (options?.tsConfig ?? './.storybook/tsconfig.json'),
82
- inlineStylesExtension: typeof framework.options?.inlineStylesExtension !== 'undefined'
83
- ? framework.options?.inlineStylesExtension
84
- : 'css',
85
- }),
86
- angularOptionsPlugin(options, { normalizePath, experimentalZoneless }),
87
- storybookEsbuildPlugin(),
88
- ],
89
- define: {
90
- STORYBOOK_ANGULAR_OPTIONS: JSON.stringify({
91
- experimentalZoneless: !!experimentalZoneless,
92
- }),
93
- },
94
- });
40
+ var viteFinal = async (config, options) => {
41
+ config.plugins = (config.plugins ?? []).flat().filter((plugin) => !plugin.name.includes("analogjs"));
42
+ const { mergeConfig, normalizePath } = await import("vite");
43
+ const { default: angular } = await import("@analogjs/vite-plugin-angular");
44
+ const framework = await options.presets.apply("framework");
45
+ const experimentalZoneless = await resolveExperimentalZoneless(framework.options, options?.angularBuilderOptions);
46
+ return mergeConfig(config, {
47
+ optimizeDeps: { include: [
48
+ "@storybook/angular/client",
49
+ "@analogjs/storybook-angular",
50
+ "@angular/compiler",
51
+ "@angular/platform-browser",
52
+ "@angular/platform-browser/animations",
53
+ "tslib",
54
+ ...experimentalZoneless ? [] : ["zone.js"]
55
+ ] },
56
+ plugins: [
57
+ angular({
58
+ jit: typeof framework.options?.jit !== "undefined" ? framework.options?.jit : true,
59
+ liveReload: typeof framework.options?.liveReload !== "undefined" ? framework.options?.liveReload : false,
60
+ tsconfig: typeof framework.options?.tsconfig !== "undefined" ? framework.options?.tsconfig : options?.tsConfig ?? "./.storybook/tsconfig.json",
61
+ inlineStylesExtension: typeof framework.options?.inlineStylesExtension !== "undefined" ? framework.options?.inlineStylesExtension : "css"
62
+ }),
63
+ angularOptionsPlugin(options, {
64
+ normalizePath,
65
+ experimentalZoneless
66
+ }),
67
+ storybookTransformConfigPlugin()
68
+ ],
69
+ define: { STORYBOOK_ANGULAR_OPTIONS: JSON.stringify({ experimentalZoneless: !!experimentalZoneless }) }
70
+ });
95
71
  };
96
72
  function angularOptionsPlugin(options, { normalizePath, experimentalZoneless }) {
97
- let resolvedConfig;
98
- return {
99
- name: 'analogjs-storybook-options-plugin',
100
- config(userConfig) {
101
- resolvedConfig = userConfig;
102
- const loadPaths = options?.angularBuilderOptions?.stylePreprocessorOptions?.loadPaths;
103
- const sassOptions = options?.angularBuilderOptions?.stylePreprocessorOptions?.sass;
104
- if (Array.isArray(loadPaths)) {
105
- const workspaceRoot = options.angularBuilderContext?.workspaceRoot ??
106
- userConfig?.root ??
107
- process.cwd();
108
- return {
109
- css: {
110
- preprocessorOptions: {
111
- scss: {
112
- ...sassOptions,
113
- loadPaths: loadPaths.map((loadPath) => `${resolve(workspaceRoot, loadPath)}`),
114
- },
115
- },
116
- },
117
- };
118
- }
119
- return;
120
- },
121
- async transform(code, id) {
122
- if (normalizePath(id).endsWith(normalizePath(`${options.configDir}/preview.ts`))) {
123
- const imports = [];
124
- const styles = options?.angularBuilderOptions?.styles;
125
- if (Array.isArray(styles)) {
126
- styles.forEach((style) => {
127
- imports.push(style);
128
- });
129
- }
130
- if (!experimentalZoneless) {
131
- imports.push('zone.js');
132
- }
133
- // Use vite config root when angularBuilderContext is not available
134
- // (e.g., when running via Vitest instead of Angular builders)
135
- const projectRoot = resolvedConfig?.root ?? process.cwd();
136
- return {
137
- code: `
138
- ${imports
139
- .map((extraImport) => {
140
- if (extraImport.startsWith('.') ||
141
- extraImport.startsWith('src')) {
142
- // relative to root
143
- return `import '${resolve(projectRoot, extraImport)}';`;
144
- }
145
- // absolute import
146
- return `import '${extraImport}';`;
147
- })
148
- .join('\n')}
73
+ let resolvedConfig;
74
+ return {
75
+ name: "analogjs-storybook-options-plugin",
76
+ config(userConfig) {
77
+ resolvedConfig = userConfig;
78
+ const loadPaths = options?.angularBuilderOptions?.stylePreprocessorOptions?.loadPaths;
79
+ const sassOptions = options?.angularBuilderOptions?.stylePreprocessorOptions?.sass;
80
+ if (Array.isArray(loadPaths)) {
81
+ const workspaceRoot = options.angularBuilderContext?.workspaceRoot ?? userConfig?.root ?? process.cwd();
82
+ return { css: { preprocessorOptions: { scss: {
83
+ ...sassOptions,
84
+ loadPaths: loadPaths.map((loadPath) => `${resolve(workspaceRoot, loadPath)}`)
85
+ } } } };
86
+ }
87
+ },
88
+ async transform(code, id) {
89
+ if (normalizePath(id).endsWith(normalizePath(`${options.configDir}/preview.ts`))) {
90
+ const imports = [];
91
+ const styles = options?.angularBuilderOptions?.styles;
92
+ if (Array.isArray(styles)) styles.forEach((style) => {
93
+ imports.push(style);
94
+ });
95
+ if (!experimentalZoneless) imports.push("zone.js");
96
+ const projectRoot = resolvedConfig?.root ?? process.cwd();
97
+ return { code: `
98
+ ${imports.map((extraImport) => {
99
+ if (extraImport.startsWith(".") || extraImport.startsWith("src")) return `import '${resolve(projectRoot, extraImport)}';`;
100
+ return `import '${extraImport}';`;
101
+ }).join("\n")}
149
102
  ${code}
150
- `,
151
- };
152
- }
153
- return;
154
- },
155
- };
103
+ ` };
104
+ }
105
+ }
106
+ };
156
107
  }
157
- function storybookEsbuildPlugin() {
158
- return {
159
- name: 'analogjs-storybook-esbuild-config',
160
- apply: 'build',
161
- config() {
162
- return {
163
- esbuild: {
164
- // Don't mangle class names during the build
165
- // This fixes display of compodoc argtypes
166
- keepNames: true,
167
- },
168
- };
169
- },
170
- };
108
+ function storybookTransformConfigPlugin() {
109
+ const configKey = vite.rolldownVersion ? "oxc" : "esbuild";
110
+ return {
111
+ name: "analogjs-storybook-transform-config",
112
+ apply: "build",
113
+ config() {
114
+ return { [configKey]: { keepNames: true } };
115
+ }
116
+ };
171
117
  }
172
- export { addons } from '@storybook/angular/preset';
173
- //# sourceMappingURL=preset.js.map
118
+ //#endregion
119
+ export { addons, core, previewAnnotations, viteFinal };
120
+
174
121
  //# sourceMappingURL=preset.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"preset.js","sourceRoot":"","sources":["../../../../../packages/storybook-angular/src/lib/preset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,EAAE,OAAO,GAAG,EAAE,EAAE,OAAO,EAAE,EAAE;IAChE,MAAM,MAAM,GAAG,aAAa,CAC1B,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,kCAAkC,CAAC,CACxD,CAAC;IACF,MAAM,WAAW,GAAG,CAAC,GAAG,OAAO,EAAE,MAAM,CAAC,CAAC;IAEzC,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;QAC3B,MAAM,eAAe,GAAG,aAAa,CACnC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,wCAAwC,CAAC,CAC9D,CAAC;QACF,WAAW,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IACvC,CAAC;IAED,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;IACpE,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;IACvD,IAAI,WAAW,EAAE,CAAC;QAChB,MAAM,cAAc,GAAG,aAAa,CAClC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,uCAAuC,CAAC,CAC7D,CAAC;QACF,WAAW,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,I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;oBAC5C,0CAA0C;oBAC1C,SAAS,EAAE,IAAI;iBAChB;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,kCAAkC"}
1
+ {"version":3,"file":"preset.js","names":[],"sources":["../../../../../packages/storybook-angular/src/lib/preset.ts"],"sourcesContent":["import { resolve } from 'node:path';\nimport { core as PresetCore } from '@storybook/angular/preset';\nimport { fileURLToPath } from 'node:url';\nimport * as vite from 'vite';\nimport type { Plugin, UserConfig } from 'vite';\n\nexport const previewAnnotations = async (\n entries: string[] = [],\n options: any,\n): Promise<string[]> => {\n const config = fileURLToPath(\n import.meta.resolve('@storybook/angular/client/config'),\n );\n const annotations = [...entries, config];\n\n if (options.enableProdMode) {\n const previewProdPath = fileURLToPath(\n import.meta.resolve('@storybook/angular/client/preview-prod'),\n );\n annotations.unshift(previewProdPath);\n }\n\n const docsConfig = await options.presets.apply('docs', {}, options);\n const docsEnabled = Object.keys(docsConfig).length > 0;\n if (docsEnabled) {\n const docsConfigPath = fileURLToPath(\n import.meta.resolve('@storybook/angular/client/docs/config'),\n );\n annotations.push(docsConfigPath);\n }\n return annotations;\n};\n\nexport const core = async (config: any, options: any): Promise<any> => {\n const presetCore = await PresetCore(config, options);\n return {\n ...presetCore,\n builder: {\n name: import.meta.resolve('@storybook/builder-vite'),\n options: { ...presetCore.options },\n },\n };\n};\n\nasync function resolveExperimentalZoneless(\n frameworkOptions: any,\n angularBuilderOptions: any,\n) {\n // 1. Explicit framework option (user's .storybook/main.ts)\n if (typeof frameworkOptions?.experimentalZoneless === 'boolean') {\n return frameworkOptions.experimentalZoneless;\n }\n\n // 2. Angular builder options (set by start-storybook/build-storybook)\n if (typeof angularBuilderOptions?.experimentalZoneless === 'boolean') {\n return angularBuilderOptions.experimentalZoneless;\n }\n\n // 3. Auto-detect Angular 21+ (matches @storybook/angular builder behavior)\n try {\n const { VERSION } = await import('@angular/core');\n return !!(VERSION.major && Number(VERSION.major) >= 21);\n } catch {\n return false;\n }\n}\n\nexport const viteFinal = async (config: any, options: any): Promise<any> => {\n // Remove any loaded analogjs plugins from a vite.config.(m)ts file\n config.plugins = (config.plugins ?? [])\n .flat()\n .filter((plugin: any) => !plugin.name.includes('analogjs'));\n\n // Merge custom configuration into the default config\n const { mergeConfig, normalizePath } = await import('vite');\n const { default: angular } = await import('@analogjs/vite-plugin-angular');\n const framework = await options.presets.apply('framework');\n const experimentalZoneless = await resolveExperimentalZoneless(\n framework.options,\n options?.angularBuilderOptions,\n );\n return mergeConfig(config, {\n // Add dependencies to pre-optimization\n optimizeDeps: {\n include: [\n '@storybook/angular/client',\n '@analogjs/storybook-angular',\n '@angular/compiler',\n '@angular/platform-browser',\n '@angular/platform-browser/animations',\n 'tslib',\n ...(experimentalZoneless ? [] : ['zone.js']),\n ],\n },\n plugins: [\n angular({\n jit:\n typeof framework.options?.jit !== 'undefined'\n ? framework.options?.jit\n : true,\n liveReload:\n typeof framework.options?.liveReload !== 'undefined'\n ? framework.options?.liveReload\n : false,\n tsconfig:\n typeof framework.options?.tsconfig !== 'undefined'\n ? framework.options?.tsconfig\n : (options?.tsConfig ?? './.storybook/tsconfig.json'),\n inlineStylesExtension:\n typeof framework.options?.inlineStylesExtension !== 'undefined'\n ? framework.options?.inlineStylesExtension\n : 'css',\n }),\n angularOptionsPlugin(options, { normalizePath, experimentalZoneless }),\n storybookTransformConfigPlugin(),\n ],\n define: {\n STORYBOOK_ANGULAR_OPTIONS: JSON.stringify({\n experimentalZoneless: !!experimentalZoneless,\n }),\n },\n });\n};\n\nfunction angularOptionsPlugin(\n options: any,\n {\n normalizePath,\n experimentalZoneless,\n }: { normalizePath: (path: string) => string; experimentalZoneless: boolean },\n): Plugin {\n let resolvedConfig: UserConfig | undefined;\n return {\n name: 'analogjs-storybook-options-plugin',\n config(userConfig: UserConfig) {\n resolvedConfig = userConfig;\n const loadPaths =\n options?.angularBuilderOptions?.stylePreprocessorOptions?.loadPaths;\n const sassOptions =\n options?.angularBuilderOptions?.stylePreprocessorOptions?.sass;\n\n if (Array.isArray(loadPaths)) {\n const workspaceRoot =\n options.angularBuilderContext?.workspaceRoot ??\n userConfig?.root ??\n process.cwd();\n return {\n css: {\n preprocessorOptions: {\n scss: {\n ...sassOptions,\n loadPaths: loadPaths.map(\n (loadPath) => `${resolve(workspaceRoot, loadPath)}`,\n ),\n },\n },\n },\n };\n }\n\n return;\n },\n async transform(code: string, id: string) {\n if (\n normalizePath(id).endsWith(\n normalizePath(`${options.configDir}/preview.ts`),\n )\n ) {\n const imports = [];\n const styles = options?.angularBuilderOptions?.styles;\n\n if (Array.isArray(styles)) {\n styles.forEach((style) => {\n imports.push(style);\n });\n }\n\n if (!experimentalZoneless) {\n imports.push('zone.js');\n }\n\n // Use vite config root when angularBuilderContext is not available\n // (e.g., when running via Vitest instead of Angular builders)\n const projectRoot = resolvedConfig?.root ?? process.cwd();\n\n return {\n code: `\n ${imports\n .map((extraImport) => {\n if (\n extraImport.startsWith('.') ||\n extraImport.startsWith('src')\n ) {\n // relative to root\n return `import '${resolve(projectRoot, extraImport)}';`;\n }\n\n // absolute import\n return `import '${extraImport}';`;\n })\n .join('\\n')}\n ${code}\n `,\n };\n }\n\n return;\n },\n };\n}\n\nfunction storybookTransformConfigPlugin(): Plugin {\n const configKey = vite.rolldownVersion ? 'oxc' : 'esbuild';\n\n return {\n name: 'analogjs-storybook-transform-config',\n apply: 'build',\n config() {\n return {\n [configKey]: {\n // Don't mangle class names during the build\n // This fixes display of compodoc argtypes\n keepNames: true,\n },\n };\n },\n };\n}\n\nexport { addons } from '@storybook/angular/preset';\n//# sourceMappingURL=preset.js.map\n"],"mappings":";;;;;AAMA,IAAa,qBAAqB,OAChC,UAAoB,EAAE,EACtB,YACsB;CACtB,MAAM,SAAS,cACb,OAAO,KAAK,QAAQ,mCAAmC,CACxD;CACD,MAAM,cAAc,CAAC,GAAG,SAAS,OAAO;AAExC,KAAI,QAAQ,gBA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AAgB,QAAQ,QAAQ,KAAK;AAEzD,WAAO,EACL,MAAM;cACF,QACC,KAAK,gBAAgB;AACpB,SACE,YAAY,WAAW,IAAI,IAC3B,YAAY,WAAW,MAAM,CAG7B,QAAO,WAAW,QAAQ,aAAa,YAAY,CAAC;AAItD,YAAO,WAAW,YAAY;MAC9B,CACD,KAAK,KAAK,CAAC;cACZ,KAAK;aAEV;;;EAKN;;AAGH,SAAS,iCAAyC;CAChD,MAAM,YAAY,KAAK,kBAAkB,QAAQ;AAEjD,QAAO;EACL,MAAM;EACN,OAAO;EACP,SAAS;AACP,UAAO,GACJ,YAAY,EAGX,WAAW,MACZ,EACF;;EAEJ"}
@@ -1,2 +1,2 @@
1
- import StartStorybookBuilder from '@storybook/angular/builders/start-storybook';
1
+ import StartStorybookBuilder from "@storybook/angular/builders/start-storybook";
2
2
  export default StartStorybookBuilder;
@@ -1,3 +1,7 @@
1
- import StartStorybookBuilder from '@storybook/angular/builders/start-storybook';
2
- export default StartStorybookBuilder;
1
+ import StartStorybookBuilder from "@storybook/angular/builders/start-storybook";
2
+ //#region packages/storybook-angular/src/lib/start-storybook/start-storybook.ts
3
+ var start_storybook_default = StartStorybookBuilder;
4
+ //#endregion
5
+ export { start_storybook_default as default };
6
+
3
7
  //# sourceMappingURL=start-storybook.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"start-storybook.js","sourceRoot":"","sources":["../../../../../../packages/storybook-angular/src/lib/start-storybook/start-storybook.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,MAAM,6CAA6C,CAAC;AAEhF,eAAe,qBAAqB,CAAC"}
1
+ {"version":3,"file":"start-storybook.js","names":[],"sources":["../../../../../../packages/storybook-angular/src/lib/start-storybook/start-storybook.ts"],"sourcesContent":["import StartStorybookBuilder from '@storybook/angular/builders/start-storybook';\n\nexport default StartStorybookBuilder;\n"],"mappings":";;AAEA,IAAA,0BAAe"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Ambient declarations for @storybook/angular subpath imports that do NOT ship types.
3
+ * Official @storybook/angular does not provide .d.ts files for builders, preset, client, etc.
4
+ * Tracked in various GitHub issues since ~2018–2023.
5
+ * See also: https://github.com/storybookjs/storybook/issues?q=is%3Aissue+angular+types+is%3Aopen
6
+ */
7
+
8
+ declare module '@storybook/angular/builders/build-storybook';
9
+ declare module '@storybook/angular/builders/start-storybook';
10
+ declare module '@storybook/angular/preset';
11
+ declare module '@storybook/angular/client';
12
+ declare module '@storybook/angular/client/config';
@@ -1,6 +1,7 @@
1
- import '@angular/compiler';
2
- import type { AngularRenderer } from '@storybook/angular';
3
- import { NamedOrDefaultProjectAnnotations, NormalizedProjectAnnotations, RenderContext } from 'storybook/internal/types';
4
- export declare const render: any;
1
+ import "@angular/compiler";
2
+ import type { AngularRenderer } from "@storybook/angular";
3
+ import { NamedOrDefaultProjectAnnotations, NormalizedProjectAnnotations, RenderContext } from "storybook/internal/types";
4
+ import * as configAnnotations from "@storybook/angular/client/config";
5
+ export declare const render: typeof configAnnotations.render;
5
6
  export declare function renderToCanvas(context: RenderContext<AngularRenderer>, element: HTMLElement): Promise<void>;
6
7
  export declare function setProjectAnnotations(projectAnnotations: NamedOrDefaultProjectAnnotations<any> | NamedOrDefaultProjectAnnotations<any>[]): NormalizedProjectAnnotations<AngularRenderer>;
@@ -1,21 +1,20 @@
1
- import '@angular/compiler';
2
- import { setProjectAnnotations as originalSetProjectAnnotations } from '@storybook/angular/client';
3
- import * as configAnnotations from '@storybook/angular/client/config';
4
- export const render = configAnnotations.render;
5
- export async function renderToCanvas(context, element) {
6
- element.id = context.id;
7
- await configAnnotations.renderToCanvas(context, element);
1
+ import "@angular/compiler";
2
+ import { setProjectAnnotations as setProjectAnnotations$1 } from "@storybook/angular/client";
3
+ import * as configAnnotations from "@storybook/angular/client/config";
4
+ //#region packages/storybook-angular/src/lib/testing.ts
5
+ var render = configAnnotations.render;
6
+ async function renderToCanvas(context, element) {
7
+ element.id = context.id;
8
+ await configAnnotations.renderToCanvas(context, element);
8
9
  }
9
- const renderAnnotations = {
10
- render,
11
- renderToCanvas,
10
+ var renderAnnotations = {
11
+ render,
12
+ renderToCanvas
12
13
  };
13
- export function setProjectAnnotations(projectAnnotations) {
14
- return originalSetProjectAnnotations([
15
- renderAnnotations,
16
- ...(Array.isArray(projectAnnotations)
17
- ? projectAnnotations
18
- : [projectAnnotations]),
19
- ]);
14
+ function setProjectAnnotations(projectAnnotations) {
15
+ return setProjectAnnotations$1([renderAnnotations, ...Array.isArray(projectAnnotations) ? projectAnnotations : [projectAnnotations]]);
20
16
  }
17
+ //#endregion
18
+ export { render, renderToCanvas, setProjectAnnotations };
19
+
21
20
  //# sourceMappingURL=testing.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"testing.js","sourceRoot":"","sources":["../../../../../packages/storybook-angular/src/lib/testing.ts"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,CAAC;AAE3B,OAAO,EAAE,qBAAqB,IAAI,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAMnG,OAAO,KAAK,iBAAiB,MAAM,kCAAkC,CAAC;AAEtE,MAAM,CAAC,MAAM,MAAM,GAAG,iBAAiB,CAAC,MAAM,CAAC;AAE/C,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,OAAuC,EACvC,OAAoB;IAEpB,OAAO,CAAC,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC;IACxB,MAAM,iBAAiB,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC3D,CAAC;AAED,MAAM,iBAAiB,GAAG;IACxB,MAAM;IACN,cAAc;CACf,CAAC;AAEF,MAAM,UAAU,qBAAqB,CACnC,kBAE2C;IAE3C,OAAO,6BAA6B,CAAC;QACnC,iBAAiB;QACjB,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,kBAAkB,CAAC;YACnC,CAAC,CAAC,kBAAkB;YACpB,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC;KAC1B,CAAkD,CAAC;AACtD,CAAC"}
1
+ {"version":3,"file":"testing.js","names":[],"sources":["../../../../../packages/storybook-angular/src/lib/testing.ts"],"sourcesContent":["import '@angular/compiler';\nimport type { AngularRenderer } from '@storybook/angular';\nimport { setProjectAnnotations as originalSetProjectAnnotations } from '@storybook/angular/client';\nimport {\n NamedOrDefaultProjectAnnotations,\n NormalizedProjectAnnotations,\n RenderContext,\n} from 'storybook/internal/types';\nimport * as configAnnotations from '@storybook/angular/client/config';\n\nexport const render: typeof configAnnotations.render = configAnnotations.render;\n\nexport async function renderToCanvas(\n context: RenderContext<AngularRenderer>,\n element: HTMLElement,\n): Promise<void> {\n element.id = context.id;\n await configAnnotations.renderToCanvas(context, element);\n}\n\nconst renderAnnotations = {\n render,\n renderToCanvas,\n};\n\nexport function setProjectAnnotations(\n projectAnnotations:\n | NamedOrDefaultProjectAnnotations<any>\n | NamedOrDefaultProjectAnnotations<any>[],\n): NormalizedProjectAnnotations<AngularRenderer> {\n return originalSetProjectAnnotations([\n renderAnnotations,\n ...(Array.isArray(projectAnnotations)\n ? projectAnnotations\n : [projectAnnotations]),\n ]) as NormalizedProjectAnnotations<AngularRenderer>;\n}\n"],"mappings":";;;;AAUA,IAAa,SAA0C,kBAAkB;AAEzE,eAAsB,eACpB,SACA,SACe;AACf,SAAQ,KAAK,QAAQ;AACrB,OAAM,kBAAkB,eAAe,SAAS,QAAQ;;AAG1D,IAAM,oBAAoB;CACxB;CACA;CACD;AAED,SAAgB,sBACd,oBAG+C;AAC/C,QAAO,wBAA8B,CACnC,mBACA,GAAI,MAAM,QAAQ,mBAAmB,GACjC,qBACA,CAAC,mBAAmB,CACzB,CAAC"}
@@ -1,9 +1,9 @@
1
- import { BuilderOptions, CLIOptions, LoadOptions } from 'storybook/internal/types';
1
+ import { BuilderOptions, CLIOptions, LoadOptions } from "storybook/internal/types";
2
2
  export type StandaloneOptions = CLIOptions & LoadOptions & BuilderOptions & {
3
- mode?: 'static' | 'dev';
4
- enableProdMode: boolean;
5
- angularBuilderOptions?: Record<string, any> & {
6
- experimentalZoneless?: boolean;
7
- };
8
- tsConfig?: string;
3
+ mode?: "static" | "dev";
4
+ enableProdMode: boolean;
5
+ angularBuilderOptions?: Record<string, any> & {
6
+ experimentalZoneless?: boolean;
7
+ };
8
+ tsConfig?: string;
9
9
  };
@@ -0,0 +1,2 @@
1
+ import "@analogjs/vite-plugin-angular/setup-vitest";
2
+ export {};
package/src/types.d.ts CHANGED
@@ -1,27 +1,27 @@
1
- import { CompatibleString } from 'storybook/internal/types';
2
- import { StorybookConfig as StorybookConfigBase } from '@storybook/angular';
3
- import { BuilderOptions, StorybookConfigVite } from '@storybook/builder-vite';
4
- type FrameworkName = CompatibleString<'@analogjs/storybook-angular'>;
5
- type BuilderName = CompatibleString<'@storybook/builder-vite'>;
1
+ import { CompatibleString } from "storybook/internal/types";
2
+ import { StorybookConfig as StorybookConfigBase } from "@storybook/angular";
3
+ import { BuilderOptions, StorybookConfigVite } from "@storybook/builder-vite";
4
+ type FrameworkName = CompatibleString<"@analogjs/storybook-angular">;
5
+ type BuilderName = CompatibleString<"@storybook/builder-vite">;
6
6
  export type FrameworkOptions = {
7
- builder?: BuilderOptions;
8
- jit?: boolean;
9
- liveReload?: boolean;
10
- inlineStylesExtension?: string;
11
- tsconfig?: string;
12
- experimentalZoneless?: boolean;
7
+ builder?: BuilderOptions;
8
+ jit?: boolean;
9
+ liveReload?: boolean;
10
+ inlineStylesExtension?: string;
11
+ tsconfig?: string;
12
+ experimentalZoneless?: boolean;
13
13
  };
14
14
  type StorybookConfigFramework = {
15
- framework: FrameworkName | {
16
- name: FrameworkName;
17
- options: FrameworkOptions;
18
- };
19
- core?: StorybookConfigBase['core'] & {
20
- builder?: BuilderName | {
21
- name: BuilderName;
22
- options: BuilderOptions;
23
- };
24
- };
15
+ framework: FrameworkName | {
16
+ name: FrameworkName;
17
+ options: FrameworkOptions;
18
+ };
19
+ core?: StorybookConfigBase["core"] & {
20
+ builder?: BuilderName | {
21
+ name: BuilderName;
22
+ options: BuilderOptions;
23
+ };
24
+ };
25
25
  };
26
26
  /** The interface for Storybook configuration in `main.ts` files. */
27
27
  export type StorybookConfig = Omit<StorybookConfigBase, keyof StorybookConfigVite | keyof StorybookConfigFramework> & StorybookConfigVite & StorybookConfigFramework;
package/README.md DELETED
@@ -1,270 +0,0 @@
1
- # @analogjs/storybook-angular
2
-
3
- Integration package for Storybook using Angular & Vite.
4
-
5
- > This is a community integration not maintained by the Storybook team. If you have issues,
6
- > file an issue in our [GitHub repo](https://github.com/analogjs/analog/issues).
7
-
8
- ## Setup
9
-
10
- If you don't have Storybook setup already, run the following command to initialize Storybook for your project:
11
-
12
- ```sh
13
- npx storybook@latest init
14
- ```
15
-
16
- Follow the provided prompts, and commit your changes.
17
-
18
- ## Installing the Storybook package
19
-
20
- Install the Storybook Plugin for Angular and Vite. Depending on your preferred package manager, run one of the following commands:
21
-
22
- ```shell
23
- npm install @analogjs/storybook-angular --save-dev
24
- ```
25
-
26
- ## Configuring Storybook
27
-
28
- Update the `.storybook/main.ts` file to use the `StorybookConfig` type. Also update the `framework` to use the `@analogjs/storybook-angular` package.
29
-
30
- ```ts
31
- import { StorybookConfig } from '@analogjs/storybook-angular';
32
-
33
- const config: StorybookConfig = {
34
- // other config, addons, etc.
35
- framework: {
36
- name: '@analogjs/storybook-angular',
37
- options: {},
38
- },
39
- };
40
-
41
- export default config;
42
- ```
43
-
44
- Remove the existing `webpackFinal` config function if present.
45
-
46
- Next, update the Storybook targets in the `angular.json` or `project.json`
47
-
48
- ```json
49
- "storybook": {
50
- "builder": "@analogjs/storybook-angular:start-storybook",
51
- },
52
- "build-storybook": {
53
- "builder": "@analogjs/storybook-angular:build-storybook"
54
- }
55
- ```
56
-
57
- Remove any `webpack` specific options and remove the `browserTarget` option.
58
-
59
- Add the `/storybook-static` folder to the `.gitignore` file.
60
-
61
- ## Setting up CSS
62
-
63
- To register global styles, add them to the `@analogjs/storybook-angular` builder options in the `angular.json` or `project.json`.
64
-
65
- ```json
66
- "storybook": {
67
- "builder": "@analogjs/storybook-angular:start-storybook",
68
- "options": {
69
- // ... other options
70
- "styles": [
71
- "src/styles.css"
72
- ],
73
- "stylePreprocessorOptions": {
74
- "loadPaths": ["libs/my-lib/styles"]
75
- }
76
- }
77
- },
78
- "build-storybook": {
79
- "builder": "@analogjs/storybook-angular:build-storybook",
80
- "options": {
81
- // ... other options
82
- "styles": [
83
- "src/styles.css"
84
- ],
85
- "stylePreprocessorOptions": {
86
- "loadPaths": ["libs/my-lib/styles"]
87
- }
88
- }
89
- }
90
- ```
91
-
92
- ## Enabling Zoneless Change Detection
93
-
94
- To use zoneless change detection for the Storybook, add the `experimentalZoneless` flag to the `@analogjs/storybook-angular` builder options in the `angular.json`.
95
-
96
- ```json
97
- "storybook": {
98
- "builder": "@analogjs/storybook-angular:start-storybook",
99
- "options": {
100
- // ... other options
101
- "experimentalZoneless": true
102
- }
103
- },
104
- "build-storybook": {
105
- "builder": "@analogjs/storybook-angular:build-storybook",
106
- "options": {
107
- // ... other options
108
- "experimentalZoneless": true
109
- }
110
- }
111
- ```
112
-
113
- For `project.json`
114
-
115
- ```json
116
- "storybook": {
117
- "executor": "@analogjs/storybook-angular:start-storybook",
118
- "options": {
119
- // ... other options
120
- "configDir": "path/to/.storybook",
121
- "experimentalZoneless": true,
122
- "compodoc": false
123
- }
124
- },
125
- "build-storybook": {
126
- "executor": "@analogjs/storybook-angular:build-storybook",
127
- "options": {
128
- // ... other options
129
- "configDir": "path/to/.storybook",
130
- "experimentalZoneless": true,
131
- "compodoc": false
132
- }
133
- }
134
- ```
135
-
136
- > Zoneless change detection is the default for new projects starting Angular v21.
137
-
138
- ## Setting up Static Assets
139
-
140
- Static assets are configured in the `.storybook/main.ts` file using the `staticDirs` array.
141
-
142
- The example below shows how to add the `public` directory from `src/public` relative to the `.storybook/main.ts` file.
143
-
144
- ```ts
145
- import { StorybookConfig } from '@analogjs/storybook-angular';
146
-
147
- const config: StorybookConfig = {
148
- // other config, addons, etc.
149
- framework: {
150
- name: '@analogjs/storybook-angular',
151
- options: {},
152
- },
153
- staticDirs: ['../public'],
154
- };
155
-
156
- export default config;
157
- ```
158
-
159
- See the [Storybook docs on images and assets](https://storybook.js.org/docs/configure/integration/images-and-assets) for more information.
160
-
161
- ## Running Storybook
162
-
163
- Run the command for starting the development server.
164
-
165
- ```sh
166
- npm run storybook
167
- ```
168
-
169
- ## Building Storybook
170
-
171
- Run the command for building the storybook.
172
-
173
- ```sh
174
- npm run build-storybook
175
- ```
176
-
177
- ## Using TypeScript Config Path Aliases
178
-
179
- If you are using `paths` in your `tsconfig.json`, support for those aliases can be added to the `vite.config.ts`.
180
-
181
- ### With Angular CLI
182
-
183
- First, install the `vite-tsconfig-paths` package.
184
-
185
- ```shell
186
- npm install vite-tsconfig-paths --save-dev
187
- ```
188
-
189
- Next, add the plugin to the `plugins` array in the `.storybook/main.ts`.
190
-
191
- ```ts
192
- import viteTsConfigPaths from 'vite-tsconfig-paths';
193
- import { UserConfig, mergeConfig } from 'vite';
194
-
195
- import type { StorybookConfig } from '@analogjs/storybook-angular';
196
-
197
- const config: StorybookConfig = {
198
- // ... other config, addons, etc.
199
- async viteFinal(config: UserConfig) {
200
- return mergeConfig(config, {
201
- plugins: [viteTsConfigPaths()],
202
- });
203
- },
204
- };
205
-
206
- export default config;
207
- ```
208
-
209
- ### With Nx
210
-
211
- For Nx workspaces, import and use the `nxViteTsPaths` plugin from the `@nx/vite` package. Add the plugin to the `plugins` array in the `.storybook/main.ts`.
212
-
213
- ```ts
214
- import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
215
- import { UserConfig, mergeConfig } from 'vite';
216
-
217
- import type { StorybookConfig } from '@analogjs/storybook-angular';
218
-
219
- const config: StorybookConfig = {
220
- // ... other config, addons, etc.
221
- async viteFinal(config: UserConfig) {
222
- return mergeConfig(config, {
223
- plugins: [nxViteTsPaths()],
224
- });
225
- },
226
- };
227
-
228
- export default config;
229
- ```
230
-
231
- ## Using File Replacements
232
-
233
- You can also use the `replaceFiles()` plugin from Nx to replace files during your build.
234
-
235
- Import the plugin and set it up:
236
-
237
- ```ts
238
- import { replaceFiles } from '@nx/vite/plugins/rollup-replace-files.plugin';
239
- import { UserConfig, mergeConfig } from 'vite';
240
-
241
- import type { StorybookConfig } from '@analogjs/storybook-angular';
242
-
243
- const config: StorybookConfig = {
244
- // ... other config, addons, etc.
245
- async viteFinal(config: UserConfig) {
246
- return mergeConfig(config, {
247
- plugins: [
248
- replaceFiles([
249
- {
250
- replace: './src/one.ts',
251
- with: './src/two.ts',
252
- },
253
- ]),
254
- ],
255
- });
256
- },
257
- };
258
-
259
- export default config;
260
- ```
261
-
262
- Adding the replacement files to `files` array in the `tsconfig.app.json` may also be necessary.
263
-
264
- ```json
265
- {
266
- "extends": "./tsconfig.json",
267
- // other config
268
- "files": ["src/main.ts", "src/main.server.ts", "src/two.ts"]
269
- }
270
- ```
package/src/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/storybook-angular/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAYL,iBAAiB,EACjB,cAAc,EACd,yBAAyB,EACzB,cAAc,EACd,qBAAqB,GACtB,MAAM,oBAAoB,CAAC"}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=standalone-options.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"standalone-options.js","sourceRoot":"","sources":["../../../../../../packages/storybook-angular/src/lib/utils/standalone-options.ts"],"names":[],"mappings":""}
package/src/types.js DELETED
@@ -1 +0,0 @@
1
- //# sourceMappingURL=types.js.map
package/src/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../packages/storybook-angular/src/types.ts"],"names":[],"mappings":""}