@docusaurus/core 4.0.0-canary-6863 → 4.0.0-canary-6866

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.
@@ -4,7 +4,7 @@
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 type { ReactElement, ReactNode } from 'react';
7
+ import { type ReactElement, type ReactNode } from 'react';
8
8
  import type { ClientModule } from '@docusaurus/types';
9
9
  import type { Location } from 'history';
10
10
  export declare function dispatchLifecycleAction<K extends keyof ClientModule>(lifecycleAction: K, ...args: Parameters<NonNullable<ClientModule[K]>>): () => void;
@@ -4,8 +4,8 @@
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 { useLayoutEffect } from 'react';
7
8
  import clientModules from '@generated/client-modules';
8
- import useIsomorphicLayoutEffect from './exports/useIsomorphicLayoutEffect';
9
9
  export function dispatchLifecycleAction(lifecycleAction, ...args) {
10
10
  const callbacks = clientModules.map((clientModule) => {
11
11
  const lifecycleFunction = (clientModule.default?.[lifecycleAction] ??
@@ -36,7 +36,7 @@ function scrollAfterNavigation({ location, previousLocation, }) {
36
36
  }
37
37
  }
38
38
  function ClientLifecyclesDispatcher({ children, location, previousLocation, }) {
39
- useIsomorphicLayoutEffect(() => {
39
+ useLayoutEffect(() => {
40
40
  if (previousLocation !== location) {
41
41
  scrollAfterNavigation({ location, previousLocation });
42
42
  dispatchLifecycleAction('onRouteDidUpdate', { previousLocation, location });
@@ -6,16 +6,15 @@
6
6
  */
7
7
  import { useLayoutEffect } from 'react';
8
8
  /**
9
- * This hook is like `useLayoutEffect`, but without the SSR warning.
10
- * It seems hacky but it's used in many React libs (Redux, Formik...).
11
- * Also mentioned here: https://github.com/facebook/react/issues/16956
9
+ * This hook is now just React's `useLayoutEffect`.
12
10
  *
13
- * It is useful when you need to update a ref as soon as possible after a React
14
- * render (before `useEffect`).
11
+ * It used to fall back to `useEffect` on the server to avoid the
12
+ * `useLayoutEffect` SSR warning, which React 19 removed.
13
+ * See https://github.com/facebook/react/pull/26395
15
14
  *
16
- * TODO should become unnecessary in React v19?
17
- * https://github.com/facebook/react/pull/26395
18
- * This was added in core with Docusaurus v3 but kept undocumented on purpose
15
+ * It is unnecessary since React 19: use `useLayoutEffect` directly.
16
+ * We only keep it for retro-compatibility, because third-party code might
17
+ * import `@docusaurus/useIsomorphicLayoutEffect`.
19
18
  */
20
19
  declare const useIsomorphicLayoutEffect: typeof useLayoutEffect;
21
20
  export default useIsomorphicLayoutEffect;
@@ -4,21 +4,17 @@
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 { useEffect, useLayoutEffect } from 'react';
8
- import ExecutionEnvironment from './ExecutionEnvironment';
7
+ import { useLayoutEffect } from 'react';
9
8
  /**
10
- * This hook is like `useLayoutEffect`, but without the SSR warning.
11
- * It seems hacky but it's used in many React libs (Redux, Formik...).
12
- * Also mentioned here: https://github.com/facebook/react/issues/16956
9
+ * This hook is now just React's `useLayoutEffect`.
13
10
  *
14
- * It is useful when you need to update a ref as soon as possible after a React
15
- * render (before `useEffect`).
11
+ * It used to fall back to `useEffect` on the server to avoid the
12
+ * `useLayoutEffect` SSR warning, which React 19 removed.
13
+ * See https://github.com/facebook/react/pull/26395
16
14
  *
17
- * TODO should become unnecessary in React v19?
18
- * https://github.com/facebook/react/pull/26395
19
- * This was added in core with Docusaurus v3 but kept undocumented on purpose
15
+ * It is unnecessary since React 19: use `useLayoutEffect` directly.
16
+ * We only keep it for retro-compatibility, because third-party code might
17
+ * import `@docusaurus/useIsomorphicLayoutEffect`.
20
18
  */
21
- const useIsomorphicLayoutEffect = ExecutionEnvironment.canUseDOM
22
- ? useLayoutEffect
23
- : useEffect;
19
+ const useIsomorphicLayoutEffect = useLayoutEffect;
24
20
  export default useIsomorphicLayoutEffect;
@@ -165,8 +165,8 @@ function handleInvalidComponentNameParam({ componentNameParam, themeComponents,
165
165
  logger_1.default.error `Component name=${componentNameParam} not found.`;
166
166
  const suggestion = (0, common_1.findClosestValue)(componentNameParam, themeComponents.all);
167
167
  if (suggestion) {
168
- logger_1.default.info `Did you mean name=${suggestion}? ${themeComponents.hasAnySafeAction(suggestion)
169
- ? `Note: this component is an unsafe internal component and can only be swizzled with code=${'--danger'} or explicit confirmation.`
168
+ logger_1.default.info `Did you mean name=${suggestion}? ${!themeComponents.hasAnySafeAction(suggestion)
169
+ ? `Note: this component is an unsafe internal component and can only be swizzled with ${logger_1.default.code('--danger')} or explicit confirmation.`
170
170
  : ''}`;
171
171
  }
172
172
  else {
@@ -51,12 +51,9 @@ async function tryOpenWithAppleScript({ url, browser, }) {
51
51
  ];
52
52
  // Among all the supported browsers, retrieves to stdout the active ones
53
53
  const command = `ps cax -o command | grep -E "^(${supportedChromiumBrowsers.join('|')})$"`;
54
- const result = await Promise
55
- // TODO Docusaurus v4: use Promise.try()
56
- // See why here https://github.com/facebook/docusaurus/issues/11204#issuecomment-3073480330
57
- .resolve()
58
- .then(() => execPromise(command))
59
- .catch(() => {
54
+ // Promise.try() also catches errors thrown synchronously
55
+ // See https://github.com/facebook/docusaurus/issues/11204#issuecomment-3073480330
56
+ const result = await Promise.try(() => execPromise(command)).catch(() => {
60
57
  // Ignore all errors
61
58
  // In particular grep errors when macOS user has no Chromium-based browser open
62
59
  // See https://github.com/facebook/docusaurus/issues/11204
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": "4.0.0-canary-6863",
4
+ "version": "4.0.0-canary-6866",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -33,14 +33,14 @@
33
33
  "url": "https://github.com/facebook/docusaurus/issues"
34
34
  },
35
35
  "dependencies": {
36
- "@docusaurus/babel": "4.0.0-canary-6863",
37
- "@docusaurus/bundler": "4.0.0-canary-6863",
38
- "@docusaurus/glob": "4.0.0-canary-6863",
39
- "@docusaurus/logger": "4.0.0-canary-6863",
40
- "@docusaurus/mdx-loader": "4.0.0-canary-6863",
41
- "@docusaurus/utils": "4.0.0-canary-6863",
42
- "@docusaurus/utils-common": "4.0.0-canary-6863",
43
- "@docusaurus/utils-validation": "4.0.0-canary-6863",
36
+ "@docusaurus/babel": "4.0.0-canary-6866",
37
+ "@docusaurus/bundler": "4.0.0-canary-6866",
38
+ "@docusaurus/glob": "4.0.0-canary-6866",
39
+ "@docusaurus/logger": "4.0.0-canary-6866",
40
+ "@docusaurus/mdx-loader": "4.0.0-canary-6866",
41
+ "@docusaurus/utils": "4.0.0-canary-6866",
42
+ "@docusaurus/utils-common": "4.0.0-canary-6866",
43
+ "@docusaurus/utils-validation": "4.0.0-canary-6866",
44
44
  "boxen": "^9.0.0",
45
45
  "cli-table3": "^0.6.5",
46
46
  "combine-promises": "^1.2.0",
@@ -74,8 +74,8 @@
74
74
  "webpack-merge": "^6.0.1"
75
75
  },
76
76
  "devDependencies": {
77
- "@docusaurus/module-type-aliases": "4.0.0-canary-6863",
78
- "@docusaurus/types": "4.0.0-canary-6863",
77
+ "@docusaurus/module-type-aliases": "4.0.0-canary-6866",
78
+ "@docusaurus/types": "4.0.0-canary-6866",
79
79
  "@total-typescript/shoehorn": "^0.1.2",
80
80
  "@types/escape-html": "^1.0.4",
81
81
  "@types/history": "^4.7.11",
@@ -90,7 +90,7 @@
90
90
  "utility-types": "^3.11.0"
91
91
  },
92
92
  "peerDependencies": {
93
- "@docusaurus/faster": "4.0.0-canary-6863",
93
+ "@docusaurus/faster": "4.0.0-canary-6866",
94
94
  "@mdx-js/react": "^3.1.1",
95
95
  "react": "^19.3.0",
96
96
  "react-dom": "^19.3.0"
@@ -103,5 +103,5 @@
103
103
  "engines": {
104
104
  "node": ">=24.21"
105
105
  },
106
- "gitHead": "dcf62792e7f4b7a7dcf4e9558665c93dd4e6da3e"
106
+ "gitHead": "7aa89e7f99bae45a706b688977d03b784ca041c1"
107
107
  }