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
@@ -1,39 +1,39 @@
1
1
  "use strict";
2
- var y = Object.defineProperty;
3
- var C = Object.getOwnPropertyDescriptor;
4
- var W = Object.getOwnPropertyNames;
5
- var M = Object.prototype.hasOwnProperty;
6
- var i = (e, t) => y(e, "name", { value: t, configurable: !0 });
7
- var l = (e, t) => {
2
+ var l = Object.defineProperty;
3
+ var F = Object.getOwnPropertyDescriptor;
4
+ var C = Object.getOwnPropertyNames;
5
+ var W = Object.prototype.hasOwnProperty;
6
+ var i = (e, t) => l(e, "name", { value: t, configurable: !0 });
7
+ var y = (e, t) => {
8
8
  for (var o in t)
9
- y(e, o, { get: t[o], enumerable: !0 });
10
- }, L = (e, t, o, r) => {
9
+ l(e, o, { get: t[o], enumerable: !0 });
10
+ }, M = (e, t, o, r) => {
11
11
  if (t && typeof t == "object" || typeof t == "function")
12
- for (let n of W(t))
13
- !M.call(e, n) && n !== o && y(e, n, { get: () => t[n], enumerable: !(r = C(t, n)) || r.enumerable });
12
+ for (let n of C(t))
13
+ !W.call(e, n) && n !== o && l(e, n, { get: () => t[n], enumerable: !(r = F(t, n)) || r.enumerable });
14
14
  return e;
15
15
  };
16
- var V = (e) => L(y({}, "__esModule", { value: !0 }), e);
16
+ var L = (e) => M(l({}, "__esModule", { value: !0 }), e);
17
17
 
18
18
  // src/actions/preview.ts
19
- var U = {};
20
- l(U, {
21
- default: () => H
19
+ var z = {};
20
+ y(z, {
21
+ default: () => K
22
22
  });
23
- module.exports = V(U);
24
- var P = require("storybook/preview-api");
23
+ module.exports = L(z);
24
+ var j = require("storybook/preview-api");
25
25
 
26
26
  // src/actions/addArgs.ts
27
27
  var A = {};
28
- l(A, {
29
- argsEnhancers: () => B
28
+ y(A, {
29
+ argsEnhancers: () => Y
30
30
  });
31
31
 
32
32
  // src/actions/runtime/action.ts
33
- var O = require("storybook/internal/preview-errors"), u = require("@storybook/global"), v = require("storybook/preview-api"), w = require("uuid");
33
+ var O = require("storybook/internal/preview-errors"), u = require("@storybook/global"), w = require("storybook/preview-api");
34
34
 
35
35
  // src/actions/constants.ts
36
- var f = "storybook/actions", J = `${f}/panel`, E = `${f}/action-event`, Q = `${f}/action-clear`;
36
+ var f = "storybook/actions", q = `${f}/panel`, E = `${f}/action-event`, G = `${f}/action-clear`;
37
37
 
38
38
  // src/actions/runtime/configureActions.ts
39
39
  var R = {
@@ -43,11 +43,11 @@ var R = {
43
43
  };
44
44
 
45
45
  // src/actions/runtime/action.ts
46
- var T = /* @__PURE__ */ i((e, t) => {
46
+ var v = /* @__PURE__ */ i((e, t) => {
47
47
  let o = Object.getPrototypeOf(e);
48
- return !o || t(o) ? o : T(o, t);
49
- }, "findProto"), N = /* @__PURE__ */ i((e) => !!(typeof e == "object" && e && T(e, (t) => /^Synthetic(?:Base)?Event$/.test(t.constructor.name)) &&
50
- typeof e.persist == "function"), "isReactSyntheticEvent"), Y = /* @__PURE__ */ i((e) => {
48
+ return !o || t(o) ? o : v(o, t);
49
+ }, "findProto"), N = /* @__PURE__ */ i((e) => !!(typeof e == "object" && e && v(e, (t) => /^Synthetic(?:Base)?Event$/.test(t.constructor.name)) &&
50
+ typeof e.persist == "function"), "isReactSyntheticEvent"), V = /* @__PURE__ */ i((e) => {
51
51
  if (N(e)) {
52
52
  let t = Object.create(
53
53
  e.constructor.prototype,
@@ -61,10 +61,7 @@ typeof e.persist == "function"), "isReactSyntheticEvent"), Y = /* @__PURE__ */ i
61
61
  }), t;
62
62
  }
63
63
  return e;
64
- }, "serializeArg"), $ = /* @__PURE__ */ i(() => typeof crypto == "object" && typeof crypto.getRandomValues == "function" ? (0, w.v4)() : (
65
- // pseudo random id, example response lo1e7zm4832bkr7yfl7
66
- Date.now().toString(36) + Math.random().toString(36).substring(2)
67
- ), "generateId");
64
+ }, "serializeArg");
68
65
  function g(e, t = {}) {
69
66
  let o = {
70
67
  ...R,
@@ -86,23 +83,24 @@ function g(e, t = {}) {
86
83
  throw b;
87
84
  }
88
85
  }
89
- let a = v.addons.getChannel(), c = $(), p = 5, m = s.map(Y), S = s.length > 1 ? m : m[0], F = {
86
+ let a = w.addons.getChannel(), c = Date.now().toString(36) + Math.random().toString(36).substring(2), p = 5, m = s.map(V), P = s.length >
87
+ 1 ? m : m[0], S = {
90
88
  id: c,
91
89
  count: 0,
92
- data: { name: e, args: S },
90
+ data: { name: e, args: P },
93
91
  options: {
94
92
  ...o,
95
93
  maxDepth: p + (o.depth || 3)
96
94
  }
97
95
  };
98
- a.emit(E, F);
96
+ a.emit(E, S);
99
97
  }, "actionHandler");
100
98
  return r.isAction = !0, r.implicit = t.implicit, r;
101
99
  }
102
100
  i(g, "action");
103
101
 
104
102
  // src/actions/addArgsHelpers.ts
105
- var _ = /* @__PURE__ */ i((e, t) => typeof t[e] > "u" && !(e in t), "isInInitialArgs"), D = /* @__PURE__ */ i((e) => {
103
+ var T = /* @__PURE__ */ i((e, t) => typeof t[e] > "u" && !(e in t), "isInInitialArgs"), _ = /* @__PURE__ */ i((e) => {
106
104
  let {
107
105
  initialArgs: t,
108
106
  argTypes: o,
@@ -114,32 +112,32 @@ var _ = /* @__PURE__ */ i((e, t) => typeof t[e] > "u" && !(e in t), "isInInitial
114
112
  let s = new RegExp(n.argTypesRegex);
115
113
  return Object.entries(o).filter(
116
114
  ([c]) => !!s.test(c)
117
- ).reduce((c, [p, m]) => (_(p, t) && (c[p] = g(p, { implicit: !0, id: r })), c), {});
118
- }, "inferActionsFromArgTypesRegex"), k = /* @__PURE__ */ i((e) => {
115
+ ).reduce((c, [p, m]) => (T(p, t) && (c[p] = g(p, { implicit: !0, id: r })), c), {});
116
+ }, "inferActionsFromArgTypesRegex"), D = /* @__PURE__ */ i((e) => {
119
117
  let {
120
118
  initialArgs: t,
121
119
  argTypes: o,
122
120
  parameters: { actions: r }
123
121
  } = e;
124
- return r?.disable || !o ? {} : Object.entries(o).filter(([s, a]) => !!a.action).reduce((s, [a, c]) => (_(a, t) && (s[a] = g(typeof c.action ==
122
+ return r?.disable || !o ? {} : Object.entries(o).filter(([s, a]) => !!a.action).reduce((s, [a, c]) => (T(a, t) && (s[a] = g(typeof c.action ==
125
123
  "string" ? c.action : a)), s), {});
126
124
  }, "addActionsFromArgTypes");
127
125
 
128
126
  // src/actions/addArgs.ts
129
- var B = [
130
- k,
131
- D
127
+ var Y = [
128
+ D,
129
+ _
132
130
  ];
133
131
 
134
132
  // src/actions/loaders.ts
135
133
  var h = {};
136
- l(h, {
137
- loaders: () => z
134
+ y(h, {
135
+ loaders: () => B
138
136
  });
139
- var j = require("storybook/test/spy");
140
- var I = !1, K = /* @__PURE__ */ i((e) => {
137
+ var I = require("storybook/test");
138
+ var k = !1, $ = /* @__PURE__ */ i((e) => {
141
139
  let { parameters: t } = e;
142
- t?.actions?.disable || I || ((0, j.onMockCall)((o, r) => {
140
+ t?.actions?.disable || k || ((0, I.onMockCall)((o, r) => {
143
141
  let n = o.getMockName();
144
142
  n !== "spy" && (!/^next\/.*::/.test(n) || [
145
143
  "next/router::useRouter()",
@@ -151,11 +149,11 @@ var I = !1, K = /* @__PURE__ */ i((e) => {
151
149
  "next/headers::headers().set",
152
150
  "next/headers::headers().delete"
153
151
  ].some((s) => n.startsWith(s))) && g(n)(r);
154
- }), I = !0);
155
- }, "logActionsWhenMockCalled"), z = [K];
152
+ }), k = !0);
153
+ }, "logActionsWhenMockCalled"), B = [$];
156
154
 
157
155
  // src/actions/preview.ts
158
- var H = /* @__PURE__ */ i(() => (0, P.definePreview)({
156
+ var K = /* @__PURE__ */ i(() => (0, j.definePreview)({
159
157
  ...A,
160
158
  ...h
161
159
  }), "default");
@@ -1,6 +1,507 @@
1
1
  import { Renderer as Renderer$1, ProjectAnnotations as ProjectAnnotations$1, StoryIdentifier, StoryContext, PartialStoryFn, LegacyStoryFn } from 'storybook/internal/csf';
2
2
  import { NormalizedProjectAnnotations, ProjectAnnotations as ProjectAnnotations$2, ComposedStoryFn } from 'storybook/internal/types';
3
3
 
4
+ /**
5
+ * Actions represent the type of change to a location value.
6
+ */
7
+ declare enum Action {
8
+ /**
9
+ * A POP indicates a change to an arbitrary index in the history stack, such
10
+ * as a back or forward navigation. It does not describe the direction of the
11
+ * navigation, only that the current index changed.
12
+ *
13
+ * Note: This is the default action for newly created history objects.
14
+ */
15
+ Pop = "POP",
16
+ /**
17
+ * A PUSH indicates a new entry being added to the history stack, such as when
18
+ * a link is clicked and a new page loads. When this happens, all subsequent
19
+ * entries in the stack are lost.
20
+ */
21
+ Push = "PUSH",
22
+ /**
23
+ * A REPLACE indicates the entry at the current index in the history stack
24
+ * being replaced by a new one.
25
+ */
26
+ Replace = "REPLACE"
27
+ }
28
+ /**
29
+ * The pathname, search, and hash values of a URL.
30
+ */
31
+ interface Path {
32
+ /**
33
+ * A URL pathname, beginning with a /.
34
+ */
35
+ pathname: string;
36
+ /**
37
+ * A URL search string, beginning with a ?.
38
+ */
39
+ search: string;
40
+ /**
41
+ * A URL fragment identifier, beginning with a #.
42
+ */
43
+ hash: string;
44
+ }
45
+ /**
46
+ * An entry in a history stack. A location contains information about the
47
+ * URL path, as well as possibly some arbitrary state and a key.
48
+ */
49
+ interface Location extends Path {
50
+ /**
51
+ * A value of arbitrary data associated with this location.
52
+ */
53
+ state: any;
54
+ /**
55
+ * A unique string associated with this location. May be used to safely store
56
+ * and retrieve data in some other storage API, like `localStorage`.
57
+ *
58
+ * Note: This value is always "default" on the initial location.
59
+ */
60
+ key: string;
61
+ }
62
+
63
+ /**
64
+ * Map of routeId -> data returned from a loader/action/error
65
+ */
66
+ interface RouteData {
67
+ [routeId: string]: any;
68
+ }
69
+ declare enum ResultType {
70
+ data = "data",
71
+ deferred = "deferred",
72
+ redirect = "redirect",
73
+ error = "error"
74
+ }
75
+ /**
76
+ * Successful result from a loader or action
77
+ */
78
+ interface SuccessResult {
79
+ type: ResultType.data;
80
+ data: any;
81
+ statusCode?: number;
82
+ headers?: Headers;
83
+ }
84
+ /**
85
+ * Successful defer() result from a loader or action
86
+ */
87
+ interface DeferredResult {
88
+ type: ResultType.deferred;
89
+ deferredData: DeferredData;
90
+ statusCode?: number;
91
+ headers?: Headers;
92
+ }
93
+ /**
94
+ * Redirect result from a loader or action
95
+ */
96
+ interface RedirectResult {
97
+ type: ResultType.redirect;
98
+ status: number;
99
+ location: string;
100
+ revalidate: boolean;
101
+ reloadDocument?: boolean;
102
+ }
103
+ /**
104
+ * Unsuccessful result from a loader or action
105
+ */
106
+ interface ErrorResult {
107
+ type: ResultType.error;
108
+ error: any;
109
+ headers?: Headers;
110
+ }
111
+ /**
112
+ * Result from a loader or action - potentially successful or unsuccessful
113
+ */
114
+ type DataResult = SuccessResult | DeferredResult | RedirectResult | ErrorResult;
115
+ type LowerCaseFormMethod = "get" | "post" | "put" | "patch" | "delete";
116
+ type UpperCaseFormMethod = Uppercase<LowerCaseFormMethod>;
117
+ /**
118
+ * Active navigation/fetcher form methods are exposed in lowercase on the
119
+ * RouterState
120
+ */
121
+ type FormMethod = LowerCaseFormMethod;
122
+ /**
123
+ * In v7, active navigation/fetcher form methods are exposed in uppercase on the
124
+ * RouterState. This is to align with the normalization done via fetch().
125
+ */
126
+ type V7_FormMethod = UpperCaseFormMethod;
127
+ type FormEncType = "application/x-www-form-urlencoded" | "multipart/form-data" | "application/json" | "text/plain";
128
+ type JsonObject = {
129
+ [Key in string]: JsonValue;
130
+ } & {
131
+ [Key in string]?: JsonValue | undefined;
132
+ };
133
+ type JsonArray = JsonValue[] | readonly JsonValue[];
134
+ type JsonPrimitive = string | number | boolean | null;
135
+ type JsonValue = JsonPrimitive | JsonObject | JsonArray;
136
+ /**
137
+ * @private
138
+ * Internal interface to pass around for action submissions, not intended for
139
+ * external consumption
140
+ */
141
+ type Submission = {
142
+ formMethod: FormMethod | V7_FormMethod;
143
+ formAction: string;
144
+ formEncType: FormEncType;
145
+ formData: FormData;
146
+ json: undefined;
147
+ text: undefined;
148
+ } | {
149
+ formMethod: FormMethod | V7_FormMethod;
150
+ formAction: string;
151
+ formEncType: FormEncType;
152
+ formData: undefined;
153
+ json: JsonValue;
154
+ text: undefined;
155
+ } | {
156
+ formMethod: FormMethod | V7_FormMethod;
157
+ formAction: string;
158
+ formEncType: FormEncType;
159
+ formData: undefined;
160
+ json: undefined;
161
+ text: string;
162
+ };
163
+ /**
164
+ * @private
165
+ * Arguments passed to route loader/action functions. Same for now but we keep
166
+ * this as a private implementation detail in case they diverge in the future.
167
+ */
168
+ interface DataFunctionArgs {
169
+ request: Request;
170
+ params: Params;
171
+ context?: any;
172
+ }
173
+ /**
174
+ * Arguments passed to loader functions
175
+ */
176
+ interface LoaderFunctionArgs extends DataFunctionArgs {
177
+ }
178
+ /**
179
+ * Arguments passed to action functions
180
+ */
181
+ interface ActionFunctionArgs extends DataFunctionArgs {
182
+ }
183
+ /**
184
+ * Loaders and actions can return anything except `undefined` (`null` is a
185
+ * valid return value if there is no data to return). Responses are preferred
186
+ * and will ease any future migration to Remix
187
+ */
188
+ type DataFunctionValue = Response | NonNullable<unknown> | null;
189
+ /**
190
+ * Route loader function signature
191
+ */
192
+ interface LoaderFunction {
193
+ (args: LoaderFunctionArgs): Promise<DataFunctionValue> | DataFunctionValue;
194
+ }
195
+ /**
196
+ * Route action function signature
197
+ */
198
+ interface ActionFunction {
199
+ (args: ActionFunctionArgs): Promise<DataFunctionValue> | DataFunctionValue;
200
+ }
201
+ /**
202
+ * Route shouldRevalidate function signature. This runs after any submission
203
+ * (navigation or fetcher), so we flatten the navigation/fetcher submission
204
+ * onto the arguments. It shouldn't matter whether it came from a navigation
205
+ * or a fetcher, what really matters is the URLs and the formData since loaders
206
+ * have to re-run based on the data models that were potentially mutated.
207
+ */
208
+ interface ShouldRevalidateFunction {
209
+ (args: {
210
+ currentUrl: URL;
211
+ currentParams: AgnosticDataRouteMatch["params"];
212
+ nextUrl: URL;
213
+ nextParams: AgnosticDataRouteMatch["params"];
214
+ formMethod?: Submission["formMethod"];
215
+ formAction?: Submission["formAction"];
216
+ formEncType?: Submission["formEncType"];
217
+ text?: Submission["text"];
218
+ formData?: Submission["formData"];
219
+ json?: Submission["json"];
220
+ actionResult?: DataResult;
221
+ defaultShouldRevalidate: boolean;
222
+ }): boolean;
223
+ }
224
+ /**
225
+ * Keys we cannot change from within a lazy() function. We spread all other keys
226
+ * onto the route. Either they're meaningful to the router, or they'll get
227
+ * ignored.
228
+ */
229
+ type ImmutableRouteKey = "lazy" | "caseSensitive" | "path" | "id" | "index" | "children";
230
+ type RequireOne<T, Key = keyof T> = Exclude<{
231
+ [K in keyof T]: K extends Key ? Omit<T, K> & Required<Pick<T, K>> : never;
232
+ }[keyof T], undefined>;
233
+ /**
234
+ * lazy() function to load a route definition, which can add non-matching
235
+ * related properties to a route
236
+ */
237
+ interface LazyRouteFunction<R extends AgnosticRouteObject> {
238
+ (): Promise<RequireOne<Omit<R, ImmutableRouteKey>>>;
239
+ }
240
+ /**
241
+ * Base RouteObject with common props shared by all types of routes
242
+ */
243
+ type AgnosticBaseRouteObject = {
244
+ caseSensitive?: boolean;
245
+ path?: string;
246
+ id?: string;
247
+ loader?: LoaderFunction;
248
+ action?: ActionFunction;
249
+ hasErrorBoundary?: boolean;
250
+ shouldRevalidate?: ShouldRevalidateFunction;
251
+ handle?: any;
252
+ lazy?: LazyRouteFunction<AgnosticBaseRouteObject>;
253
+ };
254
+ /**
255
+ * Index routes must not have children
256
+ */
257
+ type AgnosticIndexRouteObject = AgnosticBaseRouteObject & {
258
+ children?: undefined;
259
+ index: true;
260
+ };
261
+ /**
262
+ * Non-index routes may have children, but cannot have index
263
+ */
264
+ type AgnosticNonIndexRouteObject = AgnosticBaseRouteObject & {
265
+ children?: AgnosticRouteObject[];
266
+ index?: false;
267
+ };
268
+ /**
269
+ * A route object represents a logical route, with (optionally) its child
270
+ * routes organized in a tree-like structure.
271
+ */
272
+ type AgnosticRouteObject = AgnosticIndexRouteObject | AgnosticNonIndexRouteObject;
273
+ type AgnosticDataIndexRouteObject = AgnosticIndexRouteObject & {
274
+ id: string;
275
+ };
276
+ type AgnosticDataNonIndexRouteObject = AgnosticNonIndexRouteObject & {
277
+ children?: AgnosticDataRouteObject[];
278
+ id: string;
279
+ };
280
+ /**
281
+ * A data route object, which is just a RouteObject with a required unique ID
282
+ */
283
+ type AgnosticDataRouteObject = AgnosticDataIndexRouteObject | AgnosticDataNonIndexRouteObject;
284
+ /**
285
+ * The parameters that were parsed from the URL path.
286
+ */
287
+ type Params<Key extends string = string> = {
288
+ readonly [key in Key]: string | undefined;
289
+ };
290
+ /**
291
+ * A RouteMatch contains info about how a route matched a URL.
292
+ */
293
+ interface AgnosticRouteMatch<ParamKey extends string = string, RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject> {
294
+ /**
295
+ * The names and values of dynamic parameters in the URL.
296
+ */
297
+ params: Params<ParamKey>;
298
+ /**
299
+ * The portion of the URL pathname that was matched.
300
+ */
301
+ pathname: string;
302
+ /**
303
+ * The portion of the URL pathname that was matched before child routes.
304
+ */
305
+ pathnameBase: string;
306
+ /**
307
+ * The route object that was used to match.
308
+ */
309
+ route: RouteObjectType;
310
+ }
311
+ interface AgnosticDataRouteMatch extends AgnosticRouteMatch<string, AgnosticDataRouteObject> {
312
+ }
313
+ declare class DeferredData {
314
+ private pendingKeysSet;
315
+ private controller;
316
+ private abortPromise;
317
+ private unlistenAbortSignal;
318
+ private subscribers;
319
+ data: Record<string, unknown>;
320
+ init?: ResponseInit;
321
+ deferredKeys: string[];
322
+ constructor(data: Record<string, unknown>, responseInit?: ResponseInit);
323
+ private trackPromise;
324
+ private onSettle;
325
+ private emit;
326
+ subscribe(fn: (aborted: boolean, settledKey?: string) => void): () => boolean;
327
+ cancel(): void;
328
+ resolveData(signal: AbortSignal): Promise<boolean>;
329
+ get done(): boolean;
330
+ get unwrappedData(): {};
331
+ get pendingKeys(): string[];
332
+ }
333
+
334
+ /**
335
+ * State maintained internally by the router. During a navigation, all states
336
+ * reflect the the "old" location unless otherwise noted.
337
+ */
338
+ interface RouterState {
339
+ /**
340
+ * The action of the most recent navigation
341
+ */
342
+ historyAction: Action;
343
+ /**
344
+ * The current location reflected by the router
345
+ */
346
+ location: Location;
347
+ /**
348
+ * The current set of route matches
349
+ */
350
+ matches: AgnosticDataRouteMatch[];
351
+ /**
352
+ * Tracks whether we've completed our initial data load
353
+ */
354
+ initialized: boolean;
355
+ /**
356
+ * Current scroll position we should start at for a new view
357
+ * - number -> scroll position to restore to
358
+ * - false -> do not restore scroll at all (used during submissions)
359
+ * - null -> don't have a saved position, scroll to hash or top of page
360
+ */
361
+ restoreScrollPosition: number | false | null;
362
+ /**
363
+ * Indicate whether this navigation should skip resetting the scroll position
364
+ * if we are unable to restore the scroll position
365
+ */
366
+ preventScrollReset: boolean;
367
+ /**
368
+ * Tracks the state of the current navigation
369
+ */
370
+ navigation: Navigation;
371
+ /**
372
+ * Tracks any in-progress revalidations
373
+ */
374
+ revalidation: RevalidationState;
375
+ /**
376
+ * Data from the loaders for the current matches
377
+ */
378
+ loaderData: RouteData;
379
+ /**
380
+ * Data from the action for the current matches
381
+ */
382
+ actionData: RouteData | null;
383
+ /**
384
+ * Errors caught from loaders for the current matches
385
+ */
386
+ errors: RouteData | null;
387
+ /**
388
+ * Map of current fetchers
389
+ */
390
+ fetchers: Map<string, Fetcher>;
391
+ /**
392
+ * Map of current blockers
393
+ */
394
+ blockers: Map<string, Blocker>;
395
+ }
396
+ /**
397
+ * Data that can be passed into hydrate a Router from SSR
398
+ */
399
+ type HydrationState = Partial<Pick<RouterState, "loaderData" | "actionData" | "errors">>;
400
+ /**
401
+ * Potential states for state.navigation
402
+ */
403
+ type NavigationStates = {
404
+ Idle: {
405
+ state: "idle";
406
+ location: undefined;
407
+ formMethod: undefined;
408
+ formAction: undefined;
409
+ formEncType: undefined;
410
+ formData: undefined;
411
+ json: undefined;
412
+ text: undefined;
413
+ };
414
+ Loading: {
415
+ state: "loading";
416
+ location: Location;
417
+ formMethod: Submission["formMethod"] | undefined;
418
+ formAction: Submission["formAction"] | undefined;
419
+ formEncType: Submission["formEncType"] | undefined;
420
+ formData: Submission["formData"] | undefined;
421
+ json: Submission["json"] | undefined;
422
+ text: Submission["text"] | undefined;
423
+ };
424
+ Submitting: {
425
+ state: "submitting";
426
+ location: Location;
427
+ formMethod: Submission["formMethod"];
428
+ formAction: Submission["formAction"];
429
+ formEncType: Submission["formEncType"];
430
+ formData: Submission["formData"];
431
+ json: Submission["json"];
432
+ text: Submission["text"];
433
+ };
434
+ };
435
+ type Navigation = NavigationStates[keyof NavigationStates];
436
+ type RevalidationState = "idle" | "loading";
437
+ /**
438
+ * Potential states for fetchers
439
+ */
440
+ type FetcherStates<TData = any> = {
441
+ Idle: {
442
+ state: "idle";
443
+ formMethod: undefined;
444
+ formAction: undefined;
445
+ formEncType: undefined;
446
+ text: undefined;
447
+ formData: undefined;
448
+ json: undefined;
449
+ data: TData | undefined;
450
+ " _hasFetcherDoneAnything "?: boolean;
451
+ };
452
+ Loading: {
453
+ state: "loading";
454
+ formMethod: Submission["formMethod"] | undefined;
455
+ formAction: Submission["formAction"] | undefined;
456
+ formEncType: Submission["formEncType"] | undefined;
457
+ text: Submission["text"] | undefined;
458
+ formData: Submission["formData"] | undefined;
459
+ json: Submission["json"] | undefined;
460
+ data: TData | undefined;
461
+ " _hasFetcherDoneAnything "?: boolean;
462
+ };
463
+ Submitting: {
464
+ state: "submitting";
465
+ formMethod: Submission["formMethod"];
466
+ formAction: Submission["formAction"];
467
+ formEncType: Submission["formEncType"];
468
+ text: Submission["text"];
469
+ formData: Submission["formData"];
470
+ json: Submission["json"];
471
+ data: TData | undefined;
472
+ " _hasFetcherDoneAnything "?: boolean;
473
+ };
474
+ };
475
+ type Fetcher<TData = any> = FetcherStates<TData>[keyof FetcherStates<TData>];
476
+ interface BlockerBlocked {
477
+ state: "blocked";
478
+ reset(): void;
479
+ proceed(): void;
480
+ location: Location;
481
+ }
482
+ interface BlockerUnblocked {
483
+ state: "unblocked";
484
+ reset: undefined;
485
+ proceed: undefined;
486
+ location: undefined;
487
+ }
488
+ interface BlockerProceeding {
489
+ state: "proceeding";
490
+ reset: undefined;
491
+ proceed: undefined;
492
+ location: Location;
493
+ }
494
+ type Blocker = BlockerUnblocked | BlockerBlocked | BlockerProceeding;
495
+
496
+ /**
497
+ * NOTE: If you refactor this to split up the modules into separate files,
498
+ * you'll need to update the rollup config for react-router-dom-v5-compat.
499
+ */
500
+
501
+ declare global {
502
+ var __staticRouterHydrationData: HydrationState | undefined;
503
+ }
504
+
4
505
  declare global {
5
506
  interface SymbolConstructor {
6
507
  readonly observable: symbol;