-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
/
Copy pathindex.d.ts
764 lines (709 loc) · 23.2 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import type {RuleSetRule, Configuration as WebpackConfiguration} from 'webpack';
import type {CustomizeRuleString} from 'webpack-merge/dist/types';
import type {CommanderStatic} from 'commander';
import type {ParsedUrlQueryInput} from 'querystring';
import type Joi from 'joi';
import type {HelmetServerState} from 'react-helmet-async';
import type {
DeepRequired,
Required as RequireKeys,
DeepPartial,
} from 'utility-types';
import type {Location} from 'history';
// === Configuration ===
export type ReportingSeverity = 'ignore' | 'log' | 'warn' | 'error' | 'throw';
export type PluginOptions = {id?: string} & {[key: string]: unknown};
export type PluginConfig =
| string
| [string, PluginOptions]
| [PluginModule, PluginOptions]
| PluginModule
| false
| null;
export type PresetConfig =
| string
| [string, {[key: string]: unknown}]
| false
| null;
export type ThemeConfig = {
[key: string]: unknown;
};
export type I18nLocaleConfig = {
/** The label displayed for this locale in the locales dropdown. */
label: string;
/**
* BCP 47 language tag to use in `<html lang="...">` and in
* `<link ... hreflang="...">`
*/
htmlLang: string;
/** Used to select the locale's CSS and html meta attribute. */
direction: 'ltr' | 'rtl';
/**
* The [calendar](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/calendar)
* used to calculate the date era. Note that it doesn't control the actual
* string displayed: `MM/DD/YYYY` and `DD/MM/YYYY` are both gregory. To choose
* the format (`DD/MM/YYYY` or `MM/DD/YYYY`), set your locale name to `en-GB`
* or `en-US` (`en` means `en-US`).
*/
calendar: string;
};
export type I18nConfig = {
/**
* The locale that:
* 1. Does not have its name in the base URL
* 2. Gets started with `docusaurus start` without `--locale` option
* 3. Will be used for the `<link hrefLang="x-default">` tag
*/
defaultLocale: string;
/**
* Root folder which all locale folders are relative to. Can be absolute or
* relative to the config file. e.g. `i18n`
*/
path: string;
/** List of locales deployed on your site. Must contain `defaultLocale`. */
locales: [string, ...string[]];
/** Individual options for each locale. */
localeConfigs: {[locale: string]: Partial<I18nLocaleConfig>};
};
/**
* Docusaurus config, after validation/normalization.
*/
export type DocusaurusConfig = {
/**
* Title for your website. Will be used in metadata and as browser tab title.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#title
*/
title: string;
/**
* URL for your website. This can also be considered the top-level hostname.
* For example, `https://facebook.github.io` is the URL of
* https://facebook.github.io/metro/, and `https://docusaurus.io` is the URL
* for https://docusaurus.io.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#url
*/
url: string;
/**
* Can be considered as the path after the host. For example, `/metro/` is the
* base URL of https://facebook.github.io/metro/. For URLs that have no path,
* it should be set to `/`. Always has both leading and trailing slash.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#baseUrl
*/
baseUrl: string;
/**
* Path to your site favicon; must be a URL that can be used in link's href.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#favicon
*/
favicon?: string;
/**
* Allow to customize the presence/absence of a trailing slash at the end of
* URLs/links, and how static HTML files are generated:
*
* - `undefined` (default): keeps URLs untouched, and emit
* `/docs/myDoc/index.html` for `/docs/myDoc.md`
* - `true`: add trailing slashes to URLs/links, and emit
* `/docs/myDoc/index.html` for `/docs/myDoc.md`
* - `false`: remove trailing slashes from URLs/links, and emit
* `/docs/myDoc.html` for `/docs/myDoc.md`
*
* @see https://github.com/slorber/trailing-slash-guide
* @see https://docusaurus.io/docs/api/docusaurus-config#trailingSlash
* @default undefined
*/
trailingSlash: boolean | undefined;
/**
* The i18n configuration object to [localize your
* site](https://docusaurus.io/docs/i18n/introduction).
*
* @see https://docusaurus.io/docs/api/docusaurus-config#i18n
*/
i18n: I18nConfig;
/**
* This option adds `<meta name="robots" content="noindex, nofollow">` to
* every page to tell search engines to avoid indexing your site.
*
* @see https://moz.com/learn/seo/robots-meta-directives
* @see https://docusaurus.io/docs/api/docusaurus-config#noIndex
* @default false
*/
noIndex: boolean;
orphanPages?: {
onOrphanPage: ReportingSeverity;
entryPoints: string[];
};
/**
* The behavior of Docusaurus when it detects any broken link.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#onBrokenLinks
* @default "throw"
*/
onBrokenLinks: ReportingSeverity;
/**
* The behavior of Docusaurus when it detects any broken markdown link.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#onBrokenMarkdownLinks
* @default "warn"
*/
onBrokenMarkdownLinks: ReportingSeverity;
/**
* The behavior of Docusaurus when it detects any [duplicate
* routes](https://docusaurus.io/docs/creating-pages#duplicate-routes).
*
* @see https://docusaurus.io/docs/api/docusaurus-config#onDuplicateRoutes
* @default "warn"
*/
onDuplicateRoutes: ReportingSeverity;
/**
* The tagline for your website.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#tagline
* @default ""
*/
tagline: string;
/**
* The GitHub user or organization that owns the repository. You don't need
* this if you are not using the `docusaurus deploy` command.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#organizationName
*/
organizationName?: string;
/**
* The name of the GitHub repository. You don't need this if you are not using
* the `docusaurus deploy` command.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#projectName
*/
projectName?: string;
/**
* The name of the branch to deploy the static files to. You don't need this
* if you are not using the `docusaurus deploy` command.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#deploymentBranch
*/
deploymentBranch?: string;
/**
* The hostname of your server. Useful if you are using GitHub Enterprise. You
* don't need this if you are not using the `docusaurus deploy` command.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#githubHost
*/
githubHost?: string;
/**
* The port of your server. Useful if you are using GitHub Enterprise. You
* don't need this if you are not using the `docusaurus deploy` command.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#githubPort
*/
githubPort?: string;
/**
* The [theme configuration](https://docusaurus.io/docs/api/themes/configuration)
* object to customize your site UI like navbar and footer.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#themeConfig
* @default {}
*/
themeConfig: ThemeConfig;
/**
* List of plugins.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#plugins
* @default []
*/
plugins: PluginConfig[];
/**
* List of themes.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#themes
* @default []
*/
themes: PluginConfig[];
/**
* List of presets.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#presets
* @default []
*/
presets: PresetConfig[];
/**
* Docusaurus guards `docusaurus.config.js` from unknown fields. To add a
* custom field, define it on `customFields`.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#customFields
* @default {}
*/
customFields?: {
[key: string]: unknown;
};
/**
* An array of paths, relative to the site's directory or absolute. Files
* under these paths will be copied to the build output as-is.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#staticDirectories
* @default ["static"]
*/
staticDirectories: string[];
/**
* An array of scripts to load. The values can be either strings or plain
* objects of attribute-value maps. The `<script>` tags will be inserted in
* the HTML `<head>`.
*
* Note that `<script>` added here are render-blocking, so you might want to
* add `async: true`/`defer: true` to the objects.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#scripts
* @default []
*/
scripts: (
| string
| {
src: string;
[key: string]: string | boolean | undefined;
}
)[];
/**
* An array of CSS sources to load. The values can be either strings or plain
* objects of attribute-value maps. The `<link>` tags will be inserted in the
* HTML `<head>`.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#stylesheets
* @default []
*/
stylesheets: (
| string
| {
href: string;
[key: string]: string | boolean | undefined;
}
)[];
/**
* An array of [client modules](https://docusaurus.io/docs/advanced/client#client-modules)
* to load globally on your site.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#clientModules
* @default []
*/
clientModules: string[];
/**
* An HTML template written in [Eta's syntax](https://eta.js.org/docs/syntax#syntax-overview)
* that will be used to render your application. This can be used to set
* custom attributes on the `body` tags, additional `meta` tags, customize the
* `viewport`, etc. Please note that Docusaurus will rely on the template to
* be correctly structured in order to function properly, once you do
* customize it, you will have to make sure that your template is compliant
* with the requirements from upstream.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#ssrTemplate
*/
ssrTemplate?: string;
/**
* Will be used as title delimiter in the generated `<title>` tag.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#titleDelimiter
* @default "|"
*/
titleDelimiter: string;
/**
* When enabled, will show a banner in case your site can't load its CSS or
* JavaScript files, which is a very common issue, often related to a wrong
* `baseUrl` in site config.
*
* @see https://docusaurus.io/docs/api/docusaurus-config#baseUrlIssueBanner
* @default true
*/
baseUrlIssueBanner: boolean;
/** Webpack-related options. */
webpack?: {
/**
* Configuration for alternative JS loaders. "babel" will use the built-in
* Babel loader and preset; otherwise, you can provide your custom Webpack
* rule set.
*/
jsLoader: 'babel' | ((isServer: boolean) => RuleSetRule);
};
};
/**
* Docusaurus config, as provided by the user (partial/unnormalized). This type
* is used to provide type-safety / IDE auto-complete on the config file.
* @see https://docusaurus.io/docs/typescript-support
*/
export type Config = RequireKeys<
DeepPartial<DocusaurusConfig>,
'title' | 'url' | 'baseUrl'
>;
// === Data loading ===
/**
* - `type: 'package'`, plugin is in a different package.
* - `type: 'project'`, plugin is in the same docusaurus project.
* - `type: 'local'`, none of the plugin's ancestor directories contains a
* package.json.
* - `type: 'synthetic'`, docusaurus generated internal plugin.
*/
export type PluginVersionInformation =
| {
readonly type: 'package';
readonly name?: string;
readonly version?: string;
}
| {readonly type: 'project'}
| {readonly type: 'local'}
| {readonly type: 'synthetic'};
export type SiteMetadata = {
readonly docusaurusVersion: string;
readonly siteVersion?: string;
readonly pluginVersions: {[pluginName: string]: PluginVersionInformation};
};
/**
* Inspired by Chrome JSON, because it's a widely supported i18n format
* @see https://developer.chrome.com/apps/i18n-messages
* @see https://support.crowdin.com/file-formats/chrome-json/
* @see https://www.applanga.com/docs/formats/chrome_i18n_json
* @see https://docs.transifex.com/formats/chrome-json
* @see https://help.phrase.com/help/chrome-json-messages
*/
export type TranslationMessage = {message: string; description?: string};
export type TranslationFileContent = {[msgId: string]: TranslationMessage};
/**
* An abstract representation of how a translation file exists on disk. The core
* would handle the file reading/writing; plugins just need to deal with
* translations in-memory.
*/
export type TranslationFile = {
/**
* Relative to the directory where it's expected to be found. For plugin
* files, it's relative to `i18n/<locale>/<pluginName>/<pluginId>`. Should NOT
* have any extension.
*/
path: string;
content: TranslationFileContent;
};
export type I18n = DeepRequired<I18nConfig> & {currentLocale: string};
export type GlobalData = {[pluginName: string]: {[pluginId: string]: unknown}};
export type CodeTranslations = {[msgId: string]: string};
export type DocusaurusContext = {
siteConfig: DocusaurusConfig;
siteMetadata: SiteMetadata;
globalData: GlobalData;
i18n: I18n;
codeTranslations: CodeTranslations;
// Don't put mutable values here, to avoid triggering re-renders
// We could reconsider that choice if context selectors are implemented
// isBrowser: boolean; // Not here on purpose!
};
export type LoadContext = {
siteDir: string;
generatedFilesDir: string;
siteConfig: DocusaurusConfig;
siteConfigPath: string;
outDir: string;
/**
* Directory where all source translations for the current locale can be found
* in. Constructed with `i18n.path` + `i18n.currentLocale.path` (e.g.
* `<siteDir>/i18n/en`)
*/
localizationDir: string;
/**
* Duplicated from `siteConfig.baseUrl`, but probably worth keeping. We mutate
* `siteConfig` to make `baseUrl` there localized as well, but that's mostly
* for client-side. `context.baseUrl` is still more convenient for plugins.
*/
baseUrl: string;
i18n: I18n;
codeTranslations: CodeTranslations;
};
export type Props = LoadContext & {
headTags: string;
preBodyTags: string;
postBodyTags: string;
siteMetadata: SiteMetadata;
routes: RouteConfig[];
routesPaths: string[];
plugins: LoadedPlugin[];
};
// === Plugin ===
export type PluginContentLoadedActions = {
addRoute: (config: RouteConfig) => void;
createData: (name: string, data: string) => Promise<string>;
setGlobalData: (data: unknown) => void;
};
export type ConfigureWebpackUtils = {
getStyleLoaders: (
isServer: boolean,
cssOptions: {[key: string]: unknown},
) => RuleSetRule[];
getJSLoader: (options: {
isServer: boolean;
babelOptions?: {[key: string]: unknown};
}) => RuleSetRule;
};
export type AllContent = {
[pluginName: string]: {
[pluginID: string]: unknown;
};
};
// TODO improve type (not exposed by postcss-loader)
export type PostCssOptions = {plugins: unknown[]; [key: string]: unknown};
type HtmlTagObject = {
/**
* Attributes of the html tag.
* E.g. `{ disabled: true, value: "demo", rel: "preconnect" }`
*/
attributes?: Partial<{[key: string]: string | boolean}>;
/** The tag name, e.g. `div`, `script`, `link`, `meta` */
tagName: string;
/** The inner HTML */
innerHTML?: string;
};
export type HtmlTags = string | HtmlTagObject | (string | HtmlTagObject)[];
export type ValidationSchema<T> = Joi.ObjectSchema<T>;
export type Validate<In, Out> = (
validationSchema: ValidationSchema<Out>,
options: In,
) => Out;
export type OptionValidationContext<In, Out> = {
validate: Validate<In, Out>;
options: In;
};
export type ThemeConfigValidationContext<In, Out = In> = {
validate: Validate<In, Out>;
themeConfig: In;
};
export type Plugin<Content = unknown> = {
name: string;
loadContent?: () => Promise<Content> | Content;
contentLoaded?: (args: {
/** The content loaded by this plugin instance */
content: Content; //
/** Content loaded by ALL the plugins */
allContent: AllContent;
actions: PluginContentLoadedActions;
}) => Promise<void> | void;
postBuild?: (
props: Props & {
content: Content;
head: {[location: string]: HelmetServerState};
},
) => Promise<void> | void;
// TODO refactor the configureWebpack API surface: use an object instead of
// multiple params (requires breaking change)
configureWebpack?: (
config: WebpackConfiguration,
isServer: boolean,
utils: ConfigureWebpackUtils,
content: Content,
) => WebpackConfiguration & {
mergeStrategy?: {
[key: string]: CustomizeRuleString;
};
};
configurePostCss?: (options: PostCssOptions) => PostCssOptions;
getThemePath?: () => string;
getTypeScriptThemePath?: () => string;
getPathsToWatch?: () => string[];
getClientModules?: () => string[];
extendCli?: (cli: CommanderStatic) => void;
injectHtmlTags?: (args: {content: Content}) => {
headTags?: HtmlTags;
preBodyTags?: HtmlTags;
postBodyTags?: HtmlTags;
};
// TODO before/afterDevServer implementation
// translations
getTranslationFiles?: (args: {
content: Content;
}) => Promise<TranslationFile[]> | TranslationFile[];
getDefaultCodeTranslationMessages?: () =>
| Promise<{[id: string]: string}>
| {[id: string]: string};
translateContent?: (args: {
/** The content loaded by this plugin instance. */
content: Content;
translationFiles: TranslationFile[];
}) => Content;
translateThemeConfig?: (args: {
themeConfig: ThemeConfig;
translationFiles: TranslationFile[];
}) => ThemeConfig;
};
export type InitializedPlugin = Plugin & {
readonly options: Required<PluginOptions>;
readonly version: PluginVersionInformation;
/** The absolute path to the folder containing the entry point file. */
readonly path: string;
};
export type LoadedPlugin = InitializedPlugin & {
readonly content: unknown;
};
export type SwizzleAction = 'eject' | 'wrap';
export type SwizzleActionStatus = 'safe' | 'unsafe' | 'forbidden';
export type SwizzleComponentConfig = {
actions: {[action in SwizzleAction]: SwizzleActionStatus};
description?: string;
};
export type SwizzleConfig = {
components: {[componentName: string]: SwizzleComponentConfig};
// Other settings could be added here, like the ability to declare the config
// as exhaustive so that we can emit errors
};
export type PluginModule = {
(context: LoadContext, options: unknown): Plugin | Promise<Plugin>;
validateOptions?: <T, U>(data: OptionValidationContext<T, U>) => U;
validateThemeConfig?: <T>(data: ThemeConfigValidationContext<T>) => T;
getSwizzleComponentList?: () => string[] | undefined; // TODO deprecate this one later
getSwizzleConfig?: () => SwizzleConfig | undefined;
};
export type Preset = {
plugins?: PluginConfig[];
themes?: PluginConfig[];
};
export type PresetModule = {
(context: LoadContext, presetOptions: unknown): Preset;
};
// === Route registry ===
/**
* A "module" represents a unit of serialized data emitted from the plugin. It
* will be imported on client-side and passed as props, context, etc.
*
* If it's a string, it's a file path that Webpack can `require`; if it's
* an object, it can also contain `query` or other metadata.
*/
export type Module =
| {
/**
* A marker that tells the route generator this is an import and not a
* nested object to recurse.
*/
__import?: boolean;
path: string;
query?: ParsedUrlQueryInput;
}
| string;
/**
* Represents the data attached to each route. Since the routes.js is a
* monolithic data file, any data (like props) should be serialized separately
* and registered here as file paths (a {@link Module}), so that we could
* code-split.
*/
export type RouteModules = {
[propName: string]: Module | RouteModules | RouteModules[];
};
/**
* Represents a "slice" of the final route structure returned from the plugin
* `addRoute` action.
*/
export type RouteConfig = {
/** With leading slash. Trailing slash will be normalized by config. */
path: string;
/** Component used to render this route, a path that Webpack can `require`. */
component: string;
/**
* Props. Each entry should be `[propName]: pathToPropModule` (created with
* `createData`)
*/
modules?: RouteModules;
/**
* The route context will wrap the `component`. Use `useRouteContext` to
* retrieve what's declared here. Note that all custom route context declared
* here will be namespaced under {@link RouteContext.data}.
*/
context?: RouteModules;
/** Nested routes config. */
routes?: RouteConfig[];
/** React router config option: `exact` routes would not match subroutes. */
exact?: boolean;
/** Used to sort routes. Higher-priority routes will be placed first. */
priority?: number;
/** Extra props; will be copied to routes.js. */
[propName: string]: unknown;
};
export type RouteContext = {
/**
* Plugin-specific context data.
*/
data?: object | undefined;
};
/**
* Top-level plugin routes automatically add some context data to the route.
* This permits us to know which plugin is handling the current route.
*/
export type PluginRouteContext = RouteContext & {
plugin: {
id: string;
name: string;
};
};
/**
* The shape would be isomorphic to {@link RouteModules}:
* {@link Module} -> `string`, `RouteModules[]` -> `ChunkNames[]`.
*
* Each `string` chunk name will correlate with one key in the {@link Registry}.
*/
export type ChunkNames = {
[propName: string]: string | ChunkNames | ChunkNames[];
};
/**
* A map from route paths (with a hash) to the chunk names of each module, which
* the bundler will collect.
*
* Chunk keys are routes with a hash, because 2 routes can conflict with each
* other if they have the same path, e.g.: parent=/docs, child=/docs
*
* @see https://github.com/facebook/docusaurus/issues/2917
*/
export type RouteChunkNames = {
[routePathHashed: string]: ChunkNames;
};
/**
* Each key is the chunk name, which you can get from `routeChunkNames` (see
* {@link RouteChunkNames}). The values are the opts data that react-loadable
* needs. For example:
*
* ```js
* const options = {
* optsLoader: {
* component: () => import('./Pages.js'),
* content.foo: () => import('./doc1.md'),
* },
* optsModules: ['./Pages.js', './doc1.md'],
* optsWebpack: [
* require.resolveWeak('./Pages.js'),
* require.resolveWeak('./doc1.md'),
* ],
* }
* ```
*
* @see https://github.com/jamiebuilds/react-loadable#declaring-which-modules-are-being-loaded
*/
export type Registry = {
readonly [chunkName: string]: [
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Loader: () => Promise<any>,
ModuleName: string,
ResolvedModuleName: string,
];
};
export type ClientModule = {
onRouteDidUpdate?: (args: {
previousLocation: Location | null;
location: Location;
}) => (() => void) | void;
onRouteUpdate?: (args: {
previousLocation: Location | null;
location: Location;
}) => (() => void) | void;
};
export type UseDataOptions = {
/**
* Throw an error, or simply return undefined if the data cannot be found. Use
* `true` if you are sure the data must exist.
*/
failfast?: boolean;
};