@docusaurus/core 4.0.0-canary-6843 → 4.0.0-canary-6844
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/exports/BrowserOnly.js +15 -13
- package/package.json +13 -13
|
@@ -4,19 +4,21 @@
|
|
|
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, { isValidElement } from 'react';
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
throw new Error(`Docusaurus error: The children of <BrowserOnly> must be a "render function", e.g. <BrowserOnly>{() => <span>{window.location.href}</span>}</BrowserOnly>.
|
|
7
|
+
import React, { Suspense, isValidElement, use } from 'react';
|
|
8
|
+
import { browser } from 'react-dom';
|
|
9
|
+
function BrowserOnlyContent({ children }) {
|
|
10
|
+
// On the server, this bails out to the closest Suspense boundary fallback
|
|
11
|
+
// On the client, this is a no-op
|
|
12
|
+
use(browser());
|
|
13
|
+
if (typeof children !== 'function' &&
|
|
14
|
+
process.env.NODE_ENV === 'development') {
|
|
15
|
+
throw new Error(`Docusaurus error: The children of <BrowserOnly> must be a "render function", e.g. <BrowserOnly>{() => <span>{window.location.href}</span>}</BrowserOnly>.
|
|
17
16
|
Current type: ${isValidElement(children) ? 'React element' : typeof children}`);
|
|
18
|
-
}
|
|
19
|
-
return <>{children?.()}</>;
|
|
20
17
|
}
|
|
21
|
-
return
|
|
18
|
+
return <>{children?.()}</>;
|
|
19
|
+
}
|
|
20
|
+
export default function BrowserOnly({ children, fallback }) {
|
|
21
|
+
return (<Suspense fallback={fallback ?? null}>
|
|
22
|
+
<BrowserOnlyContent>{children}</BrowserOnlyContent>
|
|
23
|
+
</Suspense>);
|
|
22
24
|
}
|
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-
|
|
4
|
+
"version": "4.0.0-canary-6844",
|
|
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-
|
|
37
|
-
"@docusaurus/bundler": "4.0.0-canary-
|
|
38
|
-
"@docusaurus/glob": "4.0.0-canary-
|
|
39
|
-
"@docusaurus/logger": "4.0.0-canary-
|
|
40
|
-
"@docusaurus/mdx-loader": "4.0.0-canary-
|
|
41
|
-
"@docusaurus/utils": "4.0.0-canary-
|
|
42
|
-
"@docusaurus/utils-common": "4.0.0-canary-
|
|
43
|
-
"@docusaurus/utils-validation": "4.0.0-canary-
|
|
36
|
+
"@docusaurus/babel": "4.0.0-canary-6844",
|
|
37
|
+
"@docusaurus/bundler": "4.0.0-canary-6844",
|
|
38
|
+
"@docusaurus/glob": "4.0.0-canary-6844",
|
|
39
|
+
"@docusaurus/logger": "4.0.0-canary-6844",
|
|
40
|
+
"@docusaurus/mdx-loader": "4.0.0-canary-6844",
|
|
41
|
+
"@docusaurus/utils": "4.0.0-canary-6844",
|
|
42
|
+
"@docusaurus/utils-common": "4.0.0-canary-6844",
|
|
43
|
+
"@docusaurus/utils-validation": "4.0.0-canary-6844",
|
|
44
44
|
"boxen": "^8.0.1",
|
|
45
45
|
"cli-table3": "^0.6.5",
|
|
46
46
|
"combine-promises": "^1.2.0",
|
|
@@ -75,8 +75,8 @@
|
|
|
75
75
|
"webpack-merge": "^6.0.1"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
|
-
"@docusaurus/module-type-aliases": "4.0.0-canary-
|
|
79
|
-
"@docusaurus/types": "4.0.0-canary-
|
|
78
|
+
"@docusaurus/module-type-aliases": "4.0.0-canary-6844",
|
|
79
|
+
"@docusaurus/types": "4.0.0-canary-6844",
|
|
80
80
|
"@total-typescript/shoehorn": "^0.1.2",
|
|
81
81
|
"@types/escape-html": "^1.0.4",
|
|
82
82
|
"@types/history": "^4.7.11",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"utility-types": "^3.11.0"
|
|
92
92
|
},
|
|
93
93
|
"peerDependencies": {
|
|
94
|
-
"@docusaurus/faster": "4.0.0-canary-
|
|
94
|
+
"@docusaurus/faster": "4.0.0-canary-6844",
|
|
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": "
|
|
107
|
+
"gitHead": "4fe2b4024d57b2b0719e3fde2c3d5a04394055df"
|
|
108
108
|
}
|