@docusaurus/plugin-client-redirects 2.0.0-beta.1ec2c95e3 → 2.0.0-beta.21
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 +34 -41
- package/lib/createRedirectPageContent.d.ts +2 -4
- package/lib/createRedirectPageContent.js +2 -4
- package/lib/extensionRedirects.d.ts +1 -1
- package/lib/extensionRedirects.js +9 -16
- package/lib/index.d.ts +5 -3
- package/lib/index.js +9 -8
- 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 -21
- package/package.json +16 -14
- package/src/collectRedirects.ts +40 -56
- package/src/createRedirectPageContent.ts +8 -10
- package/src/extensionRedirects.ts +9 -17
- package/src/index.ts +11 -11
- package/src/options.ts +71 -0
- package/src/redirectValidation.ts +1 -1
- package/src/types.ts +14 -28
- package/src/writeRedirectFiles.ts +38 -28
- 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 -143
- 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,24 +5,19 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import
|
|
8
|
+
import _ from 'lodash';
|
|
9
|
+
import logger from '@docusaurus/logger';
|
|
9
10
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
RedirectOption,
|
|
14
|
-
} from './types';
|
|
11
|
+
applyTrailingSlash,
|
|
12
|
+
type ApplyTrailingSlashParams,
|
|
13
|
+
} from '@docusaurus/utils-common';
|
|
15
14
|
import {
|
|
16
15
|
createFromExtensionsRedirects,
|
|
17
16
|
createToExtensionsRedirects,
|
|
18
17
|
} from './extensionRedirects';
|
|
19
18
|
import {validateRedirect} from './redirectValidation';
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
ApplyTrailingSlashParams,
|
|
23
|
-
} from '@docusaurus/utils-common';
|
|
24
|
-
|
|
25
|
-
import chalk from 'chalk';
|
|
19
|
+
import type {PluginOptions, RedirectOption} from './options';
|
|
20
|
+
import type {PluginContext, RedirectMetadata} from './types';
|
|
26
21
|
|
|
27
22
|
export default function collectRedirects(
|
|
28
23
|
pluginContext: PluginContext,
|
|
@@ -40,32 +35,33 @@ export default function collectRedirects(
|
|
|
40
35
|
}
|
|
41
36
|
|
|
42
37
|
// If users wants to redirect to=/abc and they enable trailingSlash=true then
|
|
43
|
-
// => we don't want to reject the to=/abc (as only /abc/ is an existing/valid
|
|
44
|
-
//
|
|
45
|
-
//
|
|
38
|
+
// => we don't want to reject the to=/abc (as only /abc/ is an existing/valid
|
|
39
|
+
// path now)
|
|
40
|
+
// => we want to redirect to=/abc/ without the user having to change all its
|
|
41
|
+
// redirect plugin options
|
|
42
|
+
// It should be easy to toggle siteConfig.trailingSlash option without having to
|
|
43
|
+
// change other configs
|
|
46
44
|
function applyRedirectsTrailingSlash(
|
|
47
45
|
redirects: RedirectMetadata[],
|
|
48
46
|
params: ApplyTrailingSlashParams,
|
|
49
47
|
) {
|
|
50
|
-
return redirects.map((redirect) => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
};
|
|
55
|
-
});
|
|
48
|
+
return redirects.map((redirect) => ({
|
|
49
|
+
...redirect,
|
|
50
|
+
to: applyTrailingSlash(redirect.to, params),
|
|
51
|
+
}));
|
|
56
52
|
}
|
|
57
53
|
|
|
58
54
|
function validateCollectedRedirects(
|
|
59
55
|
redirects: RedirectMetadata[],
|
|
60
56
|
pluginContext: PluginContext,
|
|
61
57
|
) {
|
|
62
|
-
const redirectValidationErrors
|
|
58
|
+
const redirectValidationErrors = redirects
|
|
63
59
|
.map((redirect) => {
|
|
64
60
|
try {
|
|
65
61
|
validateRedirect(redirect);
|
|
66
62
|
return undefined;
|
|
67
|
-
} catch (
|
|
68
|
-
return
|
|
63
|
+
} catch (err) {
|
|
64
|
+
return (err as Error).message;
|
|
69
65
|
}
|
|
70
66
|
})
|
|
71
67
|
.filter(Boolean);
|
|
@@ -79,7 +75,7 @@ function validateCollectedRedirects(
|
|
|
79
75
|
|
|
80
76
|
const allowedToPaths = pluginContext.relativeRoutesPaths;
|
|
81
77
|
const toPaths = redirects.map((redirect) => redirect.to);
|
|
82
|
-
const illegalToPaths = difference(toPaths, allowedToPaths);
|
|
78
|
+
const illegalToPaths = _.difference(toPaths, allowedToPaths);
|
|
83
79
|
if (illegalToPaths.length > 0) {
|
|
84
80
|
throw new Error(
|
|
85
81
|
`You are trying to create client-side redirections to paths that do not exist:
|
|
@@ -96,36 +92,28 @@ function filterUnwantedRedirects(
|
|
|
96
92
|
redirects: RedirectMetadata[],
|
|
97
93
|
pluginContext: PluginContext,
|
|
98
94
|
): RedirectMetadata[] {
|
|
99
|
-
//
|
|
100
|
-
//
|
|
101
|
-
Object.entries(groupBy(redirects, (redirect) => redirect.from)).forEach(
|
|
95
|
+
// We don't want to create the same redirect twice, since that would lead to
|
|
96
|
+
// writing the same html redirection file twice.
|
|
97
|
+
Object.entries(_.groupBy(redirects, (redirect) => redirect.from)).forEach(
|
|
102
98
|
([from, groupedFromRedirects]) => {
|
|
103
99
|
if (groupedFromRedirects.length > 1) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
- ${groupedFromRedirects.map((r) => JSON.stringify(r)).join('\n- ')}
|
|
109
|
-
`,
|
|
110
|
-
),
|
|
111
|
-
);
|
|
100
|
+
logger.error`name=${'@docusaurus/plugin-client-redirects'}: multiple redirects are created with the same "from" pathname: path=${from}
|
|
101
|
+
It is not possible to redirect the same pathname to multiple destinations: ${groupedFromRedirects.map(
|
|
102
|
+
(r) => JSON.stringify(r),
|
|
103
|
+
)}`;
|
|
112
104
|
}
|
|
113
105
|
},
|
|
114
106
|
);
|
|
115
|
-
const collectedRedirects = uniqBy(redirects, (redirect) => redirect.from);
|
|
107
|
+
const collectedRedirects = _.uniqBy(redirects, (redirect) => redirect.from);
|
|
116
108
|
|
|
117
109
|
// We don't want to override an already existing route with a redirect file!
|
|
118
110
|
const redirectsOverridingExistingPath = collectedRedirects.filter(
|
|
119
111
|
(redirect) => pluginContext.relativeRoutesPaths.includes(redirect.from),
|
|
120
112
|
);
|
|
121
113
|
if (redirectsOverridingExistingPath.length > 0) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
- ${redirectsOverridingExistingPath.map((r) => JSON.stringify(r)).join('\n- ')}
|
|
126
|
-
`,
|
|
127
|
-
),
|
|
128
|
-
);
|
|
114
|
+
logger.error`name=${'@docusaurus/plugin-client-redirects'}: some redirects would override existing paths, and will be ignored: ${redirectsOverridingExistingPath.map(
|
|
115
|
+
(r) => JSON.stringify(r),
|
|
116
|
+
)}`;
|
|
129
117
|
}
|
|
130
118
|
return collectedRedirects.filter(
|
|
131
119
|
(redirect) => !pluginContext.relativeRoutesPaths.includes(redirect.from),
|
|
@@ -154,7 +142,7 @@ function doCollectRedirects(pluginContext: PluginContext): RedirectMetadata[] {
|
|
|
154
142
|
function createRedirectsOptionRedirects(
|
|
155
143
|
redirectsOption: PluginOptions['redirects'],
|
|
156
144
|
): RedirectMetadata[] {
|
|
157
|
-
// For
|
|
145
|
+
// For convenience, user can use a string or a string[]
|
|
158
146
|
function optionToRedirects(option: RedirectOption): RedirectMetadata[] {
|
|
159
147
|
if (typeof option.from === 'string') {
|
|
160
148
|
return [{from: option.from, to: option.to}];
|
|
@@ -165,7 +153,7 @@ function createRedirectsOptionRedirects(
|
|
|
165
153
|
}));
|
|
166
154
|
}
|
|
167
155
|
|
|
168
|
-
return
|
|
156
|
+
return redirectsOption.flatMap(optionToRedirects);
|
|
169
157
|
}
|
|
170
158
|
|
|
171
159
|
// Create redirects from the "createRedirects" fn provided by the user
|
|
@@ -174,20 +162,16 @@ function createCreateRedirectsOptionRedirects(
|
|
|
174
162
|
createRedirects: PluginOptions['createRedirects'],
|
|
175
163
|
): RedirectMetadata[] {
|
|
176
164
|
function createPathRedirects(path: string): RedirectMetadata[] {
|
|
177
|
-
const fromsMixed: string | string[] = createRedirects
|
|
178
|
-
? createRedirects(path) || []
|
|
179
|
-
: [];
|
|
165
|
+
const fromsMixed: string | string[] = createRedirects?.(path) ?? [];
|
|
180
166
|
|
|
181
167
|
const froms: string[] =
|
|
182
168
|
typeof fromsMixed === 'string' ? [fromsMixed] : fromsMixed;
|
|
183
169
|
|
|
184
|
-
return froms.map((from) => {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
};
|
|
189
|
-
});
|
|
170
|
+
return froms.map((from) => ({
|
|
171
|
+
from,
|
|
172
|
+
to: path,
|
|
173
|
+
}));
|
|
190
174
|
}
|
|
191
175
|
|
|
192
|
-
return
|
|
176
|
+
return paths.flatMap(createPathRedirects);
|
|
193
177
|
}
|
|
@@ -5,26 +5,24 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import _ from 'lodash';
|
|
8
9
|
import * as eta from 'eta';
|
|
9
10
|
import redirectPageTemplate from './templates/redirectPage.template.html';
|
|
10
|
-
import {memoize} 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,16 +5,15 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {flatten} from 'lodash';
|
|
9
8
|
import {
|
|
10
9
|
addTrailingSlash,
|
|
11
10
|
removeSuffix,
|
|
12
11
|
removeTrailingSlash,
|
|
13
12
|
} from '@docusaurus/utils';
|
|
14
|
-
import {RedirectMetadata} from './types';
|
|
13
|
+
import type {RedirectMetadata} from './types';
|
|
15
14
|
|
|
16
15
|
const ExtensionAdditionalMessage =
|
|
17
|
-
'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.';
|
|
18
17
|
|
|
19
18
|
const validateExtension = (ext: string) => {
|
|
20
19
|
if (!ext) {
|
|
@@ -62,7 +61,7 @@ export function createToExtensionsRedirects(
|
|
|
62
61
|
return [];
|
|
63
62
|
};
|
|
64
63
|
|
|
65
|
-
return
|
|
64
|
+
return paths.flatMap(createPathRedirects);
|
|
66
65
|
}
|
|
67
66
|
|
|
68
67
|
// Create new /path.html/index.html that redirects to existing an /path
|
|
@@ -82,22 +81,15 @@ export function createFromExtensionsRedirects(
|
|
|
82
81
|
if (path === '' || path === '/' || alreadyEndsWithAnExtension(path)) {
|
|
83
82
|
return [];
|
|
84
83
|
}
|
|
85
|
-
|
|
86
|
-
// /path => /path.html
|
|
87
|
-
// /path/ => /path.html/
|
|
88
|
-
function getFrom(ext: string) {
|
|
89
|
-
if (path.endsWith('/')) {
|
|
90
|
-
return addTrailingSlash(`${removeTrailingSlash(path)}.${ext}`);
|
|
91
|
-
} else {
|
|
92
|
-
return `${path}.${ext}`;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
84
|
return extensions.map((ext) => ({
|
|
97
|
-
|
|
85
|
+
// /path => /path.html
|
|
86
|
+
// /path/ => /path.html/
|
|
87
|
+
from: path.endsWith('/')
|
|
88
|
+
? addTrailingSlash(`${removeTrailingSlash(path)}.${ext}`)
|
|
89
|
+
: `${path}.${ext}`,
|
|
98
90
|
to: path,
|
|
99
91
|
}));
|
|
100
92
|
};
|
|
101
93
|
|
|
102
|
-
return
|
|
94
|
+
return paths.flatMap(createPathRedirects);
|
|
103
95
|
}
|
package/src/index.ts
CHANGED
|
@@ -5,28 +5,25 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
import {UserPluginOptions, PluginContext, RedirectMetadata} from './types';
|
|
10
|
-
|
|
11
|
-
import normalizePluginOptions from './normalizePluginOptions';
|
|
8
|
+
import {removePrefix, addLeadingSlash} from '@docusaurus/utils';
|
|
12
9
|
import collectRedirects from './collectRedirects';
|
|
13
10
|
import writeRedirectFiles, {
|
|
14
11
|
toRedirectFilesMetadata,
|
|
15
|
-
RedirectFileMetadata,
|
|
12
|
+
type RedirectFileMetadata,
|
|
16
13
|
} from './writeRedirectFiles';
|
|
17
|
-
import {
|
|
14
|
+
import type {LoadContext, Plugin} from '@docusaurus/types';
|
|
15
|
+
import type {PluginContext, RedirectMetadata} from './types';
|
|
16
|
+
import type {PluginOptions, Options} from './options';
|
|
18
17
|
|
|
19
18
|
export default function pluginClientRedirectsPages(
|
|
20
19
|
context: LoadContext,
|
|
21
|
-
|
|
22
|
-
): Plugin<
|
|
20
|
+
options: PluginOptions,
|
|
21
|
+
): Plugin<void> {
|
|
23
22
|
const {trailingSlash} = context.siteConfig;
|
|
24
23
|
|
|
25
|
-
const options = normalizePluginOptions(opts);
|
|
26
|
-
|
|
27
24
|
return {
|
|
28
25
|
name: 'docusaurus-plugin-client-redirects',
|
|
29
|
-
async postBuild(props
|
|
26
|
+
async postBuild(props) {
|
|
30
27
|
const pluginContext: PluginContext = {
|
|
31
28
|
relativeRoutesPaths: props.routesPaths.map(
|
|
32
29
|
(path) => `${addLeadingSlash(removePrefix(path, props.baseUrl))}`,
|
|
@@ -52,3 +49,6 @@ export default function pluginClientRedirectsPages(
|
|
|
52
49
|
},
|
|
53
50
|
};
|
|
54
51
|
}
|
|
52
|
+
|
|
53
|
+
export {validateOptions} from './options';
|
|
54
|
+
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 {Joi, PathnameSchema} from '@docusaurus/utils-validation';
|
|
9
|
+
import type {OptionValidationContext} from '@docusaurus/types';
|
|
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 | undefined, PluginOptions>): PluginOptions {
|
|
70
|
+
return validate(UserOptionsSchema, userOptions);
|
|
71
|
+
}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {RedirectMetadata} from './types';
|
|
9
8
|
import {Joi, PathnameSchema} from '@docusaurus/utils-validation';
|
|
9
|
+
import type {RedirectMetadata} from './types';
|
|
10
10
|
|
|
11
11
|
const RedirectSchema = Joi.object<RedirectMetadata>({
|
|
12
12
|
from: PathnameSchema.required(),
|
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,13 @@
|
|
|
7
7
|
|
|
8
8
|
import fs from 'fs-extra';
|
|
9
9
|
import path from 'path';
|
|
10
|
-
import
|
|
10
|
+
import _ from 'lodash';
|
|
11
|
+
import logger from '@docusaurus/logger';
|
|
12
|
+
import {normalizeUrl} from '@docusaurus/utils';
|
|
11
13
|
|
|
12
|
-
import {PluginContext, RedirectMetadata} from './types';
|
|
13
14
|
import createRedirectPageContent from './createRedirectPageContent';
|
|
14
|
-
|
|
15
|
+
|
|
16
|
+
import type {PluginContext, RedirectMetadata} from './types';
|
|
15
17
|
|
|
16
18
|
export type WriteFilesPluginContext = Pick<PluginContext, 'baseUrl' | 'outDir'>;
|
|
17
19
|
|
|
@@ -24,21 +26,34 @@ export function createToUrl(baseUrl: string, to: string): string {
|
|
|
24
26
|
return normalizeUrl([baseUrl, to]);
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
//
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
//
|
|
29
|
+
// Create redirect file path
|
|
30
|
+
// Make sure this path has lower precedence over the original file path when
|
|
31
|
+
// served by host providers!
|
|
32
|
+
// Otherwise it can produce infinite redirect loops!
|
|
31
33
|
//
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
// See
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
_trailingSlash: boolean | undefined, // Now unused, on purpose
|
|
34
|
+
// See https://github.com/facebook/docusaurus/issues/5055
|
|
35
|
+
// See https://github.com/facebook/docusaurus/pull/5085
|
|
36
|
+
// See https://github.com/facebook/docusaurus/pull/5102
|
|
37
|
+
function getRedirectFilePath(
|
|
38
|
+
fromPath: string,
|
|
39
|
+
trailingSlash: boolean | undefined, // Now unused, on purpose
|
|
39
40
|
): string {
|
|
40
|
-
const fileName = path.basename(
|
|
41
|
-
const filePath = path.dirname(
|
|
41
|
+
const fileName = path.basename(fromPath);
|
|
42
|
+
const filePath = path.dirname(fromPath);
|
|
43
|
+
// Edge case for https://github.com/facebook/docusaurus/pull/5102
|
|
44
|
+
// If the redirect source path is /xyz, with file /xyz.html
|
|
45
|
+
// We can't write the redirect file at /xyz.html/index.html because for Unix
|
|
46
|
+
// FS, a file/folder can't have the same name "xyz.html"
|
|
47
|
+
// The only possible solution for a redirect file is thus /xyz.html.html (I
|
|
48
|
+
// know, looks suspicious)
|
|
49
|
+
if (trailingSlash === false && fileName.endsWith('.html')) {
|
|
50
|
+
return path.join(filePath, `${fileName}.html`);
|
|
51
|
+
}
|
|
52
|
+
// If the target path is /xyz, with file /xyz/index.html, we don't want the
|
|
53
|
+
// redirect file to be /xyz.html, otherwise it would be picked in priority and
|
|
54
|
+
// the redirect file would redirect to itself. We prefer the redirect file to
|
|
55
|
+
// be /xyz.html/index.html, served with lower priority for most static hosting
|
|
56
|
+
// tools
|
|
42
57
|
return path.join(filePath, `${fileName}/index.html`);
|
|
43
58
|
}
|
|
44
59
|
|
|
@@ -50,15 +65,12 @@ export function toRedirectFilesMetadata(
|
|
|
50
65
|
// Perf: avoid rendering the template twice with the exact same "props"
|
|
51
66
|
// We might create multiple redirect pages for the same destination url
|
|
52
67
|
// note: the first fn arg is the cache key!
|
|
53
|
-
const createPageContentMemoized = memoize((toUrl: string) =>
|
|
54
|
-
|
|
55
|
-
|
|
68
|
+
const createPageContentMemoized = _.memoize((toUrl: string) =>
|
|
69
|
+
createRedirectPageContent({toUrl}),
|
|
70
|
+
);
|
|
56
71
|
|
|
57
72
|
const createFileMetadata = (redirect: RedirectMetadata) => {
|
|
58
|
-
const fileRelativePath =
|
|
59
|
-
redirect.from,
|
|
60
|
-
trailingSlash,
|
|
61
|
-
);
|
|
73
|
+
const fileRelativePath = getRedirectFilePath(redirect.from, trailingSlash);
|
|
62
74
|
const fileAbsolutePath = path.join(pluginContext.outDir, fileRelativePath);
|
|
63
75
|
const toUrl = createToUrl(pluginContext.baseUrl, redirect.to);
|
|
64
76
|
const fileContent = createPageContentMemoized(toUrl);
|
|
@@ -82,8 +94,7 @@ export async function writeRedirectFile(
|
|
|
82
94
|
'The redirect plugin is not supposed to override existing files.',
|
|
83
95
|
);
|
|
84
96
|
}
|
|
85
|
-
await fs.
|
|
86
|
-
await fs.writeFile(
|
|
97
|
+
await fs.outputFile(
|
|
87
98
|
file.fileAbsolutePath,
|
|
88
99
|
file.fileContent,
|
|
89
100
|
// Hard security to prevent file overrides
|
|
@@ -91,9 +102,8 @@ export async function writeRedirectFile(
|
|
|
91
102
|
{flag: 'wx'},
|
|
92
103
|
);
|
|
93
104
|
} catch (err) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
);
|
|
105
|
+
logger.error`Redirect file creation error for path=${file.fileAbsolutePath}.`;
|
|
106
|
+
throw err;
|
|
97
107
|
}
|
|
98
108
|
}
|
|
99
109
|
|
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/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","aefb89303293b92387354bd8464557e02efa728bfd0d7f9316579092e9e47856","57dc389181eeb619a8b10299e3447cd6d9b216453af993abda5afedd6b39b455","0daf3165e72cc1ed5263a3374b98cb065f78922c76602477973ee0654b99df17","98249526332851a623664fd515a293f50d680d4a86d633585ecb9168e67cd872","3fedee34f24b13af4a97c4184a9e215a6f6b2dfb655dafc24970c76791b06c43","4fae0cbdbb492b0fc847ec76d0a4af44eb04028200cec088d97fca05438213f1","c7642b1c7345e546c81831fe5fa9233e15a12fa2743f6685b0d700af8292cdd0","857d6d4a53c4372a2799e733ab122d28f7b2b580fe58b80a5fe1321a733c20f7","2c20d6df034f99432a23cfd95b2e48784fe4224cc9c0bc4094881c99bce1ef66","f69977513b0d68b014b1a9f0442d5a426981da391870d15626b595206be9ae62","889859c907d8388cfe92d4bdfe5b5ff0885a41e6e4568691230e21757f7673c9","d62aae9510ec58d3533a76b9915dae85dea65aa39c915613dc9f47918f596b1e","57e1940021e5e3ff12963f4218195c786a0d2a475a400fffb7cdd4352823854d","01c67feaa6d785a1f958c92f0e1eabdd69bd5e44cbd8a233b89a247ad9bb1dc3","700c2f83a83482242336bf0033edbd961105577f16b9cf549333159fc719add2","63c9b50b55f320e8da81290acd27de8e1dab92e13b3ec7f24b80fde9dd80b795","efc0cf69f54f6d4fbdcc205cc938f1f6f6f1d63fbcb7b3f912a4755805b05b31","20da58cecd1ad8c239745c7ebb8ae0729c182223650702ec816d3bdec566e3bb","0d14fa22c41fdc7277e6f71473b20ebc07f40f00e38875142335d5b63cdfc9d2","b12f0a6baceceb49f0f3db81a91b21ba490993ff6aff649cdb7393822cbcc301","a3cf09a8ce34726b0557b3e51135a6768b464e86b7190355e42f10ba368e9786","dcd04eabb6c23406dc589f688c7a83d25a8aa0c93ee34c0be1114113c32792d6","0a21f90e2ffaf26b305183fd2029a7dd512bb3189a9d6842ba764782e609429e","5560fae6a4c210279d4c913e62dfa82f6ebbc283800e430c4ec54e20216e4b2f","bd868c7a5868f2680d332b85283be6be45edb766a95c4b8034aff7c741ab1aad","5ec0c5db09dfb4f1cd140417dc86fed025bd757d63c11fe2c4148ec12fd20111","2737dcbf71e062619538a0d3075795be33900ccf377d5dae1e90197f95787566","2db6353e2fdcbd2842b5b0a36d11e11ffbff703552e19481a55a63155e14c6be","74175ef96c3d3cb5e7bcaf0387ca4cc3de9f1bf68b42a082d8be5e79178c2c7e","37723b12b6a526579c9a467ab70a9414fc30994e24bd4b9dae41148ed3e112a1","63a254a5a16ee3457a0dd00dedacc0d76cc7897b976ec64d59d149d43c4859b7","4977865ec3570795ce920e30b51b6c345ad782bd804202e80d95fc1a09299a7d","c8c407861245162fcf6c4a65125331964efa6f75972dd908ea0e2ba13ca77b33","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","cb22a427119152656d8a304faf1b698e173bad1f7f95ecf5eb0c2849d7804ba1","c16e15a7bbbb323cdf9df7a6b05a96b474831768886e0c85f5e0df3275249923"],"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":[[117,153],[151],[150,151],[105,110],[116,117,124,133],[106,116,124],[142],[110,117,125],[133,138],[113,116,124],[114],[113],[116],[116,118,133,141],[116,117],[124,133,141],[116,117,119,124,133,138,141],[119,138,141],[152],[141],[113,116,133],[126],[104],[140],[131,142,145],[116,134],[133],[136],[110,124],[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],[124],[130],[143],[105,110,116,118,127,133,141,145],[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],[91],[91,92],[89,90],[89,91],[89,91,92,93,94,95,96],[89,91,92],[60,61,63],[62,63],[60,61,62],[59,63,64,65],[45,58,70,78,83,86,87],[45,58,97,98],[45,58,70,77],[45,69,70,77,88,101,155],[45,70,82,100],[45,70,82],[45],[45,69],[45,58,70,77,99,126,154],[66,67,68,130],[69],[84,85],[68],[79,80,81],[79],[69,71,72,73,74,75,76]],"referencedMap":[[154,1],[102,2],[152,3],[105,4],[106,5],[107,6],[108,7],[109,8],[110,9],[111,10],[113,11],[114,12],[115,13],[116,13],[117,14],[118,15],[119,16],[120,17],[121,18],[153,19],[122,13],[123,20],[124,21],[126,22],[127,23],[128,24],[131,13],[132,25],[133,26],[134,27],[136,13],[137,28],[138,29],[150,30],[140,31],[141,32],[142,33],[144,27],[146,34],[147,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],[93,48],[89,49],[91,50],[96,50],[92,51],[97,52],[94,48],[95,53],[62,54],[64,55],[63,56],[66,57],[88,58],[99,59],[78,60],[156,61],[101,62],[83,63],[98,64],[70,65],[155,66],[69,67],[84,68],[86,69],[79,70],[82,71],[81,72],[80,72],[77,73]],"exportedModulesMap":[[154,1],[102,2],[152,3],[105,4],[106,5],[107,6],[108,7],[109,8],[110,9],[111,10],[113,11],[114,12],[115,13],[116,13],[117,14],[118,15],[119,16],[120,17],[121,18],[153,19],[122,13],[123,20],[124,21],[126,22],[127,23],[128,24],[131,13],[132,25],[133,26],[134,27],[136,13],[137,28],[138,29],[150,30],[140,31],[141,32],[142,33],[144,27],[146,34],[147,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],[93,48],[89,49],[91,50],[96,50],[92,51],[97,52],[94,48],[95,53],[62,54],[64,55],[63,56],[66,57],[88,58],[99,59],[78,60],[156,61],[101,62],[83,63],[98,64],[70,65],[155,66],[69,67],[84,68],[86,69],[79,70],[82,71],[81,72],[80,72],[77,73]],"semanticDiagnosticsPerFile":[154,151,102,104,152,105,106,107,108,109,110,111,112,113,114,115,116,117,118,103,148,119,120,121,153,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,150,140,141,142,143,144,145,149,146,147,60,47,48,46,49,50,51,52,53,54,55,56,57,58,61,87,93,89,91,96,92,97,94,95,90,68,62,64,63,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,88,99,78,156,101,83,98,70,155,67,69,84,86,85,79,82,81,80,72,75,76,77,74,73,71,100]},"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;
|