@docusaurus/core 0.0.0-4524 → 0.0.0-4531

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.
@@ -23,7 +23,7 @@ const canPreload = (routePath) => !isSlowConnection() && !loaded[routePath];
23
23
  // Remove the last part containing the route hash
24
24
  // input: /blog/2018/12/14/Happy-First-Birthday-Slash-fe9
25
25
  // output: /blog/2018/12/14/Happy-First-Birthday-Slash
26
- const removeRouteNameHash = (str) => str.replace(/(-[^-]+)$/, '');
26
+ const removeRouteNameHash = (str) => str.replace(/-[^-]+$/, '');
27
27
  const getChunkNamesToLoad = (path) => Object.entries(routesChunkNames)
28
28
  .filter(([routeNameWithHash]) => removeRouteNameHash(routeNameWithHash) === path)
29
29
  .flatMap(([, routeChunks]) =>
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  export function hasProtocol(url) {
8
- return /^(\w*:|\/\/)/.test(url) === true;
8
+ return /^(?:\w*:|\/\/)/.test(url) === true;
9
9
  }
10
10
  export default function isInternalUrl(url) {
11
11
  return typeof url !== 'undefined' && !hasProtocol(url);
@@ -37,7 +37,7 @@ export default async function render(locals) {
37
37
  catch (e) {
38
38
  logger.error `Docusaurus Node/SSR could not render static page with path path=${locals.path} because of following error:
39
39
  ${e.stack}`;
40
- const isNotDefinedErrorRegex = /(window|document|localStorage|navigator|alert|location|buffer|self) is not defined/i;
40
+ const isNotDefinedErrorRegex = /(?:window|document|localStorage|navigator|alert|location|buffer|self) is not defined/i;
41
41
  if (isNotDefinedErrorRegex.test(e.message)) {
42
42
  logger.info `It looks like you are using code that should run on the client-side only.
43
43
  To get around it, try using code=${'<BrowserOnly>'} (path=${'https://docusaurus.io/docs/docusaurus-core/#browseronly'}) or code=${'ExecutionEnvironment'} (path=${'https://docusaurus.io/docs/docusaurus-core/#executionenvironment'}).
@@ -56,7 +56,7 @@ function hasSSHProtocol(sourceRepoUrl) {
56
56
  }
57
57
  catch {
58
58
  // Fails when there isn't a protocol
59
- return /^([\w-]+@)?[\w.-]+:[\w./_-]+(\.git)?/.test(sourceRepoUrl); // git@github.com:facebook/docusaurus.git
59
+ return /^(?:[\w-]+@)?[\w.-]+:[\w./_-]+/.test(sourceRepoUrl); // git@github.com:facebook/docusaurus.git
60
60
  }
61
61
  }
62
62
  exports.hasSSHProtocol = hasSSHProtocol;
@@ -11,7 +11,7 @@ const server_1 = require("../server");
11
11
  const init_1 = (0, tslib_1.__importDefault)(require("../server/plugins/init"));
12
12
  async function externalCommand(cli, siteDir) {
13
13
  const context = await (0, server_1.loadContext)(siteDir);
14
- const pluginConfigs = (0, server_1.loadPluginConfigs)(context);
14
+ const pluginConfigs = await (0, server_1.loadPluginConfigs)(context);
15
15
  const plugins = await (0, init_1.default)({ pluginConfigs, context });
16
16
  // Plugin Lifecycle - extendCli.
17
17
  plugins.forEach((plugin) => {
@@ -45,8 +45,8 @@ function getPluginNames(plugins) {
45
45
  }
46
46
  exports.getPluginNames = getPluginNames;
47
47
  const formatComponentName = (componentName) => componentName
48
- .replace(/(\/|\\)index\.(js|tsx|ts|jsx)/, '')
49
- .replace(/\.(js|tsx|ts|jsx)/, '');
48
+ .replace(/[\\/]index\.(?:jsx?|tsx?)/, '')
49
+ .replace(/\.(?:jsx?|tsx?)/, '');
50
50
  function readComponent(themePath) {
51
51
  function walk(dir) {
52
52
  let results = [];
@@ -109,7 +109,7 @@ function colorCode(themePath, plugin) {
109
109
  async function swizzle(siteDir, themeName, componentName, typescript, danger) {
110
110
  var _a, _b, _c, _d, _e;
111
111
  const context = await (0, server_1.loadContext)(siteDir);
112
- const pluginConfigs = (0, server_1.loadPluginConfigs)(context);
112
+ const pluginConfigs = await (0, server_1.loadPluginConfigs)(context);
113
113
  const pluginNames = getPluginNames(pluginConfigs);
114
114
  const plugins = await (0, init_1.default)({
115
115
  pluginConfigs,
@@ -15,7 +15,7 @@ const init_1 = (0, tslib_1.__importDefault)(require("../server/plugins/init"));
15
15
  const utils_1 = require("@docusaurus/utils");
16
16
  const utils_2 = require("../server/utils");
17
17
  function unwrapMarkdownLinks(line) {
18
- return line.replace(/\[([^\]]+)\]\([^)]+\)/g, (match, p1) => p1);
18
+ return line.replace(/\[(?<alt>[^\]]+)\]\([^)]+\)/g, (match, p1) => p1);
19
19
  }
20
20
  function addHeadingId(line, slugger, maintainCase) {
21
21
  let headingLevel = 0;
@@ -85,7 +85,7 @@ async function transformMarkdownFile(filepath, options) {
85
85
  */
86
86
  async function getPathsToWatch(siteDir) {
87
87
  const context = await (0, server_1.loadContext)(siteDir);
88
- const pluginConfigs = (0, server_1.loadPluginConfigs)(context);
88
+ const pluginConfigs = await (0, server_1.loadPluginConfigs)(context);
89
89
  const plugins = await (0, init_1.default)({
90
90
  pluginConfigs,
91
91
  context,
@@ -53,7 +53,7 @@ async function writeTranslations(siteDir, options) {
53
53
  customConfigFilePath: options.config,
54
54
  locale: options.locale,
55
55
  });
56
- const pluginConfigs = (0, server_1.loadPluginConfigs)(context);
56
+ const pluginConfigs = await (0, server_1.loadPluginConfigs)(context);
57
57
  const plugins = await (0, init_1.default)({
58
58
  pluginConfigs,
59
59
  context,
@@ -19,5 +19,5 @@ export declare function loadSiteConfig({ siteDir, customConfigFilePath, }: {
19
19
  siteConfigPath: string;
20
20
  }>;
21
21
  export declare function loadContext(siteDir: string, options?: LoadContextOptions): Promise<LoadContext>;
22
- export declare function loadPluginConfigs(context: LoadContext): PluginConfig[];
22
+ export declare function loadPluginConfigs(context: LoadContext): Promise<PluginConfig[]>;
23
23
  export declare function load(siteDir: string, options?: LoadContextOptions): Promise<Props>;
@@ -82,8 +82,8 @@ async function loadContext(siteDir, options = {}) {
82
82
  };
83
83
  }
84
84
  exports.loadContext = loadContext;
85
- function loadPluginConfigs(context) {
86
- let { plugins: presetPlugins, themes: presetThemes } = (0, presets_1.default)(context);
85
+ async function loadPluginConfigs(context) {
86
+ let { plugins: presetPlugins, themes: presetThemes } = await (0, presets_1.default)(context);
87
87
  const { siteConfig, siteConfigPath } = context;
88
88
  const require = (0, module_1.createRequire)(siteConfigPath);
89
89
  function normalizeShorthand(pluginConfig, pluginType) {
@@ -178,7 +178,7 @@ function createMDXFallbackPlugin({ siteDir, siteConfig, }) {
178
178
  module: {
179
179
  rules: [
180
180
  {
181
- test: /(\.mdx?)$/,
181
+ test: /\.mdx?$/i,
182
182
  exclude: getMDXFallbackExcludedPaths(),
183
183
  use: [
184
184
  getJSLoader({ isServer }),
@@ -205,7 +205,7 @@ async function load(siteDir, options = {}) {
205
205
  const context = await loadContext(siteDir, options);
206
206
  const { generatedFilesDir, siteConfig, siteConfigPath, outDir, baseUrl, i18n, ssrTemplate, codeTranslations, } = context;
207
207
  // Plugins.
208
- const pluginConfigs = loadPluginConfigs(context);
208
+ const pluginConfigs = await loadPluginConfigs(context);
209
209
  const { plugins, pluginsRouteConfigs, globalData, themeConfigTranslated } = await (0, plugins_1.loadPlugins)({ pluginConfigs, context });
210
210
  // Side-effect to replace the untranslated themeConfig by the translated one
211
211
  context.siteConfig.themeConfig = themeConfigTranslated;
@@ -13,7 +13,7 @@ function getNamePatterns(moduleName, moduleType) {
13
13
  if (!moduleName.includes('/')) {
14
14
  return [`${moduleName}/docusaurus-${moduleType}`];
15
15
  }
16
- const [scope, packageName] = moduleName.split(/\/(.*)/);
16
+ const [scope, packageName] = moduleName.split(/\/(?<rest>.*)/);
17
17
  return [
18
18
  `${scope}/${packageName}`,
19
19
  `${scope}/docusaurus-${moduleType}-${packageName}`,
@@ -13,7 +13,7 @@ const utils_1 = require("@docusaurus/utils");
13
13
  const versions_1 = require("../versions");
14
14
  const pluginIds_1 = require("./pluginIds");
15
15
  const utils_validation_1 = require("@docusaurus/utils-validation");
16
- function normalizePluginConfig(pluginConfig, pluginRequire) {
16
+ async function normalizePluginConfig(pluginConfig, pluginRequire) {
17
17
  var _a, _b, _c, _d;
18
18
  // plugins: ['./plugin']
19
19
  if (typeof pluginConfig === 'string') {
@@ -121,7 +121,7 @@ async function initPlugins({ pluginConfigs, context, }) {
121
121
  };
122
122
  }
123
123
  async function initializePlugin(pluginConfig) {
124
- const normalizedPluginConfig = normalizePluginConfig(pluginConfig, pluginRequire);
124
+ const normalizedPluginConfig = await normalizePluginConfig(pluginConfig, pluginRequire);
125
125
  const pluginVersion = doGetPluginVersion(normalizedPluginConfig);
126
126
  const pluginOptions = doValidatePluginOptions(normalizedPluginConfig);
127
127
  // Side-effect: merge the normalized theme config in the original one
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import type { LoadContext, PluginConfig } from '@docusaurus/types';
8
- export default function loadPresets(context: LoadContext): {
8
+ export default function loadPresets(context: LoadContext): Promise<{
9
9
  plugins: PluginConfig[];
10
10
  themes: PluginConfig[];
11
- };
11
+ }>;
@@ -10,7 +10,7 @@ const tslib_1 = require("tslib");
10
10
  const module_1 = require("module");
11
11
  const import_fresh_1 = (0, tslib_1.__importDefault)(require("import-fresh"));
12
12
  const moduleShorthand_1 = require("../moduleShorthand");
13
- function loadPresets(context) {
13
+ async function loadPresets(context) {
14
14
  // We need to resolve presets from the perspective of the siteDir, since the
15
15
  // siteDir's package.json declares the dependency on these presets.
16
16
  const presetRequire = (0, module_1.createRequire)(context.siteConfigPath);
@@ -11,7 +11,7 @@ const lodash_1 = require("lodash");
11
11
  const querystring_1 = require("querystring");
12
12
  function indent(str) {
13
13
  const spaces = ' ';
14
- return `${spaces}${str.replace(/(\n)/g, `\n${spaces}`)}`;
14
+ return `${spaces}${str.replace(/\n/g, `\n${spaces}`)}`;
15
15
  }
16
16
  const createRouteCodeString = ({ routePath, routeHash, exact, subroutesCodeStrings, props, }) => {
17
17
  const parts = [
@@ -14,8 +14,8 @@ const path_1 = (0, tslib_1.__importDefault)(require("path"));
14
14
  const utils_1 = require("./utils");
15
15
  const themes_1 = require("../server/themes");
16
16
  const utils_2 = require("@docusaurus/utils");
17
- const CSS_REGEX = /\.css$/;
18
- const CSS_MODULE_REGEX = /\.module\.css$/;
17
+ const CSS_REGEX = /\.css$/i;
18
+ const CSS_MODULE_REGEX = /\.module\.css$/i;
19
19
  exports.clientDir = path_1.default.join(__dirname, '..', 'client');
20
20
  const LibrariesToTranspile = [
21
21
  'copy-text-to-clipboard', // contains optional catch binding, incompatible with recent versions of Edge
@@ -28,7 +28,7 @@ function excludeJS(modulePath) {
28
28
  }
29
29
  // Don't transpile node_modules except any docusaurus npm package
30
30
  return (/node_modules/.test(modulePath) &&
31
- !/(docusaurus)((?!node_modules).)*\.jsx?$/.test(modulePath) &&
31
+ !/docusaurus(?:(?!node_modules).)*\.jsx?$/.test(modulePath) &&
32
32
  !LibrariesToTranspileRegex.test(modulePath));
33
33
  }
34
34
  exports.excludeJS = excludeJS;
@@ -182,7 +182,7 @@ function createBaseConfig(props, isServer, minify = true) {
182
182
  fileLoaderUtils.rules.svg(),
183
183
  fileLoaderUtils.rules.otherAssets(),
184
184
  {
185
- test: /\.(j|t)sx?$/,
185
+ test: /\.[jt]sx?$/i,
186
186
  exclude: excludeJS,
187
187
  use: [
188
188
  (0, utils_1.getCustomizableJSLoader)((_a = siteConfig.webpack) === null || _a === void 0 ? void 0 : _a.jsLoader)({
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": "0.0.0-4524",
4
+ "version": "0.0.0-4531",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -34,34 +34,34 @@
34
34
  "@babel/core": "^7.16.0",
35
35
  "@babel/generator": "^7.16.0",
36
36
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
37
- "@babel/plugin-transform-runtime": "^7.16.0",
38
- "@babel/preset-env": "^7.16.4",
37
+ "@babel/plugin-transform-runtime": "^7.16.10",
38
+ "@babel/preset-env": "^7.16.11",
39
39
  "@babel/preset-react": "^7.16.0",
40
40
  "@babel/preset-typescript": "^7.16.0",
41
41
  "@babel/runtime": "^7.16.3",
42
42
  "@babel/runtime-corejs3": "^7.16.3",
43
43
  "@babel/traverse": "^7.16.3",
44
- "@docusaurus/cssnano-preset": "0.0.0-4524",
45
- "@docusaurus/logger": "0.0.0-4524",
46
- "@docusaurus/mdx-loader": "0.0.0-4524",
44
+ "@docusaurus/cssnano-preset": "0.0.0-4531",
45
+ "@docusaurus/logger": "0.0.0-4531",
46
+ "@docusaurus/mdx-loader": "0.0.0-4531",
47
47
  "@docusaurus/react-loadable": "5.5.2",
48
- "@docusaurus/utils": "0.0.0-4524",
49
- "@docusaurus/utils-common": "0.0.0-4524",
50
- "@docusaurus/utils-validation": "0.0.0-4524",
48
+ "@docusaurus/utils": "0.0.0-4531",
49
+ "@docusaurus/utils-common": "0.0.0-4531",
50
+ "@docusaurus/utils-validation": "0.0.0-4531",
51
51
  "@slorber/static-site-generator-webpack-plugin": "^4.0.0",
52
52
  "@svgr/webpack": "^6.0.0",
53
53
  "autoprefixer": "^10.3.5",
54
54
  "babel-loader": "^8.2.2",
55
55
  "babel-plugin-dynamic-import-node": "2.3.0",
56
56
  "boxen": "^5.0.1",
57
- "chokidar": "^3.5.2",
58
- "clean-css": "^5.1.5",
57
+ "chokidar": "^3.5.3",
58
+ "clean-css": "^5.2.4",
59
59
  "commander": "^5.1.0",
60
- "copy-webpack-plugin": "^10.2.0",
61
- "core-js": "^3.18.0",
60
+ "copy-webpack-plugin": "^10.2.4",
61
+ "core-js": "^3.21.0",
62
62
  "css-loader": "^6.5.1",
63
- "css-minimizer-webpack-plugin": "^3.3.1",
64
- "cssnano": "^5.0.8",
63
+ "css-minimizer-webpack-plugin": "^3.4.1",
64
+ "cssnano": "^5.0.16",
65
65
  "del": "^6.0.0",
66
66
  "detect-port": "^1.3.0",
67
67
  "escape-html": "^1.0.3",
@@ -75,7 +75,7 @@
75
75
  "is-root": "^2.1.0",
76
76
  "leven": "^3.1.0",
77
77
  "lodash": "^4.17.20",
78
- "mini-css-extract-plugin": "^1.6.0",
78
+ "mini-css-extract-plugin": "^2.5.3",
79
79
  "nprogress": "^0.2.0",
80
80
  "postcss": "^8.3.7",
81
81
  "postcss-loader": "^6.1.1",
@@ -92,24 +92,23 @@
92
92
  "semver": "^7.3.4",
93
93
  "serve-handler": "^6.1.3",
94
94
  "shelljs": "^0.8.4",
95
- "strip-ansi": "^6.0.0",
96
95
  "terser-webpack-plugin": "^5.2.4",
97
96
  "tslib": "^2.3.1",
98
97
  "update-notifier": "^5.1.0",
99
98
  "url-loader": "^4.1.1",
100
99
  "wait-on": "^6.0.0",
101
- "webpack": "^5.61.0",
100
+ "webpack": "^5.68.0",
102
101
  "webpack-bundle-analyzer": "^4.4.2",
103
102
  "webpack-dev-server": "^4.7.1",
104
103
  "webpack-merge": "^5.8.0",
105
104
  "webpackbar": "^5.0.2"
106
105
  },
107
106
  "devDependencies": {
108
- "@docusaurus/module-type-aliases": "0.0.0-4524",
109
- "@docusaurus/types": "0.0.0-4524",
110
- "@types/copy-webpack-plugin": "^8.0.1",
107
+ "@docusaurus/module-type-aliases": "0.0.0-4531",
108
+ "@docusaurus/types": "0.0.0-4531",
109
+ "@types/copy-webpack-plugin": "^10.1.0",
111
110
  "@types/detect-port": "^1.3.0",
112
- "@types/mini-css-extract-plugin": "^1.4.3",
111
+ "@types/mini-css-extract-plugin": "^2.5.1",
113
112
  "@types/nprogress": "^0.2.0",
114
113
  "@types/react-dom": "^17.0.9",
115
114
  "@types/react-helmet": "^6.0.0",
@@ -129,5 +128,5 @@
129
128
  "engines": {
130
129
  "node": ">=14"
131
130
  },
132
- "gitHead": "41a6bff3a67446f7d2a2972cbe4d05fec7378a15"
131
+ "gitHead": "fe104fed3e8ef603f81594311564e598c9c55a6c"
133
132
  }