storybook 9.0.0-beta.9 → 9.0.0-rc.1
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/base-preview-head.html +21 -0
- package/assets/server/template.ejs +4 -4
- package/dist/actions/preview.cjs +1 -1
- package/dist/actions/preview.d.ts +501 -0
- package/dist/actions/preview.js +1 -1
- package/dist/backgrounds/index.d.ts +501 -0
- package/dist/backgrounds/preview.d.ts +501 -0
- package/dist/bin/index.cjs +61 -62
- package/dist/bin/index.js +61 -62
- package/dist/builder-manager/index.cjs +27 -27
- package/dist/builder-manager/index.js +46 -46
- package/dist/cli/bin/index.cjs +1032 -1032
- package/dist/cli/bin/index.js +1032 -1032
- package/dist/cli/index.cjs +33709 -28783
- package/dist/cli/index.js +33641 -28711
- package/dist/common/index.cjs +3060 -3048
- package/dist/common/index.d.ts +2 -2
- package/dist/common/index.js +3247 -3235
- package/dist/components/index.cjs +711 -711
- package/dist/components/index.d.ts +2 -1
- package/dist/components/index.js +15 -15
- package/dist/controls/preview.d.ts +501 -0
- package/dist/core-events/index.cjs +55 -52
- package/dist/core-events/index.d.ts +3 -1
- package/dist/core-events/index.js +52 -49
- package/dist/core-server/index.cjs +12 -12
- package/dist/core-server/index.d.ts +512 -11
- package/dist/core-server/index.js +12 -12
- package/dist/core-server/presets/common-manager.js +4563 -5786
- package/dist/core-server/presets/common-override-preset.cjs +10 -12
- package/dist/core-server/presets/common-override-preset.js +3 -5
- package/dist/core-server/presets/common-preset.cjs +112 -116
- package/dist/core-server/presets/common-preset.js +10 -14
- package/dist/csf/index.d.ts +1 -1
- package/dist/csf-tools/index.cjs +116 -111
- package/dist/csf-tools/index.js +33 -28
- package/dist/docs-tools/index.d.ts +1 -1
- package/dist/highlight/preview.d.ts +501 -0
- package/dist/instrumenter/index.js +1849 -3547
- package/dist/manager/globals-module-info.cjs +3 -0
- package/dist/manager/globals-module-info.js +3 -0
- package/dist/manager/globals-runtime.js +21082 -22647
- package/dist/manager/runtime.js +2468 -2449
- package/dist/manager-api/index.cjs +2302 -8594
- package/dist/manager-api/index.d.ts +501 -0
- package/dist/manager-api/index.js +2602 -2631
- package/dist/measure/index.d.ts +501 -0
- package/dist/measure/preview.d.ts +501 -0
- package/dist/outline/index.d.ts +501 -0
- package/dist/outline/preview.d.ts +501 -0
- package/dist/preview/runtime.js +38420 -40024
- package/dist/preview-api/index.cjs +1546 -1459
- package/dist/preview-api/index.d.ts +8 -5
- package/dist/preview-api/index.js +1267 -1181
- package/dist/router/index.cjs +5700 -2327
- package/dist/router/index.d.ts +622 -243
- package/dist/router/index.js +1297 -870
- package/dist/test/index.cjs +1810 -1811
- package/dist/test/index.d.ts +53 -5
- package/dist/test/index.js +1907 -1908
- package/dist/test/preview.cjs +51 -15860
- package/dist/test/preview.d.ts +520 -13
- package/dist/test/preview.js +44 -14431
- package/dist/theming/index.cjs +17 -0
- package/dist/theming/index.js +17 -0
- package/dist/types/index.d.ts +516 -82
- package/dist/viewport/index.d.ts +502 -3
- package/dist/viewport/preview.d.ts +501 -0
- package/package.json +2 -18
- package/dist/test/spy.cjs +0 -258
- package/dist/test/spy.d.ts +0 -62
- package/dist/test/spy.js +0 -240
|
@@ -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 = {
|
|
@@ -93,8 +93,8 @@ type ErrorEntry = {
|
|
|
93
93
|
};
|
|
94
94
|
type CacheEntry = false | StoriesCacheEntry | DocsCacheEntry | ErrorEntry;
|
|
95
95
|
type StoryIndexGeneratorOptions = {
|
|
96
|
-
workingDir: Path;
|
|
97
|
-
configDir: Path;
|
|
96
|
+
workingDir: Path$1;
|
|
97
|
+
configDir: Path$1;
|
|
98
98
|
indexers: Indexer[];
|
|
99
99
|
docs: DocsOptions;
|
|
100
100
|
build?: StorybookConfigRaw['build'];
|
|
@@ -131,24 +131,24 @@ declare class StoryIndexGenerator {
|
|
|
131
131
|
constructor(specifiers: NormalizedStoriesSpecifier[], options: StoryIndexGeneratorOptions);
|
|
132
132
|
initialize(): Promise<void>;
|
|
133
133
|
/** Run the updater function over all the empty cache entries */
|
|
134
|
-
updateExtracted(updater: (specifier: NormalizedStoriesSpecifier, absolutePath: Path, existingEntry: CacheEntry) => Promise<CacheEntry>, overwrite?: boolean): Promise<void>;
|
|
135
|
-
isDocsMdx(absolutePath: Path): boolean;
|
|
134
|
+
updateExtracted(updater: (specifier: NormalizedStoriesSpecifier, absolutePath: Path$1, existingEntry: CacheEntry) => Promise<CacheEntry>, overwrite?: boolean): Promise<void>;
|
|
135
|
+
isDocsMdx(absolutePath: Path$1): boolean;
|
|
136
136
|
ensureExtracted({ projectTags, }: {
|
|
137
137
|
projectTags?: Tag[];
|
|
138
138
|
}): Promise<{
|
|
139
139
|
entries: (IndexEntry | ErrorEntry)[];
|
|
140
140
|
stats: IndexStatsSummary;
|
|
141
141
|
}>;
|
|
142
|
-
findDependencies(absoluteImports: Path[]): StoriesCacheEntry[];
|
|
142
|
+
findDependencies(absoluteImports: Path$1[]): StoriesCacheEntry[];
|
|
143
143
|
/**
|
|
144
144
|
* Try to find the component path from a raw import string and return it in the same format as
|
|
145
145
|
* `importPath`. Respect tsconfig paths if available.
|
|
146
146
|
*
|
|
147
147
|
* If no such file exists, assume that the import is from a package and return the raw
|
|
148
148
|
*/
|
|
149
|
-
resolveComponentPath(rawComponentPath: Path, absolutePath: Path, matchPath: MatchPath | undefined): string;
|
|
150
|
-
extractStories(specifier: NormalizedStoriesSpecifier, absolutePath: Path, projectTags?: Tag[]): Promise<StoriesCacheEntry | DocsCacheEntry>;
|
|
151
|
-
extractDocs(specifier: NormalizedStoriesSpecifier, absolutePath: Path, projectTags?: Tag[]): Promise<false | DocsIndexEntry>;
|
|
149
|
+
resolveComponentPath(rawComponentPath: Path$1, absolutePath: Path$1, matchPath: MatchPath | undefined): string;
|
|
150
|
+
extractStories(specifier: NormalizedStoriesSpecifier, absolutePath: Path$1, projectTags?: Tag[]): Promise<StoriesCacheEntry | DocsCacheEntry>;
|
|
151
|
+
extractDocs(specifier: NormalizedStoriesSpecifier, absolutePath: Path$1, projectTags?: Tag[]): Promise<false | DocsIndexEntry>;
|
|
152
152
|
chooseDuplicate(firstEntry: IndexEntry, secondEntry: IndexEntry, projectTags: Tag[]): IndexEntry;
|
|
153
153
|
sortStories(entries: StoryIndex['entries'], storySortParameter: any): Promise<Record<string, IndexEntry>>;
|
|
154
154
|
getIndex(): Promise<StoryIndex>;
|
|
@@ -157,7 +157,7 @@ declare class StoryIndexGenerator {
|
|
|
157
157
|
stats: IndexStatsSummary;
|
|
158
158
|
}>;
|
|
159
159
|
invalidateAll(): void;
|
|
160
|
-
invalidate(specifier: NormalizedStoriesSpecifier, importPath: Path, removed: boolean): void;
|
|
160
|
+
invalidate(specifier: NormalizedStoriesSpecifier, importPath: Path$1, removed: boolean): void;
|
|
161
161
|
getPreviewCode(): Promise<string | undefined>;
|
|
162
162
|
getProjectTags(previewCode?: string): string[];
|
|
163
163
|
storyFileNames(): string[];
|
|
@@ -491,6 +491,507 @@ type StatusStoreByTypeId = StatusStore & {
|
|
|
491
491
|
typeId: StatusTypeId;
|
|
492
492
|
};
|
|
493
493
|
|
|
494
|
+
/**
|
|
495
|
+
* Actions represent the type of change to a location value.
|
|
496
|
+
*/
|
|
497
|
+
declare enum Action {
|
|
498
|
+
/**
|
|
499
|
+
* A POP indicates a change to an arbitrary index in the history stack, such
|
|
500
|
+
* as a back or forward navigation. It does not describe the direction of the
|
|
501
|
+
* navigation, only that the current index changed.
|
|
502
|
+
*
|
|
503
|
+
* Note: This is the default action for newly created history objects.
|
|
504
|
+
*/
|
|
505
|
+
Pop = "POP",
|
|
506
|
+
/**
|
|
507
|
+
* A PUSH indicates a new entry being added to the history stack, such as when
|
|
508
|
+
* a link is clicked and a new page loads. When this happens, all subsequent
|
|
509
|
+
* entries in the stack are lost.
|
|
510
|
+
*/
|
|
511
|
+
Push = "PUSH",
|
|
512
|
+
/**
|
|
513
|
+
* A REPLACE indicates the entry at the current index in the history stack
|
|
514
|
+
* being replaced by a new one.
|
|
515
|
+
*/
|
|
516
|
+
Replace = "REPLACE"
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* The pathname, search, and hash values of a URL.
|
|
520
|
+
*/
|
|
521
|
+
interface Path {
|
|
522
|
+
/**
|
|
523
|
+
* A URL pathname, beginning with a /.
|
|
524
|
+
*/
|
|
525
|
+
pathname: string;
|
|
526
|
+
/**
|
|
527
|
+
* A URL search string, beginning with a ?.
|
|
528
|
+
*/
|
|
529
|
+
search: string;
|
|
530
|
+
/**
|
|
531
|
+
* A URL fragment identifier, beginning with a #.
|
|
532
|
+
*/
|
|
533
|
+
hash: string;
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* An entry in a history stack. A location contains information about the
|
|
537
|
+
* URL path, as well as possibly some arbitrary state and a key.
|
|
538
|
+
*/
|
|
539
|
+
interface Location extends Path {
|
|
540
|
+
/**
|
|
541
|
+
* A value of arbitrary data associated with this location.
|
|
542
|
+
*/
|
|
543
|
+
state: any;
|
|
544
|
+
/**
|
|
545
|
+
* A unique string associated with this location. May be used to safely store
|
|
546
|
+
* and retrieve data in some other storage API, like `localStorage`.
|
|
547
|
+
*
|
|
548
|
+
* Note: This value is always "default" on the initial location.
|
|
549
|
+
*/
|
|
550
|
+
key: string;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* Map of routeId -> data returned from a loader/action/error
|
|
555
|
+
*/
|
|
556
|
+
interface RouteData {
|
|
557
|
+
[routeId: string]: any;
|
|
558
|
+
}
|
|
559
|
+
declare enum ResultType {
|
|
560
|
+
data = "data",
|
|
561
|
+
deferred = "deferred",
|
|
562
|
+
redirect = "redirect",
|
|
563
|
+
error = "error"
|
|
564
|
+
}
|
|
565
|
+
/**
|
|
566
|
+
* Successful result from a loader or action
|
|
567
|
+
*/
|
|
568
|
+
interface SuccessResult {
|
|
569
|
+
type: ResultType.data;
|
|
570
|
+
data: any;
|
|
571
|
+
statusCode?: number;
|
|
572
|
+
headers?: Headers;
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* Successful defer() result from a loader or action
|
|
576
|
+
*/
|
|
577
|
+
interface DeferredResult {
|
|
578
|
+
type: ResultType.deferred;
|
|
579
|
+
deferredData: DeferredData;
|
|
580
|
+
statusCode?: number;
|
|
581
|
+
headers?: Headers;
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* Redirect result from a loader or action
|
|
585
|
+
*/
|
|
586
|
+
interface RedirectResult {
|
|
587
|
+
type: ResultType.redirect;
|
|
588
|
+
status: number;
|
|
589
|
+
location: string;
|
|
590
|
+
revalidate: boolean;
|
|
591
|
+
reloadDocument?: boolean;
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* Unsuccessful result from a loader or action
|
|
595
|
+
*/
|
|
596
|
+
interface ErrorResult {
|
|
597
|
+
type: ResultType.error;
|
|
598
|
+
error: any;
|
|
599
|
+
headers?: Headers;
|
|
600
|
+
}
|
|
601
|
+
/**
|
|
602
|
+
* Result from a loader or action - potentially successful or unsuccessful
|
|
603
|
+
*/
|
|
604
|
+
type DataResult = SuccessResult | DeferredResult | RedirectResult | ErrorResult;
|
|
605
|
+
type LowerCaseFormMethod = "get" | "post" | "put" | "patch" | "delete";
|
|
606
|
+
type UpperCaseFormMethod = Uppercase<LowerCaseFormMethod>;
|
|
607
|
+
/**
|
|
608
|
+
* Active navigation/fetcher form methods are exposed in lowercase on the
|
|
609
|
+
* RouterState
|
|
610
|
+
*/
|
|
611
|
+
type FormMethod = LowerCaseFormMethod;
|
|
612
|
+
/**
|
|
613
|
+
* In v7, active navigation/fetcher form methods are exposed in uppercase on the
|
|
614
|
+
* RouterState. This is to align with the normalization done via fetch().
|
|
615
|
+
*/
|
|
616
|
+
type V7_FormMethod = UpperCaseFormMethod;
|
|
617
|
+
type FormEncType = "application/x-www-form-urlencoded" | "multipart/form-data" | "application/json" | "text/plain";
|
|
618
|
+
type JsonObject = {
|
|
619
|
+
[Key in string]: JsonValue;
|
|
620
|
+
} & {
|
|
621
|
+
[Key in string]?: JsonValue | undefined;
|
|
622
|
+
};
|
|
623
|
+
type JsonArray = JsonValue[] | readonly JsonValue[];
|
|
624
|
+
type JsonPrimitive = string | number | boolean | null;
|
|
625
|
+
type JsonValue = JsonPrimitive | JsonObject | JsonArray;
|
|
626
|
+
/**
|
|
627
|
+
* @private
|
|
628
|
+
* Internal interface to pass around for action submissions, not intended for
|
|
629
|
+
* external consumption
|
|
630
|
+
*/
|
|
631
|
+
type Submission = {
|
|
632
|
+
formMethod: FormMethod | V7_FormMethod;
|
|
633
|
+
formAction: string;
|
|
634
|
+
formEncType: FormEncType;
|
|
635
|
+
formData: FormData;
|
|
636
|
+
json: undefined;
|
|
637
|
+
text: undefined;
|
|
638
|
+
} | {
|
|
639
|
+
formMethod: FormMethod | V7_FormMethod;
|
|
640
|
+
formAction: string;
|
|
641
|
+
formEncType: FormEncType;
|
|
642
|
+
formData: undefined;
|
|
643
|
+
json: JsonValue;
|
|
644
|
+
text: undefined;
|
|
645
|
+
} | {
|
|
646
|
+
formMethod: FormMethod | V7_FormMethod;
|
|
647
|
+
formAction: string;
|
|
648
|
+
formEncType: FormEncType;
|
|
649
|
+
formData: undefined;
|
|
650
|
+
json: undefined;
|
|
651
|
+
text: string;
|
|
652
|
+
};
|
|
653
|
+
/**
|
|
654
|
+
* @private
|
|
655
|
+
* Arguments passed to route loader/action functions. Same for now but we keep
|
|
656
|
+
* this as a private implementation detail in case they diverge in the future.
|
|
657
|
+
*/
|
|
658
|
+
interface DataFunctionArgs {
|
|
659
|
+
request: Request;
|
|
660
|
+
params: Params;
|
|
661
|
+
context?: any;
|
|
662
|
+
}
|
|
663
|
+
/**
|
|
664
|
+
* Arguments passed to loader functions
|
|
665
|
+
*/
|
|
666
|
+
interface LoaderFunctionArgs extends DataFunctionArgs {
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* Arguments passed to action functions
|
|
670
|
+
*/
|
|
671
|
+
interface ActionFunctionArgs extends DataFunctionArgs {
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* Loaders and actions can return anything except `undefined` (`null` is a
|
|
675
|
+
* valid return value if there is no data to return). Responses are preferred
|
|
676
|
+
* and will ease any future migration to Remix
|
|
677
|
+
*/
|
|
678
|
+
type DataFunctionValue = Response | NonNullable<unknown> | null;
|
|
679
|
+
/**
|
|
680
|
+
* Route loader function signature
|
|
681
|
+
*/
|
|
682
|
+
interface LoaderFunction {
|
|
683
|
+
(args: LoaderFunctionArgs): Promise<DataFunctionValue> | DataFunctionValue;
|
|
684
|
+
}
|
|
685
|
+
/**
|
|
686
|
+
* Route action function signature
|
|
687
|
+
*/
|
|
688
|
+
interface ActionFunction {
|
|
689
|
+
(args: ActionFunctionArgs): Promise<DataFunctionValue> | DataFunctionValue;
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* Route shouldRevalidate function signature. This runs after any submission
|
|
693
|
+
* (navigation or fetcher), so we flatten the navigation/fetcher submission
|
|
694
|
+
* onto the arguments. It shouldn't matter whether it came from a navigation
|
|
695
|
+
* or a fetcher, what really matters is the URLs and the formData since loaders
|
|
696
|
+
* have to re-run based on the data models that were potentially mutated.
|
|
697
|
+
*/
|
|
698
|
+
interface ShouldRevalidateFunction {
|
|
699
|
+
(args: {
|
|
700
|
+
currentUrl: URL;
|
|
701
|
+
currentParams: AgnosticDataRouteMatch["params"];
|
|
702
|
+
nextUrl: URL;
|
|
703
|
+
nextParams: AgnosticDataRouteMatch["params"];
|
|
704
|
+
formMethod?: Submission["formMethod"];
|
|
705
|
+
formAction?: Submission["formAction"];
|
|
706
|
+
formEncType?: Submission["formEncType"];
|
|
707
|
+
text?: Submission["text"];
|
|
708
|
+
formData?: Submission["formData"];
|
|
709
|
+
json?: Submission["json"];
|
|
710
|
+
actionResult?: DataResult;
|
|
711
|
+
defaultShouldRevalidate: boolean;
|
|
712
|
+
}): boolean;
|
|
713
|
+
}
|
|
714
|
+
/**
|
|
715
|
+
* Keys we cannot change from within a lazy() function. We spread all other keys
|
|
716
|
+
* onto the route. Either they're meaningful to the router, or they'll get
|
|
717
|
+
* ignored.
|
|
718
|
+
*/
|
|
719
|
+
type ImmutableRouteKey = "lazy" | "caseSensitive" | "path" | "id" | "index" | "children";
|
|
720
|
+
type RequireOne<T, Key = keyof T> = Exclude<{
|
|
721
|
+
[K in keyof T]: K extends Key ? Omit<T, K> & Required<Pick<T, K>> : never;
|
|
722
|
+
}[keyof T], undefined>;
|
|
723
|
+
/**
|
|
724
|
+
* lazy() function to load a route definition, which can add non-matching
|
|
725
|
+
* related properties to a route
|
|
726
|
+
*/
|
|
727
|
+
interface LazyRouteFunction<R extends AgnosticRouteObject> {
|
|
728
|
+
(): Promise<RequireOne<Omit<R, ImmutableRouteKey>>>;
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* Base RouteObject with common props shared by all types of routes
|
|
732
|
+
*/
|
|
733
|
+
type AgnosticBaseRouteObject = {
|
|
734
|
+
caseSensitive?: boolean;
|
|
735
|
+
path?: string;
|
|
736
|
+
id?: string;
|
|
737
|
+
loader?: LoaderFunction;
|
|
738
|
+
action?: ActionFunction;
|
|
739
|
+
hasErrorBoundary?: boolean;
|
|
740
|
+
shouldRevalidate?: ShouldRevalidateFunction;
|
|
741
|
+
handle?: any;
|
|
742
|
+
lazy?: LazyRouteFunction<AgnosticBaseRouteObject>;
|
|
743
|
+
};
|
|
744
|
+
/**
|
|
745
|
+
* Index routes must not have children
|
|
746
|
+
*/
|
|
747
|
+
type AgnosticIndexRouteObject = AgnosticBaseRouteObject & {
|
|
748
|
+
children?: undefined;
|
|
749
|
+
index: true;
|
|
750
|
+
};
|
|
751
|
+
/**
|
|
752
|
+
* Non-index routes may have children, but cannot have index
|
|
753
|
+
*/
|
|
754
|
+
type AgnosticNonIndexRouteObject = AgnosticBaseRouteObject & {
|
|
755
|
+
children?: AgnosticRouteObject[];
|
|
756
|
+
index?: false;
|
|
757
|
+
};
|
|
758
|
+
/**
|
|
759
|
+
* A route object represents a logical route, with (optionally) its child
|
|
760
|
+
* routes organized in a tree-like structure.
|
|
761
|
+
*/
|
|
762
|
+
type AgnosticRouteObject = AgnosticIndexRouteObject | AgnosticNonIndexRouteObject;
|
|
763
|
+
type AgnosticDataIndexRouteObject = AgnosticIndexRouteObject & {
|
|
764
|
+
id: string;
|
|
765
|
+
};
|
|
766
|
+
type AgnosticDataNonIndexRouteObject = AgnosticNonIndexRouteObject & {
|
|
767
|
+
children?: AgnosticDataRouteObject[];
|
|
768
|
+
id: string;
|
|
769
|
+
};
|
|
770
|
+
/**
|
|
771
|
+
* A data route object, which is just a RouteObject with a required unique ID
|
|
772
|
+
*/
|
|
773
|
+
type AgnosticDataRouteObject = AgnosticDataIndexRouteObject | AgnosticDataNonIndexRouteObject;
|
|
774
|
+
/**
|
|
775
|
+
* The parameters that were parsed from the URL path.
|
|
776
|
+
*/
|
|
777
|
+
type Params<Key extends string = string> = {
|
|
778
|
+
readonly [key in Key]: string | undefined;
|
|
779
|
+
};
|
|
780
|
+
/**
|
|
781
|
+
* A RouteMatch contains info about how a route matched a URL.
|
|
782
|
+
*/
|
|
783
|
+
interface AgnosticRouteMatch<ParamKey extends string = string, RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject> {
|
|
784
|
+
/**
|
|
785
|
+
* The names and values of dynamic parameters in the URL.
|
|
786
|
+
*/
|
|
787
|
+
params: Params<ParamKey>;
|
|
788
|
+
/**
|
|
789
|
+
* The portion of the URL pathname that was matched.
|
|
790
|
+
*/
|
|
791
|
+
pathname: string;
|
|
792
|
+
/**
|
|
793
|
+
* The portion of the URL pathname that was matched before child routes.
|
|
794
|
+
*/
|
|
795
|
+
pathnameBase: string;
|
|
796
|
+
/**
|
|
797
|
+
* The route object that was used to match.
|
|
798
|
+
*/
|
|
799
|
+
route: RouteObjectType;
|
|
800
|
+
}
|
|
801
|
+
interface AgnosticDataRouteMatch extends AgnosticRouteMatch<string, AgnosticDataRouteObject> {
|
|
802
|
+
}
|
|
803
|
+
declare class DeferredData {
|
|
804
|
+
private pendingKeysSet;
|
|
805
|
+
private controller;
|
|
806
|
+
private abortPromise;
|
|
807
|
+
private unlistenAbortSignal;
|
|
808
|
+
private subscribers;
|
|
809
|
+
data: Record<string, unknown>;
|
|
810
|
+
init?: ResponseInit;
|
|
811
|
+
deferredKeys: string[];
|
|
812
|
+
constructor(data: Record<string, unknown>, responseInit?: ResponseInit);
|
|
813
|
+
private trackPromise;
|
|
814
|
+
private onSettle;
|
|
815
|
+
private emit;
|
|
816
|
+
subscribe(fn: (aborted: boolean, settledKey?: string) => void): () => boolean;
|
|
817
|
+
cancel(): void;
|
|
818
|
+
resolveData(signal: AbortSignal): Promise<boolean>;
|
|
819
|
+
get done(): boolean;
|
|
820
|
+
get unwrappedData(): {};
|
|
821
|
+
get pendingKeys(): string[];
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
/**
|
|
825
|
+
* State maintained internally by the router. During a navigation, all states
|
|
826
|
+
* reflect the the "old" location unless otherwise noted.
|
|
827
|
+
*/
|
|
828
|
+
interface RouterState {
|
|
829
|
+
/**
|
|
830
|
+
* The action of the most recent navigation
|
|
831
|
+
*/
|
|
832
|
+
historyAction: Action;
|
|
833
|
+
/**
|
|
834
|
+
* The current location reflected by the router
|
|
835
|
+
*/
|
|
836
|
+
location: Location;
|
|
837
|
+
/**
|
|
838
|
+
* The current set of route matches
|
|
839
|
+
*/
|
|
840
|
+
matches: AgnosticDataRouteMatch[];
|
|
841
|
+
/**
|
|
842
|
+
* Tracks whether we've completed our initial data load
|
|
843
|
+
*/
|
|
844
|
+
initialized: boolean;
|
|
845
|
+
/**
|
|
846
|
+
* Current scroll position we should start at for a new view
|
|
847
|
+
* - number -> scroll position to restore to
|
|
848
|
+
* - false -> do not restore scroll at all (used during submissions)
|
|
849
|
+
* - null -> don't have a saved position, scroll to hash or top of page
|
|
850
|
+
*/
|
|
851
|
+
restoreScrollPosition: number | false | null;
|
|
852
|
+
/**
|
|
853
|
+
* Indicate whether this navigation should skip resetting the scroll position
|
|
854
|
+
* if we are unable to restore the scroll position
|
|
855
|
+
*/
|
|
856
|
+
preventScrollReset: boolean;
|
|
857
|
+
/**
|
|
858
|
+
* Tracks the state of the current navigation
|
|
859
|
+
*/
|
|
860
|
+
navigation: Navigation;
|
|
861
|
+
/**
|
|
862
|
+
* Tracks any in-progress revalidations
|
|
863
|
+
*/
|
|
864
|
+
revalidation: RevalidationState;
|
|
865
|
+
/**
|
|
866
|
+
* Data from the loaders for the current matches
|
|
867
|
+
*/
|
|
868
|
+
loaderData: RouteData;
|
|
869
|
+
/**
|
|
870
|
+
* Data from the action for the current matches
|
|
871
|
+
*/
|
|
872
|
+
actionData: RouteData | null;
|
|
873
|
+
/**
|
|
874
|
+
* Errors caught from loaders for the current matches
|
|
875
|
+
*/
|
|
876
|
+
errors: RouteData | null;
|
|
877
|
+
/**
|
|
878
|
+
* Map of current fetchers
|
|
879
|
+
*/
|
|
880
|
+
fetchers: Map<string, Fetcher>;
|
|
881
|
+
/**
|
|
882
|
+
* Map of current blockers
|
|
883
|
+
*/
|
|
884
|
+
blockers: Map<string, Blocker>;
|
|
885
|
+
}
|
|
886
|
+
/**
|
|
887
|
+
* Data that can be passed into hydrate a Router from SSR
|
|
888
|
+
*/
|
|
889
|
+
type HydrationState = Partial<Pick<RouterState, "loaderData" | "actionData" | "errors">>;
|
|
890
|
+
/**
|
|
891
|
+
* Potential states for state.navigation
|
|
892
|
+
*/
|
|
893
|
+
type NavigationStates = {
|
|
894
|
+
Idle: {
|
|
895
|
+
state: "idle";
|
|
896
|
+
location: undefined;
|
|
897
|
+
formMethod: undefined;
|
|
898
|
+
formAction: undefined;
|
|
899
|
+
formEncType: undefined;
|
|
900
|
+
formData: undefined;
|
|
901
|
+
json: undefined;
|
|
902
|
+
text: undefined;
|
|
903
|
+
};
|
|
904
|
+
Loading: {
|
|
905
|
+
state: "loading";
|
|
906
|
+
location: Location;
|
|
907
|
+
formMethod: Submission["formMethod"] | undefined;
|
|
908
|
+
formAction: Submission["formAction"] | undefined;
|
|
909
|
+
formEncType: Submission["formEncType"] | undefined;
|
|
910
|
+
formData: Submission["formData"] | undefined;
|
|
911
|
+
json: Submission["json"] | undefined;
|
|
912
|
+
text: Submission["text"] | undefined;
|
|
913
|
+
};
|
|
914
|
+
Submitting: {
|
|
915
|
+
state: "submitting";
|
|
916
|
+
location: Location;
|
|
917
|
+
formMethod: Submission["formMethod"];
|
|
918
|
+
formAction: Submission["formAction"];
|
|
919
|
+
formEncType: Submission["formEncType"];
|
|
920
|
+
formData: Submission["formData"];
|
|
921
|
+
json: Submission["json"];
|
|
922
|
+
text: Submission["text"];
|
|
923
|
+
};
|
|
924
|
+
};
|
|
925
|
+
type Navigation = NavigationStates[keyof NavigationStates];
|
|
926
|
+
type RevalidationState = "idle" | "loading";
|
|
927
|
+
/**
|
|
928
|
+
* Potential states for fetchers
|
|
929
|
+
*/
|
|
930
|
+
type FetcherStates<TData = any> = {
|
|
931
|
+
Idle: {
|
|
932
|
+
state: "idle";
|
|
933
|
+
formMethod: undefined;
|
|
934
|
+
formAction: undefined;
|
|
935
|
+
formEncType: undefined;
|
|
936
|
+
text: undefined;
|
|
937
|
+
formData: undefined;
|
|
938
|
+
json: undefined;
|
|
939
|
+
data: TData | undefined;
|
|
940
|
+
" _hasFetcherDoneAnything "?: boolean;
|
|
941
|
+
};
|
|
942
|
+
Loading: {
|
|
943
|
+
state: "loading";
|
|
944
|
+
formMethod: Submission["formMethod"] | undefined;
|
|
945
|
+
formAction: Submission["formAction"] | undefined;
|
|
946
|
+
formEncType: Submission["formEncType"] | undefined;
|
|
947
|
+
text: Submission["text"] | undefined;
|
|
948
|
+
formData: Submission["formData"] | undefined;
|
|
949
|
+
json: Submission["json"] | undefined;
|
|
950
|
+
data: TData | undefined;
|
|
951
|
+
" _hasFetcherDoneAnything "?: boolean;
|
|
952
|
+
};
|
|
953
|
+
Submitting: {
|
|
954
|
+
state: "submitting";
|
|
955
|
+
formMethod: Submission["formMethod"];
|
|
956
|
+
formAction: Submission["formAction"];
|
|
957
|
+
formEncType: Submission["formEncType"];
|
|
958
|
+
text: Submission["text"];
|
|
959
|
+
formData: Submission["formData"];
|
|
960
|
+
json: Submission["json"];
|
|
961
|
+
data: TData | undefined;
|
|
962
|
+
" _hasFetcherDoneAnything "?: boolean;
|
|
963
|
+
};
|
|
964
|
+
};
|
|
965
|
+
type Fetcher<TData = any> = FetcherStates<TData>[keyof FetcherStates<TData>];
|
|
966
|
+
interface BlockerBlocked {
|
|
967
|
+
state: "blocked";
|
|
968
|
+
reset(): void;
|
|
969
|
+
proceed(): void;
|
|
970
|
+
location: Location;
|
|
971
|
+
}
|
|
972
|
+
interface BlockerUnblocked {
|
|
973
|
+
state: "unblocked";
|
|
974
|
+
reset: undefined;
|
|
975
|
+
proceed: undefined;
|
|
976
|
+
location: undefined;
|
|
977
|
+
}
|
|
978
|
+
interface BlockerProceeding {
|
|
979
|
+
state: "proceeding";
|
|
980
|
+
reset: undefined;
|
|
981
|
+
proceed: undefined;
|
|
982
|
+
location: Location;
|
|
983
|
+
}
|
|
984
|
+
type Blocker = BlockerUnblocked | BlockerBlocked | BlockerProceeding;
|
|
985
|
+
|
|
986
|
+
/**
|
|
987
|
+
* NOTE: If you refactor this to split up the modules into separate files,
|
|
988
|
+
* you'll need to update the rollup config for react-router-dom-v5-compat.
|
|
989
|
+
*/
|
|
990
|
+
|
|
991
|
+
declare global {
|
|
992
|
+
var __staticRouterHydrationData: HydrationState | undefined;
|
|
993
|
+
}
|
|
994
|
+
|
|
494
995
|
type TestProviderState = 'test-provider-state:pending' | 'test-provider-state:running' | 'test-provider-state:succeeded' | 'test-provider-state:crashed';
|
|
495
996
|
type TestProviderId = string;
|
|
496
997
|
type TestProviderStateByProviderId = Record<TestProviderId, TestProviderState>;
|
|
@@ -35134,16 +35134,16 @@ var j1 = /* @__PURE__ */ s((e, t, r) => e.startsWith(".") ? Ze(qs(r, Ua(Va(q1(t)
|
|
|
35134
35134
|
tags: k
|
|
35135
35135
|
};
|
|
35136
35136
|
});
|
|
35137
|
-
if (f.some((g) => g.tags.includes(Nn)) && this.options.build?.test?.disableAutoDocs !== !0) {
|
|
35138
|
-
let
|
|
35137
|
+
if (f.some((g) => g.tags.includes(Nn)) && !!this.options.docs && this.options.build?.test?.disableAutoDocs !== !0) {
|
|
35138
|
+
let b = this.options.docs?.defaultName ?? "Docs", { metaId: D } = l[0], { title: v } = f[0], S = qh(D ?? v, b), k = jh(...i, ...l[0].tags ??
|
|
35139
35139
|
[]);
|
|
35140
35140
|
f.unshift({
|
|
35141
|
-
id:
|
|
35142
|
-
title:
|
|
35143
|
-
name:
|
|
35141
|
+
id: S,
|
|
35142
|
+
title: v,
|
|
35143
|
+
name: b,
|
|
35144
35144
|
importPath: o,
|
|
35145
35145
|
type: "docs",
|
|
35146
|
-
tags:
|
|
35146
|
+
tags: k,
|
|
35147
35147
|
storiesImports: []
|
|
35148
35148
|
});
|
|
35149
35149
|
}
|
|
@@ -35193,7 +35193,7 @@ var j1 = /* @__PURE__ */ s((e, t, r) => e.startsWith(".") ? Ze(qs(r, Ua(Va(q1(t)
|
|
|
35193
35193
|
m,
|
|
35194
35194
|
"makeTitle created an undefined title. This happens when a specifier's doesn't have any matches in its fileName"
|
|
35195
35195
|
);
|
|
35196
|
-
let g = this.options.docs
|
|
35196
|
+
let g = this.options.docs?.defaultName ?? "Docs", b = c.name || (d ? Kg(a, d.importPath, g) : g), D = qh(d?.extra.metaId || m, b), v = jh(
|
|
35197
35197
|
...i,
|
|
35198
35198
|
...d?.tags ?? [],
|
|
35199
35199
|
...c.metaTags ?? [],
|
|
@@ -35229,8 +35229,8 @@ is: ${Vh.default.yellow(
|
|
|
35229
35229
|
r.importPath
|
|
35230
35230
|
]);
|
|
35231
35231
|
if (o.type === "story") {
|
|
35232
|
-
let l = Ui(a) ? "component docs page" : "automatically generated docs page";
|
|
35233
|
-
throw o.name ===
|
|
35232
|
+
let l = Ui(a) ? "component docs page" : "automatically generated docs page", c = this.options.docs?.defaultName ?? "Docs";
|
|
35233
|
+
throw o.name === c ? new Cr(
|
|
35234
35234
|
`You have a story for ${o.title} with the same name as your default docs entry name (${o.name}), so the docs page is being dropped. \
|
|
35235
35235
|
Consider changing the story name.`,
|
|
35236
35236
|
[t.importPath, r.importPath]
|
|
@@ -35812,7 +35812,7 @@ async function IC(e) {
|
|
|
35812
35812
|
o.apply("staticDirs"),
|
|
35813
35813
|
o.apply("experimental_indexers", []),
|
|
35814
35814
|
o.apply("stories"),
|
|
35815
|
-
o.apply("docs"
|
|
35815
|
+
o.apply("docs")
|
|
35816
35816
|
]), D = {
|
|
35817
35817
|
...e,
|
|
35818
35818
|
presets: o,
|
|
@@ -36672,7 +36672,7 @@ async function JS(e, t, r) {
|
|
|
36672
36672
|
let i = process.cwd(), n = t.configDir, o = {
|
|
36673
36673
|
configDir: n,
|
|
36674
36674
|
workingDir: i
|
|
36675
|
-
}, a = t.presets.apply("stories"), u = t.presets.apply("experimental_indexers", []), l = t.presets.apply("docs"
|
|
36675
|
+
}, a = t.presets.apply("stories"), u = t.presets.apply("experimental_indexers", []), l = t.presets.apply("docs"), c = Zz(await a, o), p = new Qr(
|
|
36676
36676
|
c, {
|
|
36677
36677
|
...o,
|
|
36678
36678
|
indexers: await u,
|
|
@@ -38131,7 +38131,7 @@ var BX = /* @__PURE__ */ s(async (e) => {
|
|
|
38131
38131
|
let { presets: t } = await Zm(e), [r, i, n] = await Promise.all([
|
|
38132
38132
|
t.apply("experimental_indexers", []),
|
|
38133
38133
|
t.apply("stories", []),
|
|
38134
|
-
t.apply("docs"
|
|
38134
|
+
t.apply("docs")
|
|
38135
38135
|
]), { configDir: o } = e, a = process.cwd(), u = {
|
|
38136
38136
|
configDir: o,
|
|
38137
38137
|
workingDir: a
|