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