@storybook/react-vite 7.1.0-alpha.3 → 7.1.0-alpha.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{types-debbd39a.d.ts → index-869709be.d.ts} +98 -47
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -0
- package/dist/preset.d.ts +1 -1
- package/dist/preset.js +1 -1
- package/package.json +13 -14
- package/src/typings.d.ts +44 -0
- package/dist/chunk-R4NKYYJA.mjs +0 -1
- package/dist/preset.mjs +0 -1
- package/dist/react-docgen-IMJTCUEZ.mjs +0 -1
|
@@ -18,7 +18,40 @@ type Primitive =
|
|
|
18
18
|
| symbol
|
|
19
19
|
| bigint;
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
Matches a JSON object.
|
|
23
|
+
|
|
24
|
+
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 { … }`.
|
|
25
|
+
|
|
26
|
+
@category JSON
|
|
27
|
+
*/
|
|
28
|
+
type JsonObject = {[Key in string]: JsonValue} & {[Key in string]?: JsonValue | undefined};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
Matches a JSON array.
|
|
32
|
+
|
|
33
|
+
@category JSON
|
|
34
|
+
*/
|
|
35
|
+
type JsonArray = JsonValue[] | readonly JsonValue[];
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
Matches any valid JSON primitive value.
|
|
39
|
+
|
|
40
|
+
@category JSON
|
|
41
|
+
*/
|
|
42
|
+
type JsonPrimitive = string | number | boolean | null;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
Matches any valid JSON value.
|
|
46
|
+
|
|
47
|
+
@see `Jsonify` if you need to transform a type to one that is assignable to `JsonValue`.
|
|
48
|
+
|
|
49
|
+
@category JSON
|
|
50
|
+
*/
|
|
51
|
+
type JsonValue = JsonPrimitive | JsonObject | JsonArray;
|
|
52
|
+
|
|
21
53
|
declare global {
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
22
55
|
interface SymbolConstructor {
|
|
23
56
|
readonly observable: symbol;
|
|
24
57
|
}
|
|
@@ -84,8 +117,8 @@ declare namespace PackageJson$1 {
|
|
|
84
117
|
email?: string;
|
|
85
118
|
};
|
|
86
119
|
|
|
87
|
-
export
|
|
88
|
-
[directoryType: string]:
|
|
120
|
+
export type DirectoryLocations = {
|
|
121
|
+
[directoryType: string]: JsonValue | undefined;
|
|
89
122
|
|
|
90
123
|
/**
|
|
91
124
|
Location for executable scripts. Sugar to generate entries in the `bin` property by walking the folder.
|
|
@@ -116,7 +149,7 @@ declare namespace PackageJson$1 {
|
|
|
116
149
|
Location for test files.
|
|
117
150
|
*/
|
|
118
151
|
test?: string;
|
|
119
|
-
}
|
|
152
|
+
};
|
|
120
153
|
|
|
121
154
|
export type Scripts = {
|
|
122
155
|
/**
|
|
@@ -266,22 +299,11 @@ declare namespace PackageJson$1 {
|
|
|
266
299
|
export type Dependency = Partial<Record<string, string>>;
|
|
267
300
|
|
|
268
301
|
/**
|
|
269
|
-
|
|
302
|
+
A mapping of conditions and the paths to which they resolve.
|
|
270
303
|
*/
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
| 'node'
|
|
275
|
-
| 'node-addons'
|
|
276
|
-
| 'deno'
|
|
277
|
-
| 'browser'
|
|
278
|
-
| 'electron'
|
|
279
|
-
| 'react-native'
|
|
280
|
-
| 'default',
|
|
281
|
-
string
|
|
282
|
-
>;
|
|
283
|
-
|
|
284
|
-
type ExportConditions = {[condition in ExportCondition]: Exports};
|
|
304
|
+
type ExportConditions = { // eslint-disable-line @typescript-eslint/consistent-indexed-object-style
|
|
305
|
+
[condition: string]: Exports;
|
|
306
|
+
};
|
|
285
307
|
|
|
286
308
|
/**
|
|
287
309
|
Entry points of a module, optionally with conditions and subpath exports.
|
|
@@ -290,16 +312,16 @@ declare namespace PackageJson$1 {
|
|
|
290
312
|
| null
|
|
291
313
|
| string
|
|
292
314
|
| Array<string | ExportConditions>
|
|
293
|
-
| ExportConditions
|
|
294
|
-
| {[path: string]: Exports}; // eslint-disable-line @typescript-eslint/consistent-indexed-object-style
|
|
315
|
+
| ExportConditions;
|
|
295
316
|
|
|
296
317
|
/**
|
|
297
|
-
Import map entries of a module, optionally with conditions.
|
|
318
|
+
Import map entries of a module, optionally with conditions and subpath imports.
|
|
298
319
|
*/
|
|
299
320
|
export type Imports = { // eslint-disable-line @typescript-eslint/consistent-indexed-object-style
|
|
300
|
-
[key: string]:
|
|
321
|
+
[key: `#${string}`]: Exports;
|
|
301
322
|
};
|
|
302
323
|
|
|
324
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
|
|
303
325
|
export interface NonStandardEntryPoints {
|
|
304
326
|
/**
|
|
305
327
|
An ECMAScript module ID that is the primary entry point to the program.
|
|
@@ -332,7 +354,7 @@ declare namespace PackageJson$1 {
|
|
|
332
354
|
sideEffects?: boolean | string[];
|
|
333
355
|
}
|
|
334
356
|
|
|
335
|
-
export
|
|
357
|
+
export type TypeScriptConfiguration = {
|
|
336
358
|
/**
|
|
337
359
|
Location of the bundled TypeScript declaration file.
|
|
338
360
|
*/
|
|
@@ -347,12 +369,12 @@ declare namespace PackageJson$1 {
|
|
|
347
369
|
Location of the bundled TypeScript declaration file. Alias of `types`.
|
|
348
370
|
*/
|
|
349
371
|
typings?: string;
|
|
350
|
-
}
|
|
372
|
+
};
|
|
351
373
|
|
|
352
374
|
/**
|
|
353
|
-
An alternative configuration for
|
|
375
|
+
An alternative configuration for workspaces.
|
|
354
376
|
*/
|
|
355
|
-
export
|
|
377
|
+
export type WorkspaceConfig = {
|
|
356
378
|
/**
|
|
357
379
|
An array of workspace pattern strings which contain the workspace packages.
|
|
358
380
|
*/
|
|
@@ -361,10 +383,11 @@ declare namespace PackageJson$1 {
|
|
|
361
383
|
/**
|
|
362
384
|
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.
|
|
363
385
|
|
|
364
|
-
[
|
|
386
|
+
[Supported](https://classic.yarnpkg.com/blog/2018/02/15/nohoist/) by Yarn.
|
|
387
|
+
[Not supported](https://github.com/npm/rfcs/issues/287) by npm.
|
|
365
388
|
*/
|
|
366
389
|
nohoist?: WorkspacePattern[];
|
|
367
|
-
}
|
|
390
|
+
};
|
|
368
391
|
|
|
369
392
|
/**
|
|
370
393
|
A workspace pattern points to a directory or group of directories which contain packages that should be included in the workspace installation process.
|
|
@@ -377,16 +400,7 @@ declare namespace PackageJson$1 {
|
|
|
377
400
|
*/
|
|
378
401
|
type WorkspacePattern = string;
|
|
379
402
|
|
|
380
|
-
export
|
|
381
|
-
/**
|
|
382
|
-
Used to configure [Yarn workspaces](https://classic.yarnpkg.com/docs/workspaces/).
|
|
383
|
-
|
|
384
|
-
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.
|
|
385
|
-
|
|
386
|
-
Please note that the top-level `private` property of `package.json` **must** be set to `true` in order to use workspaces.
|
|
387
|
-
*/
|
|
388
|
-
workspaces?: WorkspacePattern[] | WorkspaceConfig;
|
|
389
|
-
|
|
403
|
+
export type YarnConfiguration = {
|
|
390
404
|
/**
|
|
391
405
|
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`.
|
|
392
406
|
|
|
@@ -398,18 +412,19 @@ declare namespace PackageJson$1 {
|
|
|
398
412
|
Selective version resolutions. Allows the definition of custom package versions inside dependencies without manual edits in the `yarn.lock` file.
|
|
399
413
|
*/
|
|
400
414
|
resolutions?: Dependency;
|
|
401
|
-
}
|
|
415
|
+
};
|
|
402
416
|
|
|
403
|
-
export
|
|
417
|
+
export type JSPMConfiguration = {
|
|
404
418
|
/**
|
|
405
419
|
JSPM configuration.
|
|
406
420
|
*/
|
|
407
421
|
jspm?: PackageJson$1;
|
|
408
|
-
}
|
|
422
|
+
};
|
|
409
423
|
|
|
410
424
|
/**
|
|
411
425
|
Type for [npm's `package.json` file](https://docs.npmjs.com/creating-a-package-json-file). Containing standard npm properties.
|
|
412
426
|
*/
|
|
427
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
|
|
413
428
|
export interface PackageJsonStandard {
|
|
414
429
|
/**
|
|
415
430
|
The name of the package.
|
|
@@ -539,7 +554,7 @@ declare namespace PackageJson$1 {
|
|
|
539
554
|
/**
|
|
540
555
|
Is used to set configuration parameters used in package scripts that persist across upgrades.
|
|
541
556
|
*/
|
|
542
|
-
config?:
|
|
557
|
+
config?: JsonObject;
|
|
543
558
|
|
|
544
559
|
/**
|
|
545
560
|
The dependencies of the package.
|
|
@@ -580,7 +595,7 @@ declare namespace PackageJson$1 {
|
|
|
580
595
|
Engines that this package runs on.
|
|
581
596
|
*/
|
|
582
597
|
engines?: {
|
|
583
|
-
[EngineName in 'npm' | 'node' | string]?: string;
|
|
598
|
+
[EngineName in 'npm' | 'node' | string]?: string; // eslint-disable-line @typescript-eslint/no-redundant-type-constituents
|
|
584
599
|
};
|
|
585
600
|
|
|
586
601
|
/**
|
|
@@ -679,13 +694,41 @@ declare namespace PackageJson$1 {
|
|
|
679
694
|
*/
|
|
680
695
|
url: string;
|
|
681
696
|
};
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
Used to configure [npm workspaces](https://docs.npmjs.com/cli/using-npm/workspaces) / [Yarn workspaces](https://classic.yarnpkg.com/docs/workspaces/).
|
|
700
|
+
|
|
701
|
+
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.
|
|
702
|
+
|
|
703
|
+
Please note that the top-level `private` property of `package.json` **must** be set to `true` in order to use workspaces.
|
|
704
|
+
*/
|
|
705
|
+
workspaces?: WorkspacePattern[] | WorkspaceConfig;
|
|
682
706
|
}
|
|
683
707
|
|
|
684
|
-
|
|
708
|
+
/**
|
|
709
|
+
Type for [`package.json` file used by the Node.js runtime](https://nodejs.org/api/packages.html#nodejs-packagejson-field-definitions).
|
|
710
|
+
*/
|
|
711
|
+
export type NodeJsStandard = {
|
|
712
|
+
/**
|
|
713
|
+
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.
|
|
714
|
+
|
|
715
|
+
__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.__
|
|
716
|
+
|
|
717
|
+
@example
|
|
718
|
+
```json
|
|
719
|
+
{
|
|
720
|
+
"packageManager": "<package manager name>@<version>"
|
|
721
|
+
}
|
|
722
|
+
```
|
|
723
|
+
*/
|
|
724
|
+
packageManager?: string;
|
|
725
|
+
};
|
|
726
|
+
|
|
727
|
+
export type PublishConfig = {
|
|
685
728
|
/**
|
|
686
729
|
Additional, less common properties from the [npm docs on `publishConfig`](https://docs.npmjs.com/cli/v7/configuring-npm/package-json#publishconfig).
|
|
687
730
|
*/
|
|
688
|
-
[additionalProperties: string]:
|
|
731
|
+
[additionalProperties: string]: JsonValue | undefined;
|
|
689
732
|
|
|
690
733
|
/**
|
|
691
734
|
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.
|
|
@@ -705,7 +748,7 @@ declare namespace PackageJson$1 {
|
|
|
705
748
|
Default: `'latest'`
|
|
706
749
|
*/
|
|
707
750
|
tag?: string;
|
|
708
|
-
}
|
|
751
|
+
};
|
|
709
752
|
}
|
|
710
753
|
|
|
711
754
|
/**
|
|
@@ -714,6 +757,8 @@ Type for [npm's `package.json` file](https://docs.npmjs.com/creating-a-package-j
|
|
|
714
757
|
@category File
|
|
715
758
|
*/
|
|
716
759
|
type PackageJson$1 =
|
|
760
|
+
JsonObject &
|
|
761
|
+
PackageJson$1.NodeJsStandard &
|
|
717
762
|
PackageJson$1.PackageJsonStandard &
|
|
718
763
|
PackageJson$1.NonStandardEntryPoints &
|
|
719
764
|
PackageJson$1.TypeScriptConfiguration &
|
|
@@ -1051,13 +1096,19 @@ interface StorybookConfig$1 {
|
|
|
1051
1096
|
previewHead?: PresetValue<string>;
|
|
1052
1097
|
previewBody?: PresetValue<string>;
|
|
1053
1098
|
/**
|
|
1054
|
-
*
|
|
1099
|
+
* Programmatically override the preview's main page template.
|
|
1055
1100
|
* This should return a reference to a file containing an `.ejs` template
|
|
1056
1101
|
* that will be interpolated with environment variables.
|
|
1057
1102
|
*
|
|
1058
1103
|
* @example '.storybook/index.ejs'
|
|
1059
1104
|
*/
|
|
1060
1105
|
previewMainTemplate?: string;
|
|
1106
|
+
/**
|
|
1107
|
+
* Programmatically modify the preview head/body HTML.
|
|
1108
|
+
* The managerHead function accept a string,
|
|
1109
|
+
* which is the existing head content, and return a modified string.
|
|
1110
|
+
*/
|
|
1111
|
+
managerHead?: PresetValue<string>;
|
|
1061
1112
|
}
|
|
1062
1113
|
type PresetValue<T> = T | ((config: T, options: Options) => T | Promise<T>);
|
|
1063
1114
|
type PresetProperty<K, TStorybookConfig = StorybookConfig$1> = TStorybookConfig[K extends keyof TStorybookConfig ? K : never] | PresetPropertyFn<K, TStorybookConfig>;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var src_exports={};module.exports=__toCommonJS(src_exports);
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var src_exports={};module.exports=__toCommonJS(src_exports);
|
package/dist/index.mjs
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/dist/preset.d.ts
CHANGED
package/dist/preset.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __esm=(fn,res)=>function(){return fn&&(res=(0,fn[__getOwnPropNames(fn)[0]])(fn=0)),res};var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod)),__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);function actualNameHandler(documentation,path2,importer){if(import_ast_types.namedTypes.ClassDeclaration.check(path2.node)||import_ast_types.namedTypes.FunctionDeclaration.check(path2.node))documentation.set("actualName",(0,import_utils.getNameOrValue)(path2.get("id")));else if(import_ast_types.namedTypes.ArrowFunctionExpression.check(path2.node)||import_ast_types.namedTypes.FunctionExpression.check(path2.node)||(0,import_utils.isReactForwardRefCall)(path2,importer)){let currentPath=path2;for(;currentPath.parent;){if(import_ast_types.namedTypes.VariableDeclarator.check(currentPath.parent.node)){documentation.set("actualName",(0,import_utils.getNameOrValue)(currentPath.parent.get("id")));return}if(import_ast_types.namedTypes.AssignmentExpression.check(currentPath.parent.node)){let leftPath=currentPath.parent.get("left");if(import_ast_types.namedTypes.Identifier.check(leftPath.node)||import_ast_types.namedTypes.Literal.check(leftPath.node)){documentation.set("actualName",(0,import_utils.getNameOrValue)(leftPath));return}}currentPath=currentPath.parent}documentation.set("actualName","")}}var import_ast_types,import_utils,init_actualNameHandler=__esm({"src/plugins/docgen-handlers/actualNameHandler.ts"(){import_ast_types=require("ast-types"),import_utils=require("react-docgen/dist/utils")}});var react_docgen_exports={};__export(react_docgen_exports,{reactDocgen:()=>reactDocgen});function reactDocgen({include=/\.(mjs|tsx?|jsx?)$/,exclude=[/node_modules\/.*/]}={}){let cwd=process.cwd(),filter=(0,import_pluginutils.createFilter)(include,exclude);return{name:"storybook:react-docgen-plugin",enforce:"pre",async transform(src,id){let relPath=import_path.default.relative(cwd,id);if(filter(relPath))try{let docgenResults=(0,import_react_docgen.parse)(src,defaultResolver,handlers,{importer:defaultImporter,filename:id}),s=new import_magic_string.default(src);return docgenResults.forEach(info=>{let{actualName,...docgenInfo}=info;if(actualName){let docNode=JSON.stringify(docgenInfo);s.append(`;${actualName}.__docgenInfo=${docNode}`)}}),{code:s.toString(),map:s.generateMap()}}catch{}}}}var import_path,import_pluginutils,import_react_docgen,import_magic_string,defaultHandlers,defaultResolver,defaultImporter,handlers,init_react_docgen=__esm({"src/plugins/react-docgen.ts"(){import_path=__toESM(require("path")),import_pluginutils=require("@rollup/pluginutils"),import_react_docgen=require("react-docgen"),import_magic_string=__toESM(require("magic-string"));init_actualNameHandler();defaultHandlers=Object.values(import_react_docgen.handlers).map(handler=>handler),defaultResolver=import_react_docgen.resolver.findAllExportedComponentDefinitions,defaultImporter=import_react_docgen.importers.makeFsImporter(),handlers=[...defaultHandlers,actualNameHandler]}});var preset_exports={};__export(preset_exports,{core:()=>core,viteFinal:()=>viteFinal});module.exports=__toCommonJS(preset_exports);var import_builder_vite=require("@storybook/builder-vite"),import_path2=require("path"),wrapForPnP=input=>(0,import_path2.dirname)(require.resolve((0,import_path2.join)(input,"package.json"))),core={builder:wrapForPnP("@storybook/builder-vite"),renderer:wrapForPnP("@storybook/react")},viteFinal=async(config,{presets})=>{let{plugins=[]}=config;if(!await(0,import_builder_vite.hasVitePlugins)(plugins,["vite:react-babel","vite:react-swc"])){let{default:react}=await import("@vitejs/plugin-react");plugins.push(react())}let{reactDocgen:reactDocgenOption,reactDocgenTypescriptOptions}=await presets.apply("typescript",{}),typescriptPresent;try{require.resolve("typescript"),typescriptPresent=!0}catch{typescriptPresent=!1}if(reactDocgenOption==="react-docgen-typescript"&&typescriptPresent&&plugins.push(require("@joshwooding/vite-plugin-react-docgen-typescript")({...reactDocgenTypescriptOptions,savePropValueAsString:!0})),typeof reactDocgenOption=="string"){let{reactDocgen:reactDocgen2}=await Promise.resolve().then(()=>(init_react_docgen(),react_docgen_exports));plugins.unshift(reactDocgen2({include:reactDocgenOption==="react-docgen"?/\.(mjs|tsx?|jsx?)$/:/\.(mjs|jsx?)$/}))}return config};0&&(module.exports={core,viteFinal});
|
|
1
|
+
"use strict";var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __esm=(fn,res)=>function(){return fn&&(res=(0,fn[__getOwnPropNames(fn)[0]])(fn=0)),res};var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod)),__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);function actualNameHandler(documentation,path2,importer){if(import_ast_types.namedTypes.ClassDeclaration.check(path2.node)||import_ast_types.namedTypes.FunctionDeclaration.check(path2.node))documentation.set("actualName",(0,import_utils.getNameOrValue)(path2.get("id")));else if(import_ast_types.namedTypes.ArrowFunctionExpression.check(path2.node)||import_ast_types.namedTypes.FunctionExpression.check(path2.node)||(0,import_utils.isReactForwardRefCall)(path2,importer)){let currentPath=path2;for(;currentPath.parent;){if(import_ast_types.namedTypes.VariableDeclarator.check(currentPath.parent.node)){documentation.set("actualName",(0,import_utils.getNameOrValue)(currentPath.parent.get("id")));return}if(import_ast_types.namedTypes.AssignmentExpression.check(currentPath.parent.node)){let leftPath=currentPath.parent.get("left");if(import_ast_types.namedTypes.Identifier.check(leftPath.node)||import_ast_types.namedTypes.Literal.check(leftPath.node)){documentation.set("actualName",(0,import_utils.getNameOrValue)(leftPath));return}}currentPath=currentPath.parent}documentation.set("actualName","")}}var import_ast_types,import_utils,init_actualNameHandler=__esm({"src/plugins/docgen-handlers/actualNameHandler.ts"(){"use strict";import_ast_types=require("ast-types"),import_utils=require("react-docgen/dist/utils")}});var react_docgen_exports={};__export(react_docgen_exports,{reactDocgen:()=>reactDocgen});function reactDocgen({include=/\.(mjs|tsx?|jsx?)$/,exclude=[/node_modules\/.*/]}={}){let cwd=process.cwd(),filter=(0,import_pluginutils.createFilter)(include,exclude);return{name:"storybook:react-docgen-plugin",enforce:"pre",async transform(src,id){let relPath=import_path.default.relative(cwd,id);if(filter(relPath))try{let docgenResults=(0,import_react_docgen.parse)(src,defaultResolver,handlers,{importer:defaultImporter,filename:id}),s=new import_magic_string.default(src);return docgenResults.forEach(info=>{let{actualName,...docgenInfo}=info;if(actualName){let docNode=JSON.stringify(docgenInfo);s.append(`;${actualName}.__docgenInfo=${docNode}`)}}),{code:s.toString(),map:s.generateMap()}}catch{}}}}var import_path,import_pluginutils,import_react_docgen,import_magic_string,defaultHandlers,defaultResolver,defaultImporter,handlers,init_react_docgen=__esm({"src/plugins/react-docgen.ts"(){"use strict";import_path=__toESM(require("path")),import_pluginutils=require("@rollup/pluginutils"),import_react_docgen=require("react-docgen"),import_magic_string=__toESM(require("magic-string"));init_actualNameHandler();defaultHandlers=Object.values(import_react_docgen.handlers).map(handler=>handler),defaultResolver=import_react_docgen.resolver.findAllExportedComponentDefinitions,defaultImporter=import_react_docgen.importers.makeFsImporter(),handlers=[...defaultHandlers,actualNameHandler]}});var preset_exports={};__export(preset_exports,{core:()=>core,viteFinal:()=>viteFinal});module.exports=__toCommonJS(preset_exports);var import_builder_vite=require("@storybook/builder-vite"),import_path2=require("path"),wrapForPnP=input=>(0,import_path2.dirname)(require.resolve((0,import_path2.join)(input,"package.json"))),core={builder:wrapForPnP("@storybook/builder-vite"),renderer:wrapForPnP("@storybook/react")},viteFinal=async(config,{presets})=>{let{plugins=[]}=config;if(!await(0,import_builder_vite.hasVitePlugins)(plugins,["vite:react-babel","vite:react-swc"])){let{default:react}=await import("@vitejs/plugin-react");plugins.push(react())}let{reactDocgen:reactDocgenOption,reactDocgenTypescriptOptions}=await presets.apply("typescript",{}),typescriptPresent;try{require.resolve("typescript"),typescriptPresent=!0}catch{typescriptPresent=!1}if(reactDocgenOption==="react-docgen-typescript"&&typescriptPresent&&plugins.push(require("@joshwooding/vite-plugin-react-docgen-typescript")({...reactDocgenTypescriptOptions,savePropValueAsString:!0})),typeof reactDocgenOption=="string"){let{reactDocgen:reactDocgen2}=await Promise.resolve().then(()=>(init_react_docgen(),react_docgen_exports));plugins.unshift(reactDocgen2({include:reactDocgenOption==="react-docgen"?/\.(mjs|tsx?|jsx?)$/:/\.(mjs|jsx?)$/}))}return config};0&&(module.exports={core,viteFinal});
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/react-vite",
|
|
3
|
-
"version": "7.1.0-alpha.
|
|
3
|
+
"version": "7.1.0-alpha.30",
|
|
4
4
|
"description": "Storybook for React and Vite: Develop React components in isolation with Hot Reloading.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook"
|
|
7
7
|
],
|
|
8
|
-
"homepage": "https://github.com/storybookjs/storybook/tree/
|
|
8
|
+
"homepage": "https://github.com/storybookjs/storybook/tree/next/code/frameworks/react-vite",
|
|
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-vite"
|
|
15
|
+
"directory": "code/frameworks/react-vite"
|
|
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
|
-
"
|
|
31
|
-
"
|
|
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
|
},
|
|
@@ -49,12 +48,12 @@
|
|
|
49
48
|
},
|
|
50
49
|
"dependencies": {
|
|
51
50
|
"@joshwooding/vite-plugin-react-docgen-typescript": "0.2.1",
|
|
52
|
-
"@rollup/pluginutils": "^
|
|
53
|
-
"@storybook/builder-vite": "7.1.0-alpha.
|
|
54
|
-
"@storybook/react": "7.1.0-alpha.
|
|
51
|
+
"@rollup/pluginutils": "^5.0.2",
|
|
52
|
+
"@storybook/builder-vite": "7.1.0-alpha.30",
|
|
53
|
+
"@storybook/react": "7.1.0-alpha.30",
|
|
55
54
|
"@vitejs/plugin-react": "^3.0.1",
|
|
56
55
|
"ast-types": "^0.14.2",
|
|
57
|
-
"magic-string": "^0.
|
|
56
|
+
"magic-string": "^0.30.0",
|
|
58
57
|
"react-docgen": "6.0.0-alpha.3"
|
|
59
58
|
},
|
|
60
59
|
"devDependencies": {
|
|
@@ -80,5 +79,5 @@
|
|
|
80
79
|
],
|
|
81
80
|
"platform": "node"
|
|
82
81
|
},
|
|
83
|
-
"gitHead": "
|
|
84
|
-
}
|
|
82
|
+
"gitHead": "e6a7fd8a655c69780bc20b9749c2699e44beae16"
|
|
83
|
+
}
|
package/src/typings.d.ts
ADDED
|
@@ -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/chunk-R4NKYYJA.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')});export{__require};
|
package/dist/preset.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{__require}from"./chunk-R4NKYYJA.mjs";import{hasVitePlugins}from"@storybook/builder-vite";import{dirname,join}from"path";var wrapForPnP=input=>dirname(__require.resolve(join(input,"package.json"))),core={builder:wrapForPnP("@storybook/builder-vite"),renderer:wrapForPnP("@storybook/react")},viteFinal=async(config,{presets})=>{let{plugins=[]}=config;if(!await hasVitePlugins(plugins,["vite:react-babel","vite:react-swc"])){let{default:react}=await import("@vitejs/plugin-react");plugins.push(react())}let{reactDocgen:reactDocgenOption,reactDocgenTypescriptOptions}=await presets.apply("typescript",{}),typescriptPresent;try{__require.resolve("typescript"),typescriptPresent=!0}catch{typescriptPresent=!1}if(reactDocgenOption==="react-docgen-typescript"&&typescriptPresent&&plugins.push(__require("@joshwooding/vite-plugin-react-docgen-typescript")({...reactDocgenTypescriptOptions,savePropValueAsString:!0})),typeof reactDocgenOption=="string"){let{reactDocgen}=await import("./react-docgen-IMJTCUEZ.mjs");plugins.unshift(reactDocgen({include:reactDocgenOption==="react-docgen"?/\.(mjs|tsx?|jsx?)$/:/\.(mjs|jsx?)$/}))}return config};export{core,viteFinal};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./chunk-R4NKYYJA.mjs";import path from"path";import{createFilter}from"@rollup/pluginutils";import{parse,handlers as docgenHandlers,resolver as docgenResolver,importers as docgenImporters}from"react-docgen";import MagicString from"magic-string";import{namedTypes as t}from"ast-types";import{getNameOrValue,isReactForwardRefCall}from"react-docgen/dist/utils";function actualNameHandler(documentation,path2,importer){if(t.ClassDeclaration.check(path2.node)||t.FunctionDeclaration.check(path2.node))documentation.set("actualName",getNameOrValue(path2.get("id")));else if(t.ArrowFunctionExpression.check(path2.node)||t.FunctionExpression.check(path2.node)||isReactForwardRefCall(path2,importer)){let currentPath=path2;for(;currentPath.parent;){if(t.VariableDeclarator.check(currentPath.parent.node)){documentation.set("actualName",getNameOrValue(currentPath.parent.get("id")));return}if(t.AssignmentExpression.check(currentPath.parent.node)){let leftPath=currentPath.parent.get("left");if(t.Identifier.check(leftPath.node)||t.Literal.check(leftPath.node)){documentation.set("actualName",getNameOrValue(leftPath));return}}currentPath=currentPath.parent}documentation.set("actualName","")}}var defaultHandlers=Object.values(docgenHandlers).map(handler=>handler),defaultResolver=docgenResolver.findAllExportedComponentDefinitions,defaultImporter=docgenImporters.makeFsImporter(),handlers=[...defaultHandlers,actualNameHandler];function reactDocgen({include=/\.(mjs|tsx?|jsx?)$/,exclude=[/node_modules\/.*/]}={}){let cwd=process.cwd(),filter=createFilter(include,exclude);return{name:"storybook:react-docgen-plugin",enforce:"pre",async transform(src,id){let relPath=path.relative(cwd,id);if(filter(relPath))try{let docgenResults=parse(src,defaultResolver,handlers,{importer:defaultImporter,filename:id}),s=new MagicString(src);return docgenResults.forEach(info=>{let{actualName,...docgenInfo}=info;if(actualName){let docNode=JSON.stringify(docgenInfo);s.append(`;${actualName}.__docgenInfo=${docNode}`)}}),{code:s.toString(),map:s.generateMap()}}catch{}}}}export{reactDocgen};
|