@umijs/renderer-react 4.0.0-canary.20240510.1 → 4.0.0-canary.20240513.1
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/dist/browser.d.ts +2 -3
- package/dist/browser.js +1 -1
- package/dist/html.d.ts +1 -1
- package/dist/html.js +26 -10
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
package/dist/browser.d.ts
CHANGED
|
@@ -29,10 +29,9 @@ export declare type RenderClientOpts = {
|
|
|
29
29
|
*/
|
|
30
30
|
rootElement?: HTMLElement;
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
33
|
-
* @doc 默认 false, 从 app root 开始 render,为 true 时从 html 开始
|
|
32
|
+
* 内部流程, 渲染特殊 html 节点, 不要使用!!!
|
|
34
33
|
*/
|
|
35
|
-
|
|
34
|
+
__SPECIAL_HTML_DO_NOT_USE_OR_YOU_WILL_BE_FIRED?: boolean;
|
|
36
35
|
/**
|
|
37
36
|
* 当前的路由配置
|
|
38
37
|
*/
|
package/dist/browser.js
CHANGED
|
@@ -280,7 +280,7 @@ export function renderClient(opts) {
|
|
|
280
280
|
loaderData: loaderData,
|
|
281
281
|
mountElementId: opts.mountElementId
|
|
282
282
|
};
|
|
283
|
-
ReactDOM.hydrateRoot(opts.
|
|
283
|
+
ReactDOM.hydrateRoot(opts.__SPECIAL_HTML_DO_NOT_USE_OR_YOU_WILL_BE_FIRED ? rootElement : document, /*#__PURE__*/React.createElement(Html, hydtateHtmloptions, /*#__PURE__*/React.createElement(Browser, null)));
|
|
284
284
|
return;
|
|
285
285
|
}
|
|
286
286
|
if (ReactDOM.createRoot) {
|
package/dist/html.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { IHtmlProps } from './types';
|
|
3
|
-
export declare function Html({ children, loaderData, manifest, htmlPageOpts,
|
|
3
|
+
export declare function Html({ children, loaderData, manifest, htmlPageOpts, __SPECIAL_HTML_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, mountElementId, }: React.PropsWithChildren<IHtmlProps>): JSX.Element;
|
package/dist/html.js
CHANGED
|
@@ -9,6 +9,17 @@ var RE_URL = /^(http:|https:)?\/\//;
|
|
|
9
9
|
function isUrl(str) {
|
|
10
10
|
return RE_URL.test(str) || str.startsWith('/') && !str.startsWith('/*') || str.startsWith('./') || str.startsWith('../');
|
|
11
11
|
}
|
|
12
|
+
var GlobalDataScript = function GlobalDataScript(props) {
|
|
13
|
+
var loaderData = props.loaderData,
|
|
14
|
+
htmlPageOpts = props.htmlPageOpts,
|
|
15
|
+
manifest = props.manifest;
|
|
16
|
+
return /*#__PURE__*/React.createElement("script", {
|
|
17
|
+
suppressHydrationWarning: true,
|
|
18
|
+
dangerouslySetInnerHTML: {
|
|
19
|
+
__html: "window.__UMI_LOADER_DATA__ = ".concat(JSON.stringify(loaderData || {}), "; window.__UMI_METADATA_LOADER_DATA__ = ").concat(JSON.stringify(htmlPageOpts || {}), "; window.__UMI_BUILD_MANIFEST_DATA__ = ").concat(JSON.stringify(manifest) || {})
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
};
|
|
12
23
|
function normalizeScripts(script) {
|
|
13
24
|
var extraProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
14
25
|
if (typeof script === 'string') {
|
|
@@ -91,16 +102,22 @@ export function Html(_ref) {
|
|
|
91
102
|
loaderData = _ref.loaderData,
|
|
92
103
|
manifest = _ref.manifest,
|
|
93
104
|
htmlPageOpts = _ref.htmlPageOpts,
|
|
94
|
-
|
|
105
|
+
__SPECIAL_HTML_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = _ref.__SPECIAL_HTML_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
|
|
95
106
|
mountElementId = _ref.mountElementId;
|
|
96
107
|
// TODO: 处理 head 标签,比如 favicon.ico 的一致性
|
|
97
108
|
// TODO: root 支持配置
|
|
98
|
-
if (
|
|
99
|
-
return /*#__PURE__*/React.createElement(React.
|
|
100
|
-
|
|
109
|
+
if (__SPECIAL_HTML_DO_NOT_USE_OR_YOU_WILL_BE_FIRED) {
|
|
110
|
+
return /*#__PURE__*/React.createElement("html", null, /*#__PURE__*/React.createElement("head", null), /*#__PURE__*/React.createElement("body", null, /*#__PURE__*/React.createElement("noscript", {
|
|
111
|
+
dangerouslySetInnerHTML: {
|
|
112
|
+
__html: "<b>Enable JavaScript to run this app.</b>"
|
|
113
|
+
}
|
|
101
114
|
}), /*#__PURE__*/React.createElement("div", {
|
|
102
115
|
id: mountElementId
|
|
103
|
-
}, children)
|
|
116
|
+
}, children), /*#__PURE__*/React.createElement(GlobalDataScript, {
|
|
117
|
+
manifest: manifest,
|
|
118
|
+
loaderData: loaderData,
|
|
119
|
+
htmlPageOpts: htmlPageOpts
|
|
120
|
+
})));
|
|
104
121
|
}
|
|
105
122
|
var serverBuildManifest = typeof window === 'undefined' ? manifest : window.__UMI_BUILD_MANIFEST_DATA__;
|
|
106
123
|
return (
|
|
@@ -126,11 +143,10 @@ export function Html(_ref) {
|
|
|
126
143
|
}
|
|
127
144
|
}), /*#__PURE__*/React.createElement("div", {
|
|
128
145
|
id: mountElementId
|
|
129
|
-
}, children), /*#__PURE__*/React.createElement(
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
146
|
+
}, children), /*#__PURE__*/React.createElement(GlobalDataScript, {
|
|
147
|
+
manifest: manifest,
|
|
148
|
+
loaderData: loaderData,
|
|
149
|
+
htmlPageOpts: htmlPageOpts
|
|
134
150
|
}), htmlPageOpts === null || htmlPageOpts === void 0 || (_htmlPageOpts$scripts = htmlPageOpts.scripts) === null || _htmlPageOpts$scripts === void 0 ? void 0 : _htmlPageOpts$scripts.map(function (script, key) {
|
|
135
151
|
var _normalizeScripts2 = normalizeScripts(script),
|
|
136
152
|
content = _normalizeScripts2.content,
|
package/dist/types.d.ts
CHANGED
|
@@ -49,7 +49,7 @@ export interface ILoaderData {
|
|
|
49
49
|
}
|
|
50
50
|
interface IHtmlHydrateOptions {
|
|
51
51
|
htmlPageOpts?: IhtmlPageOpts;
|
|
52
|
-
|
|
52
|
+
__SPECIAL_HTML_DO_NOT_USE_OR_YOU_WILL_BE_FIRED?: boolean;
|
|
53
53
|
mountElementId?: string;
|
|
54
54
|
}
|
|
55
55
|
export interface IRootComponentOptions extends IHtmlHydrateOptions {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/renderer-react",
|
|
3
|
-
"version": "4.0.0-canary.
|
|
3
|
+
"version": "4.0.0-canary.20240513.1",
|
|
4
4
|
"description": "@umijs/renderer-react",
|
|
5
5
|
"homepage": "https://github.com/umijs/umi/tree/master/packages/renderer-react#readme",
|
|
6
6
|
"bugs": "https://github.com/umijs/umi/issues",
|