@docusaurus/core 0.0.0-4383 → 0.0.0-4393

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.
@@ -6,7 +6,7 @@
6
6
  */
7
7
  /// <reference types="react" />
8
8
  declare function BrowserOnly({ children, fallback, }: {
9
- children?: () => JSX.Element;
9
+ children: () => JSX.Element;
10
10
  fallback?: JSX.Element;
11
11
  }): JSX.Element | null;
12
12
  export default BrowserOnly;
@@ -4,13 +4,18 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import React from 'react';
7
+ import React, { isValidElement } from 'react';
8
8
  import useIsBrowser from '@docusaurus/useIsBrowser';
9
9
  // Similar comp to the one described here:
10
10
  // https://www.joshwcomeau.com/react/the-perils-of-rehydration/#abstractions
11
11
  function BrowserOnly({ children, fallback, }) {
12
12
  const isBrowser = useIsBrowser();
13
- if (isBrowser && children != null) {
13
+ if (isBrowser) {
14
+ if (typeof children !== 'function' &&
15
+ process.env.NODE_ENV === 'development') {
16
+ throw new Error(`Docusaurus error: The children of <BrowserOnly> must be a "render function", e.g. <BrowserOnly>{() => <span>{window.location.href}</span>}</BrowserOnly>.
17
+ Current type: ${isValidElement(children) ? 'React element' : typeof children}`);
18
+ }
14
19
  return React.createElement(React.Fragment, null, children());
15
20
  }
16
21
  return fallback || null;
@@ -19,7 +19,7 @@ function addBaseUrl(siteUrl, baseUrl, url, { forcePrependBaseUrl = false, absolu
19
19
  return url;
20
20
  }
21
21
  if (forcePrependBaseUrl) {
22
- return baseUrl + url;
22
+ return baseUrl + url.replace(/^\//, '');
23
23
  }
24
24
  // We should avoid adding the baseurl twice if it's already there
25
25
  const shouldAddBaseUrl = !url.startsWith(baseUrl);
@@ -27,7 +27,7 @@ function addBaseUrl(siteUrl, baseUrl, url, { forcePrependBaseUrl = false, absolu
27
27
  return absolute ? siteUrl + basePath : basePath;
28
28
  }
29
29
  export function useBaseUrlUtils() {
30
- const { siteConfig: { baseUrl = '/', url: siteUrl } = {} } = useDocusaurusContext();
30
+ const { siteConfig: { baseUrl, url: siteUrl }, } = useDocusaurusContext();
31
31
  return {
32
32
  withBaseUrl: (url, options) => addBaseUrl(siteUrl, baseUrl, url, options),
33
33
  };
@@ -9,7 +9,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.handleBrokenLinks = exports.filterExistingFileLinks = exports.getBrokenLinksErrorMessage = exports.getAllBrokenLinks = void 0;
10
10
  const tslib_1 = require("tslib");
11
11
  const react_router_config_1 = require("react-router-config");
12
- const resolve_pathname_1 = (0, tslib_1.__importDefault)(require("resolve-pathname"));
13
12
  const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
14
13
  const lodash_1 = require("lodash");
15
14
  const utils_1 = require("@docusaurus/utils");
@@ -29,7 +28,7 @@ function getPageBrokenLinks({ pagePath, pageLinks, routes, }) {
29
28
  // we must resolve the links before using matchRoutes
30
29
  // resolvePathname is used internally by ReactRouter
31
30
  function resolveLink(link) {
32
- const resolvedLink = (0, resolve_pathname_1.default)(onlyPathname(link), pagePath);
31
+ const resolvedLink = (0, utils_1.resolvePathname)(onlyPathname(link), pagePath);
33
32
  return { link, resolvedLink };
34
33
  }
35
34
  function isBrokenLink(link) {
@@ -13,14 +13,8 @@ const utils_1 = require("@docusaurus/utils");
13
13
  const rtl_detect_1 = require("rtl-detect");
14
14
  const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
15
15
  function getDefaultLocaleLabel(locale) {
16
- // Intl.DisplayNames is ES2021 - Node14+
17
- // https://v8.dev/features/intl-displaynames
18
- if (typeof Intl.DisplayNames !== 'undefined') {
19
- const languageName = new Intl.DisplayNames(locale, { type: 'language' }).of(locale);
20
- return (languageName.charAt(0).toLocaleUpperCase(locale) +
21
- languageName.substring(1));
22
- }
23
- return locale;
16
+ const languageName = new Intl.DisplayNames(locale, { type: 'language' }).of(locale);
17
+ return (languageName.charAt(0).toLocaleUpperCase(locale) + languageName.substring(1));
24
18
  }
25
19
  function getDefaultLocaleConfig(locale) {
26
20
  return {
@@ -6,18 +6,19 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
+ const tslib_1 = require("tslib");
9
10
  const __1 = require("..");
10
- const path_1 = require("path");
11
+ const path_1 = (0, tslib_1.__importDefault)(require("path"));
11
12
  describe('getPluginVersion', () => {
12
13
  it('Can detect external packages plugins versions of correctly.', () => {
13
- expect((0, __1.getPluginVersion)((0, path_1.join)(__dirname, '..', '__fixtures__', 'dummy-plugin.js'),
14
+ expect((0, __1.getPluginVersion)(path_1.default.join(__dirname, '..', '__fixtures__', 'dummy-plugin.js'),
14
15
  // Make the plugin appear external.
15
- (0, path_1.join)(__dirname, '..', '..', '..', '..', '..', '..', 'website'))).toEqual({ type: 'package', version: 'random-version' });
16
+ path_1.default.join(__dirname, '..', '..', '..', '..', '..', '..', 'website'))).toEqual({ type: 'package', version: 'random-version' });
16
17
  });
17
18
  it('Can detect project plugins versions correctly.', () => {
18
- expect((0, __1.getPluginVersion)((0, path_1.join)(__dirname, '..', '__fixtures__', 'dummy-plugin.js'),
19
+ expect((0, __1.getPluginVersion)(path_1.default.join(__dirname, '..', '__fixtures__', 'dummy-plugin.js'),
19
20
  // Make the plugin appear project local.
20
- (0, path_1.join)(__dirname, '..', '__fixtures__'))).toEqual({ type: 'project' });
21
+ path_1.default.join(__dirname, '..', '__fixtures__'))).toEqual({ type: 'project' });
21
22
  });
22
23
  it('Can detect local packages versions correctly.', () => {
23
24
  expect((0, __1.getPluginVersion)('/', '/')).toEqual({ type: 'local' });
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-4383",
4
+ "version": "0.0.0-4393",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -41,13 +41,13 @@
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-4383",
45
- "@docusaurus/logger": "0.0.0-4383",
46
- "@docusaurus/mdx-loader": "0.0.0-4383",
44
+ "@docusaurus/cssnano-preset": "0.0.0-4393",
45
+ "@docusaurus/logger": "0.0.0-4393",
46
+ "@docusaurus/mdx-loader": "0.0.0-4393",
47
47
  "@docusaurus/react-loadable": "5.5.2",
48
- "@docusaurus/utils": "0.0.0-4383",
49
- "@docusaurus/utils-common": "0.0.0-4383",
50
- "@docusaurus/utils-validation": "0.0.0-4383",
48
+ "@docusaurus/utils": "0.0.0-4393",
49
+ "@docusaurus/utils-common": "0.0.0-4393",
50
+ "@docusaurus/utils-validation": "0.0.0-4393",
51
51
  "@slorber/static-site-generator-webpack-plugin": "^4.0.0",
52
52
  "@svgr/webpack": "^6.0.0",
53
53
  "autoprefixer": "^10.3.5",
@@ -108,8 +108,8 @@
108
108
  "webpackbar": "^5.0.0-3"
109
109
  },
110
110
  "devDependencies": {
111
- "@docusaurus/module-type-aliases": "0.0.0-4383",
112
- "@docusaurus/types": "0.0.0-4383",
111
+ "@docusaurus/module-type-aliases": "0.0.0-4393",
112
+ "@docusaurus/types": "0.0.0-4393",
113
113
  "@types/copy-webpack-plugin": "^8.0.1",
114
114
  "@types/css-minimizer-webpack-plugin": "^3.0.2",
115
115
  "@types/detect-port": "^1.3.0",
@@ -119,6 +119,7 @@
119
119
  "@types/rtl-detect": "^1.0.0",
120
120
  "@types/serve-handler": "^6.1.1",
121
121
  "@types/webpack-bundle-analyzer": "^4.4.1",
122
+ "react-test-renderer": "^17.0.2",
122
123
  "tmp-promise": "^3.0.2"
123
124
  },
124
125
  "peerDependencies": {
@@ -128,5 +129,5 @@
128
129
  "engines": {
129
130
  "node": ">=14"
130
131
  },
131
- "gitHead": "6ccc0daea1a7b1413cd32f515a9e661c4007a355"
132
+ "gitHead": "ab99bd917600589f5e698e45c4c6e079ddccd828"
132
133
  }