storybook 10.0.0-beta.0 → 10.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/assets/server/openBrowser.applescript +94 -0
- package/dist/_browser-chunks/Color-KPLIACXP.js +1569 -0
- package/dist/_browser-chunks/{WithTooltip-2E62HIBN.js → WithTooltip-SK46ZJ2J.js} +1 -1
- package/dist/_browser-chunks/{chunk-YY5GICNT.js → chunk-6E2SHJSL.js} +175 -32
- package/dist/_browser-chunks/{chunk-FWKO3E35.js → chunk-BOOOPFZF.js} +10 -3
- package/dist/_browser-chunks/{chunk-YWDKX534.js → chunk-FA42P6MO.js} +49 -4
- package/dist/_browser-chunks/chunk-G33S6YM3.js +521 -0
- package/dist/_browser-chunks/{chunk-MZNYTCNT.js → chunk-HMIIJ6UD.js} +6 -6
- package/dist/_browser-chunks/{chunk-4QPX7WIQ.js → chunk-JJZMHC3A.js} +57 -166
- package/dist/_browser-chunks/{chunk-MD2FTHCZ.js → chunk-JVSKG4YS.js} +3 -16
- package/dist/_browser-chunks/{chunk-E7VLET3C.js → chunk-KSCAWCCE.js} +3947 -4291
- package/dist/_browser-chunks/{chunk-PYK5ZTFK.js → chunk-PS3AOQI4.js} +48 -25
- package/dist/_browser-chunks/chunk-QK3L5AXO.js +372 -0
- package/dist/_browser-chunks/chunk-SHR3NNR3.js +5810 -0
- package/dist/_browser-chunks/{chunk-O5R5CGFA.js → chunk-TMDZCWME.js} +1 -2
- package/dist/_browser-chunks/chunk-VUAFL5XK.js +20 -0
- package/dist/_browser-chunks/{chunk-T7RCAJIX.js → chunk-Y3M7TW6K.js} +43 -47
- package/dist/_browser-chunks/{syntaxhighlighter-YYAA4CS4.js → syntaxhighlighter-R46XOLMC.js} +1 -1
- package/dist/_node-chunks/{builder-manager-OW6YGKXV.js → builder-manager-SJGIDEN6.js} +45 -155
- package/dist/_node-chunks/camelcase-VZHWABQV.js +18 -0
- package/dist/_node-chunks/{chunk-6JSVPEAU.js → chunk-6CZW7AGN.js} +7 -7
- package/dist/_node-chunks/{chunk-CD3IP6HA.js → chunk-6XT5OLNL.js} +12 -12
- package/dist/_node-chunks/{chunk-2H7LZ2SD.js → chunk-AHRH5RPR.js} +7 -7
- package/dist/_node-chunks/{chunk-5HLANIBM.js → chunk-AOH6ABSV.js} +7 -7
- package/dist/_node-chunks/chunk-C5V22GP7.js +79 -0
- package/dist/_node-chunks/{chunk-IBXERYDG.js → chunk-FIROF4DV.js} +7 -7
- package/dist/_node-chunks/{chunk-I3YCPGZJ.js → chunk-GUJVZUYI.js} +7 -7
- package/dist/_node-chunks/chunk-IHPLRRAR.js +4741 -0
- package/dist/_node-chunks/{chunk-7TISOZS6.js → chunk-JMXKCRWR.js} +30 -21
- package/dist/_node-chunks/{chunk-YWGNEBRO.js → chunk-JUMUXWEV.js} +162 -103
- package/dist/_node-chunks/{chunk-UIREEOC7.js → chunk-KGX33KXX.js} +7 -7
- package/dist/_node-chunks/{chunk-3QB3ZG6H.js → chunk-KLVABNEU.js} +7 -7
- package/dist/_node-chunks/{chunk-H5LTFJHQ.js → chunk-OL6DY6BT.js} +631 -752
- package/dist/_node-chunks/{chunk-X5GAZ3EW.js → chunk-ONJV3K2L.js} +399 -116
- package/dist/_node-chunks/{chunk-LKB7KRSV.js → chunk-PTHTD4RO.js} +223 -243
- package/dist/_node-chunks/{chunk-UHHZPSP7.js → chunk-QQ3Z5KGJ.js} +6 -6
- package/dist/_node-chunks/{chunk-MUD3GH3L.js → chunk-QRTDDTZJ.js} +9 -9
- package/dist/_node-chunks/chunk-R54K4KSM.js +1540 -0
- package/dist/_node-chunks/{chunk-IQAUGVYR.js → chunk-S2LZC6JK.js} +8 -8
- package/dist/_node-chunks/chunk-SFJFSPRT.js +62 -0
- package/dist/_node-chunks/{chunk-LH3BEEIR.js → chunk-SSN5PKIY.js} +6 -6
- package/dist/_node-chunks/{chunk-NOQITS3C.js → chunk-SXR2DITB.js} +7 -7
- package/dist/_node-chunks/{chunk-FWUE7SRE.js → chunk-TH5QVQRL.js} +7 -7
- package/dist/_node-chunks/chunk-U34NWAU2.js +18 -0
- package/dist/_node-chunks/{chunk-FBMMEEO4.js → chunk-UV3CZ3KS.js} +7 -7
- package/dist/_node-chunks/{chunk-NZGJJABJ.js → chunk-UVUGJDAI.js} +60 -102
- package/dist/_node-chunks/{chunk-GZUNYRFU.js → chunk-VOUNSD2E.js} +7 -7
- package/dist/_node-chunks/chunk-WFCPBKQJ.js +64656 -0
- package/dist/_node-chunks/{chunk-BFXER3XW.js → chunk-XHF3WWNP.js} +623 -750
- package/dist/_node-chunks/{chunk-ANEKBWDX.js → chunk-XU45KXNQ.js} +16 -25
- package/dist/_node-chunks/{camelcase-2K3EMR6G.js → chunk-YHO6XR7U.js} +9 -8
- package/dist/_node-chunks/{dist-465RSKRC.js → dist-IIC5PBL7.js} +9 -9
- package/dist/_node-chunks/{globby-LJ3MVB6M.js → globby-CJACC3HJ.js} +17 -13
- package/dist/_node-chunks/{lib-OW3DENXB.js → lib-ZY4TKSOR.js} +40 -16
- package/dist/_node-chunks/{mdx-N42X6CFJ-PYX2IFUO.js → mdx-N42X6CFJ-3XNW3DFO.js} +8 -8
- package/dist/_node-chunks/{p-limit-X4OG45RB.js → p-limit-R2OFT5HE.js} +76 -10
- package/dist/_node-chunks/{plugin-ALTIQMDE.js → plugin-5XD5R2KD.js} +10 -10
- package/dist/_node-chunks/{plugin-GE36R32R.js → plugin-WAWVQMVR.js} +10 -12
- package/dist/_node-chunks/{webpack-inject-mocker-runtime-plugin-NLCAF7S6.js → webpack-inject-mocker-runtime-plugin-SCRGJLIS.js} +1307 -847
- package/dist/_node-chunks/{webpack-mock-plugin-BRYODMCC.js → webpack-mock-plugin-3VAXEGG2.js} +9 -11
- package/dist/babel/index.d.ts +1 -1
- package/dist/babel/index.js +11 -12
- package/dist/bin/core.js +638 -187
- package/dist/bin/dispatcher.js +11 -11
- package/dist/bin/loader.js +8 -8
- package/dist/cli/index.d.ts +62 -75
- package/dist/cli/index.js +66 -56
- package/dist/common/index.d.ts +3 -1
- package/dist/common/index.js +22 -22
- package/dist/components/index.d.ts +234 -2
- package/dist/components/index.js +74 -5741
- package/dist/core-events/index.d.ts +18 -2
- package/dist/core-events/index.js +7 -1
- package/dist/core-server/index.d.ts +540 -39
- package/dist/core-server/index.js +4647 -4182
- package/dist/core-server/presets/common-manager.js +1570 -1272
- package/dist/core-server/presets/common-override-preset.js +9 -9
- package/dist/core-server/presets/common-preset.js +691 -38
- package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.js +9 -11
- package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +10 -12
- package/dist/csf/index.d.ts +9 -4
- package/dist/csf/index.js +50 -15
- package/dist/csf-tools/index.d.ts +47 -6
- package/dist/csf-tools/index.js +9 -9
- package/dist/docs-tools/index.js +4 -4
- package/dist/instrumenter/index.js +1 -1
- package/dist/manager/globals-runtime.js +9233 -18113
- package/dist/manager/globals.d.ts +0 -4
- package/dist/manager/globals.js +1 -6
- package/dist/manager/runtime.js +13396 -11518
- package/dist/manager-api/index.d.ts +540 -32
- package/dist/manager-api/index.js +364 -90
- package/dist/manager-errors.d.ts +527 -0
- package/dist/node-logger/index.d.ts +1 -1
- package/dist/node-logger/index.js +1136 -662
- package/dist/preview/globals.js +1 -1
- package/dist/preview/runtime.js +12103 -21579
- package/dist/preview-api/index.d.ts +3 -3
- package/dist/preview-api/index.js +10 -10
- package/dist/preview-errors.d.ts +527 -0
- package/dist/router/index.d.ts +668 -10
- package/dist/router/index.js +2 -2
- package/dist/server-errors.d.ts +527 -0
- package/dist/server-errors.js +10 -10
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/telemetry/index.js +23 -25
- package/dist/test/index.js +1874 -4024
- package/dist/theming/index.d.ts +2 -2
- package/dist/theming/index.js +6 -6
- package/dist/types/index.d.ts +553 -16
- package/dist/viewport/index.d.ts +36 -4
- package/dist/viewport/index.js +1 -1
- package/package.json +9 -46
- package/dist/_browser-chunks/Color-SFYJJKWL.js +0 -605
- package/dist/_browser-chunks/chunk-DHO2SA6L.js +0 -12
- package/dist/_browser-chunks/chunk-WPHPDNUA.js +0 -974
- package/dist/_node-chunks/chunk-27W2Z6VL.js +0 -28502
- package/dist/_node-chunks/chunk-G46DWX7Z.js +0 -266
- package/dist/_node-chunks/chunk-GZZDIJIB.js +0 -80
- package/dist/_node-chunks/chunk-JDKH3XYB.js +0 -9845
- package/dist/_node-chunks/chunk-R7RKO2DC.js +0 -35783
- package/dist/_node-chunks/chunk-T23YQHYB.js +0 -62
- package/dist/_node-chunks/chunk-VKKLKNFC.js +0 -2377
- package/dist/_node-chunks/chunk-W6GKFQ7F.js +0 -87
- package/dist/_node-chunks/chunk-YUYBO6S7.js +0 -18
- package/dist/_node-chunks/default-browser-id-Z6WQ7DZA.js +0 -1719
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { loadAllPresets } from 'storybook/internal/common';
|
|
2
2
|
export { getPreviewBodyTemplate, getPreviewHeadTemplate } from 'storybook/internal/common';
|
|
3
3
|
import * as storybook_internal_types from 'storybook/internal/types';
|
|
4
|
-
import { CLIOptions, LoadOptions, BuilderOptions, StorybookConfigRaw, IndexInputStats, NormalizedStoriesSpecifier, Path, Indexer, DocsOptions, StoryIndexEntry, DocsIndexEntry, Tag, IndexEntry, StoryIndex, Options, NormalizedProjectAnnotations, ProjectAnnotations, ComposedStoryFn } from 'storybook/internal/types';
|
|
4
|
+
import { CLIOptions, LoadOptions, BuilderOptions, StorybookConfigRaw, IndexInputStats, NormalizedStoriesSpecifier, Path as Path$1, Indexer, DocsOptions, StoryIndexEntry, DocsIndexEntry, Tag, IndexEntry, StoryIndex, Options, NormalizedProjectAnnotations, ProjectAnnotations, ComposedStoryFn } from 'storybook/internal/types';
|
|
5
5
|
import { EventType } from 'storybook/internal/telemetry';
|
|
6
6
|
import { Channel } from 'storybook/internal/channels';
|
|
7
7
|
import { StoryId } from 'storybook/internal/csf';
|
|
@@ -84,7 +84,7 @@ type DocsCacheEntry = DocsIndexEntry;
|
|
|
84
84
|
/** A `_.stories._` file will produce a list of stories and possibly a docs entry */
|
|
85
85
|
type StoriesCacheEntry = {
|
|
86
86
|
entries: (StoryIndexEntryWithExtra | DocsIndexEntry)[];
|
|
87
|
-
dependents: Path[];
|
|
87
|
+
dependents: Path$1[];
|
|
88
88
|
type: 'stories';
|
|
89
89
|
};
|
|
90
90
|
type ErrorEntry = {
|
|
@@ -92,10 +92,10 @@ type ErrorEntry = {
|
|
|
92
92
|
err: IndexingError;
|
|
93
93
|
};
|
|
94
94
|
type CacheEntry = false | StoriesCacheEntry | DocsCacheEntry | ErrorEntry;
|
|
95
|
-
type SpecifierStoriesCache = Record<Path, CacheEntry>;
|
|
95
|
+
type SpecifierStoriesCache = Record<Path$1, CacheEntry>;
|
|
96
96
|
type StoryIndexGeneratorOptions = {
|
|
97
|
-
workingDir: Path;
|
|
98
|
-
configDir: Path;
|
|
97
|
+
workingDir: Path$1;
|
|
98
|
+
configDir: Path$1;
|
|
99
99
|
indexers: Indexer[];
|
|
100
100
|
docs: DocsOptions;
|
|
101
101
|
build?: StorybookConfigRaw['build'];
|
|
@@ -136,28 +136,28 @@ declare class StoryIndexGenerator {
|
|
|
136
136
|
private static getFindMatchingFilesCacheKey;
|
|
137
137
|
/** Clear the findMatchingFiles cache */
|
|
138
138
|
static clearFindMatchingFilesCache(): void;
|
|
139
|
-
static findMatchingFiles(specifier: NormalizedStoriesSpecifier, workingDir: Path, ignoreWarnings?: boolean): Promise<SpecifierStoriesCache>;
|
|
140
|
-
static findMatchingFilesForSpecifiers(specifiers: NormalizedStoriesSpecifier[], workingDir: Path, ignoreWarnings?: boolean): Promise<Array<readonly [NormalizedStoriesSpecifier, SpecifierStoriesCache]>>;
|
|
139
|
+
static findMatchingFiles(specifier: NormalizedStoriesSpecifier, workingDir: Path$1, ignoreWarnings?: boolean): Promise<SpecifierStoriesCache>;
|
|
140
|
+
static findMatchingFilesForSpecifiers(specifiers: NormalizedStoriesSpecifier[], workingDir: Path$1, ignoreWarnings?: boolean): Promise<Array<readonly [NormalizedStoriesSpecifier, SpecifierStoriesCache]>>;
|
|
141
141
|
initialize(): Promise<void>;
|
|
142
142
|
/** Run the updater function over all the empty cache entries */
|
|
143
|
-
updateExtracted(updater: (specifier: NormalizedStoriesSpecifier, absolutePath: Path, existingEntry: CacheEntry) => Promise<CacheEntry>, overwrite?: boolean): Promise<void>;
|
|
144
|
-
isDocsMdx(absolutePath: Path): boolean;
|
|
143
|
+
updateExtracted(updater: (specifier: NormalizedStoriesSpecifier, absolutePath: Path$1, existingEntry: CacheEntry) => Promise<CacheEntry>, overwrite?: boolean): Promise<void>;
|
|
144
|
+
isDocsMdx(absolutePath: Path$1): boolean;
|
|
145
145
|
ensureExtracted({ projectTags, }: {
|
|
146
146
|
projectTags?: Tag[];
|
|
147
147
|
}): Promise<{
|
|
148
148
|
entries: (IndexEntry | ErrorEntry)[];
|
|
149
149
|
stats: IndexStatsSummary;
|
|
150
150
|
}>;
|
|
151
|
-
findDependencies(absoluteImports: Path[]): StoriesCacheEntry[];
|
|
151
|
+
findDependencies(absoluteImports: Path$1[]): StoriesCacheEntry[];
|
|
152
152
|
/**
|
|
153
153
|
* Try to find the component path from a raw import string and return it in the same format as
|
|
154
154
|
* `importPath`. Respect tsconfig paths if available.
|
|
155
155
|
*
|
|
156
156
|
* If no such file exists, assume that the import is from a package and return the raw
|
|
157
157
|
*/
|
|
158
|
-
resolveComponentPath(rawComponentPath: Path, absolutePath: Path, matchPath: MatchPath | undefined): string;
|
|
159
|
-
extractStories(specifier: NormalizedStoriesSpecifier, absolutePath: Path, projectTags?: Tag[]): Promise<StoriesCacheEntry | DocsCacheEntry>;
|
|
160
|
-
extractDocs(specifier: NormalizedStoriesSpecifier, absolutePath: Path, projectTags?: Tag[]): Promise<false | DocsIndexEntry>;
|
|
158
|
+
resolveComponentPath(rawComponentPath: Path$1, absolutePath: Path$1, matchPath: MatchPath | undefined): string;
|
|
159
|
+
extractStories(specifier: NormalizedStoriesSpecifier, absolutePath: Path$1, projectTags?: Tag[]): Promise<StoriesCacheEntry | DocsCacheEntry>;
|
|
160
|
+
extractDocs(specifier: NormalizedStoriesSpecifier, absolutePath: Path$1, projectTags?: Tag[]): Promise<false | DocsIndexEntry>;
|
|
161
161
|
chooseDuplicate(firstEntry: IndexEntry, secondEntry: IndexEntry, projectTags: Tag[]): IndexEntry;
|
|
162
162
|
sortStories(entries: StoryIndex['entries'], storySortParameter: any): Promise<Record<string, IndexEntry>>;
|
|
163
163
|
getIndex(): Promise<StoryIndex>;
|
|
@@ -166,7 +166,7 @@ declare class StoryIndexGenerator {
|
|
|
166
166
|
stats: IndexStatsSummary;
|
|
167
167
|
}>;
|
|
168
168
|
invalidateAll(): void;
|
|
169
|
-
invalidate(specifier: NormalizedStoriesSpecifier, importPath: Path, removed: boolean): void;
|
|
169
|
+
invalidate(specifier: NormalizedStoriesSpecifier, importPath: Path$1, removed: boolean): void;
|
|
170
170
|
getPreviewCode(): Promise<string | undefined>;
|
|
171
171
|
getProjectTags(previewCode?: string): string[];
|
|
172
172
|
static storyFileNames(specifierToCache: Map<NormalizedStoriesSpecifier, SpecifierStoriesCache>): string[];
|
|
@@ -469,36 +469,506 @@ declare class MockUniversalStore<State, CustomEvent extends {
|
|
|
469
469
|
unsubscribeAll(): void;
|
|
470
470
|
}
|
|
471
471
|
|
|
472
|
-
|
|
473
|
-
type
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
472
|
+
/**
|
|
473
|
+
* Actions represent the type of change to a location value.
|
|
474
|
+
*/
|
|
475
|
+
declare enum Action {
|
|
476
|
+
/**
|
|
477
|
+
* A POP indicates a change to an arbitrary index in the history stack, such
|
|
478
|
+
* as a back or forward navigation. It does not describe the direction of the
|
|
479
|
+
* navigation, only that the current index changed.
|
|
480
|
+
*
|
|
481
|
+
* Note: This is the default action for newly created history objects.
|
|
482
|
+
*/
|
|
483
|
+
Pop = "POP",
|
|
484
|
+
/**
|
|
485
|
+
* A PUSH indicates a new entry being added to the history stack, such as when
|
|
486
|
+
* a link is clicked and a new page loads. When this happens, all subsequent
|
|
487
|
+
* entries in the stack are lost.
|
|
488
|
+
*/
|
|
489
|
+
Push = "PUSH",
|
|
490
|
+
/**
|
|
491
|
+
* A REPLACE indicates the entry at the current index in the history stack
|
|
492
|
+
* being replaced by a new one.
|
|
493
|
+
*/
|
|
494
|
+
Replace = "REPLACE"
|
|
484
495
|
}
|
|
485
|
-
|
|
486
|
-
|
|
496
|
+
/**
|
|
497
|
+
* The pathname, search, and hash values of a URL.
|
|
498
|
+
*/
|
|
499
|
+
interface Path {
|
|
500
|
+
/**
|
|
501
|
+
* A URL pathname, beginning with a /.
|
|
502
|
+
*/
|
|
503
|
+
pathname: string;
|
|
504
|
+
/**
|
|
505
|
+
* A URL search string, beginning with a ?.
|
|
506
|
+
*/
|
|
507
|
+
search: string;
|
|
508
|
+
/**
|
|
509
|
+
* A URL fragment identifier, beginning with a #.
|
|
510
|
+
*/
|
|
511
|
+
hash: string;
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* An entry in a history stack. A location contains information about the
|
|
515
|
+
* URL path, as well as possibly some arbitrary state and a key.
|
|
516
|
+
*/
|
|
517
|
+
interface Location extends Path {
|
|
518
|
+
/**
|
|
519
|
+
* A value of arbitrary data associated with this location.
|
|
520
|
+
*/
|
|
521
|
+
state: any;
|
|
522
|
+
/**
|
|
523
|
+
* A unique string associated with this location. May be used to safely store
|
|
524
|
+
* and retrieve data in some other storage API, like `localStorage`.
|
|
525
|
+
*
|
|
526
|
+
* Note: This value is always "default" on the initial location.
|
|
527
|
+
*/
|
|
528
|
+
key: string;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Map of routeId -> data returned from a loader/action/error
|
|
533
|
+
*/
|
|
534
|
+
interface RouteData {
|
|
535
|
+
[routeId: string]: any;
|
|
536
|
+
}
|
|
537
|
+
declare enum ResultType {
|
|
538
|
+
data = "data",
|
|
539
|
+
deferred = "deferred",
|
|
540
|
+
redirect = "redirect",
|
|
541
|
+
error = "error"
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* Successful result from a loader or action
|
|
545
|
+
*/
|
|
546
|
+
interface SuccessResult {
|
|
547
|
+
type: ResultType.data;
|
|
548
|
+
data: any;
|
|
549
|
+
statusCode?: number;
|
|
550
|
+
headers?: Headers;
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Successful defer() result from a loader or action
|
|
554
|
+
*/
|
|
555
|
+
interface DeferredResult {
|
|
556
|
+
type: ResultType.deferred;
|
|
557
|
+
deferredData: DeferredData;
|
|
558
|
+
statusCode?: number;
|
|
559
|
+
headers?: Headers;
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* Redirect result from a loader or action
|
|
563
|
+
*/
|
|
564
|
+
interface RedirectResult {
|
|
565
|
+
type: ResultType.redirect;
|
|
566
|
+
status: number;
|
|
567
|
+
location: string;
|
|
568
|
+
revalidate: boolean;
|
|
569
|
+
reloadDocument?: boolean;
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* Unsuccessful result from a loader or action
|
|
573
|
+
*/
|
|
574
|
+
interface ErrorResult {
|
|
575
|
+
type: ResultType.error;
|
|
576
|
+
error: any;
|
|
577
|
+
headers?: Headers;
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* Result from a loader or action - potentially successful or unsuccessful
|
|
581
|
+
*/
|
|
582
|
+
type DataResult = SuccessResult | DeferredResult | RedirectResult | ErrorResult;
|
|
583
|
+
type LowerCaseFormMethod = "get" | "post" | "put" | "patch" | "delete";
|
|
584
|
+
type UpperCaseFormMethod = Uppercase<LowerCaseFormMethod>;
|
|
585
|
+
/**
|
|
586
|
+
* Active navigation/fetcher form methods are exposed in lowercase on the
|
|
587
|
+
* RouterState
|
|
588
|
+
*/
|
|
589
|
+
type FormMethod = LowerCaseFormMethod;
|
|
590
|
+
/**
|
|
591
|
+
* In v7, active navigation/fetcher form methods are exposed in uppercase on the
|
|
592
|
+
* RouterState. This is to align with the normalization done via fetch().
|
|
593
|
+
*/
|
|
594
|
+
type V7_FormMethod = UpperCaseFormMethod;
|
|
595
|
+
type FormEncType = "application/x-www-form-urlencoded" | "multipart/form-data" | "application/json" | "text/plain";
|
|
596
|
+
type JsonObject = {
|
|
597
|
+
[Key in string]: JsonValue;
|
|
598
|
+
} & {
|
|
599
|
+
[Key in string]?: JsonValue | undefined;
|
|
487
600
|
};
|
|
488
|
-
type
|
|
489
|
-
|
|
490
|
-
|
|
601
|
+
type JsonArray = JsonValue[] | readonly JsonValue[];
|
|
602
|
+
type JsonPrimitive = string | number | boolean | null;
|
|
603
|
+
type JsonValue = JsonPrimitive | JsonObject | JsonArray;
|
|
604
|
+
/**
|
|
605
|
+
* @private
|
|
606
|
+
* Internal interface to pass around for action submissions, not intended for
|
|
607
|
+
* external consumption
|
|
608
|
+
*/
|
|
609
|
+
type Submission = {
|
|
610
|
+
formMethod: FormMethod | V7_FormMethod;
|
|
611
|
+
formAction: string;
|
|
612
|
+
formEncType: FormEncType;
|
|
613
|
+
formData: FormData;
|
|
614
|
+
json: undefined;
|
|
615
|
+
text: undefined;
|
|
616
|
+
} | {
|
|
617
|
+
formMethod: FormMethod | V7_FormMethod;
|
|
618
|
+
formAction: string;
|
|
619
|
+
formEncType: FormEncType;
|
|
620
|
+
formData: undefined;
|
|
621
|
+
json: JsonValue;
|
|
622
|
+
text: undefined;
|
|
623
|
+
} | {
|
|
624
|
+
formMethod: FormMethod | V7_FormMethod;
|
|
625
|
+
formAction: string;
|
|
626
|
+
formEncType: FormEncType;
|
|
627
|
+
formData: undefined;
|
|
628
|
+
json: undefined;
|
|
629
|
+
text: string;
|
|
491
630
|
};
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
631
|
+
/**
|
|
632
|
+
* @private
|
|
633
|
+
* Arguments passed to route loader/action functions. Same for now but we keep
|
|
634
|
+
* this as a private implementation detail in case they diverge in the future.
|
|
635
|
+
*/
|
|
636
|
+
interface DataFunctionArgs {
|
|
637
|
+
request: Request;
|
|
638
|
+
params: Params;
|
|
639
|
+
context?: any;
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* Arguments passed to loader functions
|
|
643
|
+
*/
|
|
644
|
+
interface LoaderFunctionArgs extends DataFunctionArgs {
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* Arguments passed to action functions
|
|
648
|
+
*/
|
|
649
|
+
interface ActionFunctionArgs extends DataFunctionArgs {
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* Loaders and actions can return anything except `undefined` (`null` is a
|
|
653
|
+
* valid return value if there is no data to return). Responses are preferred
|
|
654
|
+
* and will ease any future migration to Remix
|
|
655
|
+
*/
|
|
656
|
+
type DataFunctionValue = Response | NonNullable<unknown> | null;
|
|
657
|
+
/**
|
|
658
|
+
* Route loader function signature
|
|
659
|
+
*/
|
|
660
|
+
interface LoaderFunction {
|
|
661
|
+
(args: LoaderFunctionArgs): Promise<DataFunctionValue> | DataFunctionValue;
|
|
662
|
+
}
|
|
663
|
+
/**
|
|
664
|
+
* Route action function signature
|
|
665
|
+
*/
|
|
666
|
+
interface ActionFunction {
|
|
667
|
+
(args: ActionFunctionArgs): Promise<DataFunctionValue> | DataFunctionValue;
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* Route shouldRevalidate function signature. This runs after any submission
|
|
671
|
+
* (navigation or fetcher), so we flatten the navigation/fetcher submission
|
|
672
|
+
* onto the arguments. It shouldn't matter whether it came from a navigation
|
|
673
|
+
* or a fetcher, what really matters is the URLs and the formData since loaders
|
|
674
|
+
* have to re-run based on the data models that were potentially mutated.
|
|
675
|
+
*/
|
|
676
|
+
interface ShouldRevalidateFunction {
|
|
677
|
+
(args: {
|
|
678
|
+
currentUrl: URL;
|
|
679
|
+
currentParams: AgnosticDataRouteMatch["params"];
|
|
680
|
+
nextUrl: URL;
|
|
681
|
+
nextParams: AgnosticDataRouteMatch["params"];
|
|
682
|
+
formMethod?: Submission["formMethod"];
|
|
683
|
+
formAction?: Submission["formAction"];
|
|
684
|
+
formEncType?: Submission["formEncType"];
|
|
685
|
+
text?: Submission["text"];
|
|
686
|
+
formData?: Submission["formData"];
|
|
687
|
+
json?: Submission["json"];
|
|
688
|
+
actionResult?: DataResult;
|
|
689
|
+
defaultShouldRevalidate: boolean;
|
|
690
|
+
}): boolean;
|
|
691
|
+
}
|
|
692
|
+
/**
|
|
693
|
+
* Keys we cannot change from within a lazy() function. We spread all other keys
|
|
694
|
+
* onto the route. Either they're meaningful to the router, or they'll get
|
|
695
|
+
* ignored.
|
|
696
|
+
*/
|
|
697
|
+
type ImmutableRouteKey = "lazy" | "caseSensitive" | "path" | "id" | "index" | "children";
|
|
698
|
+
type RequireOne<T, Key = keyof T> = Exclude<{
|
|
699
|
+
[K in keyof T]: K extends Key ? Omit<T, K> & Required<Pick<T, K>> : never;
|
|
700
|
+
}[keyof T], undefined>;
|
|
701
|
+
/**
|
|
702
|
+
* lazy() function to load a route definition, which can add non-matching
|
|
703
|
+
* related properties to a route
|
|
704
|
+
*/
|
|
705
|
+
interface LazyRouteFunction<R extends AgnosticRouteObject> {
|
|
706
|
+
(): Promise<RequireOne<Omit<R, ImmutableRouteKey>>>;
|
|
707
|
+
}
|
|
708
|
+
/**
|
|
709
|
+
* Base RouteObject with common props shared by all types of routes
|
|
710
|
+
*/
|
|
711
|
+
type AgnosticBaseRouteObject = {
|
|
712
|
+
caseSensitive?: boolean;
|
|
713
|
+
path?: string;
|
|
714
|
+
id?: string;
|
|
715
|
+
loader?: LoaderFunction;
|
|
716
|
+
action?: ActionFunction;
|
|
717
|
+
hasErrorBoundary?: boolean;
|
|
718
|
+
shouldRevalidate?: ShouldRevalidateFunction;
|
|
719
|
+
handle?: any;
|
|
720
|
+
lazy?: LazyRouteFunction<AgnosticBaseRouteObject>;
|
|
498
721
|
};
|
|
499
|
-
|
|
500
|
-
|
|
722
|
+
/**
|
|
723
|
+
* Index routes must not have children
|
|
724
|
+
*/
|
|
725
|
+
type AgnosticIndexRouteObject = AgnosticBaseRouteObject & {
|
|
726
|
+
children?: undefined;
|
|
727
|
+
index: true;
|
|
501
728
|
};
|
|
729
|
+
/**
|
|
730
|
+
* Non-index routes may have children, but cannot have index
|
|
731
|
+
*/
|
|
732
|
+
type AgnosticNonIndexRouteObject = AgnosticBaseRouteObject & {
|
|
733
|
+
children?: AgnosticRouteObject[];
|
|
734
|
+
index?: false;
|
|
735
|
+
};
|
|
736
|
+
/**
|
|
737
|
+
* A route object represents a logical route, with (optionally) its child
|
|
738
|
+
* routes organized in a tree-like structure.
|
|
739
|
+
*/
|
|
740
|
+
type AgnosticRouteObject = AgnosticIndexRouteObject | AgnosticNonIndexRouteObject;
|
|
741
|
+
type AgnosticDataIndexRouteObject = AgnosticIndexRouteObject & {
|
|
742
|
+
id: string;
|
|
743
|
+
};
|
|
744
|
+
type AgnosticDataNonIndexRouteObject = AgnosticNonIndexRouteObject & {
|
|
745
|
+
children?: AgnosticDataRouteObject[];
|
|
746
|
+
id: string;
|
|
747
|
+
};
|
|
748
|
+
/**
|
|
749
|
+
* A data route object, which is just a RouteObject with a required unique ID
|
|
750
|
+
*/
|
|
751
|
+
type AgnosticDataRouteObject = AgnosticDataIndexRouteObject | AgnosticDataNonIndexRouteObject;
|
|
752
|
+
/**
|
|
753
|
+
* The parameters that were parsed from the URL path.
|
|
754
|
+
*/
|
|
755
|
+
type Params<Key extends string = string> = {
|
|
756
|
+
readonly [key in Key]: string | undefined;
|
|
757
|
+
};
|
|
758
|
+
/**
|
|
759
|
+
* A RouteMatch contains info about how a route matched a URL.
|
|
760
|
+
*/
|
|
761
|
+
interface AgnosticRouteMatch<ParamKey extends string = string, RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject> {
|
|
762
|
+
/**
|
|
763
|
+
* The names and values of dynamic parameters in the URL.
|
|
764
|
+
*/
|
|
765
|
+
params: Params<ParamKey>;
|
|
766
|
+
/**
|
|
767
|
+
* The portion of the URL pathname that was matched.
|
|
768
|
+
*/
|
|
769
|
+
pathname: string;
|
|
770
|
+
/**
|
|
771
|
+
* The portion of the URL pathname that was matched before child routes.
|
|
772
|
+
*/
|
|
773
|
+
pathnameBase: string;
|
|
774
|
+
/**
|
|
775
|
+
* The route object that was used to match.
|
|
776
|
+
*/
|
|
777
|
+
route: RouteObjectType;
|
|
778
|
+
}
|
|
779
|
+
interface AgnosticDataRouteMatch extends AgnosticRouteMatch<string, AgnosticDataRouteObject> {
|
|
780
|
+
}
|
|
781
|
+
declare class DeferredData {
|
|
782
|
+
private pendingKeysSet;
|
|
783
|
+
private controller;
|
|
784
|
+
private abortPromise;
|
|
785
|
+
private unlistenAbortSignal;
|
|
786
|
+
private subscribers;
|
|
787
|
+
data: Record<string, unknown>;
|
|
788
|
+
init?: ResponseInit;
|
|
789
|
+
deferredKeys: string[];
|
|
790
|
+
constructor(data: Record<string, unknown>, responseInit?: ResponseInit);
|
|
791
|
+
private trackPromise;
|
|
792
|
+
private onSettle;
|
|
793
|
+
private emit;
|
|
794
|
+
subscribe(fn: (aborted: boolean, settledKey?: string) => void): () => boolean;
|
|
795
|
+
cancel(): void;
|
|
796
|
+
resolveData(signal: AbortSignal): Promise<boolean>;
|
|
797
|
+
get done(): boolean;
|
|
798
|
+
get unwrappedData(): {};
|
|
799
|
+
get pendingKeys(): string[];
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
/**
|
|
803
|
+
* State maintained internally by the router. During a navigation, all states
|
|
804
|
+
* reflect the the "old" location unless otherwise noted.
|
|
805
|
+
*/
|
|
806
|
+
interface RouterState {
|
|
807
|
+
/**
|
|
808
|
+
* The action of the most recent navigation
|
|
809
|
+
*/
|
|
810
|
+
historyAction: Action;
|
|
811
|
+
/**
|
|
812
|
+
* The current location reflected by the router
|
|
813
|
+
*/
|
|
814
|
+
location: Location;
|
|
815
|
+
/**
|
|
816
|
+
* The current set of route matches
|
|
817
|
+
*/
|
|
818
|
+
matches: AgnosticDataRouteMatch[];
|
|
819
|
+
/**
|
|
820
|
+
* Tracks whether we've completed our initial data load
|
|
821
|
+
*/
|
|
822
|
+
initialized: boolean;
|
|
823
|
+
/**
|
|
824
|
+
* Current scroll position we should start at for a new view
|
|
825
|
+
* - number -> scroll position to restore to
|
|
826
|
+
* - false -> do not restore scroll at all (used during submissions)
|
|
827
|
+
* - null -> don't have a saved position, scroll to hash or top of page
|
|
828
|
+
*/
|
|
829
|
+
restoreScrollPosition: number | false | null;
|
|
830
|
+
/**
|
|
831
|
+
* Indicate whether this navigation should skip resetting the scroll position
|
|
832
|
+
* if we are unable to restore the scroll position
|
|
833
|
+
*/
|
|
834
|
+
preventScrollReset: boolean;
|
|
835
|
+
/**
|
|
836
|
+
* Tracks the state of the current navigation
|
|
837
|
+
*/
|
|
838
|
+
navigation: Navigation;
|
|
839
|
+
/**
|
|
840
|
+
* Tracks any in-progress revalidations
|
|
841
|
+
*/
|
|
842
|
+
revalidation: RevalidationState;
|
|
843
|
+
/**
|
|
844
|
+
* Data from the loaders for the current matches
|
|
845
|
+
*/
|
|
846
|
+
loaderData: RouteData;
|
|
847
|
+
/**
|
|
848
|
+
* Data from the action for the current matches
|
|
849
|
+
*/
|
|
850
|
+
actionData: RouteData | null;
|
|
851
|
+
/**
|
|
852
|
+
* Errors caught from loaders for the current matches
|
|
853
|
+
*/
|
|
854
|
+
errors: RouteData | null;
|
|
855
|
+
/**
|
|
856
|
+
* Map of current fetchers
|
|
857
|
+
*/
|
|
858
|
+
fetchers: Map<string, Fetcher>;
|
|
859
|
+
/**
|
|
860
|
+
* Map of current blockers
|
|
861
|
+
*/
|
|
862
|
+
blockers: Map<string, Blocker>;
|
|
863
|
+
}
|
|
864
|
+
/**
|
|
865
|
+
* Data that can be passed into hydrate a Router from SSR
|
|
866
|
+
*/
|
|
867
|
+
type HydrationState = Partial<Pick<RouterState, "loaderData" | "actionData" | "errors">>;
|
|
868
|
+
/**
|
|
869
|
+
* Potential states for state.navigation
|
|
870
|
+
*/
|
|
871
|
+
type NavigationStates = {
|
|
872
|
+
Idle: {
|
|
873
|
+
state: "idle";
|
|
874
|
+
location: undefined;
|
|
875
|
+
formMethod: undefined;
|
|
876
|
+
formAction: undefined;
|
|
877
|
+
formEncType: undefined;
|
|
878
|
+
formData: undefined;
|
|
879
|
+
json: undefined;
|
|
880
|
+
text: undefined;
|
|
881
|
+
};
|
|
882
|
+
Loading: {
|
|
883
|
+
state: "loading";
|
|
884
|
+
location: Location;
|
|
885
|
+
formMethod: Submission["formMethod"] | undefined;
|
|
886
|
+
formAction: Submission["formAction"] | undefined;
|
|
887
|
+
formEncType: Submission["formEncType"] | undefined;
|
|
888
|
+
formData: Submission["formData"] | undefined;
|
|
889
|
+
json: Submission["json"] | undefined;
|
|
890
|
+
text: Submission["text"] | undefined;
|
|
891
|
+
};
|
|
892
|
+
Submitting: {
|
|
893
|
+
state: "submitting";
|
|
894
|
+
location: Location;
|
|
895
|
+
formMethod: Submission["formMethod"];
|
|
896
|
+
formAction: Submission["formAction"];
|
|
897
|
+
formEncType: Submission["formEncType"];
|
|
898
|
+
formData: Submission["formData"];
|
|
899
|
+
json: Submission["json"];
|
|
900
|
+
text: Submission["text"];
|
|
901
|
+
};
|
|
902
|
+
};
|
|
903
|
+
type Navigation = NavigationStates[keyof NavigationStates];
|
|
904
|
+
type RevalidationState = "idle" | "loading";
|
|
905
|
+
/**
|
|
906
|
+
* Potential states for fetchers
|
|
907
|
+
*/
|
|
908
|
+
type FetcherStates<TData = any> = {
|
|
909
|
+
Idle: {
|
|
910
|
+
state: "idle";
|
|
911
|
+
formMethod: undefined;
|
|
912
|
+
formAction: undefined;
|
|
913
|
+
formEncType: undefined;
|
|
914
|
+
text: undefined;
|
|
915
|
+
formData: undefined;
|
|
916
|
+
json: undefined;
|
|
917
|
+
data: TData | undefined;
|
|
918
|
+
" _hasFetcherDoneAnything "?: boolean;
|
|
919
|
+
};
|
|
920
|
+
Loading: {
|
|
921
|
+
state: "loading";
|
|
922
|
+
formMethod: Submission["formMethod"] | undefined;
|
|
923
|
+
formAction: Submission["formAction"] | undefined;
|
|
924
|
+
formEncType: Submission["formEncType"] | undefined;
|
|
925
|
+
text: Submission["text"] | undefined;
|
|
926
|
+
formData: Submission["formData"] | undefined;
|
|
927
|
+
json: Submission["json"] | undefined;
|
|
928
|
+
data: TData | undefined;
|
|
929
|
+
" _hasFetcherDoneAnything "?: boolean;
|
|
930
|
+
};
|
|
931
|
+
Submitting: {
|
|
932
|
+
state: "submitting";
|
|
933
|
+
formMethod: Submission["formMethod"];
|
|
934
|
+
formAction: Submission["formAction"];
|
|
935
|
+
formEncType: Submission["formEncType"];
|
|
936
|
+
text: Submission["text"];
|
|
937
|
+
formData: Submission["formData"];
|
|
938
|
+
json: Submission["json"];
|
|
939
|
+
data: TData | undefined;
|
|
940
|
+
" _hasFetcherDoneAnything "?: boolean;
|
|
941
|
+
};
|
|
942
|
+
};
|
|
943
|
+
type Fetcher<TData = any> = FetcherStates<TData>[keyof FetcherStates<TData>];
|
|
944
|
+
interface BlockerBlocked {
|
|
945
|
+
state: "blocked";
|
|
946
|
+
reset(): void;
|
|
947
|
+
proceed(): void;
|
|
948
|
+
location: Location;
|
|
949
|
+
}
|
|
950
|
+
interface BlockerUnblocked {
|
|
951
|
+
state: "unblocked";
|
|
952
|
+
reset: undefined;
|
|
953
|
+
proceed: undefined;
|
|
954
|
+
location: undefined;
|
|
955
|
+
}
|
|
956
|
+
interface BlockerProceeding {
|
|
957
|
+
state: "proceeding";
|
|
958
|
+
reset: undefined;
|
|
959
|
+
proceed: undefined;
|
|
960
|
+
location: Location;
|
|
961
|
+
}
|
|
962
|
+
type Blocker = BlockerUnblocked | BlockerBlocked | BlockerProceeding;
|
|
963
|
+
|
|
964
|
+
/**
|
|
965
|
+
* NOTE: If you refactor this to split up the modules into separate files,
|
|
966
|
+
* you'll need to update the rollup config for react-router-dom-v5-compat.
|
|
967
|
+
*/
|
|
968
|
+
|
|
969
|
+
declare global {
|
|
970
|
+
var __staticRouterHydrationData: HydrationState | undefined;
|
|
971
|
+
}
|
|
502
972
|
|
|
503
973
|
type TestProviderState = 'test-provider-state:pending' | 'test-provider-state:running' | 'test-provider-state:succeeded' | 'test-provider-state:crashed';
|
|
504
974
|
type TestProviderId = string;
|
|
@@ -717,6 +1187,37 @@ declare global {
|
|
|
717
1187
|
function __pwUnwrapObject(storyRef: WrappedStoryRef): Promise<UnwrappedJSXStoryRef | UnwrappedImportStoryRef>;
|
|
718
1188
|
}
|
|
719
1189
|
|
|
1190
|
+
type StatusValue = 'status-value:pending' | 'status-value:success' | 'status-value:error' | 'status-value:warning' | 'status-value:unknown';
|
|
1191
|
+
type StatusTypeId = string;
|
|
1192
|
+
type StatusByTypeId = Record<StatusTypeId, Status>;
|
|
1193
|
+
type StatusesByStoryIdAndTypeId = Record<StoryId, StatusByTypeId>;
|
|
1194
|
+
interface Status {
|
|
1195
|
+
value: StatusValue;
|
|
1196
|
+
typeId: StatusTypeId;
|
|
1197
|
+
storyId: StoryId;
|
|
1198
|
+
title: string;
|
|
1199
|
+
description: string;
|
|
1200
|
+
data?: any;
|
|
1201
|
+
sidebarContextMenu?: boolean;
|
|
1202
|
+
}
|
|
1203
|
+
declare const StatusStoreEventType: {
|
|
1204
|
+
readonly SELECT: "select";
|
|
1205
|
+
};
|
|
1206
|
+
type StatusStoreEvent = {
|
|
1207
|
+
type: typeof StatusStoreEventType.SELECT;
|
|
1208
|
+
payload: Status[];
|
|
1209
|
+
};
|
|
1210
|
+
type StatusStore = {
|
|
1211
|
+
getAll: () => StatusesByStoryIdAndTypeId;
|
|
1212
|
+
set: (statuses: Status[]) => void;
|
|
1213
|
+
onAllStatusChange: (listener: (statuses: StatusesByStoryIdAndTypeId, previousStatuses: StatusesByStoryIdAndTypeId) => void) => () => void;
|
|
1214
|
+
onSelect: (listener: (selectedStatuses: Status[]) => void) => () => void;
|
|
1215
|
+
unset: (storyIds?: StoryId[]) => void;
|
|
1216
|
+
};
|
|
1217
|
+
type StatusStoreByTypeId = StatusStore & {
|
|
1218
|
+
typeId: StatusTypeId;
|
|
1219
|
+
};
|
|
1220
|
+
|
|
720
1221
|
declare const fullStatusStore: StatusStore & {
|
|
721
1222
|
selectStatuses: (statuses: Status[]) => void;
|
|
722
1223
|
typeId: undefined;
|