react-vant-nova 1.0.7-test → 1.0.8
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/bundle/react-vant-nova.es.js +21 -30
- package/bundle/react-vant-nova.js +18 -27
- package/bundle/react-vant-nova.min.js +2 -2
- package/es/empty/Network.d.ts +1 -0
- package/es/radio/Radio.d.ts +1 -0
- package/es/radio/RadioGroup.d.ts +1 -0
- package/es/toast/Toast.js +30 -37
- package/es/utils/dom/render.js +12 -30
- package/es/utils/dom/render1.d.ts +9 -0
- package/es/utils/dom/render1.js +85 -0
- package/lib/empty/Network.d.ts +1 -0
- package/lib/radio/Radio.d.ts +1 -0
- package/lib/radio/RadioGroup.d.ts +1 -0
- package/lib/toast/Toast.js +30 -37
- package/lib/utils/dom/render.js +20 -32
- package/lib/utils/dom/render1.d.ts +9 -0
- package/lib/utils/dom/render1.js +106 -0
- package/package.json +1 -1
package/es/empty/Network.d.ts
CHANGED
package/es/radio/Radio.d.ts
CHANGED
package/es/radio/RadioGroup.d.ts
CHANGED
package/es/toast/Toast.js
CHANGED
|
@@ -50,7 +50,6 @@ const Toast = p => {
|
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
if (type === 'loading') {
|
|
53
|
-
// @ts-ignore
|
|
54
53
|
return _jsx(Loading, {
|
|
55
54
|
className: clsx(bem('loading')),
|
|
56
55
|
type: loadingType
|
|
@@ -59,42 +58,36 @@ const Toast = p => {
|
|
|
59
58
|
return null;
|
|
60
59
|
};
|
|
61
60
|
const renderMessage = () => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
return null;
|
|
75
|
-
}, 100);
|
|
61
|
+
const {
|
|
62
|
+
message
|
|
63
|
+
} = props;
|
|
64
|
+
if (isDef(message) && message !== '') {
|
|
65
|
+
return _jsx("div", Object.assign({
|
|
66
|
+
className: clsx(bem('info'))
|
|
67
|
+
}, {
|
|
68
|
+
children: message
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
76
72
|
};
|
|
77
|
-
return (
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
children: [renderIcon(), renderMessage()]
|
|
97
|
-
}))
|
|
98
|
-
);
|
|
73
|
+
return _jsxs(Popup, Object.assign({
|
|
74
|
+
className: clsx([bem([props.position, {
|
|
75
|
+
[props.type]: !props.icon
|
|
76
|
+
}]), props.className]),
|
|
77
|
+
visible: props.visible,
|
|
78
|
+
overlay: props.overlay,
|
|
79
|
+
transition: props.transition,
|
|
80
|
+
overlayClass: props.overlayClass,
|
|
81
|
+
overlayStyle: props.overlayStyle,
|
|
82
|
+
closeOnClickOverlay: props.closeOnClickOverlay,
|
|
83
|
+
lockScroll: false,
|
|
84
|
+
onClick: onClick,
|
|
85
|
+
onClose: props.onClose,
|
|
86
|
+
onClosed: props.onClosed,
|
|
87
|
+
onOpened: props.onOpened,
|
|
88
|
+
teleport: props.teleport
|
|
89
|
+
}, {
|
|
90
|
+
children: [renderIcon(), renderMessage()]
|
|
91
|
+
}));
|
|
99
92
|
};
|
|
100
93
|
export default Toast;
|
package/es/utils/dom/render.js
CHANGED
|
@@ -1,23 +1,13 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
2
|
import * as ReactDOM from 'react-dom';
|
|
3
|
-
|
|
3
|
+
import { createRoot } from 'react-dom/client';
|
|
4
|
+
// Copy from rc-util to fix React 19 support
|
|
5
|
+
// https://github.com/react-component/util/blob/master/src/React/render.ts
|
|
4
6
|
const fullClone = Object.assign({}, ReactDOM);
|
|
5
7
|
const {
|
|
8
|
+
render: reactRender,
|
|
6
9
|
unmountComponentAtNode
|
|
7
10
|
} = fullClone;
|
|
8
|
-
let createRoot;
|
|
9
|
-
// 确保在React 18+版本中获取createRoot
|
|
10
|
-
if (fullClone.createRoot) {
|
|
11
|
-
createRoot = fullClone.createRoot;
|
|
12
|
-
} else {
|
|
13
|
-
// 如果createRoot不可用,尝试从react-dom/client导入
|
|
14
|
-
try {
|
|
15
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
16
|
-
createRoot = require('react-dom/client').createRoot;
|
|
17
|
-
} catch (e) {
|
|
18
|
-
// 保留原有行为以兼容旧版本
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
11
|
function toggleWarning(skip) {
|
|
22
12
|
const {
|
|
23
13
|
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
|
|
@@ -27,33 +17,24 @@ function toggleWarning(skip) {
|
|
|
27
17
|
}
|
|
28
18
|
}
|
|
29
19
|
const MARK = '__react_vant_root__';
|
|
30
|
-
/************* ✨ Windsurf Command ⭐ *************/
|
|
31
|
-
/**
|
|
32
|
-
* 使用ReactDOM.render的替代方案,仅用于旧版本React
|
|
33
|
-
* 如果ReactDOM.render不可用,将降级使用createRoot(如果可用)
|
|
34
|
-
/******* 57770e2e-0e81-41a7-aee6-9175a4a59062 *******/
|
|
35
20
|
function legacyRender(node, container) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (fullClone.render) {
|
|
21
|
+
if (reactRender) {
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
39
23
|
// @ts-ignore
|
|
40
|
-
|
|
41
|
-
} else {
|
|
42
|
-
// 如果ReactDOM.render不可用,降级使用createRoot(如果可用)
|
|
43
|
-
if (createRoot) {
|
|
44
|
-
concurrentRender(node, container);
|
|
45
|
-
}
|
|
24
|
+
reactRender(node, container);
|
|
46
25
|
}
|
|
47
26
|
}
|
|
48
27
|
function concurrentRender(node, container) {
|
|
49
28
|
toggleWarning(true);
|
|
50
29
|
const root = container[MARK] || createRoot(container);
|
|
51
30
|
toggleWarning(false);
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
52
32
|
// @ts-ignore
|
|
53
33
|
root.render(node);
|
|
54
34
|
container[MARK] = root;
|
|
55
35
|
}
|
|
56
36
|
export function render(node, container) {
|
|
37
|
+
// @ts-ignore
|
|
57
38
|
if (createRoot) {
|
|
58
39
|
concurrentRender(node, container);
|
|
59
40
|
return;
|
|
@@ -62,7 +43,7 @@ export function render(node, container) {
|
|
|
62
43
|
}
|
|
63
44
|
// ========================== Unmount =========================
|
|
64
45
|
function legacyUnmount(container) {
|
|
65
|
-
return unmountComponentAtNode(container);
|
|
46
|
+
return unmountComponentAtNode ? unmountComponentAtNode(container) : false;
|
|
66
47
|
}
|
|
67
48
|
function concurrentUnmount(container) {
|
|
68
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -75,7 +56,8 @@ function concurrentUnmount(container) {
|
|
|
75
56
|
});
|
|
76
57
|
}
|
|
77
58
|
export function unmount(container) {
|
|
78
|
-
|
|
59
|
+
// @ts-ignore
|
|
60
|
+
if (createRoot || container[MARK]) {
|
|
79
61
|
return concurrentUnmount(container);
|
|
80
62
|
}
|
|
81
63
|
return legacyUnmount(container);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import type { Root } from 'react-dom/client';
|
|
3
|
+
declare const MARK = "__react_vant_root__";
|
|
4
|
+
declare type ContainerType = (Element | DocumentFragment) & {
|
|
5
|
+
[MARK]?: Root;
|
|
6
|
+
};
|
|
7
|
+
export declare function render(node: ReactElement, container: ContainerType): void;
|
|
8
|
+
export declare function unmount(container: ContainerType): boolean | Promise<void>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import * as ReactDOM from 'react-dom';
|
|
3
|
+
// Let compiler not to search module usage
|
|
4
|
+
const fullClone = Object.assign({}, ReactDOM);
|
|
5
|
+
const {
|
|
6
|
+
unmountComponentAtNode
|
|
7
|
+
} = fullClone;
|
|
8
|
+
let createRoot;
|
|
9
|
+
// 确保在React 18+版本中获取createRoot
|
|
10
|
+
if (fullClone.createRoot) {
|
|
11
|
+
createRoot = fullClone.createRoot;
|
|
12
|
+
} else {
|
|
13
|
+
// 如果createRoot不可用,尝试从react-dom/client导入
|
|
14
|
+
try {
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
16
|
+
createRoot = require('react-dom/client').createRoot;
|
|
17
|
+
} catch (e) {
|
|
18
|
+
// 保留原有行为以兼容旧版本
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function toggleWarning(skip) {
|
|
22
|
+
const {
|
|
23
|
+
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
|
|
24
|
+
} = fullClone;
|
|
25
|
+
if (__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED && typeof __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED === 'object') {
|
|
26
|
+
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.usingClientEntryPoint = skip;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const MARK = '__react_vant_root__';
|
|
30
|
+
/************* ✨ Windsurf Command ⭐ *************/
|
|
31
|
+
/**
|
|
32
|
+
* 使用ReactDOM.render的替代方案,仅用于旧版本React
|
|
33
|
+
* 如果ReactDOM.render不可用,将降级使用createRoot(如果可用)
|
|
34
|
+
/******* 57770e2e-0e81-41a7-aee6-9175a4a59062 *******/
|
|
35
|
+
function legacyRender(node, container) {
|
|
36
|
+
// 使用ReactDOM.render的替代方案,仅用于旧版本React
|
|
37
|
+
// @ts-ignore
|
|
38
|
+
if (fullClone.render) {
|
|
39
|
+
// @ts-ignore
|
|
40
|
+
fullClone.render(node, container);
|
|
41
|
+
} else {
|
|
42
|
+
// 如果ReactDOM.render不可用,降级使用createRoot(如果可用)
|
|
43
|
+
//@ts-ignore
|
|
44
|
+
if (createRoot) {
|
|
45
|
+
concurrentRender(node, container);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function concurrentRender(node, container) {
|
|
50
|
+
toggleWarning(true);
|
|
51
|
+
const root = container[MARK] || createRoot(container);
|
|
52
|
+
toggleWarning(false);
|
|
53
|
+
// @ts-ignore
|
|
54
|
+
root.render(node);
|
|
55
|
+
container[MARK] = root;
|
|
56
|
+
}
|
|
57
|
+
export function render(node, container) {
|
|
58
|
+
//@ts-ignore
|
|
59
|
+
if (createRoot) {
|
|
60
|
+
concurrentRender(node, container);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
legacyRender(node, container);
|
|
64
|
+
}
|
|
65
|
+
// ========================== Unmount =========================
|
|
66
|
+
function legacyUnmount(container) {
|
|
67
|
+
return unmountComponentAtNode(container);
|
|
68
|
+
}
|
|
69
|
+
function concurrentUnmount(container) {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
// Delay to unmount to avoid React 18 sync warning
|
|
72
|
+
return Promise.resolve().then(() => {
|
|
73
|
+
var _a;
|
|
74
|
+
(_a = container[MARK]) === null || _a === void 0 ? void 0 : _a.unmount();
|
|
75
|
+
delete container[MARK];
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
export function unmount(container) {
|
|
80
|
+
//@ts-ignore
|
|
81
|
+
if (createRoot) {
|
|
82
|
+
return concurrentUnmount(container);
|
|
83
|
+
}
|
|
84
|
+
return legacyUnmount(container);
|
|
85
|
+
}
|
package/lib/empty/Network.d.ts
CHANGED
package/lib/radio/Radio.d.ts
CHANGED
package/lib/toast/Toast.js
CHANGED
|
@@ -82,7 +82,6 @@ const Toast = p => {
|
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
84
|
if (type === 'loading') {
|
|
85
|
-
// @ts-ignore
|
|
86
85
|
return (0, _jsxRuntime().jsx)(_loading.default, {
|
|
87
86
|
className: (0, _clsx().default)(bem('loading')),
|
|
88
87
|
type: loadingType
|
|
@@ -91,42 +90,36 @@ const Toast = p => {
|
|
|
91
90
|
return null;
|
|
92
91
|
};
|
|
93
92
|
const renderMessage = () => {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
return null;
|
|
107
|
-
}, 100);
|
|
93
|
+
const {
|
|
94
|
+
message
|
|
95
|
+
} = props;
|
|
96
|
+
if ((0, _utils.isDef)(message) && message !== '') {
|
|
97
|
+
return (0, _jsxRuntime().jsx)("div", Object.assign({
|
|
98
|
+
className: (0, _clsx().default)(bem('info'))
|
|
99
|
+
}, {
|
|
100
|
+
children: message
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
return null;
|
|
108
104
|
};
|
|
109
|
-
return (
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
children: [renderIcon(), renderMessage()]
|
|
129
|
-
}))
|
|
130
|
-
);
|
|
105
|
+
return (0, _jsxRuntime().jsxs)(_popup.default, Object.assign({
|
|
106
|
+
className: (0, _clsx().default)([bem([props.position, {
|
|
107
|
+
[props.type]: !props.icon
|
|
108
|
+
}]), props.className]),
|
|
109
|
+
visible: props.visible,
|
|
110
|
+
overlay: props.overlay,
|
|
111
|
+
transition: props.transition,
|
|
112
|
+
overlayClass: props.overlayClass,
|
|
113
|
+
overlayStyle: props.overlayStyle,
|
|
114
|
+
closeOnClickOverlay: props.closeOnClickOverlay,
|
|
115
|
+
lockScroll: false,
|
|
116
|
+
onClick: onClick,
|
|
117
|
+
onClose: props.onClose,
|
|
118
|
+
onClosed: props.onClosed,
|
|
119
|
+
onOpened: props.onOpened,
|
|
120
|
+
teleport: props.teleport
|
|
121
|
+
}, {
|
|
122
|
+
children: [renderIcon(), renderMessage()]
|
|
123
|
+
}));
|
|
131
124
|
};
|
|
132
125
|
var _default = exports.default = Toast;
|
package/lib/utils/dom/render.js
CHANGED
|
@@ -19,26 +19,22 @@ function ReactDOM() {
|
|
|
19
19
|
};
|
|
20
20
|
return data;
|
|
21
21
|
}
|
|
22
|
+
function _client() {
|
|
23
|
+
const data = require("react-dom/client");
|
|
24
|
+
_client = function () {
|
|
25
|
+
return data;
|
|
26
|
+
};
|
|
27
|
+
return data;
|
|
28
|
+
}
|
|
22
29
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
23
30
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
24
|
-
//
|
|
31
|
+
// Copy from rc-util to fix React 19 support
|
|
32
|
+
// https://github.com/react-component/util/blob/master/src/React/render.ts
|
|
25
33
|
const fullClone = Object.assign({}, ReactDOM());
|
|
26
34
|
const {
|
|
35
|
+
render: reactRender,
|
|
27
36
|
unmountComponentAtNode
|
|
28
37
|
} = fullClone;
|
|
29
|
-
let createRoot;
|
|
30
|
-
// 确保在React 18+版本中获取createRoot
|
|
31
|
-
if (fullClone.createRoot) {
|
|
32
|
-
createRoot = fullClone.createRoot;
|
|
33
|
-
} else {
|
|
34
|
-
// 如果createRoot不可用,尝试从react-dom/client导入
|
|
35
|
-
try {
|
|
36
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
37
|
-
createRoot = require('react-dom/client').createRoot;
|
|
38
|
-
} catch (e) {
|
|
39
|
-
// 保留原有行为以兼容旧版本
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
38
|
function toggleWarning(skip) {
|
|
43
39
|
const {
|
|
44
40
|
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
|
|
@@ -48,34 +44,25 @@ function toggleWarning(skip) {
|
|
|
48
44
|
}
|
|
49
45
|
}
|
|
50
46
|
const MARK = '__react_vant_root__';
|
|
51
|
-
/************* ✨ Windsurf Command ⭐ *************/
|
|
52
|
-
/**
|
|
53
|
-
* 使用ReactDOM.render的替代方案,仅用于旧版本React
|
|
54
|
-
* 如果ReactDOM.render不可用,将降级使用createRoot(如果可用)
|
|
55
|
-
/******* 57770e2e-0e81-41a7-aee6-9175a4a59062 *******/
|
|
56
47
|
function legacyRender(node, container) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (fullClone.render) {
|
|
48
|
+
if (reactRender) {
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
60
50
|
// @ts-ignore
|
|
61
|
-
|
|
62
|
-
} else {
|
|
63
|
-
// 如果ReactDOM.render不可用,降级使用createRoot(如果可用)
|
|
64
|
-
if (createRoot) {
|
|
65
|
-
concurrentRender(node, container);
|
|
66
|
-
}
|
|
51
|
+
reactRender(node, container);
|
|
67
52
|
}
|
|
68
53
|
}
|
|
69
54
|
function concurrentRender(node, container) {
|
|
70
55
|
toggleWarning(true);
|
|
71
|
-
const root = container[MARK] || createRoot(container);
|
|
56
|
+
const root = container[MARK] || (0, _client().createRoot)(container);
|
|
72
57
|
toggleWarning(false);
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
73
59
|
// @ts-ignore
|
|
74
60
|
root.render(node);
|
|
75
61
|
container[MARK] = root;
|
|
76
62
|
}
|
|
77
63
|
function render(node, container) {
|
|
78
|
-
|
|
64
|
+
// @ts-ignore
|
|
65
|
+
if (_client().createRoot) {
|
|
79
66
|
concurrentRender(node, container);
|
|
80
67
|
return;
|
|
81
68
|
}
|
|
@@ -83,7 +70,7 @@ function render(node, container) {
|
|
|
83
70
|
}
|
|
84
71
|
// ========================== Unmount =========================
|
|
85
72
|
function legacyUnmount(container) {
|
|
86
|
-
return unmountComponentAtNode(container);
|
|
73
|
+
return unmountComponentAtNode ? unmountComponentAtNode(container) : false;
|
|
87
74
|
}
|
|
88
75
|
function concurrentUnmount(container) {
|
|
89
76
|
return (0, _tslib().__awaiter)(this, void 0, void 0, function* () {
|
|
@@ -96,7 +83,8 @@ function concurrentUnmount(container) {
|
|
|
96
83
|
});
|
|
97
84
|
}
|
|
98
85
|
function unmount(container) {
|
|
99
|
-
|
|
86
|
+
// @ts-ignore
|
|
87
|
+
if (_client().createRoot || container[MARK]) {
|
|
100
88
|
return concurrentUnmount(container);
|
|
101
89
|
}
|
|
102
90
|
return legacyUnmount(container);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import type { Root } from 'react-dom/client';
|
|
3
|
+
declare const MARK = "__react_vant_root__";
|
|
4
|
+
declare type ContainerType = (Element | DocumentFragment) & {
|
|
5
|
+
[MARK]?: Root;
|
|
6
|
+
};
|
|
7
|
+
export declare function render(node: ReactElement, container: ContainerType): void;
|
|
8
|
+
export declare function unmount(container: ContainerType): boolean | Promise<void>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.render = render;
|
|
7
|
+
exports.unmount = unmount;
|
|
8
|
+
function _tslib() {
|
|
9
|
+
const data = require("tslib");
|
|
10
|
+
_tslib = function () {
|
|
11
|
+
return data;
|
|
12
|
+
};
|
|
13
|
+
return data;
|
|
14
|
+
}
|
|
15
|
+
function ReactDOM() {
|
|
16
|
+
const data = _interopRequireWildcard(require("react-dom"));
|
|
17
|
+
ReactDOM = function () {
|
|
18
|
+
return data;
|
|
19
|
+
};
|
|
20
|
+
return data;
|
|
21
|
+
}
|
|
22
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
23
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
24
|
+
// Let compiler not to search module usage
|
|
25
|
+
const fullClone = Object.assign({}, ReactDOM());
|
|
26
|
+
const {
|
|
27
|
+
unmountComponentAtNode
|
|
28
|
+
} = fullClone;
|
|
29
|
+
let createRoot;
|
|
30
|
+
// 确保在React 18+版本中获取createRoot
|
|
31
|
+
if (fullClone.createRoot) {
|
|
32
|
+
createRoot = fullClone.createRoot;
|
|
33
|
+
} else {
|
|
34
|
+
// 如果createRoot不可用,尝试从react-dom/client导入
|
|
35
|
+
try {
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
37
|
+
createRoot = require('react-dom/client').createRoot;
|
|
38
|
+
} catch (e) {
|
|
39
|
+
// 保留原有行为以兼容旧版本
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function toggleWarning(skip) {
|
|
43
|
+
const {
|
|
44
|
+
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
|
|
45
|
+
} = fullClone;
|
|
46
|
+
if (__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED && typeof __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED === 'object') {
|
|
47
|
+
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.usingClientEntryPoint = skip;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const MARK = '__react_vant_root__';
|
|
51
|
+
/************* ✨ Windsurf Command ⭐ *************/
|
|
52
|
+
/**
|
|
53
|
+
* 使用ReactDOM.render的替代方案,仅用于旧版本React
|
|
54
|
+
* 如果ReactDOM.render不可用,将降级使用createRoot(如果可用)
|
|
55
|
+
/******* 57770e2e-0e81-41a7-aee6-9175a4a59062 *******/
|
|
56
|
+
function legacyRender(node, container) {
|
|
57
|
+
// 使用ReactDOM.render的替代方案,仅用于旧版本React
|
|
58
|
+
// @ts-ignore
|
|
59
|
+
if (fullClone.render) {
|
|
60
|
+
// @ts-ignore
|
|
61
|
+
fullClone.render(node, container);
|
|
62
|
+
} else {
|
|
63
|
+
// 如果ReactDOM.render不可用,降级使用createRoot(如果可用)
|
|
64
|
+
//@ts-ignore
|
|
65
|
+
if (createRoot) {
|
|
66
|
+
concurrentRender(node, container);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function concurrentRender(node, container) {
|
|
71
|
+
toggleWarning(true);
|
|
72
|
+
const root = container[MARK] || createRoot(container);
|
|
73
|
+
toggleWarning(false);
|
|
74
|
+
// @ts-ignore
|
|
75
|
+
root.render(node);
|
|
76
|
+
container[MARK] = root;
|
|
77
|
+
}
|
|
78
|
+
function render(node, container) {
|
|
79
|
+
//@ts-ignore
|
|
80
|
+
if (createRoot) {
|
|
81
|
+
concurrentRender(node, container);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
legacyRender(node, container);
|
|
85
|
+
}
|
|
86
|
+
// ========================== Unmount =========================
|
|
87
|
+
function legacyUnmount(container) {
|
|
88
|
+
return unmountComponentAtNode(container);
|
|
89
|
+
}
|
|
90
|
+
function concurrentUnmount(container) {
|
|
91
|
+
return (0, _tslib().__awaiter)(this, void 0, void 0, function* () {
|
|
92
|
+
// Delay to unmount to avoid React 18 sync warning
|
|
93
|
+
return Promise.resolve().then(() => {
|
|
94
|
+
var _a;
|
|
95
|
+
(_a = container[MARK]) === null || _a === void 0 ? void 0 : _a.unmount();
|
|
96
|
+
delete container[MARK];
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
function unmount(container) {
|
|
101
|
+
//@ts-ignore
|
|
102
|
+
if (createRoot) {
|
|
103
|
+
return concurrentUnmount(container);
|
|
104
|
+
}
|
|
105
|
+
return legacyUnmount(container);
|
|
106
|
+
}
|