storybook 9.0.0-beta.1 → 9.0.0-beta.11

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.
Files changed (94) hide show
  1. package/assets/server/base-preview-head.html +2 -1
  2. package/dist/actions/decorator.js +49 -52
  3. package/dist/actions/index.cjs +42 -44
  4. package/dist/actions/index.js +37 -40
  5. package/dist/actions/preview.cjs +44 -46
  6. package/dist/actions/preview.d.ts +501 -0
  7. package/dist/actions/preview.js +24 -27
  8. package/dist/babel/index.cjs +15060 -14974
  9. package/dist/babel/index.d.ts +37 -18
  10. package/dist/babel/index.js +15097 -15011
  11. package/dist/backgrounds/index.d.ts +501 -0
  12. package/dist/backgrounds/preview.d.ts +501 -0
  13. package/dist/bin/index.cjs +44 -44
  14. package/dist/bin/index.js +44 -44
  15. package/dist/builder-manager/index.cjs +303 -283
  16. package/dist/builder-manager/index.js +545 -524
  17. package/dist/channels/index.js +919 -941
  18. package/dist/cli/bin/index.cjs +4184 -736
  19. package/dist/cli/bin/index.js +4198 -748
  20. package/dist/cli/index.cjs +36838 -28392
  21. package/dist/cli/index.d.ts +974 -1
  22. package/dist/cli/index.js +41620 -33168
  23. package/dist/client-logger/index.d.ts +2 -1
  24. package/dist/common/index.cjs +4783 -4691
  25. package/dist/common/index.d.ts +8 -2
  26. package/dist/common/index.js +5165 -5069
  27. package/dist/components/index.cjs +7905 -5600
  28. package/dist/components/index.d.ts +12 -12
  29. package/dist/components/index.js +4713 -3786
  30. package/dist/controls/preview.d.ts +501 -0
  31. package/dist/core-server/index.cjs +6799 -6708
  32. package/dist/core-server/index.d.ts +526 -25
  33. package/dist/core-server/index.js +6948 -6851
  34. package/dist/core-server/presets/common-manager.js +4528 -3377
  35. package/dist/core-server/presets/common-override-preset.cjs +10 -12
  36. package/dist/core-server/presets/common-override-preset.js +3 -5
  37. package/dist/core-server/presets/common-preset.cjs +2301 -2238
  38. package/dist/core-server/presets/common-preset.js +2389 -2322
  39. package/dist/docs-tools/index.cjs +484 -464
  40. package/dist/docs-tools/index.js +781 -768
  41. package/dist/highlight/index.cjs +19 -18
  42. package/dist/highlight/index.d.ts +4 -5
  43. package/dist/highlight/index.js +3 -2
  44. package/dist/highlight/preview.cjs +314 -310
  45. package/dist/highlight/preview.d.ts +501 -0
  46. package/dist/highlight/preview.js +296 -292
  47. package/dist/instrumenter/index.cjs +561 -559
  48. package/dist/instrumenter/index.js +1564 -1516
  49. package/dist/manager/globals-module-info.cjs +2 -0
  50. package/dist/manager/globals-module-info.js +2 -0
  51. package/dist/manager/globals-runtime.js +23602 -23339
  52. package/dist/manager/runtime.js +4891 -4650
  53. package/dist/manager-api/index.cjs +2400 -2321
  54. package/dist/manager-api/index.d.ts +513 -1
  55. package/dist/manager-api/index.js +1951 -1903
  56. package/dist/manager-errors.js +37 -41
  57. package/dist/measure/index.d.ts +501 -0
  58. package/dist/measure/preview.d.ts +501 -0
  59. package/dist/node-logger/index.cjs +25 -25
  60. package/dist/node-logger/index.js +25 -25
  61. package/dist/outline/index.d.ts +501 -0
  62. package/dist/outline/preview.d.ts +501 -0
  63. package/dist/preview/runtime.js +35803 -35785
  64. package/dist/preview-api/index.cjs +1287 -1265
  65. package/dist/preview-api/index.d.ts +1 -1
  66. package/dist/preview-api/index.js +1367 -1361
  67. package/dist/preview-errors.js +152 -173
  68. package/dist/router/index.cjs +5674 -2282
  69. package/dist/router/index.d.ts +622 -243
  70. package/dist/router/index.js +1318 -872
  71. package/dist/server-errors.cjs +192 -177
  72. package/dist/server-errors.d.ts +11 -1
  73. package/dist/server-errors.js +173 -158
  74. package/dist/telemetry/index.cjs +4934 -1445
  75. package/dist/telemetry/index.d.ts +2 -1
  76. package/dist/telemetry/index.js +4966 -1475
  77. package/dist/test/index.cjs +1876 -1878
  78. package/dist/test/index.d.ts +1269 -83
  79. package/dist/test/index.js +9157 -9248
  80. package/dist/test/preview.cjs +49 -15862
  81. package/dist/test/preview.d.ts +520 -13
  82. package/dist/test/preview.js +42 -14493
  83. package/dist/theming/create.cjs +2244 -79
  84. package/dist/theming/create.js +951 -67
  85. package/dist/theming/index.cjs +3209 -1067
  86. package/dist/theming/index.js +1816 -947
  87. package/dist/types/index.cjs +4 -4
  88. package/dist/types/index.d.ts +3124 -2596
  89. package/dist/viewport/index.d.ts +502 -3
  90. package/dist/viewport/preview.d.ts +501 -0
  91. package/package.json +14 -38
  92. package/dist/test/spy.cjs +0 -258
  93. package/dist/test/spy.d.ts +0 -66
  94. package/dist/test/spy.js +0 -240
@@ -2,7 +2,7 @@ import React, { FC, ReactNode, ReactElement, Component } from 'react';
2
2
  import { Channel, Listener as Listener$1 } from 'storybook/internal/channels';
3
3
  export { Listener as ChannelListener } from 'storybook/internal/channels';
4
4
  import { RouterData, NavigateOptions } from 'storybook/internal/router';
5
- import { Addon_Types, Addon_TypesEnum, Addon_Collection, Addon_TypesMapping, Addon_BaseType, Addon_TestProviderType, Addon_PageType, Addon_WrapperType, Addon_Config, API_ProviderData, API_StateMerger, API_Provider, Globals, GlobalTypes, API_PanelPositions, API_Layout, API_UI, API_Notification, API_IframeRenderer, API_ComposedRef, API_SetRefData, API_ComposedRefUpdate, API_Refs, StoryId, API_Settings, API_HashEntry, API_ViewMode, API_LeafEntry, API_PreparedStoryIndex, API_StoryEntry, Args, API_IndexHash, API_DocsEntry, API_FilterFunction, API_LoadedRefData, API_Version, API_Versions, API_UnknownEntries, API_OptionsData, Parameters, ArgTypes, NormalizedProjectAnnotations, ProjectAnnotations, ComposedStoryFn } from 'storybook/internal/types';
5
+ import { Addon_Types, Addon_TypesEnum, Addon_Collection, Addon_TypesMapping, Addon_BaseType, Addon_TestProviderType, Addon_PageType, Addon_WrapperType, Addon_Config, API_ProviderData, API_StateMerger, API_Provider, Globals, GlobalTypes, API_PanelPositions, API_Layout, API_LayoutCustomisations, API_UI, API_Notification, API_IframeRenderer, API_ComposedRef, API_SetRefData, API_ComposedRefUpdate, API_Refs, StoryId, API_Settings, API_HashEntry, API_ViewMode, API_LeafEntry, API_PreparedStoryIndex, API_StoryEntry, Args, API_IndexHash, API_DocsEntry, API_FilterFunction, API_LoadedRefData, API_Version, API_Versions, API_UnknownEntries, API_OptionsData, Parameters, ArgTypes, NormalizedProjectAnnotations, ProjectAnnotations, ComposedStoryFn } from 'storybook/internal/types';
6
6
  export { Addon_Type as Addon, API_ComponentEntry as ComponentEntry, API_ComposedRef as ComposedRef, API_DocsEntry as DocsEntry, API_GroupEntry as GroupEntry, API_HashEntry as HashEntry, API_IndexHash as IndexHash, API_LeafEntry as LeafEntry, API_Refs as Refs, API_RootEntry as RootEntry, API_IndexHash as StoriesHash, API_StoryEntry as StoryEntry } from 'storybook/internal/types';
7
7
  import { ThemeVars } from 'storybook/theming';
8
8
  import { toId, StoryId as StoryId$1 } from 'storybook/internal/csf';
@@ -211,6 +211,7 @@ interface SubAPI$a {
211
211
 
212
212
  interface SubState$8 {
213
213
  layout: API_Layout;
214
+ layoutCustomisations: API_LayoutCustomisations;
214
215
  ui: API_UI;
215
216
  selectedPanel: string | undefined;
216
217
  theme: ThemeVars;
@@ -265,6 +266,16 @@ interface SubAPI$9 {
265
266
  getIsPanelShown: () => boolean;
266
267
  /** GetIsNavShown - Returns the current visibility of the navigation bar in the Storybook UI. */
267
268
  getIsNavShown: () => boolean;
269
+ /**
270
+ * GetShowToolbarWithCustomisations - Returns the current visibility of the toolbar, taking into
271
+ * account customisations requested by the end user via a layoutCustomisations function.
272
+ */
273
+ getShowToolbarWithCustomisations: (showToolbar: boolean) => boolean;
274
+ /**
275
+ * GetNavSizeWithCustomisations - Returns the size to apply to the sidebar/nav, taking into
276
+ * account customisations requested by the end user via a layoutCustomisations function.
277
+ */
278
+ getNavSizeWithCustomisations: (navSize: number) => number;
268
279
  }
269
280
 
270
281
  interface SubState$7 {
@@ -1211,6 +1222,507 @@ type StatusStoreByTypeId = StatusStore & {
1211
1222
  };
1212
1223
  type UseStatusStore = <T = StatusesByStoryIdAndTypeId>(selector?: (statuses: StatusesByStoryIdAndTypeId) => T) => T;
1213
1224
 
1225
+ /**
1226
+ * Actions represent the type of change to a location value.
1227
+ */
1228
+ declare enum Action {
1229
+ /**
1230
+ * A POP indicates a change to an arbitrary index in the history stack, such
1231
+ * as a back or forward navigation. It does not describe the direction of the
1232
+ * navigation, only that the current index changed.
1233
+ *
1234
+ * Note: This is the default action for newly created history objects.
1235
+ */
1236
+ Pop = "POP",
1237
+ /**
1238
+ * A PUSH indicates a new entry being added to the history stack, such as when
1239
+ * a link is clicked and a new page loads. When this happens, all subsequent
1240
+ * entries in the stack are lost.
1241
+ */
1242
+ Push = "PUSH",
1243
+ /**
1244
+ * A REPLACE indicates the entry at the current index in the history stack
1245
+ * being replaced by a new one.
1246
+ */
1247
+ Replace = "REPLACE"
1248
+ }
1249
+ /**
1250
+ * The pathname, search, and hash values of a URL.
1251
+ */
1252
+ interface Path {
1253
+ /**
1254
+ * A URL pathname, beginning with a /.
1255
+ */
1256
+ pathname: string;
1257
+ /**
1258
+ * A URL search string, beginning with a ?.
1259
+ */
1260
+ search: string;
1261
+ /**
1262
+ * A URL fragment identifier, beginning with a #.
1263
+ */
1264
+ hash: string;
1265
+ }
1266
+ /**
1267
+ * An entry in a history stack. A location contains information about the
1268
+ * URL path, as well as possibly some arbitrary state and a key.
1269
+ */
1270
+ interface Location extends Path {
1271
+ /**
1272
+ * A value of arbitrary data associated with this location.
1273
+ */
1274
+ state: any;
1275
+ /**
1276
+ * A unique string associated with this location. May be used to safely store
1277
+ * and retrieve data in some other storage API, like `localStorage`.
1278
+ *
1279
+ * Note: This value is always "default" on the initial location.
1280
+ */
1281
+ key: string;
1282
+ }
1283
+
1284
+ /**
1285
+ * Map of routeId -> data returned from a loader/action/error
1286
+ */
1287
+ interface RouteData {
1288
+ [routeId: string]: any;
1289
+ }
1290
+ declare enum ResultType {
1291
+ data = "data",
1292
+ deferred = "deferred",
1293
+ redirect = "redirect",
1294
+ error = "error"
1295
+ }
1296
+ /**
1297
+ * Successful result from a loader or action
1298
+ */
1299
+ interface SuccessResult {
1300
+ type: ResultType.data;
1301
+ data: any;
1302
+ statusCode?: number;
1303
+ headers?: Headers;
1304
+ }
1305
+ /**
1306
+ * Successful defer() result from a loader or action
1307
+ */
1308
+ interface DeferredResult {
1309
+ type: ResultType.deferred;
1310
+ deferredData: DeferredData;
1311
+ statusCode?: number;
1312
+ headers?: Headers;
1313
+ }
1314
+ /**
1315
+ * Redirect result from a loader or action
1316
+ */
1317
+ interface RedirectResult {
1318
+ type: ResultType.redirect;
1319
+ status: number;
1320
+ location: string;
1321
+ revalidate: boolean;
1322
+ reloadDocument?: boolean;
1323
+ }
1324
+ /**
1325
+ * Unsuccessful result from a loader or action
1326
+ */
1327
+ interface ErrorResult {
1328
+ type: ResultType.error;
1329
+ error: any;
1330
+ headers?: Headers;
1331
+ }
1332
+ /**
1333
+ * Result from a loader or action - potentially successful or unsuccessful
1334
+ */
1335
+ type DataResult = SuccessResult | DeferredResult | RedirectResult | ErrorResult;
1336
+ type LowerCaseFormMethod = "get" | "post" | "put" | "patch" | "delete";
1337
+ type UpperCaseFormMethod = Uppercase<LowerCaseFormMethod>;
1338
+ /**
1339
+ * Active navigation/fetcher form methods are exposed in lowercase on the
1340
+ * RouterState
1341
+ */
1342
+ type FormMethod = LowerCaseFormMethod;
1343
+ /**
1344
+ * In v7, active navigation/fetcher form methods are exposed in uppercase on the
1345
+ * RouterState. This is to align with the normalization done via fetch().
1346
+ */
1347
+ type V7_FormMethod = UpperCaseFormMethod;
1348
+ type FormEncType = "application/x-www-form-urlencoded" | "multipart/form-data" | "application/json" | "text/plain";
1349
+ type JsonObject = {
1350
+ [Key in string]: JsonValue;
1351
+ } & {
1352
+ [Key in string]?: JsonValue | undefined;
1353
+ };
1354
+ type JsonArray = JsonValue[] | readonly JsonValue[];
1355
+ type JsonPrimitive = string | number | boolean | null;
1356
+ type JsonValue = JsonPrimitive | JsonObject | JsonArray;
1357
+ /**
1358
+ * @private
1359
+ * Internal interface to pass around for action submissions, not intended for
1360
+ * external consumption
1361
+ */
1362
+ type Submission = {
1363
+ formMethod: FormMethod | V7_FormMethod;
1364
+ formAction: string;
1365
+ formEncType: FormEncType;
1366
+ formData: FormData;
1367
+ json: undefined;
1368
+ text: undefined;
1369
+ } | {
1370
+ formMethod: FormMethod | V7_FormMethod;
1371
+ formAction: string;
1372
+ formEncType: FormEncType;
1373
+ formData: undefined;
1374
+ json: JsonValue;
1375
+ text: undefined;
1376
+ } | {
1377
+ formMethod: FormMethod | V7_FormMethod;
1378
+ formAction: string;
1379
+ formEncType: FormEncType;
1380
+ formData: undefined;
1381
+ json: undefined;
1382
+ text: string;
1383
+ };
1384
+ /**
1385
+ * @private
1386
+ * Arguments passed to route loader/action functions. Same for now but we keep
1387
+ * this as a private implementation detail in case they diverge in the future.
1388
+ */
1389
+ interface DataFunctionArgs {
1390
+ request: Request;
1391
+ params: Params;
1392
+ context?: any;
1393
+ }
1394
+ /**
1395
+ * Arguments passed to loader functions
1396
+ */
1397
+ interface LoaderFunctionArgs extends DataFunctionArgs {
1398
+ }
1399
+ /**
1400
+ * Arguments passed to action functions
1401
+ */
1402
+ interface ActionFunctionArgs extends DataFunctionArgs {
1403
+ }
1404
+ /**
1405
+ * Loaders and actions can return anything except `undefined` (`null` is a
1406
+ * valid return value if there is no data to return). Responses are preferred
1407
+ * and will ease any future migration to Remix
1408
+ */
1409
+ type DataFunctionValue = Response | NonNullable<unknown> | null;
1410
+ /**
1411
+ * Route loader function signature
1412
+ */
1413
+ interface LoaderFunction {
1414
+ (args: LoaderFunctionArgs): Promise<DataFunctionValue> | DataFunctionValue;
1415
+ }
1416
+ /**
1417
+ * Route action function signature
1418
+ */
1419
+ interface ActionFunction {
1420
+ (args: ActionFunctionArgs): Promise<DataFunctionValue> | DataFunctionValue;
1421
+ }
1422
+ /**
1423
+ * Route shouldRevalidate function signature. This runs after any submission
1424
+ * (navigation or fetcher), so we flatten the navigation/fetcher submission
1425
+ * onto the arguments. It shouldn't matter whether it came from a navigation
1426
+ * or a fetcher, what really matters is the URLs and the formData since loaders
1427
+ * have to re-run based on the data models that were potentially mutated.
1428
+ */
1429
+ interface ShouldRevalidateFunction {
1430
+ (args: {
1431
+ currentUrl: URL;
1432
+ currentParams: AgnosticDataRouteMatch["params"];
1433
+ nextUrl: URL;
1434
+ nextParams: AgnosticDataRouteMatch["params"];
1435
+ formMethod?: Submission["formMethod"];
1436
+ formAction?: Submission["formAction"];
1437
+ formEncType?: Submission["formEncType"];
1438
+ text?: Submission["text"];
1439
+ formData?: Submission["formData"];
1440
+ json?: Submission["json"];
1441
+ actionResult?: DataResult;
1442
+ defaultShouldRevalidate: boolean;
1443
+ }): boolean;
1444
+ }
1445
+ /**
1446
+ * Keys we cannot change from within a lazy() function. We spread all other keys
1447
+ * onto the route. Either they're meaningful to the router, or they'll get
1448
+ * ignored.
1449
+ */
1450
+ type ImmutableRouteKey = "lazy" | "caseSensitive" | "path" | "id" | "index" | "children";
1451
+ type RequireOne<T, Key = keyof T> = Exclude<{
1452
+ [K in keyof T]: K extends Key ? Omit<T, K> & Required<Pick<T, K>> : never;
1453
+ }[keyof T], undefined>;
1454
+ /**
1455
+ * lazy() function to load a route definition, which can add non-matching
1456
+ * related properties to a route
1457
+ */
1458
+ interface LazyRouteFunction<R extends AgnosticRouteObject> {
1459
+ (): Promise<RequireOne<Omit<R, ImmutableRouteKey>>>;
1460
+ }
1461
+ /**
1462
+ * Base RouteObject with common props shared by all types of routes
1463
+ */
1464
+ type AgnosticBaseRouteObject = {
1465
+ caseSensitive?: boolean;
1466
+ path?: string;
1467
+ id?: string;
1468
+ loader?: LoaderFunction;
1469
+ action?: ActionFunction;
1470
+ hasErrorBoundary?: boolean;
1471
+ shouldRevalidate?: ShouldRevalidateFunction;
1472
+ handle?: any;
1473
+ lazy?: LazyRouteFunction<AgnosticBaseRouteObject>;
1474
+ };
1475
+ /**
1476
+ * Index routes must not have children
1477
+ */
1478
+ type AgnosticIndexRouteObject = AgnosticBaseRouteObject & {
1479
+ children?: undefined;
1480
+ index: true;
1481
+ };
1482
+ /**
1483
+ * Non-index routes may have children, but cannot have index
1484
+ */
1485
+ type AgnosticNonIndexRouteObject = AgnosticBaseRouteObject & {
1486
+ children?: AgnosticRouteObject[];
1487
+ index?: false;
1488
+ };
1489
+ /**
1490
+ * A route object represents a logical route, with (optionally) its child
1491
+ * routes organized in a tree-like structure.
1492
+ */
1493
+ type AgnosticRouteObject = AgnosticIndexRouteObject | AgnosticNonIndexRouteObject;
1494
+ type AgnosticDataIndexRouteObject = AgnosticIndexRouteObject & {
1495
+ id: string;
1496
+ };
1497
+ type AgnosticDataNonIndexRouteObject = AgnosticNonIndexRouteObject & {
1498
+ children?: AgnosticDataRouteObject[];
1499
+ id: string;
1500
+ };
1501
+ /**
1502
+ * A data route object, which is just a RouteObject with a required unique ID
1503
+ */
1504
+ type AgnosticDataRouteObject = AgnosticDataIndexRouteObject | AgnosticDataNonIndexRouteObject;
1505
+ /**
1506
+ * The parameters that were parsed from the URL path.
1507
+ */
1508
+ type Params<Key extends string = string> = {
1509
+ readonly [key in Key]: string | undefined;
1510
+ };
1511
+ /**
1512
+ * A RouteMatch contains info about how a route matched a URL.
1513
+ */
1514
+ interface AgnosticRouteMatch<ParamKey extends string = string, RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject> {
1515
+ /**
1516
+ * The names and values of dynamic parameters in the URL.
1517
+ */
1518
+ params: Params<ParamKey>;
1519
+ /**
1520
+ * The portion of the URL pathname that was matched.
1521
+ */
1522
+ pathname: string;
1523
+ /**
1524
+ * The portion of the URL pathname that was matched before child routes.
1525
+ */
1526
+ pathnameBase: string;
1527
+ /**
1528
+ * The route object that was used to match.
1529
+ */
1530
+ route: RouteObjectType;
1531
+ }
1532
+ interface AgnosticDataRouteMatch extends AgnosticRouteMatch<string, AgnosticDataRouteObject> {
1533
+ }
1534
+ declare class DeferredData {
1535
+ private pendingKeysSet;
1536
+ private controller;
1537
+ private abortPromise;
1538
+ private unlistenAbortSignal;
1539
+ private subscribers;
1540
+ data: Record<string, unknown>;
1541
+ init?: ResponseInit;
1542
+ deferredKeys: string[];
1543
+ constructor(data: Record<string, unknown>, responseInit?: ResponseInit);
1544
+ private trackPromise;
1545
+ private onSettle;
1546
+ private emit;
1547
+ subscribe(fn: (aborted: boolean, settledKey?: string) => void): () => boolean;
1548
+ cancel(): void;
1549
+ resolveData(signal: AbortSignal): Promise<boolean>;
1550
+ get done(): boolean;
1551
+ get unwrappedData(): {};
1552
+ get pendingKeys(): string[];
1553
+ }
1554
+
1555
+ /**
1556
+ * State maintained internally by the router. During a navigation, all states
1557
+ * reflect the the "old" location unless otherwise noted.
1558
+ */
1559
+ interface RouterState {
1560
+ /**
1561
+ * The action of the most recent navigation
1562
+ */
1563
+ historyAction: Action;
1564
+ /**
1565
+ * The current location reflected by the router
1566
+ */
1567
+ location: Location;
1568
+ /**
1569
+ * The current set of route matches
1570
+ */
1571
+ matches: AgnosticDataRouteMatch[];
1572
+ /**
1573
+ * Tracks whether we've completed our initial data load
1574
+ */
1575
+ initialized: boolean;
1576
+ /**
1577
+ * Current scroll position we should start at for a new view
1578
+ * - number -> scroll position to restore to
1579
+ * - false -> do not restore scroll at all (used during submissions)
1580
+ * - null -> don't have a saved position, scroll to hash or top of page
1581
+ */
1582
+ restoreScrollPosition: number | false | null;
1583
+ /**
1584
+ * Indicate whether this navigation should skip resetting the scroll position
1585
+ * if we are unable to restore the scroll position
1586
+ */
1587
+ preventScrollReset: boolean;
1588
+ /**
1589
+ * Tracks the state of the current navigation
1590
+ */
1591
+ navigation: Navigation;
1592
+ /**
1593
+ * Tracks any in-progress revalidations
1594
+ */
1595
+ revalidation: RevalidationState;
1596
+ /**
1597
+ * Data from the loaders for the current matches
1598
+ */
1599
+ loaderData: RouteData;
1600
+ /**
1601
+ * Data from the action for the current matches
1602
+ */
1603
+ actionData: RouteData | null;
1604
+ /**
1605
+ * Errors caught from loaders for the current matches
1606
+ */
1607
+ errors: RouteData | null;
1608
+ /**
1609
+ * Map of current fetchers
1610
+ */
1611
+ fetchers: Map<string, Fetcher>;
1612
+ /**
1613
+ * Map of current blockers
1614
+ */
1615
+ blockers: Map<string, Blocker>;
1616
+ }
1617
+ /**
1618
+ * Data that can be passed into hydrate a Router from SSR
1619
+ */
1620
+ type HydrationState = Partial<Pick<RouterState, "loaderData" | "actionData" | "errors">>;
1621
+ /**
1622
+ * Potential states for state.navigation
1623
+ */
1624
+ type NavigationStates = {
1625
+ Idle: {
1626
+ state: "idle";
1627
+ location: undefined;
1628
+ formMethod: undefined;
1629
+ formAction: undefined;
1630
+ formEncType: undefined;
1631
+ formData: undefined;
1632
+ json: undefined;
1633
+ text: undefined;
1634
+ };
1635
+ Loading: {
1636
+ state: "loading";
1637
+ location: Location;
1638
+ formMethod: Submission["formMethod"] | undefined;
1639
+ formAction: Submission["formAction"] | undefined;
1640
+ formEncType: Submission["formEncType"] | undefined;
1641
+ formData: Submission["formData"] | undefined;
1642
+ json: Submission["json"] | undefined;
1643
+ text: Submission["text"] | undefined;
1644
+ };
1645
+ Submitting: {
1646
+ state: "submitting";
1647
+ location: Location;
1648
+ formMethod: Submission["formMethod"];
1649
+ formAction: Submission["formAction"];
1650
+ formEncType: Submission["formEncType"];
1651
+ formData: Submission["formData"];
1652
+ json: Submission["json"];
1653
+ text: Submission["text"];
1654
+ };
1655
+ };
1656
+ type Navigation = NavigationStates[keyof NavigationStates];
1657
+ type RevalidationState = "idle" | "loading";
1658
+ /**
1659
+ * Potential states for fetchers
1660
+ */
1661
+ type FetcherStates<TData = any> = {
1662
+ Idle: {
1663
+ state: "idle";
1664
+ formMethod: undefined;
1665
+ formAction: undefined;
1666
+ formEncType: undefined;
1667
+ text: undefined;
1668
+ formData: undefined;
1669
+ json: undefined;
1670
+ data: TData | undefined;
1671
+ " _hasFetcherDoneAnything "?: boolean;
1672
+ };
1673
+ Loading: {
1674
+ state: "loading";
1675
+ formMethod: Submission["formMethod"] | undefined;
1676
+ formAction: Submission["formAction"] | undefined;
1677
+ formEncType: Submission["formEncType"] | undefined;
1678
+ text: Submission["text"] | undefined;
1679
+ formData: Submission["formData"] | undefined;
1680
+ json: Submission["json"] | undefined;
1681
+ data: TData | undefined;
1682
+ " _hasFetcherDoneAnything "?: boolean;
1683
+ };
1684
+ Submitting: {
1685
+ state: "submitting";
1686
+ formMethod: Submission["formMethod"];
1687
+ formAction: Submission["formAction"];
1688
+ formEncType: Submission["formEncType"];
1689
+ text: Submission["text"];
1690
+ formData: Submission["formData"];
1691
+ json: Submission["json"];
1692
+ data: TData | undefined;
1693
+ " _hasFetcherDoneAnything "?: boolean;
1694
+ };
1695
+ };
1696
+ type Fetcher<TData = any> = FetcherStates<TData>[keyof FetcherStates<TData>];
1697
+ interface BlockerBlocked {
1698
+ state: "blocked";
1699
+ reset(): void;
1700
+ proceed(): void;
1701
+ location: Location;
1702
+ }
1703
+ interface BlockerUnblocked {
1704
+ state: "unblocked";
1705
+ reset: undefined;
1706
+ proceed: undefined;
1707
+ location: undefined;
1708
+ }
1709
+ interface BlockerProceeding {
1710
+ state: "proceeding";
1711
+ reset: undefined;
1712
+ proceed: undefined;
1713
+ location: Location;
1714
+ }
1715
+ type Blocker = BlockerUnblocked | BlockerBlocked | BlockerProceeding;
1716
+
1717
+ /**
1718
+ * NOTE: If you refactor this to split up the modules into separate files,
1719
+ * you'll need to update the rollup config for react-router-dom-v5-compat.
1720
+ */
1721
+
1722
+ declare global {
1723
+ var __staticRouterHydrationData: HydrationState | undefined;
1724
+ }
1725
+
1214
1726
  declare global {
1215
1727
  interface SymbolConstructor {
1216
1728
  readonly observable: symbol;