@docusaurus/plugin-client-redirects 2.0.0-beta.2 → 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/lib/collectRedirects.d.ts +1 -1
- package/lib/collectRedirects.js +38 -42
- package/lib/createRedirectPageContent.d.ts +2 -4
- package/lib/createRedirectPageContent.js +2 -4
- package/lib/extensionRedirects.d.ts +1 -1
- package/lib/extensionRedirects.js +12 -8
- package/lib/index.d.ts +5 -3
- package/lib/index.js +8 -15
- package/lib/options.d.ts +31 -0
- package/lib/options.js +36 -0
- package/lib/redirectValidation.d.ts +1 -1
- package/lib/types.d.ts +12 -14
- package/lib/writeRedirectFiles.d.ts +1 -1
- package/lib/writeRedirectFiles.js +33 -9
- package/package.json +16 -14
- package/src/collectRedirects.ts +48 -55
- package/src/createRedirectPageContent.ts +8 -10
- package/src/extensionRedirects.ts +17 -9
- package/src/index.ts +9 -21
- package/src/options.ts +71 -0
- package/src/redirectValidation.ts +1 -1
- package/src/types.ts +14 -28
- package/src/writeRedirectFiles.ts +40 -10
- package/lib/.tsbuildinfo +0 -1
- package/lib/normalizePluginOptions.d.ts +0 -9
- package/lib/normalizePluginOptions.js +0 -44
- package/src/__tests__/__snapshots__/collectRedirects.test.ts.snap +0 -27
- package/src/__tests__/__snapshots__/createRedirectPageContent.test.ts.snap +0 -29
- package/src/__tests__/__snapshots__/normalizePluginOptions.test.ts.snap +0 -35
- package/src/__tests__/__snapshots__/redirectValidation.test.ts.snap +0 -11
- package/src/__tests__/__snapshots__/writeRedirectFiles.test.ts.snap +0 -147
- package/src/__tests__/collectRedirects.test.ts +0 -340
- package/src/__tests__/createRedirectPageContent.test.ts +0 -26
- package/src/__tests__/extensionRedirects.test.ts +0 -140
- package/src/__tests__/normalizePluginOptions.test.ts +0 -76
- package/src/__tests__/redirectValidation.test.ts +0 -66
- package/src/__tests__/writeRedirectFiles.test.ts +0 -203
- package/src/normalizePluginOptions.ts +0 -55
- package/tsconfig.json +0 -10
package/src/collectRedirects.ts
CHANGED
|
@@ -5,59 +5,64 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
RedirectMetadata,
|
|
12
|
-
PluginOptions,
|
|
13
|
-
RedirectOption,
|
|
14
|
-
} from './types';
|
|
8
|
+
import _ from 'lodash';
|
|
9
|
+
import type {PluginOptions, RedirectOption} from './options';
|
|
10
|
+
import type {PluginContext, RedirectMetadata} from './types';
|
|
15
11
|
import {
|
|
16
12
|
createFromExtensionsRedirects,
|
|
17
13
|
createToExtensionsRedirects,
|
|
18
14
|
} from './extensionRedirects';
|
|
19
15
|
import {validateRedirect} from './redirectValidation';
|
|
20
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
applyTrailingSlash,
|
|
18
|
+
type ApplyTrailingSlashParams,
|
|
19
|
+
} from '@docusaurus/utils-common';
|
|
21
20
|
|
|
22
|
-
import
|
|
21
|
+
import logger from '@docusaurus/logger';
|
|
23
22
|
|
|
24
23
|
export default function collectRedirects(
|
|
25
24
|
pluginContext: PluginContext,
|
|
26
25
|
trailingSlash: boolean | undefined,
|
|
27
26
|
): RedirectMetadata[] {
|
|
28
27
|
let redirects = doCollectRedirects(pluginContext);
|
|
29
|
-
|
|
28
|
+
|
|
29
|
+
redirects = applyRedirectsTrailingSlash(redirects, {
|
|
30
|
+
trailingSlash,
|
|
31
|
+
baseUrl: pluginContext.baseUrl,
|
|
32
|
+
});
|
|
33
|
+
|
|
30
34
|
validateCollectedRedirects(redirects, pluginContext);
|
|
31
35
|
return filterUnwantedRedirects(redirects, pluginContext);
|
|
32
36
|
}
|
|
33
37
|
|
|
34
38
|
// If users wants to redirect to=/abc and they enable trailingSlash=true then
|
|
35
|
-
// => we don't want to reject the to=/abc (as only /abc/ is an existing/valid
|
|
36
|
-
//
|
|
37
|
-
//
|
|
39
|
+
// => we don't want to reject the to=/abc (as only /abc/ is an existing/valid
|
|
40
|
+
// path now)
|
|
41
|
+
// => we want to redirect to=/abc/ without the user having to change all its
|
|
42
|
+
// redirect plugin options
|
|
43
|
+
// It should be easy to toggle siteConfig.trailingSlash option without having to
|
|
44
|
+
// change other configs
|
|
38
45
|
function applyRedirectsTrailingSlash(
|
|
39
46
|
redirects: RedirectMetadata[],
|
|
40
|
-
|
|
47
|
+
params: ApplyTrailingSlashParams,
|
|
41
48
|
) {
|
|
42
|
-
return redirects.map((redirect) => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
};
|
|
47
|
-
});
|
|
49
|
+
return redirects.map((redirect) => ({
|
|
50
|
+
...redirect,
|
|
51
|
+
to: applyTrailingSlash(redirect.to, params),
|
|
52
|
+
}));
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
function validateCollectedRedirects(
|
|
51
56
|
redirects: RedirectMetadata[],
|
|
52
57
|
pluginContext: PluginContext,
|
|
53
58
|
) {
|
|
54
|
-
const redirectValidationErrors
|
|
59
|
+
const redirectValidationErrors = redirects
|
|
55
60
|
.map((redirect) => {
|
|
56
61
|
try {
|
|
57
62
|
validateRedirect(redirect);
|
|
58
63
|
return undefined;
|
|
59
|
-
} catch (
|
|
60
|
-
return
|
|
64
|
+
} catch (err) {
|
|
65
|
+
return (err as Error).message;
|
|
61
66
|
}
|
|
62
67
|
})
|
|
63
68
|
.filter(Boolean);
|
|
@@ -71,7 +76,7 @@ function validateCollectedRedirects(
|
|
|
71
76
|
|
|
72
77
|
const allowedToPaths = pluginContext.relativeRoutesPaths;
|
|
73
78
|
const toPaths = redirects.map((redirect) => redirect.to);
|
|
74
|
-
const illegalToPaths = difference(toPaths, allowedToPaths);
|
|
79
|
+
const illegalToPaths = _.difference(toPaths, allowedToPaths);
|
|
75
80
|
if (illegalToPaths.length > 0) {
|
|
76
81
|
throw new Error(
|
|
77
82
|
`You are trying to create client-side redirections to paths that do not exist:
|
|
@@ -88,36 +93,28 @@ function filterUnwantedRedirects(
|
|
|
88
93
|
redirects: RedirectMetadata[],
|
|
89
94
|
pluginContext: PluginContext,
|
|
90
95
|
): RedirectMetadata[] {
|
|
91
|
-
//
|
|
92
|
-
//
|
|
93
|
-
Object.entries(groupBy(redirects, (redirect) => redirect.from)).forEach(
|
|
96
|
+
// We don't want to create the same redirect twice, since that would lead to
|
|
97
|
+
// writing the same html redirection file twice.
|
|
98
|
+
Object.entries(_.groupBy(redirects, (redirect) => redirect.from)).forEach(
|
|
94
99
|
([from, groupedFromRedirects]) => {
|
|
95
100
|
if (groupedFromRedirects.length > 1) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
- ${groupedFromRedirects.map((r) => JSON.stringify(r)).join('\n- ')}
|
|
101
|
-
`,
|
|
102
|
-
),
|
|
103
|
-
);
|
|
101
|
+
logger.error`name=${'@docusaurus/plugin-client-redirects'}: multiple redirects are created with the same "from" pathname: path=${from}
|
|
102
|
+
It is not possible to redirect the same pathname to multiple destinations: ${groupedFromRedirects.map(
|
|
103
|
+
(r) => JSON.stringify(r),
|
|
104
|
+
)}`;
|
|
104
105
|
}
|
|
105
106
|
},
|
|
106
107
|
);
|
|
107
|
-
const collectedRedirects = uniqBy(redirects, (redirect) => redirect.from);
|
|
108
|
+
const collectedRedirects = _.uniqBy(redirects, (redirect) => redirect.from);
|
|
108
109
|
|
|
109
110
|
// We don't want to override an already existing route with a redirect file!
|
|
110
111
|
const redirectsOverridingExistingPath = collectedRedirects.filter(
|
|
111
112
|
(redirect) => pluginContext.relativeRoutesPaths.includes(redirect.from),
|
|
112
113
|
);
|
|
113
114
|
if (redirectsOverridingExistingPath.length > 0) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
- ${redirectsOverridingExistingPath.map((r) => JSON.stringify(r)).join('\n- ')}
|
|
118
|
-
`,
|
|
119
|
-
),
|
|
120
|
-
);
|
|
115
|
+
logger.error`name=${'@docusaurus/plugin-client-redirects'}: some redirects would override existing paths, and will be ignored: ${redirectsOverridingExistingPath.map(
|
|
116
|
+
(r) => JSON.stringify(r),
|
|
117
|
+
)}`;
|
|
121
118
|
}
|
|
122
119
|
return collectedRedirects.filter(
|
|
123
120
|
(redirect) => !pluginContext.relativeRoutesPaths.includes(redirect.from),
|
|
@@ -146,7 +143,7 @@ function doCollectRedirects(pluginContext: PluginContext): RedirectMetadata[] {
|
|
|
146
143
|
function createRedirectsOptionRedirects(
|
|
147
144
|
redirectsOption: PluginOptions['redirects'],
|
|
148
145
|
): RedirectMetadata[] {
|
|
149
|
-
// For
|
|
146
|
+
// For convenience, user can use a string or a string[]
|
|
150
147
|
function optionToRedirects(option: RedirectOption): RedirectMetadata[] {
|
|
151
148
|
if (typeof option.from === 'string') {
|
|
152
149
|
return [{from: option.from, to: option.to}];
|
|
@@ -157,7 +154,7 @@ function createRedirectsOptionRedirects(
|
|
|
157
154
|
}));
|
|
158
155
|
}
|
|
159
156
|
|
|
160
|
-
return
|
|
157
|
+
return redirectsOption.flatMap(optionToRedirects);
|
|
161
158
|
}
|
|
162
159
|
|
|
163
160
|
// Create redirects from the "createRedirects" fn provided by the user
|
|
@@ -166,20 +163,16 @@ function createCreateRedirectsOptionRedirects(
|
|
|
166
163
|
createRedirects: PluginOptions['createRedirects'],
|
|
167
164
|
): RedirectMetadata[] {
|
|
168
165
|
function createPathRedirects(path: string): RedirectMetadata[] {
|
|
169
|
-
const fromsMixed: string | string[] = createRedirects
|
|
170
|
-
? createRedirects(path) || []
|
|
171
|
-
: [];
|
|
166
|
+
const fromsMixed: string | string[] = createRedirects?.(path) ?? [];
|
|
172
167
|
|
|
173
168
|
const froms: string[] =
|
|
174
169
|
typeof fromsMixed === 'string' ? [fromsMixed] : fromsMixed;
|
|
175
170
|
|
|
176
|
-
return froms.map((from) => {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
};
|
|
181
|
-
});
|
|
171
|
+
return froms.map((from) => ({
|
|
172
|
+
from,
|
|
173
|
+
to: path,
|
|
174
|
+
}));
|
|
182
175
|
}
|
|
183
176
|
|
|
184
|
-
return
|
|
177
|
+
return paths.flatMap(createPathRedirects);
|
|
185
178
|
}
|
|
@@ -7,24 +7,22 @@
|
|
|
7
7
|
|
|
8
8
|
import * as eta from 'eta';
|
|
9
9
|
import redirectPageTemplate from './templates/redirectPage.template.html';
|
|
10
|
-
import
|
|
10
|
+
import _ from 'lodash';
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const getCompiledRedirectPageTemplate = memoize(() => {
|
|
17
|
-
return eta.compile(redirectPageTemplate.trim());
|
|
18
|
-
});
|
|
12
|
+
const getCompiledRedirectPageTemplate = _.memoize(() =>
|
|
13
|
+
eta.compile(redirectPageTemplate.trim()),
|
|
14
|
+
);
|
|
19
15
|
|
|
20
|
-
function renderRedirectPageTemplate(data:
|
|
16
|
+
function renderRedirectPageTemplate(data: {toUrl: string}) {
|
|
21
17
|
const compiled = getCompiledRedirectPageTemplate();
|
|
22
18
|
return compiled(data, eta.defaultConfig);
|
|
23
19
|
}
|
|
24
20
|
|
|
25
21
|
export default function createRedirectPageContent({
|
|
26
22
|
toUrl,
|
|
27
|
-
}:
|
|
23
|
+
}: {
|
|
24
|
+
toUrl: string;
|
|
25
|
+
}): string {
|
|
28
26
|
return renderRedirectPageTemplate({
|
|
29
27
|
toUrl: encodeURI(toUrl),
|
|
30
28
|
});
|
|
@@ -5,12 +5,15 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
import {
|
|
9
|
+
addTrailingSlash,
|
|
10
|
+
removeSuffix,
|
|
11
|
+
removeTrailingSlash,
|
|
12
|
+
} from '@docusaurus/utils';
|
|
13
|
+
import type {RedirectMetadata} from './types';
|
|
11
14
|
|
|
12
15
|
const ExtensionAdditionalMessage =
|
|
13
|
-
'If the redirect extension system is not good enough for your
|
|
16
|
+
'If the redirect extension system is not good enough for your use case, you can create redirects yourself with the "createRedirects" plugin option.';
|
|
14
17
|
|
|
15
18
|
const validateExtension = (ext: string) => {
|
|
16
19
|
if (!ext) {
|
|
@@ -58,10 +61,11 @@ export function createToExtensionsRedirects(
|
|
|
58
61
|
return [];
|
|
59
62
|
};
|
|
60
63
|
|
|
61
|
-
return
|
|
64
|
+
return paths.flatMap(createPathRedirects);
|
|
62
65
|
}
|
|
63
66
|
|
|
64
|
-
// Create new /path.html that redirects to existing an /path
|
|
67
|
+
// Create new /path.html/index.html that redirects to existing an /path
|
|
68
|
+
// The filename pattern might look weird but it's on purpose (see https://github.com/facebook/docusaurus/issues/5055)
|
|
65
69
|
export function createFromExtensionsRedirects(
|
|
66
70
|
paths: string[],
|
|
67
71
|
extensions: string[],
|
|
@@ -74,14 +78,18 @@ export function createFromExtensionsRedirects(
|
|
|
74
78
|
dottedExtensions.some((ext) => str.endsWith(ext));
|
|
75
79
|
|
|
76
80
|
const createPathRedirects = (path: string): RedirectMetadata[] => {
|
|
77
|
-
if (path === '' || path
|
|
81
|
+
if (path === '' || path === '/' || alreadyEndsWithAnExtension(path)) {
|
|
78
82
|
return [];
|
|
79
83
|
}
|
|
80
84
|
return extensions.map((ext) => ({
|
|
81
|
-
|
|
85
|
+
// /path => /path.html
|
|
86
|
+
// /path/ => /path.html/
|
|
87
|
+
from: path.endsWith('/')
|
|
88
|
+
? addTrailingSlash(`${removeTrailingSlash(path)}.${ext}`)
|
|
89
|
+
: `${path}.${ext}`,
|
|
82
90
|
to: path,
|
|
83
91
|
}));
|
|
84
92
|
};
|
|
85
93
|
|
|
86
|
-
return
|
|
94
|
+
return paths.flatMap(createPathRedirects);
|
|
87
95
|
}
|
package/src/index.ts
CHANGED
|
@@ -5,41 +5,26 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {LoadContext, Plugin
|
|
9
|
-
import {
|
|
8
|
+
import type {LoadContext, Plugin} from '@docusaurus/types';
|
|
9
|
+
import type {PluginContext, RedirectMetadata} from './types';
|
|
10
|
+
import type {PluginOptions, Options} from './options';
|
|
10
11
|
|
|
11
|
-
import normalizePluginOptions from './normalizePluginOptions';
|
|
12
12
|
import collectRedirects from './collectRedirects';
|
|
13
13
|
import writeRedirectFiles, {
|
|
14
14
|
toRedirectFilesMetadata,
|
|
15
|
-
RedirectFileMetadata,
|
|
15
|
+
type RedirectFileMetadata,
|
|
16
16
|
} from './writeRedirectFiles';
|
|
17
17
|
import {removePrefix, addLeadingSlash} from '@docusaurus/utils';
|
|
18
|
-
import chalk from 'chalk';
|
|
19
18
|
|
|
20
19
|
export default function pluginClientRedirectsPages(
|
|
21
20
|
context: LoadContext,
|
|
22
|
-
|
|
21
|
+
options: PluginOptions,
|
|
23
22
|
): Plugin<unknown> {
|
|
24
23
|
const {trailingSlash} = context.siteConfig;
|
|
25
24
|
|
|
26
|
-
const options = normalizePluginOptions(opts);
|
|
27
|
-
|
|
28
|
-
// Special case, when using trailingSlash=false we output /xyz.html files instead of /xyz/index.html
|
|
29
|
-
// It makes no sense to use option fromExtensions=["html"]: the redirect files would be the same as the original files
|
|
30
|
-
if (options.fromExtensions.includes('html') && trailingSlash === false) {
|
|
31
|
-
console.warn(
|
|
32
|
-
chalk.yellow(`Using the Docusaurus redirect plugin with fromExtensions=['html'] and siteConfig.trailingSlash=false is prevented.
|
|
33
|
-
It would lead the redirect plugin to override all the page.html files created by Docusaurus.`),
|
|
34
|
-
);
|
|
35
|
-
options.fromExtensions = options.fromExtensions.filter(
|
|
36
|
-
(ext) => ext !== 'html',
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
25
|
return {
|
|
41
26
|
name: 'docusaurus-plugin-client-redirects',
|
|
42
|
-
async postBuild(props
|
|
27
|
+
async postBuild(props) {
|
|
43
28
|
const pluginContext: PluginContext = {
|
|
44
29
|
relativeRoutesPaths: props.routesPaths.map(
|
|
45
30
|
(path) => `${addLeadingSlash(removePrefix(path, props.baseUrl))}`,
|
|
@@ -65,3 +50,6 @@ It would lead the redirect plugin to override all the page.html files created by
|
|
|
65
50
|
},
|
|
66
51
|
};
|
|
67
52
|
}
|
|
53
|
+
|
|
54
|
+
export {validateOptions} from './options';
|
|
55
|
+
export type {PluginOptions, Options};
|
package/src/options.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
import type {OptionValidationContext} from '@docusaurus/types';
|
|
9
|
+
import {Joi, PathnameSchema} from '@docusaurus/utils-validation';
|
|
10
|
+
|
|
11
|
+
export type RedirectOption = {
|
|
12
|
+
to: string;
|
|
13
|
+
from: string | string[];
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type PluginOptions = {
|
|
17
|
+
/** Plugin ID. */
|
|
18
|
+
id: string;
|
|
19
|
+
/** The extensions to be removed from the route after redirecting. */
|
|
20
|
+
fromExtensions: string[];
|
|
21
|
+
/** The extensions to be appended to the route after redirecting. */
|
|
22
|
+
toExtensions: string[];
|
|
23
|
+
/** The list of redirect rules, each one with multiple `from`s → one `to`. */
|
|
24
|
+
redirects: RedirectOption[];
|
|
25
|
+
/**
|
|
26
|
+
* A callback to create a redirect rule.
|
|
27
|
+
* @returns All the paths from which we should redirect to `path`
|
|
28
|
+
*/
|
|
29
|
+
createRedirects?: (
|
|
30
|
+
/** An existing Docusaurus route path */
|
|
31
|
+
path: string,
|
|
32
|
+
) => string[] | string | null | undefined;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type Options = Partial<PluginOptions>;
|
|
36
|
+
|
|
37
|
+
export const DEFAULT_OPTIONS: Partial<PluginOptions> = {
|
|
38
|
+
fromExtensions: [],
|
|
39
|
+
toExtensions: [],
|
|
40
|
+
redirects: [],
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const RedirectPluginOptionValidation = Joi.object<RedirectOption>({
|
|
44
|
+
to: PathnameSchema.required(),
|
|
45
|
+
from: Joi.alternatives().try(
|
|
46
|
+
PathnameSchema.required(),
|
|
47
|
+
Joi.array().items(PathnameSchema.required()),
|
|
48
|
+
),
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const isString = Joi.string().required().not(null);
|
|
52
|
+
|
|
53
|
+
const UserOptionsSchema = Joi.object<PluginOptions>({
|
|
54
|
+
fromExtensions: Joi.array()
|
|
55
|
+
.items(isString)
|
|
56
|
+
.default(DEFAULT_OPTIONS.fromExtensions),
|
|
57
|
+
toExtensions: Joi.array()
|
|
58
|
+
.items(isString)
|
|
59
|
+
.default(DEFAULT_OPTIONS.toExtensions),
|
|
60
|
+
redirects: Joi.array()
|
|
61
|
+
.items(RedirectPluginOptionValidation)
|
|
62
|
+
.default(DEFAULT_OPTIONS.redirects),
|
|
63
|
+
createRedirects: Joi.function().maxArity(1),
|
|
64
|
+
}).default(DEFAULT_OPTIONS);
|
|
65
|
+
|
|
66
|
+
export function validateOptions({
|
|
67
|
+
validate,
|
|
68
|
+
options: userOptions,
|
|
69
|
+
}: OptionValidationContext<Options, PluginOptions>): PluginOptions {
|
|
70
|
+
return validate(UserOptionsSchema, userOptions);
|
|
71
|
+
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {RedirectMetadata} from './types';
|
|
8
|
+
import type {RedirectMetadata} from './types';
|
|
9
9
|
import {Joi, PathnameSchema} from '@docusaurus/utils-validation';
|
|
10
10
|
|
|
11
11
|
const RedirectSchema = Joi.object<RedirectMetadata>({
|
package/src/types.ts
CHANGED
|
@@ -5,39 +5,25 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {Props} from '@docusaurus/types';
|
|
8
|
+
import type {Props} from '@docusaurus/types';
|
|
9
|
+
import type {PluginOptions} from './options';
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
toExtensions: string[];
|
|
14
|
-
redirects: RedirectOption[];
|
|
15
|
-
createRedirects?: CreateRedirectsFnOption;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
// For a given existing route path,
|
|
19
|
-
// return all the paths from which we should redirect from
|
|
20
|
-
export type CreateRedirectsFnOption = (
|
|
21
|
-
path: string,
|
|
22
|
-
) => string[] | string | null | undefined;
|
|
23
|
-
|
|
24
|
-
export type RedirectOption = {
|
|
25
|
-
to: string;
|
|
26
|
-
from: string | string[];
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export type UserPluginOptions = Partial<PluginOptions>;
|
|
30
|
-
|
|
31
|
-
// The minimal infos the plugin needs to work
|
|
11
|
+
/**
|
|
12
|
+
* The minimal infos the plugin needs to work
|
|
13
|
+
*/
|
|
32
14
|
export type PluginContext = Pick<Props, 'outDir' | 'baseUrl'> & {
|
|
33
15
|
options: PluginOptions;
|
|
34
16
|
relativeRoutesPaths: string[];
|
|
35
17
|
};
|
|
36
18
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
19
|
+
/**
|
|
20
|
+
* In-memory representation of redirects we want: easier to test
|
|
21
|
+
* /!\ easy to be confused: "from" is the new page we should create,
|
|
22
|
+
* that redirects to "to": the existing Docusaurus page
|
|
23
|
+
*/
|
|
40
24
|
export type RedirectMetadata = {
|
|
41
|
-
|
|
42
|
-
|
|
25
|
+
/** Pathname of the new page we should create */
|
|
26
|
+
from: string;
|
|
27
|
+
/** Pathname of an existing Docusaurus page */
|
|
28
|
+
to: string;
|
|
43
29
|
};
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
|
|
8
8
|
import fs from 'fs-extra';
|
|
9
9
|
import path from 'path';
|
|
10
|
-
import
|
|
10
|
+
import _ from 'lodash';
|
|
11
11
|
|
|
12
|
-
import {PluginContext, RedirectMetadata} from './types';
|
|
12
|
+
import type {PluginContext, RedirectMetadata} from './types';
|
|
13
13
|
import createRedirectPageContent from './createRedirectPageContent';
|
|
14
|
-
import {
|
|
14
|
+
import {normalizeUrl} from '@docusaurus/utils';
|
|
15
15
|
|
|
16
16
|
export type WriteFilesPluginContext = Pick<PluginContext, 'baseUrl' | 'outDir'>;
|
|
17
17
|
|
|
@@ -24,6 +24,37 @@ export function createToUrl(baseUrl: string, to: string): string {
|
|
|
24
24
|
return normalizeUrl([baseUrl, to]);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
// Create redirect file path
|
|
28
|
+
// Make sure this path has lower precedence over the original file path when
|
|
29
|
+
// served by host providers!
|
|
30
|
+
// Otherwise it can produce infinite redirect loops!
|
|
31
|
+
//
|
|
32
|
+
// See https://github.com/facebook/docusaurus/issues/5055
|
|
33
|
+
// See https://github.com/facebook/docusaurus/pull/5085
|
|
34
|
+
// See https://github.com/facebook/docusaurus/pull/5102
|
|
35
|
+
function getRedirectFilePath(
|
|
36
|
+
fromPath: string,
|
|
37
|
+
trailingSlash: boolean | undefined, // Now unused, on purpose
|
|
38
|
+
): string {
|
|
39
|
+
const fileName = path.basename(fromPath);
|
|
40
|
+
const filePath = path.dirname(fromPath);
|
|
41
|
+
// Edge case for https://github.com/facebook/docusaurus/pull/5102
|
|
42
|
+
// If the redirect source path is /xyz, with file /xyz.html
|
|
43
|
+
// We can't write the redirect file at /xyz.html/index.html because for Unix
|
|
44
|
+
// FS, a file/folder can't have the same name "xyz.html"
|
|
45
|
+
// The only possible solution for a redirect file is thus /xyz.html.html (I
|
|
46
|
+
// know, looks suspicious)
|
|
47
|
+
if (trailingSlash === false && fileName.endsWith('.html')) {
|
|
48
|
+
return path.join(filePath, `${fileName}.html`);
|
|
49
|
+
}
|
|
50
|
+
// If the target path is /xyz, with file /xyz/index.html, we don't want the
|
|
51
|
+
// redirect file to be /xyz.html, otherwise it would be picked in priority and
|
|
52
|
+
// the redirect file would redirect to itself. We prefer the redirect file to
|
|
53
|
+
// be /xyz.html/index.html, served with lower priority for most static hosting
|
|
54
|
+
// tools
|
|
55
|
+
return path.join(filePath, `${fileName}/index.html`);
|
|
56
|
+
}
|
|
57
|
+
|
|
27
58
|
export function toRedirectFilesMetadata(
|
|
28
59
|
redirects: RedirectMetadata[],
|
|
29
60
|
pluginContext: WriteFilesPluginContext,
|
|
@@ -32,13 +63,13 @@ export function toRedirectFilesMetadata(
|
|
|
32
63
|
// Perf: avoid rendering the template twice with the exact same "props"
|
|
33
64
|
// We might create multiple redirect pages for the same destination url
|
|
34
65
|
// note: the first fn arg is the cache key!
|
|
35
|
-
const createPageContentMemoized = memoize((toUrl: string) =>
|
|
36
|
-
|
|
37
|
-
|
|
66
|
+
const createPageContentMemoized = _.memoize((toUrl: string) =>
|
|
67
|
+
createRedirectPageContent({toUrl}),
|
|
68
|
+
);
|
|
38
69
|
|
|
39
70
|
const createFileMetadata = (redirect: RedirectMetadata) => {
|
|
40
|
-
const
|
|
41
|
-
const fileAbsolutePath = path.join(pluginContext.outDir,
|
|
71
|
+
const fileRelativePath = getRedirectFilePath(redirect.from, trailingSlash);
|
|
72
|
+
const fileAbsolutePath = path.join(pluginContext.outDir, fileRelativePath);
|
|
42
73
|
const toUrl = createToUrl(pluginContext.baseUrl, redirect.to);
|
|
43
74
|
const fileContent = createPageContentMemoized(toUrl);
|
|
44
75
|
return {
|
|
@@ -61,8 +92,7 @@ export async function writeRedirectFile(
|
|
|
61
92
|
'The redirect plugin is not supposed to override existing files.',
|
|
62
93
|
);
|
|
63
94
|
}
|
|
64
|
-
await fs.
|
|
65
|
-
await fs.writeFile(
|
|
95
|
+
await fs.outputFile(
|
|
66
96
|
file.fileAbsolutePath,
|
|
67
97
|
file.fileContent,
|
|
68
98
|
// Hard security to prevent file overrides
|
package/lib/.tsbuildinfo
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"program":{"fileNames":["../../../node_modules/typescript/lib/lib.es5.d.ts","../../../node_modules/typescript/lib/lib.es2015.d.ts","../../../node_modules/typescript/lib/lib.es2016.d.ts","../../../node_modules/typescript/lib/lib.es2017.d.ts","../../../node_modules/typescript/lib/lib.es2018.d.ts","../../../node_modules/typescript/lib/lib.es2019.d.ts","../../../node_modules/typescript/lib/lib.es2020.d.ts","../../../node_modules/typescript/lib/lib.es2021.d.ts","../../../node_modules/typescript/lib/lib.esnext.d.ts","../../../node_modules/typescript/lib/lib.dom.d.ts","../../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../../node_modules/tslib/tslib.d.ts","../../../node_modules/@types/lodash/common/common.d.ts","../../../node_modules/@types/lodash/common/array.d.ts","../../../node_modules/@types/lodash/common/collection.d.ts","../../../node_modules/@types/lodash/common/date.d.ts","../../../node_modules/@types/lodash/common/function.d.ts","../../../node_modules/@types/lodash/common/lang.d.ts","../../../node_modules/@types/lodash/common/math.d.ts","../../../node_modules/@types/lodash/common/number.d.ts","../../../node_modules/@types/lodash/common/object.d.ts","../../../node_modules/@types/lodash/common/seq.d.ts","../../../node_modules/@types/lodash/common/string.d.ts","../../../node_modules/@types/lodash/common/util.d.ts","../../../node_modules/@types/lodash/index.d.ts","../../../node_modules/webpack/node_modules/@types/estree/index.d.ts","../../../node_modules/@types/json-schema/index.d.ts","../../../node_modules/ajv/lib/ajv.d.ts","../../../node_modules/schema-utils/declarations/validationerror.d.ts","../../../node_modules/schema-utils/declarations/validate.d.ts","../../../node_modules/schema-utils/declarations/index.d.ts","../../../node_modules/tapable/tapable.d.ts","../../../node_modules/webpack/types.d.ts","../../docusaurus-types/node_modules/commander/typings/index.d.ts","../../../node_modules/joi/lib/index.d.ts","../../docusaurus-types/src/index.d.ts","../src/types.ts","../../docusaurus-utils/lib/posixpath.d.ts","../../docusaurus-utils/lib/getfilepathforroutepath.d.ts","../../docusaurus-utils/lib/codetranslationsutils.d.ts","../../docusaurus-utils/lib/markdownparser.d.ts","../../docusaurus-utils/lib/markdownlinks.d.ts","../../docusaurus-utils/lib/escapepath.d.ts","../../docusaurus-utils/lib/hashutils.d.ts","../../docusaurus-utils/lib/index.d.ts","../src/extensionredirects.ts","../../docusaurus-utils-validation/lib/joi.d.ts","../../docusaurus-utils-validation/lib/validationutils.d.ts","../../docusaurus-utils-validation/lib/validationschemas.d.ts","../../docusaurus-utils-validation/lib/index.d.ts","../src/redirectvalidation.ts","../../docusaurus-utils-common/lib/applytrailingslash.d.ts","../../docusaurus-utils-common/lib/uniq.d.ts","../../docusaurus-utils-common/lib/index.d.ts","../../../node_modules/chalk/index.d.ts","../src/collectredirects.ts","../../../node_modules/eta/dist/types/compile.d.ts","../../../node_modules/eta/dist/types/storage.d.ts","../../../node_modules/eta/dist/types/config.d.ts","../../../node_modules/eta/dist/types/file-handlers.d.ts","../../../node_modules/eta/dist/types/compile-string.d.ts","../../../node_modules/eta/dist/types/parse.d.ts","../../../node_modules/eta/dist/types/render.d.ts","../../../node_modules/eta/dist/types/containers.d.ts","../../../node_modules/eta/dist/types/index.d.ts","../src/templates/redirectpage.template.html.ts","../src/createredirectpagecontent.ts","../../docusaurus/lib/constants.d.ts","../src/normalizepluginoptions.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/assert/strict.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/globals.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/async_hooks.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/buffer.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/child_process.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/cluster.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/console.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/constants.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/crypto.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/dgram.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/diagnostic_channel.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/dns.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/dns/promises.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/domain.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/events.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/fs.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/fs/promises.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/http.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/http2.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/https.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/inspector.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/module.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/net.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/os.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/path.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/perf_hooks.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/process.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/punycode.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/querystring.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/readline.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/repl.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/stream.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/stream/promises.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/string_decoder.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/timers.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/timers/promises.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/tls.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/trace_events.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/tty.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/url.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/util.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/util/types.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/v8.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/vm.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/worker_threads.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/zlib.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/globals.global.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/wasi.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/ts3.6/base.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/assert.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/base.d.ts","../../../node_modules/@types/fs-extra/node_modules/@types/node/index.d.ts","../../../node_modules/@types/fs-extra/index.d.ts","../src/writeredirectfiles.ts","../src/index.ts"],"fileInfos":[{"version":"ac3a8c4040e183ce38da69d23b96939112457d1936198e6542672b7963cf0fce","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","e21c071ca3e1b4a815d5f04a7475adcaeea5d64367e840dd0154096d705c3940","eb75e89d63b3b72dd9ca8b0cac801cecae5be352307c004adeaa60bc9d6df51f","2cc028cd0bdb35b1b5eb723d84666a255933fffbea607f72cbd0c7c7b4bee144",{"version":"1dad4fe1561d99dfd6709127608b99a76e5c2643626c800434f99c48038567ee","affectsGlobalScope":true},{"version":"cce43d02223f8049864f8568bed322c39424013275cd3bcc3f51492d8b546cb3","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"8dff1b4c2df638fcd976cbb0e636f23ab5968e836cd45084cc31d47d1ab19c49","affectsGlobalScope":true},{"version":"2bb4b3927299434052b37851a47bf5c39764f2ba88a888a107b32262e9292b7c","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"8f4c9f651c8294a2eb1cbd12581fe25bfb901ab1d474bb93cd38c7e2f4be7a30","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"df9c8a72ca8b0ed62f5470b41208a0587f0f73f0a7db28e5a1272cf92537518e","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"93544ca2f26a48716c1b6c5091842cad63129daac422dfa4bc52460465f22bb1","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"60761e6ea886034af0f294f025a7199360ce4e2c8ba4ec6408bc049cf9b89799","affectsGlobalScope":true},{"version":"7435b75fdf3509622e79622dbe5091cf4b09688410ee2034e4fc17d0c99d0862","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"9f1817f7c3f02f6d56e0f403b927e90bb133f371dcebc36fa7d6d208ef6899da","affectsGlobalScope":true},{"version":"cd6efb9467a8b6338ece2e2855e37765700f2cd061ca54b01b33878cf5c7677e","affectsGlobalScope":true},{"version":"fb4416144c1bf0323ccbc9afb0ab289c07312214e8820ad17d709498c865a3fe","affectsGlobalScope":true},{"version":"5b0ca94ec819d68d33da516306c15297acec88efeb0ae9e2b39f71dbd9685ef7","affectsGlobalScope":true},{"version":"506b80b9951c9381dc5f11897b31fca5e2a65731d96ddefa19687fbc26b23c6e","affectsGlobalScope":true},"ea7abf23498b7c214c67fc14f22f41983fbb7bf7c4826c7fcdef542b2022545f","3594c022901a1c8993b0f78a3f534cfb81e7b619ed215348f7f6882f3db02abc","438284c7c455a29b9c0e2d1e72abc62ee93d9a163029ffe918a34c5db3b92da2","0c75b204aed9cf6ff1c7b4bed87a3ece0d9d6fc857a6350c0c95ed0c38c814e8","187119ff4f9553676a884e296089e131e8cc01691c546273b1d0089c3533ce42","782abf371043fc65a987f835a3acfd80602a30c3e2122f6d5756a86bf6913352","509235563ea2b939e1bbe92aae17e71e6a82ceab8f568b45fb4fce7d72523a32","9364c7566b0be2f7b70ff5285eb34686f83ccb01bda529b82d23b2a844653bfb","00baffbe8a2f2e4875367479489b5d43b5fc1429ecb4a4cc98cfc3009095f52a","82251920b05f30981c9a4109cb5f3169dce4b477effc845c6d781044a30e7672","3c92b6dfd43cc1c2485d9eba5ff0b74a19bb8725b692773ef1d66dac48cda4bd","4908e4c00832b26ce77a629de8501b0e23a903c094f9e79a7fec313a15da796a","2630a7cbb597e85d713b7ef47f2946d4280d3d4c02733282770741d40672b1a5",{"version":"0714e2046df66c0e93c3330d30dbc0565b3e8cd3ee302cf99e4ede6220e5fec8","affectsGlobalScope":true},"f1e8ecd1d960d12e57316fd2889b0a57635f38f8c4c976d8deafa29650bbf320","3a1e165b22a1cb8df82c44c9a09502fd2b33f160cd277de2cd3a055d8e5c6b27","67f129ed8b372622ff36b8b10e39d03e09e363a5ff7821105f92f085b8d1ccba","327f42ab31ff4539ba868d0374f8825af328b104b5f78d26b2e3ce9cc17b43a0","62a05210201c793349ec28254f06a01814c5b4f5591f6d1921941286db78ea2a","8f877178233f74095130e129ce86128a6a15afcfc6171d714e154863b6a65fe8","b395ec0779c66de885f97974534e95ee2c8bbf9acaf5857a6782ddc32972b6d8","572b4d4c4e2cd3026db925ca5cb721f5c3f4f52938da404de1148a126348f29b","c72b982add26c5ddf410899bcafe3f47253a5d274d4b93d2ef67850d4af4545b","332bc92a89da24ef3a645208f2b3159292460a52fbe63c40eef64c2a63bb1e40","13e5e388b5816cb8325e79b26bae6ba24bcd6f9f22e636f6f4329ccf650f8751",{"version":"57dc389181eeb619a8b10299e3447cd6d9b216453af993abda5afedd6b39b455","signature":"15f291a8ecc966b96a0c2ce5ee5e195b8b073d90bb1d5505871c17e917c43ccb"},"0daf3165e72cc1ed5263a3374b98cb065f78922c76602477973ee0654b99df17","54908e77ad591652580ebdfcc70078a3ae69978e8393a0c95e9e4319fd7d591a","98249526332851a623664fd515a293f50d680d4a86d633585ecb9168e67cd872","3fedee34f24b13af4a97c4184a9e215a6f6b2dfb655dafc24970c76791b06c43","4fae0cbdbb492b0fc847ec76d0a4af44eb04028200cec088d97fca05438213f1","c7642b1c7345e546c81831fe5fa9233e15a12fa2743f6685b0d700af8292cdd0","857d6d4a53c4372a2799e733ab122d28f7b2b580fe58b80a5fe1321a733c20f7","507c590897f90453e6f2e8945a52153d14cc67241ad84d85704df2eb5960a87e",{"version":"2785a6dc43904230555b9b7a93415322690664a2b62e2eb8539c8c756e2d0eba","signature":"3c6f107c1686a4d91468fbbafc6c0d17d4c3939559d937a5d57510c573adb498"},"889859c907d8388cfe92d4bdfe5b5ff0885a41e6e4568691230e21757f7673c9","d62aae9510ec58d3533a76b9915dae85dea65aa39c915613dc9f47918f596b1e","57e1940021e5e3ff12963f4218195c786a0d2a475a400fffb7cdd4352823854d","01c67feaa6d785a1f958c92f0e1eabdd69bd5e44cbd8a233b89a247ad9bb1dc3",{"version":"700c2f83a83482242336bf0033edbd961105577f16b9cf549333159fc719add2","signature":"9817220e32e22d9388e93fe022040ab747991e0b06045843d21a6996aead8751"},"f22900d42391c1cd865f34d9b7c9cf292a3af2fba696da93be1904cb90820ed2","efc0cf69f54f6d4fbdcc205cc938f1f6f6f1d63fbcb7b3f912a4755805b05b31","cf20beb00c0275e57881ec614d8da648adea0fc80996e09e66a2bd667f53a2cb","0d14fa22c41fdc7277e6f71473b20ebc07f40f00e38875142335d5b63cdfc9d2",{"version":"82a5a6c28e41407f0f6c9cd82400105b76a005d8210999da1fc28fa50480d7fb","signature":"a321505d0b92e3b5b35f9601d2492a88c0053494b6e5b2d01cf91b44492b4dc7"},"a3cf09a8ce34726b0557b3e51135a6768b464e86b7190355e42f10ba368e9786","dcd04eabb6c23406dc589f688c7a83d25a8aa0c93ee34c0be1114113c32792d6","0a21f90e2ffaf26b305183fd2029a7dd512bb3189a9d6842ba764782e609429e","5560fae6a4c210279d4c913e62dfa82f6ebbc283800e430c4ec54e20216e4b2f","bd868c7a5868f2680d332b85283be6be45edb766a95c4b8034aff7c741ab1aad","5ec0c5db09dfb4f1cd140417dc86fed025bd757d63c11fe2c4148ec12fd20111","2737dcbf71e062619538a0d3075795be33900ccf377d5dae1e90197f95787566","2db6353e2fdcbd2842b5b0a36d11e11ffbff703552e19481a55a63155e14c6be","74175ef96c3d3cb5e7bcaf0387ca4cc3de9f1bf68b42a082d8be5e79178c2c7e","37723b12b6a526579c9a467ab70a9414fc30994e24bd4b9dae41148ed3e112a1","63a254a5a16ee3457a0dd00dedacc0d76cc7897b976ec64d59d149d43c4859b7","4977865ec3570795ce920e30b51b6c345ad782bd804202e80d95fc1a09299a7d",{"version":"c8c407861245162fcf6c4a65125331964efa6f75972dd908ea0e2ba13ca77b33","signature":"78f48b14b7f2f7d3b1b1ee0fc72ca2dcd365e4d5ea1683bd25f6617eaa92b703"},"c7bdc99177a2a94d25fb13722adaaf5b3291bf70b4d1b27584ba189dd3889ba3",{"version":"7c4064a324cd755a9b281d5795fc6ebd9dd713b1c356220185c61eb1b2d0f1af","affectsGlobalScope":true},"e23424b97418eca3226fd24de079f1203eb70360622e4e093af2aff14d4be6ec","ff16181fe134bb123283eb6777c624f6f3ee3f5c17d70b8447fa68af0935d312","54868134aa26f98b6fbc8d28040d8a0f5e64a1cb0dfac7f059b35cac99d626f2","04eaa93bd75f937f9184dcb95a7983800c5770cf8ddd8ac0f3734dc02f5b20ef",{"version":"7ddd5487c03df04c01a8618e06d875e167524902ed3dd9a2a9345a0ef5202d6f","affectsGlobalScope":true},"45ac321f2e15d268fd74a90ddaa6467dcaaff2c5b13f95b4b85831520fb7a491","dfc747ab8dd5f623055a4c26fd35e8cceca869fd3f1cf09701c941ca3679665a","c9f5f2920ff61d7158417b8440d5181ddc34a3dfef811a5677dd8a9fb91471e9","5cc0a492da3602510b8f5ed1852b1e0390002780d8758fbc8c0cd023ca7085f8","ec7dafafe751a5121f8f1c80201ebe7e7238c47e6329280a73c4d1ca4bb7fa28","64debeb10e4b7ae4ec9e89bfb4e04c6101ab98c3cc806d14e5488607cfec2753",{"version":"2866a528b2708aa272ec3eaafd3c980abb23aec1ef831cfc5eb2186b98c37ce5","affectsGlobalScope":true},{"version":"a5782d6cea81fe43d2db7ed41e789458c933ab3ab60602f7b5b14c4da3370496","affectsGlobalScope":true},"b86b7ff709a82ef3cba2184136c025989958bad483ffb13e4ca35d720245adf4","05b1c856de9c8f2c09c86a89455e25965342496ebe6d089760a9646c51295c76","c0d983dfc997b446ec8e456dea90e8c0c97ba896d55d7e34dfc351f32c405eb9","b447e123210c68f205f67b20c996c04a1eb64b0e591c5e06e164cd3d3a869b28","13257840c0850d4ebd7c2b17604a9e006f752de76c2400ebc752bc465c330452","42176966283d3835c34278b9b5c0f470d484c0c0c6a55c20a2c916a1ce69b6e8","0cff7901aedfe78e314f7d44088f07e2afa1b6e4f0473a4169b8456ca2fb245d","6ea59cf5479f3fad5db2caa4513d8d06d6cfee8d8df69e7a040c9b5b7f25f39c","e2236264a811ed1d09a2487a433e8f5216ae62378cf233954ae220cf886f6717","3ec1e108d587a5661ec790db607f482605ba9f3830e118ce578e3ffa3c42e22b","100b3bb9d39d2b1b5340f1bf45a52e94ef1692b45232b4ba00fac5c3cc56d331",{"version":"ec1a29ddaecb683aa360df0bd98ab5d4171d2d549554f7c5ab2a5c183a3dcb67","affectsGlobalScope":true},"7f77304372efe3c9967e5f9ea2061f1b4bf41dc3cda3c83cdd676f2e5af6b7e6","992c6f6be16c0a1d2eec13ece33adeea2c747ba27fcd078353a8f4bb5b4fea58","2597718d91e306949d89e285bf34c44192014ef541c3bd7cbb825c022749e974","a6b0abdb67d63ebe964ba5fee31bc3daf10c12eecd46b24d778426010c04c67e","ac4801ebc2355ba32329070123b1cd15891bf71b41dcaf9e75b4744832126a59","fd2298fba0640e7295e7bd545e2dfbfcccbb00c27019e501c87965a02bbdebf6","4fd3c4debadce3e9ab9dec3eb45f7f5e2e3d4ad65cf975a6d938d883cfb25a50","71ddd49185b68f27bfac127ef5d22cb2672c278e53e5370d9020ef50ca9c377d","b1ea7a6eaa7608e0e0529aebd323b526a79c6c05a4e519ae5c779675004dcdf1","9fcb033a6208485d8f3fadde31eb5cbcaf99149cff3e40c0dc53ebc6d0dff4e9","7df562288f949945cf69c21cd912100c2afedeeb7cdb219085f7f4b46cb7dde4","9d16690485ff1eb4f6fc57aebe237728fd8e03130c460919da3a35f4d9bd97f5","dcc6910d95a3625fd2b0487fda055988e46ab46c357a1b3618c27b4a8dd739c9","f4149f1aa299474c7040a35fe8f8ac2ad078cc1b190415adc1fff3ed52d490ea","3730099ed008776216268a97771de31753ef71e0a7d0ec650f588cba2a06ce44","8d649dbc429d7139a1d9a14ea2bf8af1dc089e0a879447539587463d4b6c248c","60c9e27816ec8ac8df7240598bb086e95b47edfb454c5cbf4003c812e0ed6e39","e361aecf17fc4034b4c122a1564471cdcd22ef3a51407803cb5a5fc020c04d02","4926467de88a92a4fc9971d8c6f21b91eca1c0e7fc2a46cc4638ab9440c73875",{"version":"2708349d5a11a5c2e5f3a0765259ebe7ee00cdcc8161cb9990cb4910328442a1","affectsGlobalScope":true},"fc0ae4a8ad3c762b96f9d2c3700cb879a373458cb0bf3175478e3b4f85f7ef2f","fabbec378e1ddd86fcf2662e716c2b8318acedb664ee3a4cba6f9e8ee8269cf1","b3593bd345ebea5e4d0a894c03251a3774b34df3d6db57075c18e089a599ba76","e61a21e9418f279bc480394a94d1581b2dee73747adcbdef999b6737e34d721b","13c7832f048b08604b7e88b69247aecf955bb7b27a0881c2f7f23bb645435479","8d01c38ccb9af3a4035a68818799e5ef32ccc8cf70bdb83e181e1921d7ad32f6",{"version":"b9a4105d0aeff4b9d5b694be2efd09c95cfe1ee28784e3a95dfb658aabe539af","signature":"3243a98905045e1a6aa71f56b6db4d2b3c918dc8ebafff36b88c3e1cae5715bc"},{"version":"da4f3cdbfac5e573bc714b06f64c5346c33a69364981bf6437f058a0099656e0","signature":"44893e0846d3f58dcb3ae9ae1f15c7f3f7effab2abd25abe0bc732789ad6b9d7"}],"options":{"allowSyntheticDefaultImports":true,"declaration":true,"declarationMap":false,"esModuleInterop":true,"importHelpers":true,"jsx":2,"module":1,"noEmitHelpers":true,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noImplicitThis":true,"noUnusedLocals":false,"noUnusedParameters":false,"outDir":"./","rootDir":"../src","skipLibCheck":true,"strictFunctionTypes":true,"strictNullChecks":true,"strictPropertyInitialization":true,"target":6,"tsBuildInfoFile":"./.tsbuildinfo"},"fileIdsList":[[118,154],[152],[151,152],[106,111],[117,118,125,134],[107,117,125],[143],[111,118,126],[134,139],[114,117,125],[115],[114],[117],[117,119,134,142],[117,118],[125,134,142],[117,118,120,125,134,139,142],[120,139,142],[153],[142],[114,117,134],[127],[105],[141],[132,143,146],[117,135],[134],[137],[111,125],[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],[125],[131],[144],[106,111,117,119,128,134,142,146],[46,48,49,50,51,52,53,54,55,56,57,58],[46,47,49,50,51,52,53,54,55,56,57,58],[47,48,49,50,51,52,53,54,55,56,57,58],[46,47,48,50,51,52,53,54,55,56,57,58],[46,47,48,49,51,52,53,54,55,56,57,58],[46,47,48,49,50,52,53,54,55,56,57,58],[46,47,48,49,50,51,53,54,55,56,57,58],[46,47,48,49,50,51,52,54,55,56,57,58],[46,47,48,49,50,51,52,53,55,56,57,58],[46,47,48,49,50,51,52,53,54,56,57,58],[46,47,48,49,50,51,52,53,54,55,57,58],[46,47,48,49,50,51,52,53,54,55,56,58],[46,47,48,49,50,51,52,53,54,55,56,57],[92],[92,93],[90,91],[90,92],[90,92,93,94,95,96,97],[90,92,93],[62,63],[60,61,62],[60,61,63],[59,63,64,65],[45,58,70,79,84,87,88],[45,58,98,99],[45,58,70,78],[45,69,70,78,88,89,102,156],[45,70,83,101],[45,70,83],[45],[45,69],[45,58,70,78,100,127,155],[66,67,68,131],[85,86],[80,81,82],[68],[80],[69,71,72,73,74,75,76,77],[70],[69,70],[69]],"referencedMap":[[155,1],[103,2],[153,3],[106,4],[107,5],[108,6],[109,7],[110,8],[111,9],[112,10],[114,11],[115,12],[116,13],[117,13],[118,14],[119,15],[120,16],[121,17],[122,18],[154,19],[123,13],[124,20],[125,21],[127,22],[128,23],[129,24],[132,13],[133,25],[134,26],[135,27],[137,13],[138,28],[139,29],[151,30],[141,31],[142,32],[143,33],[145,27],[147,34],[148,27],[47,35],[48,36],[46,37],[49,38],[50,39],[51,40],[52,41],[53,42],[54,43],[55,44],[56,45],[57,46],[58,47],[94,48],[90,49],[92,50],[97,50],[93,51],[98,52],[95,48],[96,53],[64,54],[63,55],[62,56],[66,57],[89,58],[100,59],[79,60],[157,61],[102,62],[84,63],[99,64],[70,65],[156,66],[69,67],[87,68],[83,69],[80,70],[82,71],[81,71],[78,72]],"exportedModulesMap":[[155,1],[103,2],[153,3],[106,4],[107,5],[108,6],[109,7],[110,8],[111,9],[112,10],[114,11],[115,12],[116,13],[117,13],[118,14],[119,15],[120,16],[121,17],[122,18],[154,19],[123,13],[124,20],[125,21],[127,22],[128,23],[129,24],[132,13],[133,25],[134,26],[135,27],[137,13],[138,28],[139,29],[151,30],[141,31],[142,32],[143,33],[145,27],[147,34],[148,27],[47,35],[48,36],[46,37],[49,38],[50,39],[51,40],[52,41],[53,42],[54,43],[55,44],[56,45],[57,46],[58,47],[94,48],[90,49],[92,50],[97,50],[93,51],[98,52],[95,48],[96,53],[64,54],[63,55],[62,56],[66,57],[89,73],[100,59],[79,73],[157,74],[102,73],[84,73],[99,64],[70,75],[156,73],[69,67],[87,68],[83,69],[80,70],[82,71],[81,71],[78,72]],"semanticDiagnosticsPerFile":[155,152,103,105,153,106,107,108,109,110,111,112,113,114,115,116,117,118,119,104,149,120,121,122,154,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,151,141,142,143,144,145,146,150,147,148,60,47,48,46,49,50,51,52,53,54,55,56,57,58,61,88,94,90,92,97,93,98,95,96,91,68,64,63,62,65,45,10,12,11,2,13,14,15,16,17,18,19,20,3,4,24,21,22,23,25,26,27,5,28,29,30,31,6,32,33,34,35,7,40,36,37,38,39,8,41,42,43,1,9,44,59,66,89,100,79,157,102,84,99,70,156,67,69,85,87,86,83,80,82,81,73,76,72,77,78,75,74,71,101]},"version":"4.3.2"}
|
|
@@ -1,9 +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
|
-
import { PluginOptions, UserPluginOptions } from './types';
|
|
8
|
-
export declare const DefaultPluginOptions: PluginOptions;
|
|
9
|
-
export default function normalizePluginOptions(userPluginOptions?: UserPluginOptions): PluginOptions;
|