@docusaurus/core 2.0.0-beta.16 → 2.0.0-beta.19
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/bin/beforeCli.mjs +14 -12
- package/bin/docusaurus.mjs +41 -93
- package/lib/babel/preset.js +2 -2
- package/lib/client/.eslintrc.js +2 -3
- package/lib/client/App.d.ts +1 -1
- package/lib/client/App.js +15 -7
- package/lib/client/{baseUrlIssueBanner/BaseUrlIssueBanner.d.ts → BaseUrlIssueBanner/index.d.ts} +10 -5
- package/lib/client/{baseUrlIssueBanner/BaseUrlIssueBanner.js → BaseUrlIssueBanner/index.js} +14 -9
- package/lib/client/{baseUrlIssueBanner → BaseUrlIssueBanner}/styles.module.css +0 -0
- package/lib/client/ClientLifecyclesDispatcher.d.ts +16 -0
- package/lib/client/ClientLifecyclesDispatcher.js +34 -0
- package/lib/client/LinksCollector.d.ts +1 -1
- package/lib/client/LinksCollector.js +4 -5
- package/lib/client/PendingNavigation.d.ts +8 -17
- package/lib/client/PendingNavigation.js +39 -70
- package/lib/{server/loadSetup.d.ts → client/SiteMetadataDefaults.d.ts} +2 -2
- package/lib/client/SiteMetadataDefaults.js +19 -0
- package/lib/client/{exports/browserContext.d.ts → browserContext.d.ts} +0 -0
- package/lib/client/{exports/browserContext.js → browserContext.js} +0 -0
- package/lib/client/clientEntry.js +3 -4
- package/lib/client/docusaurus.d.ts +5 -5
- package/lib/client/docusaurus.js +26 -33
- package/lib/client/{exports/docusaurusContext.d.ts → docusaurusContext.d.ts} +0 -0
- package/lib/client/{exports/docusaurusContext.js → docusaurusContext.js} +0 -0
- package/lib/client/exports/BrowserOnly.d.ts +3 -4
- package/lib/client/exports/BrowserOnly.js +2 -2
- package/lib/client/exports/ComponentCreator.js +65 -40
- package/lib/client/exports/ErrorBoundary.d.ts +2 -2
- package/lib/client/exports/ErrorBoundary.js +4 -5
- package/lib/client/exports/Interpolate.d.ts +1 -1
- package/lib/client/exports/Interpolate.js +18 -41
- package/lib/client/exports/Link.d.ts +3 -15
- package/lib/client/exports/Link.js +24 -30
- package/lib/client/exports/Translate.d.ts +2 -2
- package/lib/client/exports/Translate.js +3 -3
- package/lib/client/exports/useBaseUrl.js +8 -9
- package/lib/client/exports/useDocusaurusContext.js +1 -1
- package/lib/client/exports/useGlobalData.d.ts +4 -3
- package/lib/client/exports/useGlobalData.js +5 -5
- package/lib/client/exports/useIsBrowser.js +1 -1
- package/lib/{server/client-modules/index.d.ts → client/exports/useRouteContext.d.ts} +2 -2
- package/lib/client/exports/useRouteContext.js +15 -0
- package/lib/client/flat.d.ts +12 -2
- package/lib/client/flat.js +12 -5
- package/lib/client/normalizeLocation.js +13 -8
- package/lib/client/prefetch.js +10 -28
- package/lib/client/preload.d.ts +1 -3
- package/lib/client/preload.js +5 -11
- package/lib/client/routeContext.d.ts +13 -0
- package/lib/client/routeContext.js +31 -0
- package/lib/client/serverEntry.js +19 -18
- package/lib/client/theme-fallback/Error/index.js +7 -1
- package/lib/client/theme-fallback/Layout/index.d.ts +1 -1
- package/lib/client/theme-fallback/Layout/index.js +2 -17
- package/lib/client/theme-fallback/Loading/index.js +2 -0
- package/lib/client/theme-fallback/NotFound/index.js +13 -5
- package/lib/client/theme-fallback/Root/index.d.ts +4 -4
- package/lib/client/theme-fallback/Root/index.js +2 -1
- package/lib/{server/html-tags/htmlTags.d.ts → client/theme-fallback/SiteMetadata/index.d.ts} +2 -1
- package/lib/client/theme-fallback/SiteMetadata/index.js +10 -0
- package/lib/commands/build.d.ts +6 -2
- package/lib/commands/build.js +48 -30
- package/lib/commands/clear.d.ts +1 -1
- package/lib/commands/clear.js +6 -5
- package/lib/commands/deploy.d.ts +5 -5
- package/lib/commands/deploy.js +21 -45
- package/lib/commands/external.d.ts +1 -1
- package/lib/commands/external.js +6 -11
- package/lib/commands/serve.d.ts +7 -2
- package/lib/commands/serve.js +18 -19
- package/lib/commands/start.d.ts +8 -2
- package/lib/commands/start.js +33 -30
- package/lib/commands/swizzle/actions.d.ts +2 -2
- package/lib/commands/swizzle/actions.js +10 -10
- package/lib/commands/swizzle/common.d.ts +3 -3
- package/lib/commands/swizzle/common.js +8 -9
- package/lib/commands/swizzle/components.js +48 -13
- package/lib/commands/swizzle/config.js +21 -15
- package/lib/commands/swizzle/context.js +6 -12
- package/lib/commands/swizzle/index.d.ts +2 -2
- package/lib/commands/swizzle/index.js +5 -4
- package/lib/commands/swizzle/prompts.js +2 -2
- package/lib/commands/swizzle/tables.js +10 -13
- package/lib/commands/swizzle/themes.js +9 -8
- package/lib/commands/writeHeadingIds.d.ts +2 -9
- package/lib/commands/writeHeadingIds.js +11 -69
- package/lib/commands/writeTranslations.d.ts +3 -4
- package/lib/commands/writeTranslations.js +10 -14
- package/lib/index.d.ts +9 -10
- package/lib/index.js +18 -19
- package/lib/server/brokenLinks.d.ts +3 -16
- package/lib/server/brokenLinks.js +37 -31
- package/lib/server/clientModules.d.ts +12 -0
- package/lib/server/clientModules.js +20 -0
- package/lib/server/config.d.ts +5 -2
- package/lib/server/config.js +14 -9
- package/lib/server/configValidation.d.ts +1 -1
- package/lib/server/configValidation.js +39 -13
- package/lib/server/getHostPort.d.ts +14 -0
- package/lib/{choosePort.js → server/getHostPort.js} +24 -41
- package/lib/server/htmlTags.d.ts +12 -0
- package/lib/server/htmlTags.js +62 -0
- package/lib/server/i18n.d.ts +2 -11
- package/lib/server/i18n.js +7 -28
- package/lib/server/index.d.ts +28 -13
- package/lib/server/index.js +62 -229
- package/lib/server/plugins/configs.d.ts +51 -0
- package/lib/server/plugins/configs.js +101 -0
- package/lib/server/plugins/index.d.ts +9 -8
- package/lib/server/plugins/index.js +65 -132
- package/lib/server/plugins/init.d.ts +6 -15
- package/lib/server/plugins/init.js +25 -83
- package/lib/server/{moduleShorthand.d.ts → plugins/moduleShorthand.d.ts} +0 -0
- package/lib/server/{moduleShorthand.js → plugins/moduleShorthand.js} +0 -0
- package/lib/server/plugins/pluginIds.d.ts +4 -0
- package/lib/server/plugins/pluginIds.js +6 -4
- package/lib/server/plugins/presets.d.ts +12 -0
- package/lib/server/{presets/index.js → plugins/presets.js} +21 -20
- package/lib/server/plugins/{applyRouteTrailingSlash.d.ts → routeConfig.d.ts} +3 -1
- package/lib/server/plugins/routeConfig.js +54 -0
- package/lib/server/plugins/synthetic.d.ts +20 -0
- package/lib/server/plugins/synthetic.js +112 -0
- package/lib/server/routes.d.ts +39 -7
- package/lib/server/routes.js +169 -102
- package/lib/server/siteMetadata.d.ts +12 -0
- package/lib/server/siteMetadata.js +81 -0
- package/lib/server/translations/translations.d.ts +5 -14
- package/lib/server/translations/translations.js +23 -39
- package/lib/server/translations/translationsExtractor.d.ts +2 -2
- package/lib/server/translations/translationsExtractor.js +16 -19
- package/lib/server/utils.js +1 -1
- package/lib/webpack/aliases/index.d.ts +34 -0
- package/lib/webpack/aliases/index.js +106 -0
- package/lib/webpack/base.d.ts +0 -1
- package/lib/webpack/base.js +12 -30
- package/lib/webpack/client.js +7 -8
- package/lib/webpack/plugins/ChunkAssetPlugin.js +7 -7
- package/lib/webpack/plugins/CleanWebpackPlugin.d.ts +2 -2
- package/lib/webpack/plugins/CleanWebpackPlugin.js +2 -2
- package/lib/webpack/plugins/LogPlugin.js +2 -2
- package/lib/webpack/plugins/WaitPlugin.d.ts +2 -2
- package/lib/webpack/plugins/WaitPlugin.js +3 -3
- package/lib/webpack/server.d.ts +2 -2
- package/lib/webpack/server.js +10 -8
- package/lib/webpack/utils.d.ts +9 -3
- package/lib/webpack/utils.js +20 -25
- package/package.json +38 -41
- package/lib/choosePort.d.ts +0 -11
- package/lib/client/client-lifecycles-dispatcher.d.ts +0 -9
- package/lib/client/client-lifecycles-dispatcher.js +0 -23
- package/lib/client/nprogress.css +0 -36
- package/lib/commands/commandUtils.d.ts +0 -9
- package/lib/commands/commandUtils.js +0 -21
- package/lib/server/client-modules/index.js +0 -12
- package/lib/server/duplicateRoutes.d.ts +0 -10
- package/lib/server/duplicateRoutes.js +0 -42
- package/lib/server/html-tags/htmlTags.js +0 -38
- package/lib/server/html-tags/index.d.ts +0 -9
- package/lib/server/html-tags/index.js +0 -43
- package/lib/server/loadSetup.js +0 -25
- package/lib/server/plugins/applyRouteTrailingSlash.js +0 -19
- package/lib/server/presets/index.d.ts +0 -11
- package/lib/server/themes/alias.d.ts +0 -9
- package/lib/server/themes/alias.js +0 -48
- package/lib/server/themes/index.d.ts +0 -12
- package/lib/server/themes/index.js +0 -47
- package/lib/server/versions/__fixtures__/dummy-plugin.d.ts +0 -0
- package/lib/server/versions/__fixtures__/dummy-plugin.js +0 -0
- package/lib/server/versions/__fixtures__/package.json +0 -3
- package/lib/server/versions/index.d.ts +0 -9
- package/lib/server/versions/index.js +0 -51
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
const tslib_1 = require("tslib");
|
|
10
|
-
const path_1 =
|
|
11
|
-
const fs_extra_1 =
|
|
12
|
-
const wait_on_1 =
|
|
10
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
11
|
+
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
|
+
const wait_on_1 = tslib_1.__importDefault(require("wait-on"));
|
|
13
13
|
class WaitPlugin {
|
|
14
14
|
constructor(options) {
|
|
15
15
|
this.filepath = options.filepath;
|
package/lib/webpack/server.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { Configuration } from 'webpack';
|
|
8
8
|
import type { Props } from '@docusaurus/types';
|
|
9
|
-
|
|
9
|
+
import { type Locals } from '@slorber/static-site-generator-webpack-plugin';
|
|
10
|
+
export default function createServerConfig({ props, onLinksCollected, onHeadTagsCollected, }: Pick<Locals, 'onLinksCollected' | 'onHeadTagsCollected'> & {
|
|
10
11
|
props: Props;
|
|
11
|
-
onLinksCollected?: (staticPagePath: string, links: string[]) => void;
|
|
12
12
|
}): Promise<Configuration>;
|
package/lib/webpack/server.js
CHANGED
|
@@ -7,16 +7,17 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
const tslib_1 = require("tslib");
|
|
10
|
-
const path_1 =
|
|
11
|
-
const webpack_merge_1 =
|
|
10
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
11
|
+
const webpack_merge_1 = tslib_1.__importDefault(require("webpack-merge"));
|
|
12
12
|
const base_1 = require("./base");
|
|
13
|
-
const WaitPlugin_1 =
|
|
14
|
-
const LogPlugin_1 =
|
|
13
|
+
const WaitPlugin_1 = tslib_1.__importDefault(require("./plugins/WaitPlugin"));
|
|
14
|
+
const LogPlugin_1 = tslib_1.__importDefault(require("./plugins/LogPlugin"));
|
|
15
15
|
const utils_1 = require("@docusaurus/utils");
|
|
16
|
+
const ssr_html_template_1 = tslib_1.__importDefault(require("./templates/ssr.html.template"));
|
|
16
17
|
// Forked for Docusaurus: https://github.com/slorber/static-site-generator-webpack-plugin
|
|
17
|
-
const static_site_generator_webpack_plugin_1 =
|
|
18
|
-
async function createServerConfig({ props, onLinksCollected
|
|
19
|
-
const { baseUrl, routesPaths, generatedFilesDir, headTags, preBodyTags, postBodyTags,
|
|
18
|
+
const static_site_generator_webpack_plugin_1 = tslib_1.__importDefault(require("@slorber/static-site-generator-webpack-plugin"));
|
|
19
|
+
async function createServerConfig({ props, onLinksCollected, onHeadTagsCollected, }) {
|
|
20
|
+
const { baseUrl, routesPaths, generatedFilesDir, headTags, preBodyTags, postBodyTags, siteConfig: { noIndex, trailingSlash, ssrTemplate }, } = props;
|
|
20
21
|
const config = await (0, base_1.createBaseConfig)(props, true);
|
|
21
22
|
const routesLocation = {};
|
|
22
23
|
// Array of paths to be rendered. Relative to output directory
|
|
@@ -52,7 +53,8 @@ async function createServerConfig({ props, onLinksCollected = () => { }, }) {
|
|
|
52
53
|
preBodyTags,
|
|
53
54
|
postBodyTags,
|
|
54
55
|
onLinksCollected,
|
|
55
|
-
|
|
56
|
+
onHeadTagsCollected,
|
|
57
|
+
ssrTemplate: ssrTemplate ?? ssr_html_template_1.default,
|
|
56
58
|
noIndex,
|
|
57
59
|
},
|
|
58
60
|
paths: ssgPaths,
|
package/lib/webpack/utils.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
/// <reference types="node" />
|
|
8
8
|
import { type Configuration, type RuleSetRule, type WebpackPluginInstance } from 'webpack';
|
|
9
9
|
import type { TransformOptions } from '@babel/core';
|
|
10
|
-
import type {
|
|
10
|
+
import type { Plugin } from '@docusaurus/types';
|
|
11
11
|
export declare function getStyleLoaders(isServer: boolean, cssOptionsArg?: {
|
|
12
12
|
[key: string]: unknown;
|
|
13
13
|
}): RuleSetRule[];
|
|
@@ -29,8 +29,14 @@ export declare const getCustomizableJSLoader: (jsLoader?: "babel" | ((isServer:
|
|
|
29
29
|
* @param content content loaded by the plugin
|
|
30
30
|
* @returns final/ modified webpack config
|
|
31
31
|
*/
|
|
32
|
-
export declare function applyConfigureWebpack(configureWebpack:
|
|
33
|
-
export declare function applyConfigurePostCss(configurePostCss: NonNullable<
|
|
32
|
+
export declare function applyConfigureWebpack(configureWebpack: NonNullable<Plugin['configureWebpack']>, config: Configuration, isServer: boolean, jsLoader: 'babel' | ((isServer: boolean) => RuleSetRule) | undefined, content: unknown): Configuration;
|
|
33
|
+
export declare function applyConfigurePostCss(configurePostCss: NonNullable<Plugin['configurePostCss']>, config: Configuration): Configuration;
|
|
34
|
+
declare global {
|
|
35
|
+
interface Error {
|
|
36
|
+
/** @see https://webpack.js.org/api/node/#error-handling */
|
|
37
|
+
details: unknown;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
34
40
|
export declare function compile(config: Configuration[]): Promise<void>;
|
|
35
41
|
export declare function getHttpsConfig(): Promise<boolean | {
|
|
36
42
|
cert: Buffer;
|
package/lib/webpack/utils.js
CHANGED
|
@@ -8,15 +8,15 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.getMinimizer = exports.getHttpsConfig = exports.compile = exports.applyConfigurePostCss = exports.applyConfigureWebpack = exports.getCustomizableJSLoader = exports.getBabelOptions = exports.getCustomBabelConfigFilePath = exports.getStyleLoaders = void 0;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
|
-
const mini_css_extract_plugin_1 =
|
|
11
|
+
const mini_css_extract_plugin_1 = tslib_1.__importDefault(require("mini-css-extract-plugin"));
|
|
12
12
|
const webpack_merge_1 = require("webpack-merge");
|
|
13
|
-
const webpack_1 =
|
|
14
|
-
const fs_extra_1 =
|
|
15
|
-
const terser_webpack_plugin_1 =
|
|
16
|
-
const css_minimizer_webpack_plugin_1 =
|
|
17
|
-
const path_1 =
|
|
18
|
-
const crypto_1 =
|
|
19
|
-
const logger_1 =
|
|
13
|
+
const webpack_1 = tslib_1.__importDefault(require("webpack"));
|
|
14
|
+
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
15
|
+
const terser_webpack_plugin_1 = tslib_1.__importDefault(require("terser-webpack-plugin"));
|
|
16
|
+
const css_minimizer_webpack_plugin_1 = tslib_1.__importDefault(require("css-minimizer-webpack-plugin"));
|
|
17
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
18
|
+
const crypto_1 = tslib_1.__importDefault(require("crypto"));
|
|
19
|
+
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
20
20
|
const utils_1 = require("@docusaurus/utils");
|
|
21
21
|
// Utility method to get style loaders
|
|
22
22
|
function getStyleLoaders(isServer, cssOptionsArg = {}) {
|
|
@@ -95,7 +95,7 @@ function getBabelOptions({ isServer, babelOptions, } = {}) {
|
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
97
|
return {
|
|
98
|
-
...(babelOptions
|
|
98
|
+
...(babelOptions ?? { presets: [require.resolve('../babel/preset')] }),
|
|
99
99
|
babelrc: false,
|
|
100
100
|
configFile: false,
|
|
101
101
|
caller: { name: isServer ? 'server' : 'client' },
|
|
@@ -130,9 +130,9 @@ function applyConfigureWebpack(configureWebpack, config, isServer, jsLoader, con
|
|
|
130
130
|
getJSLoader: (0, exports.getCustomizableJSLoader)(jsLoader),
|
|
131
131
|
};
|
|
132
132
|
if (typeof configureWebpack === 'function') {
|
|
133
|
-
const { mergeStrategy, ...res } = configureWebpack(config, isServer, utils, content);
|
|
133
|
+
const { mergeStrategy, ...res } = configureWebpack(config, isServer, utils, content) ?? {};
|
|
134
134
|
if (res && typeof res === 'object') {
|
|
135
|
-
const customizeRules = mergeStrategy
|
|
135
|
+
const customizeRules = mergeStrategy ?? {};
|
|
136
136
|
return (0, webpack_merge_1.mergeWithCustomize)({
|
|
137
137
|
customizeArray: (0, webpack_merge_1.customizeArray)(customizeRules),
|
|
138
138
|
customizeObject: (0, webpack_merge_1.customizeObject)(customizeRules),
|
|
@@ -143,11 +143,9 @@ function applyConfigureWebpack(configureWebpack, config, isServer, jsLoader, con
|
|
|
143
143
|
}
|
|
144
144
|
exports.applyConfigureWebpack = applyConfigureWebpack;
|
|
145
145
|
function applyConfigurePostCss(configurePostCss, config) {
|
|
146
|
-
|
|
147
|
-
// not ideal heuristic but good enough for our use-case?
|
|
146
|
+
// Not ideal heuristic but good enough for our use-case?
|
|
148
147
|
function isPostCssLoader(loader) {
|
|
149
|
-
|
|
150
|
-
return !!((_b = (_a = loader) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.postcssOptions);
|
|
148
|
+
return !!loader?.options?.postcssOptions;
|
|
151
149
|
}
|
|
152
150
|
// Does not handle all edge cases, but good enough for now
|
|
153
151
|
function overridePostCssOptions(entry) {
|
|
@@ -163,7 +161,7 @@ function applyConfigurePostCss(configurePostCss, config) {
|
|
|
163
161
|
.forEach((rule) => overridePostCssOptions(rule));
|
|
164
162
|
}
|
|
165
163
|
}
|
|
166
|
-
|
|
164
|
+
config.module?.rules?.forEach((rule) => overridePostCssOptions(rule));
|
|
167
165
|
return config;
|
|
168
166
|
}
|
|
169
167
|
exports.applyConfigurePostCss = applyConfigurePostCss;
|
|
@@ -171,23 +169,20 @@ function compile(config) {
|
|
|
171
169
|
return new Promise((resolve, reject) => {
|
|
172
170
|
const compiler = (0, webpack_1.default)(config);
|
|
173
171
|
compiler.run((err, stats) => {
|
|
174
|
-
var _a;
|
|
175
172
|
if (err) {
|
|
176
173
|
logger_1.default.error(err.stack || err);
|
|
177
|
-
// @ts-expect-error: see https://webpack.js.org/api/node/#error-handling
|
|
178
174
|
if (err.details) {
|
|
179
|
-
// @ts-expect-error: see https://webpack.js.org/api/node/#error-handling
|
|
180
175
|
logger_1.default.error(err.details);
|
|
181
176
|
}
|
|
182
177
|
reject(err);
|
|
183
178
|
}
|
|
184
|
-
//
|
|
185
|
-
const errorsWarnings = stats
|
|
186
|
-
if (stats
|
|
179
|
+
// Let plugins consume all the stats
|
|
180
|
+
const errorsWarnings = stats?.toJson('errors-warnings');
|
|
181
|
+
if (stats?.hasErrors()) {
|
|
187
182
|
reject(new Error('Failed to compile with errors.'));
|
|
188
183
|
}
|
|
189
|
-
if (errorsWarnings &&
|
|
190
|
-
|
|
184
|
+
if (errorsWarnings && stats?.hasWarnings()) {
|
|
185
|
+
errorsWarnings.warnings?.forEach((warning) => {
|
|
191
186
|
logger_1.default.warn(warning);
|
|
192
187
|
});
|
|
193
188
|
}
|
|
@@ -271,7 +266,7 @@ function getMinimizer(useSimpleCssMinifier = false) {
|
|
|
271
266
|
parallel: getTerserParallel(),
|
|
272
267
|
terserOptions: {
|
|
273
268
|
parse: {
|
|
274
|
-
//
|
|
269
|
+
// We want uglify-js to parse ecma 8 code. However, we don't want it
|
|
275
270
|
// to apply any minification steps that turns valid ecma 5 code
|
|
276
271
|
// into invalid ecma 5 code. This is why the 'compress' and 'output'
|
|
277
272
|
// sections only apply transformations that are ecma 5 safe
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/core",
|
|
3
3
|
"description": "Easy to Maintain Open Source Documentation Websites",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.19",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -24,66 +24,64 @@
|
|
|
24
24
|
"docusaurus": "bin/docusaurus.mjs"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
|
-
"build": "tsc && tsc -p tsconfig.client.json && node copyUntypedFiles.mjs",
|
|
28
|
-
"watch": "node copyUntypedFiles.mjs && concurrently -n \"server,client\" --kill-others \"tsc --watch\" \"tsc -p tsconfig.client.json --watch\""
|
|
27
|
+
"build": "tsc -p tsconfig.server.json && tsc -p tsconfig.client.json && node copyUntypedFiles.mjs",
|
|
28
|
+
"watch": "node copyUntypedFiles.mjs && concurrently -n \"server,client\" --kill-others \"tsc -p tsconfig.server.json --watch\" \"tsc -p tsconfig.client.json --watch\""
|
|
29
29
|
},
|
|
30
30
|
"bugs": {
|
|
31
31
|
"url": "https://github.com/facebook/docusaurus/issues"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@babel/core": "^7.17.
|
|
35
|
-
"@babel/generator": "^7.17.
|
|
34
|
+
"@babel/core": "^7.17.10",
|
|
35
|
+
"@babel/generator": "^7.17.10",
|
|
36
36
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
37
|
-
"@babel/plugin-transform-runtime": "^7.17.
|
|
38
|
-
"@babel/preset-env": "^7.
|
|
37
|
+
"@babel/plugin-transform-runtime": "^7.17.10",
|
|
38
|
+
"@babel/preset-env": "^7.17.10",
|
|
39
39
|
"@babel/preset-react": "^7.16.7",
|
|
40
40
|
"@babel/preset-typescript": "^7.16.7",
|
|
41
|
-
"@babel/runtime": "^7.17.
|
|
42
|
-
"@babel/runtime-corejs3": "^7.17.
|
|
43
|
-
"@babel/traverse": "^7.17.
|
|
44
|
-
"@docusaurus/cssnano-preset": "2.0.0-beta.
|
|
45
|
-
"@docusaurus/logger": "2.0.0-beta.
|
|
46
|
-
"@docusaurus/mdx-loader": "2.0.0-beta.
|
|
41
|
+
"@babel/runtime": "^7.17.9",
|
|
42
|
+
"@babel/runtime-corejs3": "^7.17.9",
|
|
43
|
+
"@babel/traverse": "^7.17.10",
|
|
44
|
+
"@docusaurus/cssnano-preset": "2.0.0-beta.19",
|
|
45
|
+
"@docusaurus/logger": "2.0.0-beta.19",
|
|
46
|
+
"@docusaurus/mdx-loader": "2.0.0-beta.19",
|
|
47
47
|
"@docusaurus/react-loadable": "5.5.2",
|
|
48
|
-
"@docusaurus/utils": "2.0.0-beta.
|
|
49
|
-
"@docusaurus/utils-common": "2.0.0-beta.
|
|
50
|
-
"@docusaurus/utils-validation": "2.0.0-beta.
|
|
51
|
-
"@slorber/static-site-generator-webpack-plugin": "^4.0.
|
|
48
|
+
"@docusaurus/utils": "2.0.0-beta.19",
|
|
49
|
+
"@docusaurus/utils-common": "2.0.0-beta.19",
|
|
50
|
+
"@docusaurus/utils-validation": "2.0.0-beta.19",
|
|
51
|
+
"@slorber/static-site-generator-webpack-plugin": "^4.0.4",
|
|
52
52
|
"@svgr/webpack": "^6.2.1",
|
|
53
|
-
"autoprefixer": "^10.4.
|
|
54
|
-
"babel-loader": "^8.2.
|
|
53
|
+
"autoprefixer": "^10.4.5",
|
|
54
|
+
"babel-loader": "^8.2.5",
|
|
55
55
|
"babel-plugin-dynamic-import-node": "2.3.0",
|
|
56
56
|
"boxen": "^6.2.1",
|
|
57
57
|
"chokidar": "^3.5.3",
|
|
58
|
-
"clean-css": "^5.
|
|
59
|
-
"cli-table3": "^0.6.
|
|
58
|
+
"clean-css": "^5.3.0",
|
|
59
|
+
"cli-table3": "^0.6.2",
|
|
60
60
|
"combine-promises": "^1.1.0",
|
|
61
61
|
"commander": "^5.1.0",
|
|
62
62
|
"copy-webpack-plugin": "^10.2.4",
|
|
63
|
-
"core-js": "^3.
|
|
64
|
-
"css-loader": "^6.
|
|
63
|
+
"core-js": "^3.22.3",
|
|
64
|
+
"css-loader": "^6.7.1",
|
|
65
65
|
"css-minimizer-webpack-plugin": "^3.4.1",
|
|
66
|
-
"cssnano": "^5.
|
|
66
|
+
"cssnano": "^5.1.7",
|
|
67
67
|
"del": "^6.0.0",
|
|
68
68
|
"detect-port": "^1.3.0",
|
|
69
69
|
"escape-html": "^1.0.3",
|
|
70
70
|
"eta": "^1.12.3",
|
|
71
71
|
"file-loader": "^6.2.0",
|
|
72
|
-
"fs-extra": "^10.0
|
|
72
|
+
"fs-extra": "^10.1.0",
|
|
73
73
|
"html-minifier-terser": "^6.1.0",
|
|
74
|
-
"html-tags": "^3.
|
|
74
|
+
"html-tags": "^3.2.0",
|
|
75
75
|
"html-webpack-plugin": "^5.5.0",
|
|
76
76
|
"import-fresh": "^3.3.0",
|
|
77
|
-
"is-root": "^2.1.0",
|
|
78
77
|
"leven": "^3.1.0",
|
|
79
78
|
"lodash": "^4.17.21",
|
|
80
|
-
"mini-css-extract-plugin": "^2.
|
|
81
|
-
"
|
|
82
|
-
"postcss": "^8.4.6",
|
|
79
|
+
"mini-css-extract-plugin": "^2.6.0",
|
|
80
|
+
"postcss": "^8.4.13",
|
|
83
81
|
"postcss-loader": "^6.2.1",
|
|
84
82
|
"prompts": "^2.4.2",
|
|
85
|
-
"react-dev-utils": "^12.0.
|
|
86
|
-
"react-helmet-async": "^1.
|
|
83
|
+
"react-dev-utils": "^12.0.1",
|
|
84
|
+
"react-helmet-async": "^1.3.0",
|
|
87
85
|
"react-loadable": "npm:@docusaurus/react-loadable@5.5.2",
|
|
88
86
|
"react-loadable-ssr-addon-v5-slorber": "^1.0.1",
|
|
89
87
|
"react-router": "^5.2.0",
|
|
@@ -91,26 +89,25 @@
|
|
|
91
89
|
"react-router-dom": "^5.2.0",
|
|
92
90
|
"remark-admonitions": "^1.2.1",
|
|
93
91
|
"rtl-detect": "^1.0.4",
|
|
94
|
-
"semver": "^7.3.
|
|
92
|
+
"semver": "^7.3.7",
|
|
95
93
|
"serve-handler": "^6.1.3",
|
|
96
94
|
"shelljs": "^0.8.5",
|
|
97
95
|
"terser-webpack-plugin": "^5.3.1",
|
|
98
|
-
"tslib": "^2.
|
|
96
|
+
"tslib": "^2.4.0",
|
|
99
97
|
"update-notifier": "^5.1.0",
|
|
100
98
|
"url-loader": "^4.1.1",
|
|
101
99
|
"wait-on": "^6.0.1",
|
|
102
|
-
"webpack": "^5.
|
|
100
|
+
"webpack": "^5.72.0",
|
|
103
101
|
"webpack-bundle-analyzer": "^4.5.0",
|
|
104
|
-
"webpack-dev-server": "^4.
|
|
102
|
+
"webpack-dev-server": "^4.8.1",
|
|
105
103
|
"webpack-merge": "^5.8.0",
|
|
106
104
|
"webpackbar": "^5.0.2"
|
|
107
105
|
},
|
|
108
106
|
"devDependencies": {
|
|
109
|
-
"@docusaurus/module-type-aliases": "2.0.0-beta.
|
|
110
|
-
"@docusaurus/types": "2.0.0-beta.
|
|
107
|
+
"@docusaurus/module-type-aliases": "2.0.0-beta.19",
|
|
108
|
+
"@docusaurus/types": "2.0.0-beta.19",
|
|
111
109
|
"@types/detect-port": "^1.3.2",
|
|
112
|
-
"@types/
|
|
113
|
-
"@types/react-dom": "^17.0.11",
|
|
110
|
+
"@types/react-dom": "^18.0.3",
|
|
114
111
|
"@types/react-router-config": "^5.0.6",
|
|
115
112
|
"@types/rtl-detect": "^1.0.0",
|
|
116
113
|
"@types/serve-handler": "^6.1.1",
|
|
@@ -128,5 +125,5 @@
|
|
|
128
125
|
"engines": {
|
|
129
126
|
"node": ">=14"
|
|
130
127
|
},
|
|
131
|
-
"gitHead": "
|
|
128
|
+
"gitHead": "a71e60a49cce93c1006ef10c41ac03187f057102"
|
|
132
129
|
}
|
package/lib/choosePort.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Detects if program is running on port and prompts user
|
|
9
|
-
* to choose another if port is already being used
|
|
10
|
-
*/
|
|
11
|
-
export default function choosePort(host: string, defaultPort: number): Promise<number | null>;
|
|
@@ -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 type { ClientModule } from '@docusaurus/types';
|
|
8
|
-
declare const clientLifecyclesDispatchers: Required<ClientModule>;
|
|
9
|
-
export default clientLifecyclesDispatchers;
|
|
@@ -1,23 +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 clientModules from '@generated/client-modules';
|
|
8
|
-
function dispatchLifecycleAction(lifecycleAction, args) {
|
|
9
|
-
clientModules.forEach((clientModule) => {
|
|
10
|
-
var _a, _b;
|
|
11
|
-
const lifecycleFunction = ((_b = (_a = clientModule === null || clientModule === void 0 ? void 0 : clientModule.default) === null || _a === void 0 ? void 0 : _a[lifecycleAction]) !== null && _b !== void 0 ? _b : clientModule[lifecycleAction]);
|
|
12
|
-
lifecycleFunction === null || lifecycleFunction === void 0 ? void 0 : lifecycleFunction(...args);
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
const clientLifecyclesDispatchers = {
|
|
16
|
-
onRouteUpdate(...args) {
|
|
17
|
-
dispatchLifecycleAction('onRouteUpdate', args);
|
|
18
|
-
},
|
|
19
|
-
onRouteUpdateDelayed(...args) {
|
|
20
|
-
dispatchLifecycleAction('onRouteUpdateDelayed', args);
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
export default clientLifecyclesDispatchers;
|
package/lib/client/nprogress.css
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Styles for NProgress
|
|
10
|
-
* Copied over to remove unused styles for the spinner.
|
|
11
|
-
* https://github.com/rstacruz/nprogress/blob/master/nprogress.css
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
#nprogress {
|
|
15
|
-
pointer-events: none;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
#nprogress .bar {
|
|
19
|
-
background: #29d;
|
|
20
|
-
position: fixed;
|
|
21
|
-
z-index: 1031;
|
|
22
|
-
top: 0;
|
|
23
|
-
left: 0;
|
|
24
|
-
width: 100%;
|
|
25
|
-
height: 2px;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
#nprogress .peg {
|
|
29
|
-
position: absolute;
|
|
30
|
-
right: 0;
|
|
31
|
-
width: 100px;
|
|
32
|
-
height: 100%;
|
|
33
|
-
box-shadow: 0 0 10px #29d, 0 0 5px #29d;
|
|
34
|
-
opacity: 1;
|
|
35
|
-
transform: rotate(3deg) translate(0, -4px);
|
|
36
|
-
}
|
|
@@ -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 type { HostPortCLIOptions } from '@docusaurus/types';
|
|
8
|
-
export declare function getCLIOptionHost(hostOption: HostPortCLIOptions['host']): string;
|
|
9
|
-
export declare function getCLIOptionPort(portOption: HostPortCLIOptions['port'], host: string): Promise<number | null>;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the MIT license found in the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.getCLIOptionPort = exports.getCLIOptionHost = void 0;
|
|
10
|
-
const tslib_1 = require("tslib");
|
|
11
|
-
const choosePort_1 = (0, tslib_1.__importDefault)(require("../choosePort"));
|
|
12
|
-
const utils_1 = require("@docusaurus/utils");
|
|
13
|
-
function getCLIOptionHost(hostOption) {
|
|
14
|
-
return hostOption || 'localhost';
|
|
15
|
-
}
|
|
16
|
-
exports.getCLIOptionHost = getCLIOptionHost;
|
|
17
|
-
async function getCLIOptionPort(portOption, host) {
|
|
18
|
-
const basePort = portOption ? parseInt(portOption, 10) : utils_1.DEFAULT_PORT;
|
|
19
|
-
return (0, choosePort_1.default)(host, basePort);
|
|
20
|
-
}
|
|
21
|
-
exports.getCLIOptionPort = getCLIOptionPort;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the MIT license found in the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
function loadClientModules(plugins) {
|
|
10
|
-
return plugins.flatMap((plugin) => { var _a, _b; return (_b = (_a = plugin.getClientModules) === null || _a === void 0 ? void 0 : _a.call(plugin)) !== null && _b !== void 0 ? _b : []; });
|
|
11
|
-
}
|
|
12
|
-
exports.default = loadClientModules;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
import type { ReportingSeverity, RouteConfig } from '@docusaurus/types';
|
|
8
|
-
export declare function getAllDuplicateRoutes(pluginsRouteConfigs: RouteConfig[]): string[];
|
|
9
|
-
export declare function getDuplicateRoutesMessage(allDuplicateRoutes: string[]): string;
|
|
10
|
-
export declare function handleDuplicateRoutes(pluginsRouteConfigs: RouteConfig[], onDuplicateRoutes: ReportingSeverity): void;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the MIT license found in the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.handleDuplicateRoutes = exports.getDuplicateRoutesMessage = exports.getAllDuplicateRoutes = void 0;
|
|
10
|
-
const utils_1 = require("@docusaurus/utils");
|
|
11
|
-
const utils_2 = require("./utils");
|
|
12
|
-
function getAllDuplicateRoutes(pluginsRouteConfigs) {
|
|
13
|
-
const allRoutes = (0, utils_2.getAllFinalRoutes)(pluginsRouteConfigs).map((routeConfig) => routeConfig.path);
|
|
14
|
-
const seenRoutes = {};
|
|
15
|
-
return allRoutes.filter((route) => {
|
|
16
|
-
if (Object.prototype.hasOwnProperty.call(seenRoutes, route)) {
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
seenRoutes[route] = true;
|
|
20
|
-
return false;
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
exports.getAllDuplicateRoutes = getAllDuplicateRoutes;
|
|
24
|
-
function getDuplicateRoutesMessage(allDuplicateRoutes) {
|
|
25
|
-
const message = allDuplicateRoutes
|
|
26
|
-
.map((duplicateRoute) => `Attempting to create page at ${duplicateRoute}, but a page already exists at this route`)
|
|
27
|
-
.join('\n');
|
|
28
|
-
return message;
|
|
29
|
-
}
|
|
30
|
-
exports.getDuplicateRoutesMessage = getDuplicateRoutesMessage;
|
|
31
|
-
function handleDuplicateRoutes(pluginsRouteConfigs, onDuplicateRoutes) {
|
|
32
|
-
if (onDuplicateRoutes === 'ignore') {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
const duplicatePaths = getAllDuplicateRoutes(pluginsRouteConfigs);
|
|
36
|
-
const message = getDuplicateRoutesMessage(duplicatePaths);
|
|
37
|
-
if (message) {
|
|
38
|
-
const finalMessage = `Duplicate routes found!\n${message}\nThis could lead to non-deterministic routing behavior`;
|
|
39
|
-
(0, utils_1.reportMessage)(finalMessage, onDuplicateRoutes);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
exports.handleDuplicateRoutes = handleDuplicateRoutes;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the MIT license found in the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
const tslib_1 = require("tslib");
|
|
10
|
-
const html_tags_1 = (0, tslib_1.__importDefault)(require("html-tags"));
|
|
11
|
-
const void_1 = (0, tslib_1.__importDefault)(require("html-tags/void"));
|
|
12
|
-
const escape_html_1 = (0, tslib_1.__importDefault)(require("escape-html"));
|
|
13
|
-
function assertIsHtmlTagObject(val) {
|
|
14
|
-
if (typeof val !== 'object' || !val) {
|
|
15
|
-
throw new Error(`"${val}" is not a valid HTML tag object.`);
|
|
16
|
-
}
|
|
17
|
-
if (typeof val.tagName !== 'string') {
|
|
18
|
-
throw new Error(`${JSON.stringify(val)} is not a valid HTML tag object. "tagName" must be defined as a string.`);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
function htmlTagObjectToString(tagDefinition) {
|
|
22
|
-
assertIsHtmlTagObject(tagDefinition);
|
|
23
|
-
if (html_tags_1.default.indexOf(tagDefinition.tagName) === -1) {
|
|
24
|
-
throw new Error(`Error loading ${JSON.stringify(tagDefinition)}, "${tagDefinition.tagName}" is not a valid HTML tags.`);
|
|
25
|
-
}
|
|
26
|
-
const isVoidTag = void_1.default.indexOf(tagDefinition.tagName) !== -1;
|
|
27
|
-
const tagAttributes = tagDefinition.attributes || {};
|
|
28
|
-
const attributes = Object.keys(tagAttributes)
|
|
29
|
-
.filter((attributeName) => tagAttributes[attributeName] !== false)
|
|
30
|
-
.map((attributeName) => {
|
|
31
|
-
if (tagAttributes[attributeName] === true) {
|
|
32
|
-
return attributeName;
|
|
33
|
-
}
|
|
34
|
-
return `${attributeName}="${(0, escape_html_1.default)(tagAttributes[attributeName])}"`;
|
|
35
|
-
});
|
|
36
|
-
return `<${[tagDefinition.tagName].concat(attributes).join(' ')}>${(!isVoidTag && tagDefinition.innerHTML) || ''}${isVoidTag ? '' : `</${tagDefinition.tagName}>`}`;
|
|
37
|
-
}
|
|
38
|
-
exports.default = htmlTagObjectToString;
|
|
@@ -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 type { InjectedHtmlTags, HtmlTags, LoadedPlugin } from '@docusaurus/types';
|
|
8
|
-
export declare function createHtmlTagsString(tags: HtmlTags): string;
|
|
9
|
-
export declare function loadHtmlTags(plugins: LoadedPlugin[]): InjectedHtmlTags;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the MIT license found in the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.loadHtmlTags = exports.createHtmlTagsString = void 0;
|
|
10
|
-
const tslib_1 = require("tslib");
|
|
11
|
-
const htmlTags_1 = (0, tslib_1.__importDefault)(require("./htmlTags"));
|
|
12
|
-
function toString(val) {
|
|
13
|
-
return typeof val === 'string' ? val : (0, htmlTags_1.default)(val);
|
|
14
|
-
}
|
|
15
|
-
function createHtmlTagsString(tags) {
|
|
16
|
-
return Array.isArray(tags) ? tags.map(toString).join('\n') : toString(tags);
|
|
17
|
-
}
|
|
18
|
-
exports.createHtmlTagsString = createHtmlTagsString;
|
|
19
|
-
function loadHtmlTags(plugins) {
|
|
20
|
-
const htmlTags = plugins.reduce((acc, plugin) => {
|
|
21
|
-
if (!plugin.injectHtmlTags) {
|
|
22
|
-
return acc;
|
|
23
|
-
}
|
|
24
|
-
const { headTags, preBodyTags, postBodyTags } = plugin.injectHtmlTags({ content: plugin.content }) || {};
|
|
25
|
-
return {
|
|
26
|
-
headTags: headTags
|
|
27
|
-
? `${acc.headTags}\n${createHtmlTagsString(headTags)}`
|
|
28
|
-
: acc.headTags,
|
|
29
|
-
preBodyTags: preBodyTags
|
|
30
|
-
? `${acc.preBodyTags}\n${createHtmlTagsString(preBodyTags)}`
|
|
31
|
-
: acc.preBodyTags,
|
|
32
|
-
postBodyTags: postBodyTags
|
|
33
|
-
? `${acc.postBodyTags}\n${createHtmlTagsString(postBodyTags)}`
|
|
34
|
-
: acc.postBodyTags,
|
|
35
|
-
};
|
|
36
|
-
}, { headTags: '', preBodyTags: '', postBodyTags: '' });
|
|
37
|
-
return {
|
|
38
|
-
headTags: htmlTags.headTags.trim(),
|
|
39
|
-
preBodyTags: htmlTags.preBodyTags.trim(),
|
|
40
|
-
postBodyTags: htmlTags.postBodyTags.trim(),
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
exports.loadHtmlTags = loadHtmlTags;
|
package/lib/server/loadSetup.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the MIT license found in the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
const tslib_1 = require("tslib");
|
|
10
|
-
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
11
|
-
const index_1 = require("./index");
|
|
12
|
-
// Helper methods to setup dummy/fake projects.
|
|
13
|
-
async function loadSetup(name) {
|
|
14
|
-
const fixtures = path_1.default.join(__dirname, '__tests__', '__fixtures__');
|
|
15
|
-
const simpleSite = path_1.default.join(fixtures, 'simple-site');
|
|
16
|
-
const customSite = path_1.default.join(fixtures, 'custom-site');
|
|
17
|
-
switch (name) {
|
|
18
|
-
case 'custom':
|
|
19
|
-
return (0, index_1.load)(customSite);
|
|
20
|
-
case 'simple':
|
|
21
|
-
default:
|
|
22
|
-
return (0, index_1.load)(simpleSite);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.default = loadSetup;
|