first commit
This commit is contained in:
4
frontend/node_modules/rc-util/lib/React/isFragment.d.ts
generated
vendored
Normal file
4
frontend/node_modules/rc-util/lib/React/isFragment.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* Compatible with React 18 or 19 to check if node is a Fragment.
|
||||
*/
|
||||
export default function isFragment(object: any): boolean;
|
||||
25
frontend/node_modules/rc-util/lib/React/isFragment.js
generated
vendored
Normal file
25
frontend/node_modules/rc-util/lib/React/isFragment.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = isFragment;
|
||||
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
||||
var REACT_ELEMENT_TYPE_18 = Symbol.for('react.element');
|
||||
var REACT_ELEMENT_TYPE_19 = Symbol.for('react.transitional.element');
|
||||
var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
|
||||
|
||||
/**
|
||||
* Compatible with React 18 or 19 to check if node is a Fragment.
|
||||
*/
|
||||
function isFragment(object) {
|
||||
return (
|
||||
// Base object type
|
||||
object && (0, _typeof2.default)(object) === 'object' && (
|
||||
// React Element type
|
||||
object.$$typeof === REACT_ELEMENT_TYPE_18 || object.$$typeof === REACT_ELEMENT_TYPE_19) &&
|
||||
// React Fragment type
|
||||
object.type === REACT_FRAGMENT_TYPE
|
||||
);
|
||||
}
|
||||
13
frontend/node_modules/rc-util/lib/React/render.d.ts
generated
vendored
Normal file
13
frontend/node_modules/rc-util/lib/React/render.d.ts
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import type * as React from 'react';
|
||||
import type { Root } from 'react-dom/client';
|
||||
declare const MARK = "__rc_react_root__";
|
||||
type ContainerType = (Element | DocumentFragment) & {
|
||||
[MARK]?: Root;
|
||||
};
|
||||
/** @private Test usage. Not work in prod */
|
||||
export declare function _r(node: React.ReactElement, container: ContainerType): void;
|
||||
export declare function render(node: React.ReactElement, container: ContainerType): void;
|
||||
/** @private Test usage. Not work in prod */
|
||||
export declare function _u(container: ContainerType): void;
|
||||
export declare function unmount(container: ContainerType): Promise<void>;
|
||||
export {};
|
||||
120
frontend/node_modules/rc-util/lib/React/render.js
generated
vendored
Normal file
120
frontend/node_modules/rc-util/lib/React/render.js
generated
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports._r = _r;
|
||||
exports._u = _u;
|
||||
exports.render = render;
|
||||
exports.unmount = unmount;
|
||||
var _regeneratorRuntime2 = _interopRequireDefault(require("@babel/runtime/helpers/regeneratorRuntime"));
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
||||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
||||
var ReactDOM = _interopRequireWildcard(require("react-dom"));
|
||||
// Let compiler not to search module usage
|
||||
var fullClone = (0, _objectSpread2.default)({}, ReactDOM);
|
||||
var version = fullClone.version,
|
||||
reactRender = fullClone.render,
|
||||
unmountComponentAtNode = fullClone.unmountComponentAtNode;
|
||||
var createRoot;
|
||||
try {
|
||||
var mainVersion = Number((version || '').split('.')[0]);
|
||||
if (mainVersion >= 18) {
|
||||
createRoot = fullClone.createRoot;
|
||||
}
|
||||
} catch (e) {
|
||||
// Do nothing;
|
||||
}
|
||||
function toggleWarning(skip) {
|
||||
var __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = fullClone.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
||||
if (__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED && (0, _typeof2.default)(__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED) === 'object') {
|
||||
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.usingClientEntryPoint = skip;
|
||||
}
|
||||
}
|
||||
var MARK = '__rc_react_root__';
|
||||
|
||||
// ========================== Render ==========================
|
||||
|
||||
function modernRender(node, container) {
|
||||
toggleWarning(true);
|
||||
var root = container[MARK] || createRoot(container);
|
||||
toggleWarning(false);
|
||||
root.render(node);
|
||||
container[MARK] = root;
|
||||
}
|
||||
function legacyRender(node, container) {
|
||||
reactRender === null || reactRender === void 0 || reactRender(node, container);
|
||||
}
|
||||
|
||||
/** @private Test usage. Not work in prod */
|
||||
function _r(node, container) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
return legacyRender(node, container);
|
||||
}
|
||||
}
|
||||
function render(node, container) {
|
||||
if (createRoot) {
|
||||
modernRender(node, container);
|
||||
return;
|
||||
}
|
||||
legacyRender(node, container);
|
||||
}
|
||||
|
||||
// ========================= Unmount ==========================
|
||||
function modernUnmount(_x) {
|
||||
return _modernUnmount.apply(this, arguments);
|
||||
}
|
||||
function _modernUnmount() {
|
||||
_modernUnmount = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee(container) {
|
||||
return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
|
||||
while (1) switch (_context.prev = _context.next) {
|
||||
case 0:
|
||||
return _context.abrupt("return", Promise.resolve().then(function () {
|
||||
var _container$MARK;
|
||||
(_container$MARK = container[MARK]) === null || _container$MARK === void 0 || _container$MARK.unmount();
|
||||
delete container[MARK];
|
||||
}));
|
||||
case 1:
|
||||
case "end":
|
||||
return _context.stop();
|
||||
}
|
||||
}, _callee);
|
||||
}));
|
||||
return _modernUnmount.apply(this, arguments);
|
||||
}
|
||||
function legacyUnmount(container) {
|
||||
unmountComponentAtNode(container);
|
||||
}
|
||||
|
||||
/** @private Test usage. Not work in prod */
|
||||
function _u(container) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
return legacyUnmount(container);
|
||||
}
|
||||
}
|
||||
function unmount(_x2) {
|
||||
return _unmount.apply(this, arguments);
|
||||
}
|
||||
function _unmount() {
|
||||
_unmount = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee2(container) {
|
||||
return (0, _regeneratorRuntime2.default)().wrap(function _callee2$(_context2) {
|
||||
while (1) switch (_context2.prev = _context2.next) {
|
||||
case 0:
|
||||
if (!(createRoot !== undefined)) {
|
||||
_context2.next = 2;
|
||||
break;
|
||||
}
|
||||
return _context2.abrupt("return", modernUnmount(container));
|
||||
case 2:
|
||||
legacyUnmount(container);
|
||||
case 3:
|
||||
case "end":
|
||||
return _context2.stop();
|
||||
}
|
||||
}, _callee2);
|
||||
}));
|
||||
return _unmount.apply(this, arguments);
|
||||
}
|
||||
Reference in New Issue
Block a user