@storybook/react-webpack5 7.1.0-alpha.3 → 7.1.0-alpha.31

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,27 @@
1
- export { F as FrameworkOptions, S as StorybookConfig } from './types-6a41b796.js';
2
- import '@storybook/preset-react-webpack';
3
- import '@storybook/builder-webpack5';
1
+ import { ReactOptions, StorybookConfig as StorybookConfig$1, TypescriptOptions as TypescriptOptions$1 } from '@storybook/preset-react-webpack';
2
+ import { BuilderOptions, StorybookConfigWebpack, TypescriptOptions } from '@storybook/builder-webpack5';
3
+
4
+ type FrameworkName = '@storybook/react-webpack5';
5
+ type BuilderName = '@storybook/builder-webpack5';
6
+ type FrameworkOptions = ReactOptions & {
7
+ builder?: BuilderOptions;
8
+ };
9
+ type StorybookConfigFramework = {
10
+ framework: FrameworkName | {
11
+ name: FrameworkName;
12
+ options: FrameworkOptions;
13
+ };
14
+ core?: StorybookConfig$1['core'] & {
15
+ builder?: BuilderName | {
16
+ name: BuilderName;
17
+ options: BuilderOptions;
18
+ };
19
+ };
20
+ typescript?: Partial<TypescriptOptions & TypescriptOptions$1> & StorybookConfig$1['typescript'];
21
+ };
22
+ /**
23
+ * The interface for Storybook configuration in `main.ts` files.
24
+ */
25
+ type StorybookConfig = Omit<StorybookConfig$1, keyof StorybookConfigWebpack | keyof StorybookConfigFramework> & StorybookConfigWebpack & StorybookConfigFramework;
26
+
27
+ export { FrameworkOptions, StorybookConfig };
package/dist/index.mjs CHANGED
@@ -0,0 +1 @@
1
+
package/dist/preset.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { FileSystemCache } from 'file-system-cache';
2
2
  import { TransformOptions } from '@babel/core';
3
3
  import { Server } from 'http';
4
- import { S as StorybookConfig$1 } from './types-6a41b796.js';
4
+ import { StorybookConfig as StorybookConfig$1 } from './index.js';
5
5
  import '@storybook/preset-react-webpack';
6
6
  import '@storybook/builder-webpack5';
7
7
 
@@ -19,7 +19,40 @@ type Primitive =
19
19
  | symbol
20
20
  | bigint;
21
21
 
22
+ /**
23
+ Matches a JSON object.
24
+
25
+ This type can be useful to enforce some input to be JSON-compatible or as a super-type to be extended from. Don't use this as a direct return type as the user would have to double-cast it: `jsonObject as unknown as CustomResponse`. Instead, you could extend your CustomResponse type from it to ensure your type only uses JSON-compatible types: `interface CustomResponse extends JsonObject { … }`.
26
+
27
+ @category JSON
28
+ */
29
+ type JsonObject = {[Key in string]: JsonValue} & {[Key in string]?: JsonValue | undefined};
30
+
31
+ /**
32
+ Matches a JSON array.
33
+
34
+ @category JSON
35
+ */
36
+ type JsonArray = JsonValue[] | readonly JsonValue[];
37
+
38
+ /**
39
+ Matches any valid JSON primitive value.
40
+
41
+ @category JSON
42
+ */
43
+ type JsonPrimitive = string | number | boolean | null;
44
+
45
+ /**
46
+ Matches any valid JSON value.
47
+
48
+ @see `Jsonify` if you need to transform a type to one that is assignable to `JsonValue`.
49
+
50
+ @category JSON
51
+ */
52
+ type JsonValue = JsonPrimitive | JsonObject | JsonArray;
53
+
22
54
  declare global {
55
+ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
23
56
  interface SymbolConstructor {
24
57
  readonly observable: symbol;
25
58
  }
@@ -85,8 +118,8 @@ declare namespace PackageJson$1 {
85
118
  email?: string;
86
119
  };
87
120
 
88
- export interface DirectoryLocations {
89
- [directoryType: string]: unknown;
121
+ export type DirectoryLocations = {
122
+ [directoryType: string]: JsonValue | undefined;
90
123
 
91
124
  /**
92
125
  Location for executable scripts. Sugar to generate entries in the `bin` property by walking the folder.
@@ -117,7 +150,7 @@ declare namespace PackageJson$1 {
117
150
  Location for test files.
118
151
  */
119
152
  test?: string;
120
- }
153
+ };
121
154
 
122
155
  export type Scripts = {
123
156
  /**
@@ -267,22 +300,11 @@ declare namespace PackageJson$1 {
267
300
  export type Dependency = Partial<Record<string, string>>;
268
301
 
269
302
  /**
270
- Conditions which provide a way to resolve a package entry point based on the environment.
303
+ A mapping of conditions and the paths to which they resolve.
271
304
  */
272
- export type ExportCondition = LiteralUnion<
273
- | 'import'
274
- | 'require'
275
- | 'node'
276
- | 'node-addons'
277
- | 'deno'
278
- | 'browser'
279
- | 'electron'
280
- | 'react-native'
281
- | 'default',
282
- string
283
- >;
284
-
285
- type ExportConditions = {[condition in ExportCondition]: Exports};
305
+ type ExportConditions = { // eslint-disable-line @typescript-eslint/consistent-indexed-object-style
306
+ [condition: string]: Exports;
307
+ };
286
308
 
287
309
  /**
288
310
  Entry points of a module, optionally with conditions and subpath exports.
@@ -291,16 +313,16 @@ declare namespace PackageJson$1 {
291
313
  | null
292
314
  | string
293
315
  | Array<string | ExportConditions>
294
- | ExportConditions
295
- | {[path: string]: Exports}; // eslint-disable-line @typescript-eslint/consistent-indexed-object-style
316
+ | ExportConditions;
296
317
 
297
318
  /**
298
- Import map entries of a module, optionally with conditions.
319
+ Import map entries of a module, optionally with conditions and subpath imports.
299
320
  */
300
321
  export type Imports = { // eslint-disable-line @typescript-eslint/consistent-indexed-object-style
301
- [key: string]: string | {[key in ExportCondition]: Exports};
322
+ [key: `#${string}`]: Exports;
302
323
  };
303
324
 
325
+ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions
304
326
  export interface NonStandardEntryPoints {
305
327
  /**
306
328
  An ECMAScript module ID that is the primary entry point to the program.
@@ -333,7 +355,7 @@ declare namespace PackageJson$1 {
333
355
  sideEffects?: boolean | string[];
334
356
  }
335
357
 
336
- export interface TypeScriptConfiguration {
358
+ export type TypeScriptConfiguration = {
337
359
  /**
338
360
  Location of the bundled TypeScript declaration file.
339
361
  */
@@ -348,12 +370,12 @@ declare namespace PackageJson$1 {
348
370
  Location of the bundled TypeScript declaration file. Alias of `types`.
349
371
  */
350
372
  typings?: string;
351
- }
373
+ };
352
374
 
353
375
  /**
354
- An alternative configuration for Yarn workspaces.
376
+ An alternative configuration for workspaces.
355
377
  */
356
- export interface WorkspaceConfig {
378
+ export type WorkspaceConfig = {
357
379
  /**
358
380
  An array of workspace pattern strings which contain the workspace packages.
359
381
  */
@@ -362,10 +384,11 @@ declare namespace PackageJson$1 {
362
384
  /**
363
385
  Designed to solve the problem of packages which break when their `node_modules` are moved to the root workspace directory - a process known as hoisting. For these packages, both within your workspace, and also some that have been installed via `node_modules`, it is important to have a mechanism for preventing the default Yarn workspace behavior. By adding workspace pattern strings here, Yarn will resume non-workspace behavior for any package which matches the defined patterns.
364
386
 
365
- [Read more](https://classic.yarnpkg.com/blog/2018/02/15/nohoist/)
387
+ [Supported](https://classic.yarnpkg.com/blog/2018/02/15/nohoist/) by Yarn.
388
+ [Not supported](https://github.com/npm/rfcs/issues/287) by npm.
366
389
  */
367
390
  nohoist?: WorkspacePattern[];
368
- }
391
+ };
369
392
 
370
393
  /**
371
394
  A workspace pattern points to a directory or group of directories which contain packages that should be included in the workspace installation process.
@@ -378,16 +401,7 @@ declare namespace PackageJson$1 {
378
401
  */
379
402
  type WorkspacePattern = string;
380
403
 
381
- export interface YarnConfiguration {
382
- /**
383
- Used to configure [Yarn workspaces](https://classic.yarnpkg.com/docs/workspaces/).
384
-
385
- Workspaces allow you to manage multiple packages within the same repository in such a way that you only need to run `yarn install` once to install all of them in a single pass.
386
-
387
- Please note that the top-level `private` property of `package.json` **must** be set to `true` in order to use workspaces.
388
- */
389
- workspaces?: WorkspacePattern[] | WorkspaceConfig;
390
-
404
+ export type YarnConfiguration = {
391
405
  /**
392
406
  If your package only allows one version of a given dependency, and you’d like to enforce the same behavior as `yarn install --flat` on the command-line, set this to `true`.
393
407
 
@@ -399,18 +413,19 @@ declare namespace PackageJson$1 {
399
413
  Selective version resolutions. Allows the definition of custom package versions inside dependencies without manual edits in the `yarn.lock` file.
400
414
  */
401
415
  resolutions?: Dependency;
402
- }
416
+ };
403
417
 
404
- export interface JSPMConfiguration {
418
+ export type JSPMConfiguration = {
405
419
  /**
406
420
  JSPM configuration.
407
421
  */
408
422
  jspm?: PackageJson$1;
409
- }
423
+ };
410
424
 
411
425
  /**
412
426
  Type for [npm's `package.json` file](https://docs.npmjs.com/creating-a-package-json-file). Containing standard npm properties.
413
427
  */
428
+ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions
414
429
  export interface PackageJsonStandard {
415
430
  /**
416
431
  The name of the package.
@@ -540,7 +555,7 @@ declare namespace PackageJson$1 {
540
555
  /**
541
556
  Is used to set configuration parameters used in package scripts that persist across upgrades.
542
557
  */
543
- config?: Record<string, unknown>;
558
+ config?: JsonObject;
544
559
 
545
560
  /**
546
561
  The dependencies of the package.
@@ -581,7 +596,7 @@ declare namespace PackageJson$1 {
581
596
  Engines that this package runs on.
582
597
  */
583
598
  engines?: {
584
- [EngineName in 'npm' | 'node' | string]?: string;
599
+ [EngineName in 'npm' | 'node' | string]?: string; // eslint-disable-line @typescript-eslint/no-redundant-type-constituents
585
600
  };
586
601
 
587
602
  /**
@@ -680,13 +695,41 @@ declare namespace PackageJson$1 {
680
695
  */
681
696
  url: string;
682
697
  };
698
+
699
+ /**
700
+ Used to configure [npm workspaces](https://docs.npmjs.com/cli/using-npm/workspaces) / [Yarn workspaces](https://classic.yarnpkg.com/docs/workspaces/).
701
+
702
+ Workspaces allow you to manage multiple packages within the same repository in such a way that you only need to run your install command once in order to install all of them in a single pass.
703
+
704
+ Please note that the top-level `private` property of `package.json` **must** be set to `true` in order to use workspaces.
705
+ */
706
+ workspaces?: WorkspacePattern[] | WorkspaceConfig;
683
707
  }
684
708
 
685
- export interface PublishConfig {
709
+ /**
710
+ Type for [`package.json` file used by the Node.js runtime](https://nodejs.org/api/packages.html#nodejs-packagejson-field-definitions).
711
+ */
712
+ export type NodeJsStandard = {
713
+ /**
714
+ Defines which package manager is expected to be used when working on the current project. It can set to any of the [supported package managers](https://nodejs.org/api/corepack.html#supported-package-managers), and will ensure that your teams use the exact same package manager versions without having to install anything else than Node.js.
715
+
716
+ __This field is currently experimental and needs to be opted-in; check the [Corepack](https://nodejs.org/api/corepack.html) page for details about the procedure.__
717
+
718
+ @example
719
+ ```json
720
+ {
721
+ "packageManager": "<package manager name>@<version>"
722
+ }
723
+ ```
724
+ */
725
+ packageManager?: string;
726
+ };
727
+
728
+ export type PublishConfig = {
686
729
  /**
687
730
  Additional, less common properties from the [npm docs on `publishConfig`](https://docs.npmjs.com/cli/v7/configuring-npm/package-json#publishconfig).
688
731
  */
689
- [additionalProperties: string]: unknown;
732
+ [additionalProperties: string]: JsonValue | undefined;
690
733
 
691
734
  /**
692
735
  When publishing scoped packages, the access level defaults to restricted. If you want your scoped package to be publicly viewable (and installable) set `--access=public`. The only valid values for access are public and restricted. Unscoped packages always have an access level of public.
@@ -706,7 +749,7 @@ declare namespace PackageJson$1 {
706
749
  Default: `'latest'`
707
750
  */
708
751
  tag?: string;
709
- }
752
+ };
710
753
  }
711
754
 
712
755
  /**
@@ -715,6 +758,8 @@ Type for [npm's `package.json` file](https://docs.npmjs.com/creating-a-package-j
715
758
  @category File
716
759
  */
717
760
  type PackageJson$1 =
761
+ JsonObject &
762
+ PackageJson$1.NodeJsStandard &
718
763
  PackageJson$1.PackageJsonStandard &
719
764
  PackageJson$1.NonStandardEntryPoints &
720
765
  PackageJson$1.TypeScriptConfiguration &
@@ -1052,13 +1097,19 @@ interface StorybookConfig {
1052
1097
  previewHead?: PresetValue<string>;
1053
1098
  previewBody?: PresetValue<string>;
1054
1099
  /**
1055
- * Programatically override the preview's main page template.
1100
+ * Programmatically override the preview's main page template.
1056
1101
  * This should return a reference to a file containing an `.ejs` template
1057
1102
  * that will be interpolated with environment variables.
1058
1103
  *
1059
1104
  * @example '.storybook/index.ejs'
1060
1105
  */
1061
1106
  previewMainTemplate?: string;
1107
+ /**
1108
+ * Programmatically modify the preview head/body HTML.
1109
+ * The managerHead function accept a string,
1110
+ * which is the existing head content, and return a modified string.
1111
+ */
1112
+ managerHead?: PresetValue<string>;
1062
1113
  }
1063
1114
  type PresetValue<T> = T | ((config: T, options: Options) => T | Promise<T>);
1064
1115
  type PresetProperty<K, TStorybookConfig = StorybookConfig> = TStorybookConfig[K extends keyof TStorybookConfig ? K : never] | PresetPropertyFn<K, TStorybookConfig>;
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@storybook/react-webpack5",
3
- "version": "7.1.0-alpha.3",
3
+ "version": "7.1.0-alpha.31",
4
4
  "description": "Storybook for React: Develop React Component in isolation with Hot Reloading.",
5
5
  "keywords": [
6
6
  "storybook"
7
7
  ],
8
- "homepage": "https://github.com/storybookjs/storybook/tree/main/frameworks/react-webpack5",
8
+ "homepage": "https://github.com/storybookjs/storybook/tree/next/code/frameworks/react-webpack5",
9
9
  "bugs": {
10
10
  "url": "https://github.com/storybookjs/storybook/issues"
11
11
  },
12
12
  "repository": {
13
13
  "type": "git",
14
14
  "url": "https://github.com/storybookjs/storybook.git",
15
- "directory": "frameworks/react-webpack5"
15
+ "directory": "code/frameworks/react-webpack5"
16
16
  },
17
17
  "funding": {
18
18
  "type": "opencollective",
@@ -21,15 +21,14 @@
21
21
  "license": "MIT",
22
22
  "exports": {
23
23
  ".": {
24
+ "types": "./dist/index.d.ts",
24
25
  "node": "./dist/index.js",
25
26
  "require": "./dist/index.js",
26
- "import": "./dist/index.mjs",
27
- "types": "./dist/index.d.ts"
27
+ "import": "./dist/index.mjs"
28
28
  },
29
29
  "./preset": {
30
- "require": "./dist/preset.js",
31
- "import": "./dist/preset.mjs",
32
- "types": "./dist/preset.d.ts"
30
+ "types": "./dist/preset.d.ts",
31
+ "require": "./dist/preset.js"
33
32
  },
34
33
  "./package.json": "./package.json"
35
34
  },
@@ -48,17 +47,17 @@
48
47
  "prep": "../../../scripts/prepare/bundle.ts"
49
48
  },
50
49
  "dependencies": {
51
- "@storybook/builder-webpack5": "7.1.0-alpha.3",
52
- "@storybook/preset-react-webpack": "7.1.0-alpha.3",
53
- "@storybook/react": "7.1.0-alpha.3",
50
+ "@storybook/builder-webpack5": "7.1.0-alpha.31",
51
+ "@storybook/preset-react-webpack": "7.1.0-alpha.31",
52
+ "@storybook/react": "7.1.0-alpha.31",
54
53
  "@types/node": "^16.0.0"
55
54
  },
56
55
  "devDependencies": {
57
- "jest-specific-snapshot": "^7.0.0",
56
+ "jest-specific-snapshot": "^8.0.0",
58
57
  "typescript": "~4.9.3"
59
58
  },
60
59
  "peerDependencies": {
61
- "@babel/core": "^7.11.5",
60
+ "@babel/core": "^7.22.0",
62
61
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
63
62
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
64
63
  },
@@ -83,5 +82,5 @@
83
82
  ],
84
83
  "platform": "node"
85
84
  },
86
- "gitHead": "d0acd16fdf394463add948bac3f226b93f92c235"
87
- }
85
+ "gitHead": "e6a7fd8a655c69780bc20b9749c2699e44beae16"
86
+ }
@@ -0,0 +1,44 @@
1
+ // TODO: Replace, as soon as @types/react-dom 17.0.14 is used
2
+ // Source: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/fb0f14b7a35cde26ffaa82e7536c062e593e9ae6/types/react-dom/client.d.ts
3
+ declare module 'react-dom/client' {
4
+ import React = require('react');
5
+
6
+ export interface HydrationOptions {
7
+ onHydrated?(suspenseInstance: Comment): void;
8
+ onDeleted?(suspenseInstance: Comment): void;
9
+ /**
10
+ * Prefix for `useId`.
11
+ */
12
+ identifierPrefix?: string;
13
+ onRecoverableError?: (error: unknown) => void;
14
+ }
15
+
16
+ export interface RootOptions {
17
+ /**
18
+ * Prefix for `useId`.
19
+ */
20
+ identifierPrefix?: string;
21
+ onRecoverableError?: (error: unknown) => void;
22
+ }
23
+
24
+ export interface Root {
25
+ render(children: React.ReactChild | Iterable<React.ReactNode>): void;
26
+ unmount(): void;
27
+ }
28
+
29
+ /**
30
+ * Replaces `ReactDOM.render` when the `.render` method is called and enables Concurrent Mode.
31
+ *
32
+ * @see https://reactjs.org/docs/concurrent-mode-reference.html#createroot
33
+ */
34
+ export function createRoot(
35
+ container: Element | Document | DocumentFragment | Comment,
36
+ options?: RootOptions
37
+ ): Root;
38
+
39
+ export function hydrateRoot(
40
+ container: Element | Document | DocumentFragment | Comment,
41
+ initialChildren: React.ReactChild | Iterable<React.ReactNode>,
42
+ options?: HydrationOptions
43
+ ): Root;
44
+ }
package/dist/preset.mjs DELETED
@@ -1 +0,0 @@
1
- var __require=(x=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(x,{get:(a,b)=>(typeof require<"u"?require:a)[b]}):x)(function(x){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+x+'" is not supported')});import{dirname,join}from"path";var wrapForPnP=input=>dirname(__require.resolve(join(input,"package.json"))),addons=[wrapForPnP("@storybook/preset-react-webpack")],defaultFrameworkOptions={legacyRootApi:!0},frameworkOptions=async(_,options)=>{let config=await options.presets.apply("framework");return typeof config=="string"?{name:config,options:defaultFrameworkOptions}:typeof config>"u"?{name:wrapForPnP("@storybook/react-webpack5"),options:defaultFrameworkOptions}:{name:config.name,options:{...defaultFrameworkOptions,...config.options}}},core=async(config,options)=>{let framework=await options.presets.apply("framework");return{...config,builder:{name:wrapForPnP("@storybook/builder-webpack5"),options:typeof framework=="string"?{}:framework.options.builder||{}},renderer:wrapForPnP("@storybook/react")}},webpack=async config=>(config.resolve=config.resolve||{},config.resolve.alias={...config.resolve?.alias,"@storybook/react":wrapForPnP("@storybook/react")},config);export{addons,core,frameworkOptions,webpack};
@@ -1,27 +0,0 @@
1
- import { ReactOptions, StorybookConfig as StorybookConfig$1, TypescriptOptions as TypescriptOptions$1 } from '@storybook/preset-react-webpack';
2
- import { BuilderOptions, StorybookConfigWebpack, TypescriptOptions } from '@storybook/builder-webpack5';
3
-
4
- type FrameworkName = '@storybook/react-webpack5';
5
- type BuilderName = '@storybook/builder-webpack5';
6
- type FrameworkOptions = ReactOptions & {
7
- builder?: BuilderOptions;
8
- };
9
- type StorybookConfigFramework = {
10
- framework: FrameworkName | {
11
- name: FrameworkName;
12
- options: FrameworkOptions;
13
- };
14
- core?: StorybookConfig$1['core'] & {
15
- builder?: BuilderName | {
16
- name: BuilderName;
17
- options: BuilderOptions;
18
- };
19
- };
20
- typescript?: Partial<TypescriptOptions & TypescriptOptions$1> & StorybookConfig$1['typescript'];
21
- };
22
- /**
23
- * The interface for Storybook configuration in `main.ts` files.
24
- */
25
- type StorybookConfig = Omit<StorybookConfig$1, keyof StorybookConfigWebpack | keyof StorybookConfigFramework> & StorybookConfigWebpack & StorybookConfigFramework;
26
-
27
- export { FrameworkOptions as F, StorybookConfig as S };