@docusaurus/core 0.0.0-4525 → 0.0.0-4533

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.
@@ -7,6 +7,7 @@
7
7
  import React from 'react';
8
8
  import { hydrate, render } from 'react-dom';
9
9
  import { BrowserRouter } from 'react-router-dom';
10
+ import { HelmetProvider } from 'react-helmet-async';
10
11
  import routes from '@generated/routes';
11
12
  import ExecutionEnvironment from './exports/ExecutionEnvironment';
12
13
  import App from './App';
@@ -22,9 +23,11 @@ if (ExecutionEnvironment.canUseDOM) {
22
23
  // We also preload async component to avoid first-load loading screen.
23
24
  const renderMethod = process.env.NODE_ENV === 'production' ? hydrate : render;
24
25
  preload(routes, window.location.pathname).then(() => {
25
- renderMethod(<BrowserRouter>
26
- <App />
27
- </BrowserRouter>, document.getElementById('__docusaurus'));
26
+ renderMethod(<HelmetProvider>
27
+ <BrowserRouter>
28
+ <App />
29
+ </BrowserRouter>
30
+ </HelmetProvider>, document.getElementById('__docusaurus'));
28
31
  });
29
32
  // Webpack Hot Module Replacement API
30
33
  if (module.hot) {
@@ -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
  import React from 'react';
8
- import { Helmet } from 'react-helmet';
8
+ import { Helmet } from 'react-helmet-async';
9
9
  function Head(props) {
10
10
  return <Helmet {...props}/>;
11
11
  }
@@ -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);
@@ -8,7 +8,7 @@ import * as eta from 'eta';
8
8
  import React from 'react';
9
9
  import { StaticRouter } from 'react-router-dom';
10
10
  import ReactDOMServer from 'react-dom/server';
11
- import { Helmet } from 'react-helmet';
11
+ import { HelmetProvider } from 'react-helmet-async';
12
12
  import { getBundles } from 'react-loadable-ssr-addon-v5-slorber';
13
13
  import Loadable from 'react-loadable';
14
14
  import { minify } from 'html-minifier-terser';
@@ -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'}).
@@ -53,16 +53,19 @@ async function doRender(locals) {
53
53
  await preload(routes, location);
54
54
  const modules = new Set();
55
55
  const context = {};
56
+ const helmetContext = {};
56
57
  const linksCollector = createStatefulLinksCollector();
57
58
  const appHtml = ReactDOMServer.renderToString(<Loadable.Capture report={(moduleName) => modules.add(moduleName)}>
58
- <StaticRouter location={location} context={context}>
59
- <ProvideLinksCollector linksCollector={linksCollector}>
60
- <App />
61
- </ProvideLinksCollector>
62
- </StaticRouter>
59
+ <HelmetProvider context={helmetContext}>
60
+ <StaticRouter location={location} context={context}>
61
+ <ProvideLinksCollector linksCollector={linksCollector}>
62
+ <App />
63
+ </ProvideLinksCollector>
64
+ </StaticRouter>
65
+ </HelmetProvider>
63
66
  </Loadable.Capture>);
64
67
  onLinksCollected(location, linksCollector.getCollectedLinks());
65
- const helmet = Helmet.renderStatic();
68
+ const { helmet } = helmetContext;
66
69
  const htmlAttributes = helmet.htmlAttributes.toString();
67
70
  const bodyAttributes = helmet.bodyAttributes.toString();
68
71
  const metaStrings = [
@@ -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;
@@ -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 = [];
@@ -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;
@@ -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 }),
@@ -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}`,
@@ -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-4525",
4
+ "version": "0.0.0-4533",
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-4525",
45
- "@docusaurus/logger": "0.0.0-4525",
46
- "@docusaurus/mdx-loader": "0.0.0-4525",
44
+ "@docusaurus/cssnano-preset": "0.0.0-4533",
45
+ "@docusaurus/logger": "0.0.0-4533",
46
+ "@docusaurus/mdx-loader": "0.0.0-4533",
47
47
  "@docusaurus/react-loadable": "5.5.2",
48
- "@docusaurus/utils": "0.0.0-4525",
49
- "@docusaurus/utils-common": "0.0.0-4525",
50
- "@docusaurus/utils-validation": "0.0.0-4525",
48
+ "@docusaurus/utils": "0.0.0-4533",
49
+ "@docusaurus/utils-common": "0.0.0-4533",
50
+ "@docusaurus/utils-validation": "0.0.0-4533",
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,13 +75,13 @@
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",
82
82
  "prompts": "^2.4.1",
83
83
  "react-dev-utils": "^12.0.0",
84
- "react-helmet": "^6.1.0",
84
+ "react-helmet-async": "^1.2.2",
85
85
  "react-loadable": "npm:@docusaurus/react-loadable@5.5.2",
86
86
  "react-loadable-ssr-addon-v5-slorber": "^1.0.1",
87
87
  "react-router": "^5.2.0",
@@ -92,27 +92,25 @@
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-4525",
109
- "@docusaurus/types": "0.0.0-4525",
110
- "@types/copy-webpack-plugin": "^8.0.1",
107
+ "@docusaurus/module-type-aliases": "0.0.0-4533",
108
+ "@docusaurus/types": "0.0.0-4533",
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
- "@types/react-helmet": "^6.0.0",
116
114
  "@types/react-router-config": "^5.0.1",
117
115
  "@types/rtl-detect": "^1.0.0",
118
116
  "@types/serve-handler": "^6.1.1",
@@ -129,5 +127,5 @@
129
127
  "engines": {
130
128
  "node": ">=14"
131
129
  },
132
- "gitHead": "c1122ee21d114f85261bed9b8296ab3501454098"
130
+ "gitHead": "5ab127cc566e3d1af8653a162eafbfbd64d0764e"
133
131
  }