@analogjs/storybook-angular 2.0.0-alpha.9 → 2.0.0-beta.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/README.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  Integration package for Storybook using Angular & Vite.
4
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
+
5
8
  ## Setup
6
9
 
7
10
  If you don't have Storybook setup already, run the following command to initialize Storybook for your project:
@@ -22,33 +25,7 @@ npm install @analogjs/storybook-angular --save-dev
22
25
 
23
26
  ## Configuring Storybook
24
27
 
25
- Add the `zone.js` import to the top of the `.storybook/preview.ts` file.
26
-
27
- ```ts
28
- import 'zone.js';
29
- import { applicationConfig, type Preview } from '@storybook/angular';
30
- import { provideNoopAnimations } from '@angular/platform-browser/animations';
31
-
32
- const preview: Preview = {
33
- decorators: [
34
- applicationConfig({
35
- providers: [provideNoopAnimations()],
36
- }),
37
- ],
38
- parameters: {
39
- controls: {
40
- matchers: {
41
- color: /(background|color)$/i,
42
- date: /Date$/i,
43
- },
44
- },
45
- },
46
- };
47
-
48
- export default preview;
49
- ```
50
-
51
- Next, update the `.storybook/main.ts` file to use the `StorybookConfig`. Also update the `framework` to use the `@analogjs/storybook-angular` package.
28
+ Update the `.storybook/main.ts` file to use the `StorybookConfig` type. Also update the `framework` to use the `@analogjs/storybook-angular` package.
52
29
 
53
30
  ```ts
54
31
  import { StorybookConfig } from '@analogjs/storybook-angular';
@@ -60,11 +37,13 @@ const config: StorybookConfig = {
60
37
  options: {},
61
38
  },
62
39
  };
40
+
41
+ export default config;
63
42
  ```
64
43
 
65
44
  Remove the existing `webpackFinal` config function if present.
66
45
 
67
- Next, update the Storybook builders in the `angular.json` or `project.json`.
46
+ Next, update the Storybook targets in the `angular.json` or `project.json`
68
47
 
69
48
  ```json
70
49
  "storybook": {
@@ -77,7 +56,61 @@ Next, update the Storybook builders in the `angular.json` or `project.json`.
77
56
 
78
57
  Remove any `webpack` specific options and remove the `browserTarget` option.
79
58
 
80
- Add the `/storybook-static` folder to your `.gitignore` file.
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
+ ## Setting up Static Assets
93
+
94
+ Static assets are configured in the `.storybook/main.ts` file using the `staticDirs` array.
95
+
96
+ The example below shows how to add the `public` directory from `src/public` relative to the `.storybook/main.ts` file.
97
+
98
+ ```ts
99
+ import { StorybookConfig } from '@analogjs/storybook-angular';
100
+
101
+ const config: StorybookConfig = {
102
+ // other config, addons, etc.
103
+ framework: {
104
+ name: '@analogjs/storybook-angular',
105
+ options: {},
106
+ },
107
+ staticDirs: ['../public'],
108
+ };
109
+
110
+ export default config;
111
+ ```
112
+
113
+ See the [Storybook docs on images and assets](https://storybook.js.org/docs/configure/integration/images-and-assets) for more information.
81
114
 
82
115
  ## Running Storybook
83
116
 
@@ -95,26 +128,6 @@ Run the command for building the storybook.
95
128
  npm run build-storybook
96
129
  ```
97
130
 
98
- ## Using shared CSS paths
99
-
100
- To load shared CSS paths, configure them using `loadPaths` css option in the `viteFinal` function.
101
-
102
- ```ts
103
- import path from 'node:path';
104
-
105
- async viteFinal() {
106
- return {
107
- css: {
108
- preprocessorOptions: {
109
- scss: {
110
- loadPaths: `${path.resolve(__dirname, '../src/lib/styles')}`
111
- }
112
- }
113
- }
114
- };
115
- }
116
- ```
117
-
118
131
  ## Using TypeScript Config Path Aliases
119
132
 
120
133
  If you are using `paths` in your `tsconfig.json`, support for those aliases can be added to the `vite.config.ts`.
@@ -127,32 +140,85 @@ First, install the `vite-tsconfig-paths` package.
127
140
  npm install vite-tsconfig-paths --save-dev
128
141
  ```
129
142
 
130
- Next, add the plugin to the `plugins` array.
143
+ Next, add the plugin to the `plugins` array in the `.storybook/main.ts`.
131
144
 
132
145
  ```ts
133
146
  import viteTsConfigPaths from 'vite-tsconfig-paths';
147
+ import { UserConfig, mergeConfig } from 'vite';
134
148
 
135
- async viteFinal() {
136
- return {
137
- plugins: [
138
- viteTsConfigPaths()
139
- ],
140
- };
141
- }
149
+ import type { StorybookConfig } from '@analogjs/storybook-angular';
150
+
151
+ const config: StorybookConfig = {
152
+ // ... other config, addons, etc.
153
+ async viteFinal(config: UserConfig) {
154
+ return mergeConfig(config, {
155
+ plugins: [viteTsConfigPaths()],
156
+ });
157
+ },
158
+ };
159
+
160
+ export default config;
142
161
  ```
143
162
 
144
163
  ### With Nx
145
164
 
146
- For Nx workspaces, import and use the `nxViteTsPaths` plugin from the `@nx/vite` package.
165
+ 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`.
147
166
 
148
167
  ```ts
149
168
  import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
169
+ import { UserConfig, mergeConfig } from 'vite';
170
+
171
+ import type { StorybookConfig } from '@analogjs/storybook-angular';
172
+
173
+ const config: StorybookConfig = {
174
+ // ... other config, addons, etc.
175
+ async viteFinal(config: UserConfig) {
176
+ return mergeConfig(config, {
177
+ plugins: [nxViteTsPaths()],
178
+ });
179
+ },
180
+ };
181
+
182
+ export default config;
183
+ ```
184
+
185
+ ## Using File Replacements
186
+
187
+ You can also use the `replaceFiles()` plugin from Nx to replace files during your build.
188
+
189
+ Import the plugin and set it up:
190
+
191
+ ```ts
192
+ import { replaceFiles } from '@nx/vite/plugins/rollup-replace-files.plugin';
193
+ import { UserConfig, mergeConfig } from 'vite';
150
194
 
151
- async viteFinal(config: UserConfig) {
152
- return {
153
- plugins: [
154
- nxViteTsPaths()
155
- ],
156
- };
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: [
202
+ replaceFiles([
203
+ {
204
+ replace: './src/one.ts',
205
+ with: './src/two.ts',
206
+ },
207
+ ]),
208
+ ],
209
+ });
210
+ },
211
+ };
212
+
213
+ export default config;
214
+ ```
215
+
216
+ Adding the replacement files to `files` array in the `tsconfig.app.json` may also be necessary.
217
+
218
+ ```json
219
+ {
220
+ "extends": "./tsconfig.json",
221
+ // other config
222
+ "files": ["src/main.ts", "src/main.server.ts", "src/two.ts"]
157
223
  }
158
224
  ```
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@analogjs/storybook-angular",
3
- "version": "2.0.0-alpha.9",
3
+ "version": "2.0.0-beta.10",
4
4
  "description": "Storybook Integration for Angular & Vite",
5
+ "type": "module",
5
6
  "keywords": [
6
7
  "storybook",
7
8
  "angular",
@@ -27,19 +28,24 @@
27
28
  "import": "./src/index.js",
28
29
  "require": "./src/index.js"
29
30
  },
30
- "./preset": "./src/preset.js",
31
+ "./preset": "./preset.mjs",
31
32
  "./package.json": "./package.json",
32
- "./*": "./src/*"
33
+ "./*": "./src/*",
34
+ "./testing": {
35
+ "types": "./src/lib/testing.d.ts",
36
+ "import": "./src/lib/testing.js",
37
+ "require": "./src/lib/testing.js"
38
+ }
33
39
  },
34
40
  "main": "src/index.js",
35
41
  "dependencies": {
36
- "@storybook/builder-vite": ">=8.6.0 || next"
42
+ "@storybook/builder-vite": ">=8.6.0 || ^9.0.0"
37
43
  },
38
44
  "peerDependencies": {
39
- "@storybook/angular": ">=8.6.0 || next",
40
- "@analogjs/vite-plugin-angular": ">=1.12.0 < 2.0.0 || beta",
41
- "storybook": ">=8.6.0 || next",
42
- "vite": "^5.0.0 || ^6.0.0"
45
+ "@storybook/angular": ">=8.6.0 || ^9.0.0",
46
+ "@analogjs/vite-plugin-angular": "*",
47
+ "storybook": ">=8.6.0 || ^9.0.0",
48
+ "vite": "^5.0.0 || ^6.0.0 || ^7.0.0"
43
49
  },
44
50
  "engines": {
45
51
  "node": ">=18.0.0"
@@ -59,6 +65,10 @@
59
65
  "@analogjs/vitest-angular"
60
66
  ]
61
67
  },
68
+ "publishConfig": {
69
+ "access": "public",
70
+ "provenance": true
71
+ },
62
72
  "types": "./src/index.d.ts",
63
- "type": "commonjs"
73
+ "module": "./src/index.js"
64
74
  }
@@ -1,5 +1,5 @@
1
1
  import { PresetProperty } from 'storybook/internal/types';
2
- import { StorybookConfig } from './types';
2
+ import { StorybookConfig } from './src/types';
3
3
  export declare const core: PresetProperty<'core'>;
4
4
  export declare const viteFinal: NonNullable<StorybookConfig['viteFinal']>;
5
5
  export { addons, previewAnnotations } from '@storybook/angular/dist/preset.js';
package/preset.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preset.js","sourceRoot":"","sources":["../../../../packages/storybook-angular/src/preset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAKvE,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,eAAe,GAAG,CAAmB,KAAQ,EAAK,EAAE,CACxD,OAAO,CAAC,OAA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,CAAC,OAAO,EAAE,UAAU;oBAC/B,CAAC,CAAC,KAAK;gBACX,QAAQ,EAAE,OAAO,EAAE,QAAQ,IAAI,4BAA4B;aAC5D,CAAC;SACH;QACD,MAAM,EAAE;YACN,yBAAyB,EAAE,IAAI,CAAC,SAAS,CAAC;gBACxC,oBAAoB,EAClB,CAAC,CAAC,OAAO,EAAE,qBAAqB,EAAE,oBAAoB;aACzD,CAAC;SACH;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC"}
package/preset.mjs ADDED
@@ -0,0 +1,149 @@
1
+ import { dirname, join, resolve } from 'node:path';
2
+ import { createRequire } from 'node:module';
3
+ import { core as PresetCore } from '@storybook/angular/dist/preset.js';
4
+ const require = createRequire(import.meta.url);
5
+ const getAbsolutePath = (input) =>
6
+ dirname(require.resolve(join(input, 'package.json')));
7
+ export const core = async (config, options) => {
8
+ const presetCore = PresetCore(config, options);
9
+ return {
10
+ ...presetCore,
11
+ builder: {
12
+ name: getAbsolutePath('@storybook/builder-vite'),
13
+ options: { ...presetCore.options },
14
+ },
15
+ };
16
+ };
17
+ export const viteFinal = async (config, options) => {
18
+ // Remove any loaded analogjs plugins from a vite.config.(m)ts file
19
+ config.plugins = config.plugins
20
+ .flat()
21
+ .filter((plugin) => !plugin.name.includes('analogjs'));
22
+
23
+ // Merge custom configuration into the default config
24
+ const { mergeConfig, normalizePath } = await import('vite');
25
+ const { default: angular } = await import('@analogjs/vite-plugin-angular');
26
+ // @ts-ignore
27
+ const framework = await options.presets.apply('framework');
28
+ return mergeConfig(config, {
29
+ // Add dependencies to pre-optimization
30
+ optimizeDeps: {
31
+ include: [
32
+ '@storybook/angular/dist/client/index.js',
33
+ '@analogjs/storybook-angular',
34
+ '@angular/compiler',
35
+ '@angular/platform-browser',
36
+ '@angular/platform-browser/animations',
37
+ 'tslib',
38
+ ...(options?.angularBuilderOptions?.experimentalZoneless
39
+ ? []
40
+ : ['zone.js']),
41
+ ],
42
+ },
43
+ plugins: [
44
+ angular({
45
+ jit:
46
+ typeof framework.options?.jit !== 'undefined'
47
+ ? framework.options?.jit
48
+ : true,
49
+ liveReload:
50
+ typeof framework.options?.liveReload !== 'undefined'
51
+ ? framework.options?.liveReload
52
+ : false,
53
+ tsconfig: options?.tsConfig ?? './.storybook/tsconfig.json',
54
+ inlineStylesExtension:
55
+ typeof framework.options?.inlineStylesExtension !== 'undefined'
56
+ ? framework.options?.inlineStylesExtension
57
+ : 'css',
58
+ }),
59
+ angularOptionsPlugin(options, { normalizePath }),
60
+ storybookEsbuildPlugin(),
61
+ ],
62
+ define: {
63
+ STORYBOOK_ANGULAR_OPTIONS: JSON.stringify({
64
+ experimentalZoneless:
65
+ !!options?.angularBuilderOptions?.experimentalZoneless,
66
+ }),
67
+ },
68
+ });
69
+ };
70
+
71
+ function angularOptionsPlugin(options, { normalizePath }) {
72
+ return {
73
+ name: 'analogjs-storybook-options-plugin',
74
+ config() {
75
+ const loadPaths =
76
+ options?.angularBuilderOptions?.stylePreprocessorOptions?.loadPaths;
77
+ const sassOptions =
78
+ options?.angularBuilderOptions?.stylePreprocessorOptions?.sass;
79
+
80
+ if (Array.isArray(loadPaths)) {
81
+ return {
82
+ css: {
83
+ preprocessorOptions: {
84
+ scss: {
85
+ ...sassOptions,
86
+ loadPaths: loadPaths.map(
87
+ (loadPath) =>
88
+ `${resolve(options.angularBuilderContext.workspaceRoot, loadPath)}`,
89
+ ),
90
+ },
91
+ },
92
+ },
93
+ };
94
+ }
95
+
96
+ return;
97
+ },
98
+ transform(code, id) {
99
+ if (
100
+ normalizePath(id).endsWith(
101
+ normalizePath(`${options.configDir}/preview.ts`),
102
+ )
103
+ ) {
104
+ const imports = [];
105
+ const styles = options?.angularBuilderOptions?.styles;
106
+
107
+ if (Array.isArray(styles)) {
108
+ styles.forEach((style) => {
109
+ imports.push(style);
110
+ });
111
+ }
112
+
113
+ const zoneless = options?.angularBuilderOptions?.experimentalZoneless;
114
+
115
+ if (!zoneless) {
116
+ imports.push('zone.js');
117
+ }
118
+
119
+ return {
120
+ code: `
121
+ ${imports.map((extraImport) => `import '${extraImport}';`).join('\n')}
122
+ ${code}
123
+ `,
124
+ };
125
+ }
126
+
127
+ return;
128
+ },
129
+ };
130
+ }
131
+
132
+ function storybookEsbuildPlugin() {
133
+ return {
134
+ name: 'analogjs-storybook-esbuild-config',
135
+ apply: 'build',
136
+ config() {
137
+ return {
138
+ esbuild: {
139
+ // Don't mangle class names during the build
140
+ // This fixes display of compodoc argtypes
141
+ keepNames: true,
142
+ },
143
+ };
144
+ },
145
+ };
146
+ }
147
+
148
+ export { addons, previewAnnotations } from '@storybook/angular/dist/preset.js';
149
+ //# sourceMappingURL=preset.js.map
package/src/index.js CHANGED
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./types"), exports);
5
- tslib_1.__exportStar(require("@storybook/angular/dist/client/index.js"), exports);
1
+ export * from './types';
2
+ export * from '@storybook/angular/dist/client/index.js';
6
3
  //# sourceMappingURL=index.js.map
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/storybook-angular/src/index.ts"],"names":[],"mappings":";;;AAAA,kDAAwB;AACxB,kFAAwD"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/storybook-angular/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,yCAAyC,CAAC"}
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const index_js_1 = tslib_1.__importDefault(require("@storybook/angular/dist/builders/build-storybook/index.js"));
5
- exports.default = index_js_1.default;
1
+ import BuildStorybookBuilder from '@storybook/angular/dist/builders/build-storybook/index.js';
2
+ export default BuildStorybookBuilder;
6
3
  //# 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,iHAA8F;AAE9F,kBAAe,kBAAqB,CAAC"}
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,2DAA2D,CAAC;AAE9F,eAAe,qBAAqB,CAAC"}
@@ -69,6 +69,56 @@
69
69
  "type": "boolean",
70
70
  "description": "Experimental: Use zoneless change detection.",
71
71
  "default": false
72
+ },
73
+ "styles": {
74
+ "type": "array",
75
+ "description": "Global styles to be included in the build.",
76
+ "default": [],
77
+ "items": {
78
+ "type": "string"
79
+ }
80
+ },
81
+ "stylePreprocessorOptions": {
82
+ "description": "Options to pass to style preprocessors.",
83
+ "type": "object",
84
+ "properties": {
85
+ "loadPaths": {
86
+ "description": "Paths to include.",
87
+ "type": "array",
88
+ "items": {
89
+ "type": "string"
90
+ }
91
+ },
92
+ "sass": {
93
+ "description": "Options to pass to the sass preprocessor.",
94
+ "type": "object",
95
+ "properties": {
96
+ "fatalDeprecations": {
97
+ "description": "A set of deprecations to treat as fatal. If a deprecation warning of any provided type is encountered during compilation, the compiler will error instead. If a Version is provided, then all deprecations that were active in that compiler version will be treated as fatal.",
98
+ "type": "array",
99
+ "items": {
100
+ "type": "string"
101
+ }
102
+ },
103
+ "silenceDeprecations": {
104
+ "description": " A set of active deprecations to ignore. If a deprecation warning of any provided type is encountered during compilation, the compiler will ignore it instead.",
105
+ "type": "array",
106
+ "items": {
107
+ "type": "string"
108
+ }
109
+ },
110
+ "futureDeprecations": {
111
+ "description": "A set of future deprecations to opt into early. Future deprecations passed here will be treated as active by the compiler, emitting warnings as necessary.",
112
+ "type": "array",
113
+ "items": {
114
+ "type": "string"
115
+ }
116
+ }
117
+ },
118
+ "additionalProperties": false
119
+ }
120
+ },
121
+ "additionalProperties": false
72
122
  }
73
123
  },
74
124
  "additionalProperties": false
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "builders": {
3
3
  "build-storybook": {
4
- "implementation": "./build-storybook/build-storybook",
4
+ "implementation": "./build-storybook/build-storybook.js",
5
5
  "schema": "./build-storybook/schema.json",
6
6
  "description": "Build storybook"
7
7
  },
8
8
  "start-storybook": {
9
- "implementation": "./start-storybook/start-storybook",
9
+ "implementation": "./start-storybook/start-storybook.js",
10
10
  "schema": "./start-storybook/schema.json",
11
11
  "description": "Start storybook"
12
- }
12
+ },
13
+ "test-storybook": "@analogjs/vitest-angular:test"
13
14
  }
14
15
  }
@@ -105,6 +105,56 @@
105
105
  "type": "boolean",
106
106
  "description": "Experimental: Use zoneless change detection.",
107
107
  "default": false
108
+ },
109
+ "styles": {
110
+ "type": "array",
111
+ "description": "Global styles to be included in the build.",
112
+ "default": [],
113
+ "items": {
114
+ "type": "string"
115
+ }
116
+ },
117
+ "stylePreprocessorOptions": {
118
+ "description": "Options to pass to style preprocessors.",
119
+ "type": "object",
120
+ "properties": {
121
+ "loadPaths": {
122
+ "description": "Paths to include.",
123
+ "type": "array",
124
+ "items": {
125
+ "type": "string"
126
+ }
127
+ },
128
+ "sass": {
129
+ "description": "Options to pass to the sass preprocessor.",
130
+ "type": "object",
131
+ "properties": {
132
+ "fatalDeprecations": {
133
+ "description": "A set of deprecations to treat as fatal. If a deprecation warning of any provided type is encountered during compilation, the compiler will error instead. If a Version is provided, then all deprecations that were active in that compiler version will be treated as fatal.",
134
+ "type": "array",
135
+ "items": {
136
+ "type": "string"
137
+ }
138
+ },
139
+ "silenceDeprecations": {
140
+ "description": " A set of active deprecations to ignore. If a deprecation warning of any provided type is encountered during compilation, the compiler will ignore it instead.",
141
+ "type": "array",
142
+ "items": {
143
+ "type": "string"
144
+ }
145
+ },
146
+ "futureDeprecations": {
147
+ "description": "A set of future deprecations to opt into early. Future deprecations passed here will be treated as active by the compiler, emitting warnings as necessary.",
148
+ "type": "array",
149
+ "items": {
150
+ "type": "string"
151
+ }
152
+ }
153
+ },
154
+ "additionalProperties": false
155
+ }
156
+ },
157
+ "additionalProperties": false
108
158
  }
109
159
  },
110
160
  "additionalProperties": false
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const index_js_1 = tslib_1.__importDefault(require("@storybook/angular/dist/builders/start-storybook/index.js"));
5
- exports.default = index_js_1.default;
1
+ import StartStorybookBuilder from '@storybook/angular/dist/builders/start-storybook/index.js';
2
+ export default StartStorybookBuilder;
6
3
  //# 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,iHAA8F;AAE9F,kBAAe,kBAAqB,CAAC"}
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,2DAA2D,CAAC;AAE9F,eAAe,qBAAqB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { AngularRenderer } from '@storybook/angular';
2
+ import { NamedOrDefaultProjectAnnotations, NormalizedProjectAnnotations, RenderContext } from 'storybook/internal/types';
3
+ export declare const render: any;
4
+ export declare function renderToCanvas(context: RenderContext<AngularRenderer>, element: HTMLElement): Promise<void>;
5
+ export declare function setProjectAnnotations(projectAnnotations: NamedOrDefaultProjectAnnotations<any> | NamedOrDefaultProjectAnnotations<any>[]): NormalizedProjectAnnotations<AngularRenderer>;
@@ -0,0 +1,20 @@
1
+ import { setProjectAnnotations as originalSetProjectAnnotations } from '@storybook/angular/dist/client/index.mjs';
2
+ import * as configAnnotations from '@storybook/angular/dist/client/config.mjs';
3
+ export const render = configAnnotations.render;
4
+ export async function renderToCanvas(context, element) {
5
+ element.id = context.id;
6
+ await configAnnotations.renderToCanvas(context, element);
7
+ }
8
+ const renderAnnotations = {
9
+ render,
10
+ renderToCanvas,
11
+ };
12
+ export function setProjectAnnotations(projectAnnotations) {
13
+ return originalSetProjectAnnotations([
14
+ renderAnnotations,
15
+ ...(Array.isArray(projectAnnotations)
16
+ ? projectAnnotations
17
+ : [projectAnnotations]),
18
+ ]);
19
+ }
20
+ //# sourceMappingURL=testing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing.js","sourceRoot":"","sources":["../../../../../packages/storybook-angular/src/lib/testing.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,IAAI,6BAA6B,EAAE,MAAM,0CAA0C,CAAC;AAMlH,OAAO,KAAK,iBAAiB,MAAM,2CAA2C,CAAC;AAE/E,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,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=standalone-options.js.map
package/src/types.d.ts CHANGED
@@ -7,6 +7,7 @@ export type FrameworkOptions = {
7
7
  builder?: BuilderOptions;
8
8
  jit?: boolean;
9
9
  liveReload?: boolean;
10
+ inlineStylesExtension?: string;
10
11
  };
11
12
  type StorybookConfigFramework = {
12
13
  framework: FrameworkName | {
package/src/types.js CHANGED
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
3
2
  //# sourceMappingURL=types.js.map
package/src/preset.js DELETED
@@ -1,93 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.previewAnnotations = exports.addons = exports.viteFinal = exports.core = void 0;
37
- const node_path_1 = require("node:path");
38
- const preset_js_1 = require("@storybook/angular/dist/preset.js");
39
- const getAbsolutePath = (input) => (0, node_path_1.dirname)(require.resolve((0, node_path_1.join)(input, 'package.json')));
40
- const core = async (config, options) => {
41
- const presetCore = preset_js_1.core(config, options);
42
- return {
43
- ...presetCore,
44
- builder: {
45
- name: getAbsolutePath('@storybook/builder-vite'),
46
- options: { ...presetCore.options },
47
- },
48
- };
49
- };
50
- exports.core = core;
51
- const viteFinal = async (config, options) => {
52
- // Merge custom configuration into the default config
53
- const { mergeConfig } = await Promise.resolve().then(() => __importStar(require('vite')));
54
- const { default: angular } = await Promise.resolve().then(() => __importStar(require('@analogjs/vite-plugin-angular')));
55
- // @ts-ignore
56
- const framework = await options.presets.apply('framework');
57
- return mergeConfig(config, {
58
- // Add dependencies to pre-optimization
59
- optimizeDeps: {
60
- include: [
61
- '@storybook/angular/dist/client/index.js',
62
- '@analogjs/storybook-angular',
63
- '@angular/compiler',
64
- '@angular/platform-browser/animations',
65
- '@storybook/addon-docs/angular',
66
- 'react/jsx-dev-runtime',
67
- 'tslib',
68
- '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: options?.tsConfig ?? './.storybook/tsconfig.json',
80
- }),
81
- ],
82
- define: {
83
- STORYBOOK_ANGULAR_OPTIONS: JSON.stringify({
84
- experimentalZoneless: !!options?.angularBuilderOptions?.experimentalZoneless,
85
- }),
86
- },
87
- });
88
- };
89
- exports.viteFinal = viteFinal;
90
- var preset_js_2 = require("@storybook/angular/dist/preset.js");
91
- Object.defineProperty(exports, "addons", { enumerable: true, get: function () { return preset_js_2.addons; } });
92
- Object.defineProperty(exports, "previewAnnotations", { enumerable: true, get: function () { return preset_js_2.previewAnnotations; } });
93
- //# sourceMappingURL=preset.js.map
package/src/preset.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":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,CAAC,OAAO,EAAE,GAAG,KAAK,WAAW;oBAC3C,CAAC,CAAC,SAAS,CAAC,OAAO,EAAE,GAAG;oBACxB,CAAC,CAAC,IAAI;gBACV,UAAU,EACR,OAAO,SAAS,CAAC,OAAO,EAAE,UAAU,KAAK,WAAW;oBAClD,CAAC,CAAC,SAAS,CAAC,OAAO,EAAE,UAAU;oBAC/B,CAAC,CAAC,KAAK;gBACX,QAAQ,EAAE,OAAO,EAAE,QAAQ,IAAI,4BAA4B;aAC5D,CAAC;SACH;QACD,MAAM,EAAE;YACN,yBAAyB,EAAE,IAAI,CAAC,SAAS,CAAC;gBACxC,oBAAoB,EAClB,CAAC,CAAC,OAAO,EAAE,qBAAqB,EAAE,oBAAoB;aACzD,CAAC;SACH;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AA7CW,QAAA,SAAS,aA6CpB;AAEF,+DAA+E;AAAtE,mGAAA,MAAM,OAAA;AAAE,+GAAA,kBAAkB,OAAA"}
@@ -1 +0,0 @@
1
- import '@analogjs/vite-plugin-angular/setup-vitest';
package/src/test-setup.js DELETED
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- require("@analogjs/vite-plugin-angular/setup-vitest");
4
- const testing_1 = require("@angular/core/testing");
5
- const testing_2 = require("@angular/platform-browser-dynamic/testing");
6
- (0, testing_1.getTestBed)().initTestEnvironment(testing_2.BrowserDynamicTestingModule, (0, testing_2.platformBrowserDynamicTesting)());
7
- //# sourceMappingURL=test-setup.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-setup.js","sourceRoot":"","sources":["../../../../packages/storybook-angular/src/test-setup.ts"],"names":[],"mappings":";;AAAA,sDAAoD;AACpD,mDAAmD;AACnD,uEAGmD;AAEnD,IAAA,oBAAU,GAAE,CAAC,mBAAmB,CAC9B,qCAA2B,EAC3B,IAAA,uCAA6B,GAAE,CAChC,CAAC"}