@docusaurus/core 4.0.0-canary-6839 → 4.0.0-canary-6840

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/lib/client/App.js CHANGED
@@ -13,7 +13,6 @@ import Root from '@theme/Root';
13
13
  import ThemeProvider from '@theme/ThemeProvider';
14
14
  import SiteMetadata from '@theme/SiteMetadata';
15
15
  import normalizeLocation from './normalizeLocation';
16
- import { BrowserContextProvider } from './browserContext';
17
16
  import { DocusaurusContextProvider } from './docusaurusContext';
18
17
  import PendingNavigation from './PendingNavigation';
19
18
  import BaseUrlIssueBanner from './BaseUrlIssueBanner';
@@ -33,17 +32,15 @@ function AppNavigation() {
33
32
  export default function App() {
34
33
  return (<ErrorBoundary>
35
34
  <DocusaurusContextProvider>
36
- <BrowserContextProvider>
37
- <Root>
38
- <ThemeProvider>
39
- <SiteMetadataDefaults />
40
- <SiteMetadata />
41
- <BaseUrlIssueBanner />
42
- <AppNavigation />
43
- </ThemeProvider>
44
- </Root>
45
- <HasHydratedDataAttribute />
46
- </BrowserContextProvider>
35
+ <Root>
36
+ <ThemeProvider>
37
+ <SiteMetadataDefaults />
38
+ <SiteMetadata />
39
+ <BaseUrlIssueBanner />
40
+ <AppNavigation />
41
+ </ThemeProvider>
42
+ </Root>
43
+ <HasHydratedDataAttribute />
47
44
  </DocusaurusContextProvider>
48
45
  </ErrorBoundary>);
49
46
  }
@@ -4,8 +4,14 @@
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 { useContext } from 'react';
8
- import { Context } from '../browserContext';
7
+ import { useSyncExternalStore } from 'react';
8
+ // The "browser" state never changes, there's nothing to subscribe to
9
+ const subscribe = () => () => { };
10
+ // On first client-side render, we need to render exactly as the server rendered
11
+ // See https://www.joshwcomeau.com/react/the-perils-of-rehydration/
12
+ // React uses getServerSnapshot during SSR and hydration, and re-renders with
13
+ // getSnapshot right after hydration. Components mounted after hydration
14
+ // directly get the client value, without an extra re-render.
9
15
  export default function useIsBrowser() {
10
- return useContext(Context);
16
+ return useSyncExternalStore(subscribe, () => true, () => false);
11
17
  }
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-6839",
4
+ "version": "4.0.0-canary-6840",
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-6839",
37
- "@docusaurus/bundler": "4.0.0-canary-6839",
38
- "@docusaurus/glob": "4.0.0-canary-6839",
39
- "@docusaurus/logger": "4.0.0-canary-6839",
40
- "@docusaurus/mdx-loader": "4.0.0-canary-6839",
41
- "@docusaurus/utils": "4.0.0-canary-6839",
42
- "@docusaurus/utils-common": "4.0.0-canary-6839",
43
- "@docusaurus/utils-validation": "4.0.0-canary-6839",
36
+ "@docusaurus/babel": "4.0.0-canary-6840",
37
+ "@docusaurus/bundler": "4.0.0-canary-6840",
38
+ "@docusaurus/glob": "4.0.0-canary-6840",
39
+ "@docusaurus/logger": "4.0.0-canary-6840",
40
+ "@docusaurus/mdx-loader": "4.0.0-canary-6840",
41
+ "@docusaurus/utils": "4.0.0-canary-6840",
42
+ "@docusaurus/utils-common": "4.0.0-canary-6840",
43
+ "@docusaurus/utils-validation": "4.0.0-canary-6840",
44
44
  "boxen": "^8.0.1",
45
45
  "cli-table3": "^0.6.5",
46
46
  "combine-promises": "^1.2.0",
@@ -76,8 +76,8 @@
76
76
  "webpack-merge": "^6.0.1"
77
77
  },
78
78
  "devDependencies": {
79
- "@docusaurus/module-type-aliases": "4.0.0-canary-6839",
80
- "@docusaurus/types": "4.0.0-canary-6839",
79
+ "@docusaurus/module-type-aliases": "4.0.0-canary-6840",
80
+ "@docusaurus/types": "4.0.0-canary-6840",
81
81
  "@total-typescript/shoehorn": "^0.1.2",
82
82
  "@types/escape-html": "^1.0.4",
83
83
  "@types/history": "^4.7.11",
@@ -91,7 +91,7 @@
91
91
  "tree-node-cli": "^3.0.0"
92
92
  },
93
93
  "peerDependencies": {
94
- "@docusaurus/faster": "4.0.0-canary-6839",
94
+ "@docusaurus/faster": "4.0.0-canary-6840",
95
95
  "@mdx-js/react": "^3.1.1",
96
96
  "react": "^19.3.0",
97
97
  "react-dom": "^19.3.0"
@@ -104,5 +104,5 @@
104
104
  "engines": {
105
105
  "node": ">=24.21"
106
106
  },
107
- "gitHead": "c93a33b60c528917c38fbf07e54c14ff52bdc190"
107
+ "gitHead": "b767143bc76b7747a9d1cc747dece7b06195a5c0"
108
108
  }
@@ -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
- import React, { type ReactNode } from 'react';
8
- export declare const Context: React.Context<boolean>;
9
- export declare function BrowserContextProvider({ children, }: {
10
- children: ReactNode;
11
- }): ReactNode;
@@ -1,22 +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 React, { useEffect, useState } from 'react';
8
- // Encapsulate the logic to avoid React hydration problems
9
- // See https://www.joshwcomeau.com/react/the-perils-of-rehydration/
10
- // On first client-side render, we need to render exactly as the server rendered
11
- // isBrowser is set to true only after a successful hydration
12
- // Note, isBrowser is not part of useDocusaurusContext() for perf reasons
13
- // Using useDocusaurusContext() (much more common need) should not trigger
14
- // re-rendering after a successful hydration
15
- export const Context = React.createContext(false);
16
- export function BrowserContextProvider({ children, }) {
17
- const [isBrowser, setIsBrowser] = useState(false);
18
- useEffect(() => {
19
- setIsBrowser(true);
20
- }, []);
21
- return <Context.Provider value={isBrowser}>{children}</Context.Provider>;
22
- }